File tree 5 files changed +59
-5
lines changed
packages/editor-ui-property
property-input-toggle-group
5 files changed +59
-5
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ export * from "./property-input-checkbox";
6
6
export * from "./property-input-slider" ;
7
7
export * from "./property-input-color" ;
8
8
export * from "./property-input-select" ;
9
+ export * from "./property-input-toggle-group" ;
9
10
export * from "./property-line" ;
10
11
export * from "./property-lines" ;
11
12
export * from "./layout" ;
Original file line number Diff line number Diff line change 14
14
"@radix-ui/react-checkbox" : " ^1.0.4" ,
15
15
"@radix-ui/react-icons" : " ^1.0.3" ,
16
16
"@radix-ui/react-select" : " ^1.2.0" ,
17
- "@radix-ui/react-slider" : " ^0.0.11"
17
+ "@radix-ui/react-slider" : " ^0.0.11" ,
18
+ "@radix-ui/react-toggle-group" : " ^1.0.4"
18
19
},
19
20
"peerDependencies" : {
20
21
"@emotion/react" : " ^11.10.5" ,
26
27
"@emotion/react" : " ^11.10.5" ,
27
28
"@emotion/styled" : " ^11.10.5" ,
28
29
"@types/react" : " 18.2.58" ,
29
- "react" : " ^18.2.0"
30
+ "autoprefixer" : " ^10.0.1" ,
31
+ "postcss" : " ^8" ,
32
+ "react" : " ^18.2.0" ,
33
+ "tailwindcss" : " ^3.3.0"
30
34
}
31
35
}
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ interface SelectInputProps {
19
19
readonly ?: boolean ;
20
20
disabled ?: boolean ;
21
21
22
- onChange : ( value : string ) => void ;
22
+ onChange ? : ( value : string ) => void ;
23
23
onClick ?: ( ) => void ;
24
24
25
25
// aria
@@ -55,7 +55,7 @@ export function PropertySelectInput({
55
55
< Select . Root
56
56
onValueChange = { ( v ) => {
57
57
setValue ( v ) ;
58
- onChange ( v ) ;
58
+ onChange ?. ( v ) ;
59
59
} }
60
60
value = { value }
61
61
disabled = { disabled }
@@ -70,7 +70,11 @@ export function PropertySelectInput({
70
70
< ChevronDownIcon />
71
71
</ Select . Icon >
72
72
</ StyledTrigger >
73
- < Select . Portal >
73
+ < Select . Portal
74
+ style = { {
75
+ zIndex : 1000 ,
76
+ } }
77
+ >
74
78
< SelectContent >
75
79
< SelectScrollUpButton >
76
80
< ChevronUpIcon />
Original file line number Diff line number Diff line change
1
+ export * from "./property-input-toggle-group" ;
Original file line number Diff line number Diff line change
1
+ import React from "react" ;
2
+ import * as ToggleGroup from "@radix-ui/react-toggle-group" ;
3
+
4
+ export function PropertyInputToggleGroup ( {
5
+ ariaLabel,
6
+ defaultValue,
7
+ value,
8
+ options,
9
+ onValueChange,
10
+ } : {
11
+ ariaLabel ?: string ;
12
+ defaultValue ?: string ;
13
+ value ?: string ;
14
+ options ?: {
15
+ value : string ;
16
+ ariaLabel ?: string ;
17
+ icon : React . ReactNode ;
18
+ } [ ] ;
19
+ onValueChange ?: ( value : string ) => void ;
20
+ } ) {
21
+ return (
22
+ < ToggleGroup . Root
23
+ className = "flex gap-2"
24
+ type = "single"
25
+ defaultValue = { defaultValue }
26
+ aria-label = { ariaLabel }
27
+ value = { value }
28
+ onValueChange = { onValueChange }
29
+ >
30
+ { options ?. map ( ( option ) => {
31
+ return (
32
+ < ToggleGroup . Item
33
+ key = { option . value }
34
+ className = "p-2 rounded-md data-[state='on']:bg-white/10"
35
+ value = { option . value }
36
+ aria-label = { option . ariaLabel }
37
+ >
38
+ { option . icon }
39
+ </ ToggleGroup . Item >
40
+ ) ;
41
+ } ) }
42
+ </ ToggleGroup . Root >
43
+ ) ;
44
+ }
You can’t perform that action at this time.
0 commit comments