Skip to content

Commit fda9798

Browse files
add slider
1 parent 532159d commit fda9798

File tree

4 files changed

+38
-18
lines changed

4 files changed

+38
-18
lines changed
+9-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import { css } from "@emotion/react";
22

33
export const input_type_number_disable_browser_default_appearence = css`
4-
/* disable default number up down arrow */
5-
::-webkit-outer-spin-button,
6-
::-webkit-inner-spin-button {
4+
/* Disabling up and down arrows for number inputs */
5+
&[type="number"] {
6+
-moz-appearance: textfield; /* Firefox */
7+
appearance: textfield; /* Chrome, Safari, Edge, and Opera */
8+
}
9+
10+
/* Hide the spin button in Chrome, Safari, Edge, and Opera */
11+
&::-webkit-outer-spin-button,
12+
&::-webkit-inner-spin-button {
713
-webkit-appearance: none;
814
margin: 0;
915
}
10-
/* firefox */
11-
&[type="number"] {
12-
-moz-appearance: textfield;
13-
}
1416
`;

packages/editor-ui-property/property-input-slider/property-input-slider.tsx

+14-7
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,41 @@ import React from "react";
22
import * as Slider from "@radix-ui/react-slider";
33

44
export function PropertySliderInput({
5+
stopPropagation,
56
value,
67
min,
78
max,
89
step,
910
onValueChange,
10-
}: // onValueCommit,
11-
{
11+
}: {
12+
stopPropagation?: boolean;
1213
value?: number[];
1314
min?: number;
1415
max?: number;
1516
step?: number;
1617
orientation?: "horizontal" | "vertical";
1718
onValueChange?: (value: number[]) => void;
18-
// onValueCommit?: (value: number[]) => void;
1919
}) {
2020
return (
2121
<Slider.Root
22-
className="SliderRoot"
22+
className="w-full h-6 rounded-md relative overflow-hidden focus:ring focus:ring-blue-500 focus:ring-opacity-50"
2323
value={value}
2424
min={min}
2525
max={max}
2626
step={step}
27+
onKeyDown={
28+
stopPropagation
29+
? (event) => {
30+
event.stopPropagation();
31+
}
32+
: undefined
33+
}
2734
onValueChange={onValueChange}
2835
>
29-
<Slider.Track className="SliderTrack">
30-
<Slider.Range className="SliderRange" />
36+
<Slider.Track className="absolute bg-gray-300 rounded h-1 left-0 right-0">
37+
<Slider.Range className="absolute bg-blue-500 rounded h-full" />
3138
</Slider.Track>
32-
<Slider.Thumb className="SliderThumb" aria-label="Volume" />
39+
<Slider.Thumb className="block w-4 h-4 bg-white border border-gray-400 rounded-full shadow focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50" />
3340
</Slider.Root>
3441
);
3542
}

packages/editor-ui-property/property-input/property-input.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import styled from "../theme/styled";
2-
import React from "react";
2+
import React, { useEffect } from "react";
33

44
import { PropertyCell } from "../property-cell";
55
import { useTheme } from "../theme";
@@ -52,6 +52,10 @@ export function PropertyInput({
5252
const theme = useTheme();
5353
const inputRef = React.useRef<HTMLInputElement>(null);
5454

55+
useEffect(() => {
56+
setValue(initial);
57+
}, [initial]);
58+
5559
const onclick = (e) => {
5660
if (inputRef.current) {
5761
inputRef.current.focus();
@@ -187,7 +191,7 @@ const PlainInput = styled.input`
187191
color: #999;
188192
}
189193
190-
/* input_type_number_disable_browser_default_appearence */
194+
${input_type_number_disable_browser_default_appearence}
191195
`;
192196

193197
const _fix = css`

packages/editor-ui-property/property-line/property-line.tsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,22 @@ export function PropertyLine({
44
label,
55
children,
66
onClick,
7+
gap = 8,
78
}: React.PropsWithChildren<{
89
label?: string;
10+
gap?: number;
911
onClick?: (e) => void;
1012
}>) {
1113
return (
1214
<Line onClick={onClick}>
1315
{label && <Label>{label}</Label>}
14-
<Items>{children}</Items>
16+
<Items
17+
style={{
18+
gap,
19+
}}
20+
>
21+
{children}
22+
</Items>
1523
</Line>
1624
);
1725
}
@@ -25,7 +33,6 @@ const Line = styled.div`
2533
const Items = styled.div`
2634
display: flex;
2735
flex: 7;
28-
gap: 8px;
2936
`;
3037

3138
const Label = styled.label`

0 commit comments

Comments
 (0)