Skip to content

Commit 79c9e89

Browse files
committed
Add grayscale slider below color wheel.
1 parent a7a52ba commit 79c9e89

File tree

3 files changed

+67
-7
lines changed

3 files changed

+67
-7
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import HorizontalSlider from "../slider/horizontalSlider";
2+
3+
type Props = {
4+
value: number;
5+
onChange(value: number): void;
6+
onFocus(): void;
7+
onBlur(): void;
8+
};
9+
10+
export default function GrayscaleSlider(props: Props) {
11+
return (
12+
<div class="flex items-center gap-4">
13+
<div>
14+
<svg width="100%" height="16px" viewBox="0 0 100% 16px" class="mb-3">
15+
<linearGradient id="grayscaleGradient" x1="0" x2="1" y1="0" y2="0">
16+
<stop offset="0%" stop-color="black" />
17+
<stop offset="100%" stop-color="white" />
18+
</linearGradient>
19+
20+
<rect
21+
x="0"
22+
y="0"
23+
rx="2"
24+
ry="2"
25+
width="100%"
26+
height="16"
27+
fill="url(#grayscaleGradient)"
28+
/>
29+
</svg>
30+
31+
<HorizontalSlider
32+
min={0}
33+
max={1}
34+
value={props.value}
35+
onChange={props.onChange}
36+
onPointerDown={props.onFocus}
37+
onPointerUp={props.onBlur}
38+
/>
39+
</div>
40+
<div class="w-[26px] text-center">{Math.round(props.value * 255)}</div>
41+
</div>
42+
);
43+
}

packages/ui/editor/history-panel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default function HistoryPanel() {
88

99
return (
1010
<PanelSection label="History">
11-
<div class="h-[340px] overflow-y-auto">
11+
<div class="h-[271px] overflow-y-auto">
1212
<For each={history.stack().entries}>
1313
{(entry) => <HistoryPanelItem entry={entry} />}
1414
</For>
Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
11
import ColorWheel from "../../../components/color-wheel/color-wheel";
22
import { RgbParameterInputInfo } from "../../../../material/node-parameter";
33
import { InputProps } from "../parameter";
4+
import GrayscaleSlider from "../../../components/grayscale-slider/grayscale-slider";
45

56
export default function MaterialNodeInspectorRGBInput(
67
props: InputProps<RgbParameterInputInfo, [number, number, number]>,
78
) {
89
return (
9-
<ColorWheel
10-
value={props.value()}
11-
onChange={props.onChange}
12-
onFocus={props.onFocus}
13-
onBlur={props.onBlur}
14-
/>
10+
<>
11+
<ColorWheel
12+
value={props.value()}
13+
onChange={props.onChange}
14+
onFocus={props.onFocus}
15+
onBlur={props.onBlur}
16+
/>
17+
18+
<div class="h-4" />
19+
20+
<GrayscaleSlider
21+
value={props.value()[0]}
22+
onChange={(value) => props.onChange([value, 0, 0])}
23+
onFocus={props.onFocus}
24+
onBlur={props.onBlur}
25+
/>
26+
27+
<div class="text-sm text-gray-800 mt-2">
28+
Note: For now, all textures use RGB format and grayscale values are kept in the red
29+
channel.
30+
</div>
31+
</>
1532
);
1633
}

0 commit comments

Comments
 (0)