mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-09 19:20:57 +08:00
Bezier-rs: Update interactive demo site UI/UX (#1085)
* wip - change demo iframe styling * fix typo * change tVariant select from radio buttons to dropdown * Added iframe styling * fix linting errors * Integrated tvariant picker as input options * Updated points in demos * Lint * Clean up CSS --------- Co-authored-by: Thomas Cheng <contact.chengthomas@gmail.com> Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
committed by
Keavon Chambers
co-authored by
Thomas Cheng
Keavon Chambers
parent
bfbabbc4dc
commit
834cb1a227
@@ -1,27 +1,27 @@
|
||||
import bezierFeatures, { BezierFeatureKey } from "@/features/bezier-features";
|
||||
import { renderDemoPane } from "@/utils/render";
|
||||
import { BezierCurveType, BEZIER_CURVE_TYPE, TVariant, BezierDemoOptions, SliderOption, Demo, DemoPane, BezierDemoArgs } from "@/utils/types";
|
||||
import { BezierCurveType, BEZIER_CURVE_TYPE, BezierDemoOptions, InputOption, Demo, DemoPane, BezierDemoArgs } from "@/utils/types";
|
||||
|
||||
const demoDefaults = {
|
||||
Linear: {
|
||||
points: [
|
||||
[30, 60],
|
||||
[140, 120],
|
||||
[55, 60],
|
||||
[165, 120],
|
||||
],
|
||||
},
|
||||
Quadratic: {
|
||||
points: [
|
||||
[30, 50],
|
||||
[140, 30],
|
||||
[160, 170],
|
||||
[55, 50],
|
||||
[165, 30],
|
||||
[185, 170],
|
||||
],
|
||||
},
|
||||
Cubic: {
|
||||
points: [
|
||||
[30, 30],
|
||||
[60, 140],
|
||||
[150, 30],
|
||||
[160, 160],
|
||||
[55, 30],
|
||||
[85, 140],
|
||||
[175, 30],
|
||||
[185, 160],
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -36,25 +36,19 @@ class BezierDemoPane extends HTMLElement implements DemoPane {
|
||||
|
||||
triggerOnMouseMove!: boolean;
|
||||
|
||||
chooseTVariant!: boolean;
|
||||
|
||||
// Data
|
||||
demos!: BezierDemoArgs[];
|
||||
|
||||
id!: string;
|
||||
|
||||
tVariant!: TVariant;
|
||||
|
||||
connectedCallback(): void {
|
||||
this.tVariant = "Parametric";
|
||||
this.key = (this.getAttribute("name") || "") as BezierFeatureKey;
|
||||
this.id = `bezier/${this.key}`;
|
||||
this.name = bezierFeatures[this.key].name;
|
||||
this.demoOptions = JSON.parse(this.getAttribute("demoOptions") || "[]");
|
||||
this.triggerOnMouseMove = this.getAttribute("triggerOnMouseMove") === "true";
|
||||
this.chooseTVariant = this.getAttribute("chooseTVariant") === "true";
|
||||
// Use quadratic slider options as a default if sliders are not provided for the other curve types.
|
||||
const defaultSliderOptions: SliderOption[] = this.demoOptions.Quadratic?.sliderOptions || [];
|
||||
const defaultSliderOptions: InputOption[] = this.demoOptions.Quadratic?.inputOptions || [];
|
||||
this.demos = BEZIER_CURVE_TYPE.map((curveType: BezierCurveType) => {
|
||||
const givenData = this.demoOptions[curveType];
|
||||
const defaultData = demoDefaults[curveType];
|
||||
@@ -62,7 +56,7 @@ class BezierDemoPane extends HTMLElement implements DemoPane {
|
||||
title: curveType,
|
||||
disabled: givenData?.disabled || false,
|
||||
points: givenData?.customPoints || defaultData.points,
|
||||
sliderOptions: givenData?.sliderOptions || defaultSliderOptions,
|
||||
inputOptions: givenData?.inputOptions || defaultSliderOptions,
|
||||
};
|
||||
});
|
||||
this.render();
|
||||
@@ -77,9 +71,8 @@ class BezierDemoPane extends HTMLElement implements DemoPane {
|
||||
bezierDemo.setAttribute("title", demo.title);
|
||||
bezierDemo.setAttribute("points", JSON.stringify(demo.points));
|
||||
bezierDemo.setAttribute("key", this.key);
|
||||
bezierDemo.setAttribute("sliderOptions", JSON.stringify(demo.sliderOptions));
|
||||
bezierDemo.setAttribute("inputOptions", JSON.stringify(demo.inputOptions));
|
||||
bezierDemo.setAttribute("triggerOnMouseMove", String(this.triggerOnMouseMove));
|
||||
bezierDemo.setAttribute("tvariant", this.tVariant);
|
||||
return bezierDemo;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user