File tree Expand file tree Collapse file tree 5 files changed +53
-1
lines changed Expand file tree Collapse file tree 5 files changed +53
-1
lines changed Original file line number Diff line number Diff line change 11export * as button from './button/index.ts'
2+ export * as toggleSwitch from './toggle_switch/index.ts'
Original file line number Diff line number Diff line change 1+ .ui .toggle-switch {
2+ display : flex;
3+ align-items : center;
4+ padding : 0 12px ;
5+ width : 64px ;
6+ height : 32px ;
7+ appearance : none;
8+ border : 1px solid;
9+ border-radius : 6px ;
10+ font-size : 14px ;
11+ font-weight : 500 ;
12+ cursor : pointer;
13+ user-select : none;
14+
15+ & [class $= "--active" ] {
16+ background-color : # f6f8fa ;
17+ box-shadow : 0px 1px 0px 0px # 1f23280a ;
18+ border-color : # d1d9e0 ;
19+ color : # 25292e ;
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ export { ToggleSwitch } from './toggle_switch.tsx'
Original file line number Diff line number Diff line change 1+ import { type JSXElement , createSignal } from '@solid-js'
2+
3+ import './index.css'
4+
5+
6+ export function ToggleSwitch ( ) : JSXElement {
7+
8+ const [ state , setState ] = createSignal ( false ) ;
9+
10+ const toggle = ( ) => {
11+ setState ( ( v ) => ! v ) ;
12+ console . log ( 'State is now:' , state ( ) ) ;
13+ }
14+
15+ return (
16+ < button
17+ type = 'button'
18+ class = { `ui toggle-switch` }
19+ classList = { {
20+ 'toggle-switch--active' : state ( )
21+ } }
22+ data-checked = { state ( ) }
23+ onClick = { toggle }
24+ >
25+ { state ( ) ? 'ON' : 'OFF' }
26+ </ button >
27+ )
28+ }
Original file line number Diff line number Diff line change 11import { render } from '@solid-js/web' ;
22import { HashRouter , Route } from '@solid-js/router'
3- import { button } from '../components/index.ts' ;
3+ import { button , toggleSwitch } from '../components/index.ts' ;
44import './index.css'
55
66
77render (
88 ( ) => < HashRouter >
99 < Route path = '/button' component = { ( ) => < button . Button > Hello</ button . Button > } />
10+ < Route path = '/toggle-switch' component = { ( ) => < toggleSwitch . ToggleSwitch /> } />
1011 </ HashRouter > ,
1112 globalThis . document . body
1213) ;
You can’t perform that action at this time.
0 commit comments