1- import { camelCaseToWords } from '@/lib/utils' ;
21import {
32 InfoCircledIcon ,
43 Pencil2Icon ,
@@ -15,6 +14,7 @@ import {
1514 Text
1615} from '@raystack/apsara' ;
1716import { cx } from 'class-variance-authority' ;
17+ import { camelCaseToWords } from '@/lib/utils' ;
1818import styles from './styles.module.css' ;
1919import {
2020 ComponentPropsType ,
@@ -48,6 +48,7 @@ export default function DemoControls({
4848 const propValue = componentProps ?. [ prop ] ?? '' ;
4949 const isCheckbox = control . type === 'checkbox' ;
5050 const isIcon = control . type === 'icon' ;
51+ const isIconOptional = control . isIconOptional ?? true ;
5152
5253 // For checkbox and icon types, render in a special container
5354 if ( isCheckbox || isIcon ) {
@@ -61,18 +62,20 @@ export default function DemoControls({
6162 < Text variant = 'secondary' size = 'small' weight = 'medium' >
6263 { propLabel }
6364 </ Text >
64- < Switch
65- size = 'small'
66- checked = { ! ! componentProps [ prop ] }
67- onCheckedChange = { checked => {
68- if ( isCheckbox ) onPropChange ( prop , checked ) ;
69- else
70- onPropChange (
71- prop ,
72- checked ? String ( ICONS_MAP . plus . value ) : ''
73- ) ;
74- } }
75- />
65+ { isIconOptional && (
66+ < Switch
67+ size = 'small'
68+ checked = { ! ! componentProps [ prop ] }
69+ onCheckedChange = { checked => {
70+ if ( isCheckbox ) onPropChange ( prop , checked ) ;
71+ else
72+ onPropChange (
73+ prop ,
74+ checked ? String ( ICONS_MAP . plus . value ) : ''
75+ ) ;
76+ } }
77+ />
78+ ) }
7679 </ Flex >
7780 { isIcon && (
7881 < Flex gap = { 2 } align = 'center' className = { styles . iconContainer } >
@@ -90,6 +93,12 @@ export default function DemoControls({
9093 e . stopPropagation ( ) ;
9194 } }
9295 aria-label = { `Select ${ icon . value || 'none' } icon` }
96+ style = { {
97+ color :
98+ propValue === icon . value
99+ ? 'var(--rs-color-background-accent-emphasis)'
100+ : undefined
101+ } }
93102 >
94103 { icon . icon }
95104 </ IconButton >
0 commit comments