1
1
import cs from 'classnames' ;
2
2
import { useAtom , useAtomValue } from 'jotai' ;
3
+ import { useState } from 'react' ;
3
4
import DiscordIconSvg from '../assets/discord-icon.svg' ;
4
5
import GithubIconSvg from '../assets/github-icon.svg' ;
5
6
import HamburgerSvg from '../assets/hamburger.svg' ;
@@ -11,8 +12,7 @@ import {
11
12
import ExampleList from './ExampleList' ;
12
13
import ExamplePage from './ExamplePage' ;
13
14
import { Button } from './design/Button' ;
14
-
15
- const isDev = import . meta. env . DEV ;
15
+ import { Toggle } from './design/Toggle' ;
16
16
17
17
export function ExampleLayout ( ) {
18
18
const menuShown = useAtomValue ( menuShownAtom ) ;
@@ -47,9 +47,14 @@ export function ExampleLayout() {
47
47
) ;
48
48
}
49
49
50
+ const experimentalShowingLSKey = 'experimental-showing' ;
51
+
50
52
function SideMenu ( ) {
51
53
const menuShown = useAtomValue ( menuShownAtom ) ;
52
54
const menuShownMobile = useAtomValue ( menuShownMobileAtom ) ;
55
+ const [ experimentalShowing , setExperimentalShowing ] = useState (
56
+ localStorage . getItem ( experimentalShowingLSKey ) === 'true' ,
57
+ ) ;
53
58
54
59
return (
55
60
< aside
@@ -93,11 +98,28 @@ function SideMenu() {
93
98
94
99
< ExampleList
95
100
excludeTags = { [
96
- isDev ? [ ] : [ 'experimental' ] ,
101
+ experimentalShowing ? [ ] : [ 'experimental' ] ,
97
102
typeof MediaStreamTrackProcessor === 'undefined' ? [ 'camera' ] : [ ] ,
98
103
] . flat ( ) }
99
104
/>
100
105
106
+ < hr className = "my-0 box-border w-full border-t border-tameplum-100" />
107
+
108
+ < label className = "flex items-center justify-between gap-3 text-sm cursor-pointer" >
109
+ < span > Experimental examples</ span >
110
+ < Toggle
111
+ checked = { experimentalShowing }
112
+ onChange = { ( e ) => {
113
+ const checked = e . target . checked ;
114
+ localStorage . setItem (
115
+ experimentalShowingLSKey ,
116
+ checked ? 'true' : 'false' ,
117
+ ) ;
118
+ setExperimentalShowing ( checked ) ;
119
+ } }
120
+ />
121
+ </ label >
122
+
101
123
< div className = "flex justify-between text-tameplum-800 text-xs" >
102
124
< div > © { new Date ( ) . getFullYear ( ) } Software Mansion S.A.</ div >
103
125
< div className = "flex gap-3 items-center" >
0 commit comments