ISSUE-005 - Added indicator "I" and "O", emulating an accessibility option found in iOS.
Added a subtle background color transition. Gave up on the idea of giving the toggle circle a shadow (not worth the hassle). But if I did decide to do that, I'd be able to animate the toggle circle fairly easily, I think.
This commit is contained in:
1 parent
3151c58d9d
commit
dd4df61fec
3 files changed
+32
-10
No files matched your search
@@ -13,13 +13,17 @@ export type ToggleProps = {
|
||||
label: string,
|
||||
toggled: boolean,
|
||||
onToggle: (value: AnimatedBG) => void,
|
||||
showIndicators?: boolean,
|
||||
};
|
||||
/**
|
||||
* This is my attempt at making a iOS-style toggle switch.
|
||||
* @param param0
|
||||
* @returns
|
||||
*/
|
||||
export const Toggle = ({ label, toggled, onToggle }: ToggleProps) => {
|
||||
export const Toggle = ({
|
||||
label,
|
||||
toggled,
|
||||
onToggle,
|
||||
showIndicators = false,
|
||||
}: ToggleProps) => {
|
||||
const [hovered, setHovered] = useState(false);
|
||||
return (
|
||||
<ToggleContainer>
|
||||
@@ -37,8 +41,9 @@ export const Toggle = ({ label, toggled, onToggle }: ToggleProps) => {
|
||||
onMouseDown={() => setHovered(true)}
|
||||
onMouseUp={() => setHovered(false)}
|
||||
>
|
||||
<ToggleBackground toggled={toggled} />
|
||||
<ToggleCircle toggled={toggled} stretched={hovered} />
|
||||
<ToggleBackground toggled={toggled} showIndicators={showIndicators}>
|
||||
<ToggleCircle toggled={toggled} stretched={hovered} />
|
||||
</ToggleBackground>
|
||||
</ToggleLabel>
|
||||
</ToggleBody>
|
||||
</ToggleContainer>
|
||||
|
||||
Reference in new issue
Block a user