File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed
packages/gui/src/components Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @compai/css-gui ' : patch
3
+ ---
4
+
5
+ Display theme value for scales
Original file line number Diff line number Diff line change @@ -9,9 +9,13 @@ interface Props<T extends string> {
9
9
options : readonly T [ ]
10
10
ruleset ?: any
11
11
property ?: string
12
+ decorateText ?( text : T ) : string
12
13
}
13
14
// A select input with a label
14
- export function SelectInput < T extends string > ( props : Props < T > ) {
15
+ export function SelectInput < T extends string > ( {
16
+ decorateText,
17
+ ...props
18
+ } : Props < T > ) {
15
19
const { value, onChange, options = [ ] } = props
16
20
17
21
return (
@@ -34,7 +38,9 @@ export function SelectInput<T extends string>(props: Props<T>) {
34
38
return (
35
39
< Select . Item key = { v } value = { v } >
36
40
< Select . ItemIndicator />
37
- < Select . ItemText > { v } </ Select . ItemText >
41
+ < Select . ItemText >
42
+ { decorateText ? decorateText ( v ) : v }
43
+ </ Select . ItemText >
38
44
</ Select . Item >
39
45
)
40
46
} ) }
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { get, range } from 'lodash-es'
3
3
import { ThemeNamedValue , ThemeValue } from '../../types/css'
4
4
import { SelectInput } from '../inputs/SelectInput'
5
5
import { DataTypeSchema } from './types'
6
+ import { joinPath } from '../providers/util'
6
7
7
8
export function themeScale ( path : string ) : DataTypeSchema < ThemeValue > {
8
9
return {
@@ -16,11 +17,15 @@ export function themeScale(path: string): DataTypeSchema<ThemeValue> {
16
17
)
17
18
} ) as any ,
18
19
stringify ( value , theme ) {
19
- return get ( theme , ` ${ value . path } . ${ value . index } ` )
20
+ return get ( theme , joinPath ( value . path , value . index ) )
20
21
} ,
21
22
inlineInput ( props ) {
22
23
const theme = useTheme ( )
23
24
const numOptions = get ( theme , path ) ?. length || 0
25
+ const decorateText = ( step : string ) => {
26
+ const value = get ( theme , joinPath ( path , step ) )
27
+ return `${ step } - ${ value } `
28
+ }
24
29
return (
25
30
< SelectInput
26
31
label = ""
@@ -32,6 +37,7 @@ export function themeScale(path: string): DataTypeSchema<ThemeValue> {
32
37
} )
33
38
}
34
39
options = { range ( 0 , numOptions ) . map ( ( x ) => x . toString ( ) ) }
40
+ decorateText = { decorateText }
35
41
/>
36
42
)
37
43
} ,
You can’t perform that action at this time.
0 commit comments