11'use client' ;
2- import { useUI } from '@react-zero-ui/core' ;
2+ import { useScopedUI , useUI } from '@react-zero-ui/core' ;
33import UseEffectComponent from './UseEffectComponent' ;
44import FAQ from './FAQ' ;
55import { ChildComponent } from './ChildComponent' ;
66import { ChildWithoutSetter } from './ChildWithoutSetter' ;
77
88export default function Page ( ) {
9+ const [ scope , setScope ] = useScopedUI < 'off' | 'on' > ( 'scope' , 'off' ) ;
10+
911 const [ , setTheme ] = useUI < 'light' | 'dark' > ( 'theme' , 'light' ) ;
1012 const [ , setTheme2 ] = useUI < 'light' | 'dark' > ( 'theme-2' , 'light' ) ;
1113 const [ , setThemeThree ] = useUI < 'light' | 'dark' > ( 'theme-three' , 'light' ) ;
1214 const [ , setToggle ] = useUI < 'true' | 'false' > ( 'toggle-boolean' , 'true' ) ;
1315 const [ , setNumber ] = useUI < '1' | '2' > ( 'number' , '1' ) ;
14- const [ , setOpen ] = useUI < 'open' | 'closed' > ( 'faq' , 'closed' ) ; // Same key everywhere!
15- const [ , setScope ] = useUI < 'off' | 'on' > ( 'scope' , 'off' ) ;
16- const [ , setMobile ] = useUI < 'true' | 'false' > ( 'mobile' , 'false' ) ;
16+ const [ open , setOpen ] = useScopedUI < 'open' | 'closed' > ( 'faq' , 'closed' ) ;
17+ const [ mobile , setMobile ] = useScopedUI < 'true' | 'false' > ( 'mobile' , 'false' ) ;
1718 const [ , setChildOpen ] = useUI < 'open' | 'closed' > ( 'child' , 'closed' ) ;
1819
1920 const [ , setToggleFunction ] = useUI < 'white' | 'black' > ( 'toggle-function' , 'white' ) ;
@@ -145,6 +146,7 @@ export default function Page() {
145146 className = "scope-off:bg-blue-100 scope-on:bg-blue-900 scope-on:text-white"
146147 data-testid = "scope-container"
147148 //this ref tells the hook to flip the data key here
149+ data-scope = { scope }
148150 ref = { setScope . ref } >
149151 < button
150152 type = "button"
@@ -166,7 +168,8 @@ export default function Page() {
166168 className = "mobile-false:bg-blue-100 mobile-true:bg-blue-900 mobile-true:text-white"
167169 data-testid = "mobile-container"
168170 //this ref tells the hook to flip the data key here
169- ref = { setMobile . ref } >
171+ ref = { setMobile . ref }
172+ data-mobile = { mobile } >
170173 < button
171174 type = "button"
172175 onClick = { ( ) => {
@@ -194,7 +197,9 @@ export default function Page() {
194197
195198 < hr />
196199
197- < div ref = { setOpen . ref } >
200+ < div
201+ ref = { setOpen . ref }
202+ data-faq = { open } >
198203 < button
199204 className = "bg-blue-500 text-white p-2 rounded-md m-5"
200205 onClick = { ( ) => setOpen ( ( prev ) => ( prev === 'open' ? 'closed' : 'open' ) ) } >
0 commit comments