Bezier-rs: Add hash URLs for individual API examples (#968)

* Handle displaying single demos

* Address comments

* Update eslintrc

* Add hash links

* Use hash instead of pathname

* Address small nits

* Change url format

* CSS improvements

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Hannah Li
2023-02-08 23:32:28 -05:00
committed by Keavon Chambers
co-authored by Keavon Chambers
parent 875f2a5cd1
commit ff51098c11
10 changed files with 209 additions and 87 deletions
@@ -1,10 +1,12 @@
import { SubpathFeatureName } from "@/features/subpath-features";
import subpathFeatures, { SubpathFeatureKey } from "@/features/subpath-features";
import { renderDemoPane } from "@/utils/render";
import { ComputeType, Demo, DemoPane, SliderOption, SubpathDemoArgs } from "@/utils/types";
class SubpathDemoPane extends HTMLElement implements DemoPane {
// Props
name!: SubpathFeatureName;
key!: SubpathFeatureKey;
name!: string;
sliderOptions!: SliderOption[];
@@ -45,10 +47,11 @@ class SubpathDemoPane extends HTMLElement implements DemoPane {
closed: true,
},
];
this.id = `${Math.random()}`.substring(2);
this.computeType = "Parametric";
this.name = (this.getAttribute("name") || "") as SubpathFeatureName;
this.key = (this.getAttribute("name") || "") as SubpathFeatureKey;
this.id = `subpath/${this.key}`;
this.name = subpathFeatures[this.key].name;
this.sliderOptions = JSON.parse(this.getAttribute("sliderOptions") || "[]");
this.triggerOnMouseMove = this.getAttribute("triggerOnMouseMove") === "true";
this.chooseComputeType = this.getAttribute("chooseComputeType") === "true";
@@ -65,7 +68,7 @@ class SubpathDemoPane extends HTMLElement implements DemoPane {
subpathDemo.setAttribute("title", demo.title);
subpathDemo.setAttribute("triples", JSON.stringify(demo.triples));
subpathDemo.setAttribute("closed", String(demo.closed));
subpathDemo.setAttribute("name", this.name);
subpathDemo.setAttribute("key", this.key);
subpathDemo.setAttribute("sliderOptions", JSON.stringify(this.sliderOptions));
subpathDemo.setAttribute("triggerOnMouseMove", String(this.triggerOnMouseMove));
subpathDemo.setAttribute("computetype", this.computeType);