Skip to content

🎥 Make videos programmatically with React

model edge roundness

Jonny Burger536e8b56b1a1
diff --git a/packages/docs/components/demos/control.tsx b/packages/docs/components/demos/control.tsx
index ba940c6440..0a13a17805 100644
--- a/packages/docs/components/demos/control.tsx
+++ b/packages/docs/components/demos/control.tsx
@@ -6,10 +6,17 @@ const left: React.CSSProperties = {
width: 100,
fontFamily: "GTPlanar",
flex: 1,
+ flexDirection: "row",
+ display: "flex",
+ alignItems: "center",
+};
+
+const check: React.CSSProperties = {
+ marginRight: 5,
};
const right: React.CSSProperties = {
- width: 50,
+ width: 40,
textAlign: "right",
fontVariantNumeric: "tabular-nums",
};
@@ -23,6 +30,8 @@ export const Control = ({
value: number;
setValue: (value: number) => void;
}) => {
+ const enabled = value !== null;
+
const labelStyle = useMemo<React.CSSProperties>(
() => ({
display: "flex",
@@ -34,7 +43,7 @@ export const Control = ({
const inputStyle = useMemo<React.CSSProperties>(
() => ({
- width: 90,
+ width: 80,
marginRight: 8,
}),
[]
@@ -46,7 +55,24 @@ export const Control = ({
return (
<label style={labelStyle} className={styles.item}>
- <div style={left}>{`${option.name}`}</div>
+ <div style={left}>
+ {option.optional === "no" ? null : (
+ <input
+ onChange={(c) => {
+ if (c.target.checked) {
+ console.log(c.target.checked);
+ setValue(option.default);
+ } else {
+ setValue(null);
+ }
+ }}
+ style={check}
+ checked={enabled}
+ type={"checkbox"}
+ />
+ )}
+ {`${option.name}`}
+ </div>
<input
type="range"
min={option.min}
@@ -54,6 +80,7 @@ export const Control = ({
step={option.step}
value={value as number}
style={inputStyle}
+ disabled={!enabled}
onChange={(e) => setValue(Number(e.target.value))}
/>
<div style={right}>
diff --git a/packages/docs/components/demos/index.tsx b/packages/docs/components/demos/index.tsx
index 3e459fe6f2..4f522414cc 100644
--- a/packages/docs/components/demos/index.tsx
+++ b/packages/docs/components/demos/index.tsx
@@ -28,7 +28,13 @@ export const Demo: React.FC<{
const [state, setState] = useState(() =>
demo.options
- .map((o) => [o.name, o.default] as const)
+ .map(
+ (o) =>
+ [
+ o.name,
+ o.optional === "default-disabled" ? null : o.default,
+ ] as const
+ )
.reduce((a, b) => {
a[b[0]] = b[1];
return a;
diff --git a/packages/docs/components/demos/types.ts b/packages/docs/components/demos/types.ts
index 53852c6ee7..6e494d92b5 100644
--- a/packages/docs/components/demos/types.ts
+++ b/packages/docs/components/demos/types.ts
@@ -8,12 +8,14 @@ export type Option = { name: string } & (
default: number;
max: number;
step: number;
+ optional: "no" | "default-enabled" | "default-disabled";
}
| {
type: "boolean";
default: boolean;
max: number;
step: number;
+ optional: boolean;
}
);
@@ -44,6 +46,7 @@ export const triangleDemo: DemoType = {
min: 1,
type: "numeric",
name: "length",
+ optional: "no",
},
{
name: "edgeRoundness",
@@ -52,6 +55,7 @@ export const triangleDemo: DemoType = {
min: -2,
step: 0.01,
type: "numeric",
+ optional: "default-disabled",
},
],
};
@@ -72,6 +76,7 @@ export const noiseDemo: DemoType = {
step: 0.001,
type: "numeric",
name: "speed",
+ optional: "no",
},
{
min: 0,
@@ -80,6 +85,7 @@ export const noiseDemo: DemoType = {
default: 50,
name: "maxOffset",
type: "numeric",
+ optional: "no",
},
{
name: "circleRadius",
@@ -88,6 +94,7 @@ export const noiseDemo: DemoType = {
min: 2,
step: 1,
type: "numeric",
+ optional: "no",
},
],
};