-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed home screen and safe-form (#92)
- Loading branch information
Showing
5 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/components/primitive/toggle-switch/toggle-switch.component.props.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export interface ToggleSwitchComponentProps { | ||
/** | ||
* Mandatory props to identify the switch. | ||
*/ | ||
toggleID: string; | ||
|
||
/** | ||
* used to toggle the switch. | ||
*/ | ||
|
||
checked: boolean; | ||
|
||
/** | ||
* onChange Handler. | ||
*/ | ||
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void; | ||
} |
68 changes: 68 additions & 0 deletions
68
src/components/primitive/toggle-switch/toggle-switch.component.styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import styled from 'styled-components'; | ||
|
||
// Todo - Fix the border latter | ||
export const ToggleSwitchContainer = styled.div` | ||
.label { | ||
display: block; | ||
overflow: hidden; | ||
cursor: pointer; | ||
border-radius: 2rem; | ||
} | ||
.inner { | ||
display: block; | ||
width: 200%; | ||
margin-left: -100%; | ||
transition: margin 0.3s ease-in 0s; | ||
} | ||
.inner:before, | ||
.inner:after { | ||
float: left; | ||
width: 3.4rem; | ||
height: 1.4rem; | ||
padding: 0; | ||
line-height: 3.6rem; | ||
background: ${({ theme: { colors } }) => colors.toggleSwitchBackground}; | ||
opacity: 0.24; | ||
font-weight: bold; | ||
box-sizing: border-box; | ||
} | ||
.inner:before { | ||
content: ''; | ||
color: #fff; | ||
} | ||
.inner:after { | ||
content: ''; | ||
background: ${({ theme: { colors } }) => colors.toggleSwitchBackground}; | ||
opacity: 0.24; | ||
border-left: 50%; | ||
} | ||
.switch { | ||
display: block; | ||
width: 2rem; | ||
height: 2rem; | ||
margin: 0; | ||
background: ${({ theme: { colors } }) => colors.toggleSwitchBackground}; | ||
position: absolute; | ||
top: -0.3rem; | ||
bottom: 0; | ||
right: 1.5rem; | ||
border-radius: 50%; | ||
transition: all 0.3s ease-in 0s; | ||
} | ||
`; | ||
|
||
export const Switch = styled.div` | ||
position: relative; | ||
width: 3.7rem; | ||
top: 0.8rem; | ||
`; | ||
|
||
export const StyledInput = styled.input` | ||
display: none; | ||
&:checked + .label .inner { | ||
margin-left: 0; | ||
} | ||
&:checked + .label .switch { | ||
right: 0; | ||
} | ||
`; |
18 changes: 18 additions & 0 deletions
18
src/components/primitive/toggle-switch/toggle-switch.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { ToggleSwitchComponentProps } from './toggle-switch.component.props'; | ||
import { ToggleSwitchContainer, StyledInput, Switch } from './toggle-switch.component.styles'; | ||
|
||
export const ToggleSwitch: React.FC<ToggleSwitchComponentProps> = (props) => { | ||
const { toggleID, checked, onChange } = props; | ||
|
||
return ( | ||
<ToggleSwitchContainer> | ||
<Switch> | ||
<StyledInput type='checkbox' id={toggleID} checked={checked} onChange={onChange} /> | ||
<label className='label' htmlFor={toggleID}> | ||
<span className='inner' /> | ||
<span className='switch' /> | ||
</label> | ||
</Switch> | ||
</ToggleSwitchContainer> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters