File tree Expand file tree Collapse file tree 3 files changed +25
-6
lines changed Expand file tree Collapse file tree 3 files changed +25
-6
lines changed Original file line number Diff line number Diff line change 3737
3838.cell-menu-item .heading {
3939 color : rgba (255 , 255 , 255 , 0.6 );
40+ }
41+
42+ .cell-menu-item .cell-menu-item-toggle {
43+ width : 100% ;
44+ display : flex;
45+ justify-content : space-between;
4046}
Original file line number Diff line number Diff line change 1- import React from 'react' ;
1+ import React , { HTMLAttributes } from 'react' ;
22import Toggle from 'react-toggle' ;
33import './ToggleSwitch.css' ;
4- interface Props {
4+
5+ type LabelPlacement = 'start' | 'end' ;
6+
7+ interface Props extends HTMLAttributes < HTMLLabelElement > {
58 label ?: string ;
69 checked ?: boolean ;
710 onChange ?: ( ) => void ;
11+ labelPlacement ?: LabelPlacement ;
812}
913
10- export const ToggleSwitch : React . FC < Props > = ( { label, checked, onChange } ) => (
11- < label >
14+ export const ToggleSwitch : React . FC < Props > = ( {
15+ label,
16+ checked,
17+ onChange,
18+ labelPlacement = 'end' ,
19+ ...props
20+ } ) => (
21+ < label { ...props } >
22+ { label && labelPlacement === 'start' && < span > { label } </ span > }
1223 < Toggle
1324 icons = { false }
1425 checked = { checked }
1526 onChange = { onChange }
1627 className = "toggle-switch"
1728 />
18- { label && < span > { label } </ span > }
29+ { label && labelPlacement === 'end' && < span > { label } </ span > }
1930 </ label >
2031) ;
Original file line number Diff line number Diff line change @@ -26,10 +26,12 @@ export const Default = (props?: Partial<Props>) => {
2626 < span > Two</ span >
2727 </ CellMenuItem >
2828 < CellMenuItem >
29- Two
3029 < ToggleSwitch
30+ label = "Input"
31+ labelPlacement = "start"
3132 checked = { checked }
3233 onChange = { ( ) => toggleChecked ( previous => ! previous ) }
34+ className = "cell-menu-item-toggle"
3335 />
3436 </ CellMenuItem >
3537 </ CellMenuSection >
You can’t perform that action at this time.
0 commit comments