-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,405 additions
and
112 deletions.
There are no files selected for viewing
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,134 @@ | ||
import { Box, useTheme } from '@mui/system'; | ||
import { useState } from 'react'; | ||
|
||
import { texts } from '../helpers/texts/texts'; | ||
import { BoxWith3D } from './BoxWith3D'; | ||
|
||
const TextBox = ({ | ||
value, | ||
text, | ||
isHovered, | ||
isClicked, | ||
isOff, | ||
}: { | ||
value: boolean; | ||
text: string; | ||
isHovered?: boolean; | ||
isClicked?: boolean; | ||
isOff?: boolean; | ||
}) => { | ||
return ( | ||
<Box | ||
sx={{ | ||
typography: 'descriptor', | ||
color: isClicked | ||
? '$textDisabled' | ||
: value | ||
? isHovered | ||
? '$textWhite' | ||
: isOff | ||
? '$text' | ||
: '$textWhite' | ||
: '$textDisabled', | ||
width: 30, | ||
display: 'inline-flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
position: 'relative', | ||
zIndex: 2, | ||
left: | ||
value && !isHovered && !isClicked | ||
? isOff | ||
? 2 | ||
: 4 | ||
: value && isHovered && !isClicked | ||
? isOff | ||
? 0 | ||
: 2 | ||
: 0, | ||
bottom: | ||
value && !isHovered && !isClicked | ||
? 3 | ||
: value && isHovered && !isClicked | ||
? 1 | ||
: 0, | ||
}}> | ||
{text} | ||
</Box> | ||
); | ||
}; | ||
|
||
interface GelatoSwitcherProps { | ||
value: boolean; | ||
setValue?: (value: boolean) => void; | ||
disabled?: boolean; | ||
} | ||
|
||
export function GelatoSwitcher({ | ||
disabled, | ||
value, | ||
setValue, | ||
}: GelatoSwitcherProps) { | ||
const theme = useTheme(); | ||
|
||
const [isHovered, setIsHoverer] = useState(false); | ||
const [isClicked, setIsClicked] = useState(false); | ||
|
||
const borderSize = isClicked ? 0 : isHovered ? 2 : 4; | ||
const contentColor = | ||
isHovered || isClicked ? '$secondary' : value ? '$mainButton' : '$light'; | ||
|
||
return ( | ||
<Box | ||
onMouseOver={() => !disabled && !isClicked && setIsHoverer(true)} | ||
onMouseOut={() => setIsHoverer(false)} | ||
sx={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
width: 60, | ||
height: 18, | ||
position: 'relative', | ||
border: `1px solid ${theme.palette.$mainBorder}`, | ||
backgroundColor: '$mainLight', | ||
cursor: disabled ? 'default' : 'pointer', | ||
}} | ||
onClick={() => { | ||
if (!disabled && setValue) { | ||
setIsHoverer(false); | ||
setIsClicked(true); | ||
setValue(!value); | ||
setTimeout(() => setIsClicked(false), 700); | ||
} | ||
}}> | ||
<BoxWith3D | ||
wrapperCss={{ | ||
position: 'absolute', | ||
transition: 'all 0.7s ease', | ||
left: value ? 30 : -1, | ||
bottom: -1, | ||
zIndex: 1, | ||
}} | ||
contentColor={contentColor} | ||
borderSize={borderSize} | ||
leftBorderColor="$buttonBorderBottom" | ||
bottomBorderColor="$buttonBorderLeft" | ||
anySize> | ||
<Box sx={{ width: 26, height: 16 }} /> | ||
</BoxWith3D> | ||
|
||
<TextBox | ||
text={texts.other.off} | ||
value={!value} | ||
isOff | ||
isClicked={isClicked} | ||
isHovered={isHovered} | ||
/> | ||
<TextBox | ||
text={texts.other.on} | ||
value={value} | ||
isClicked={isClicked} | ||
isHovered={isHovered} | ||
/> | ||
</Box> | ||
); | ||
} |
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
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
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
Oops, something went wrong.
6522393
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit was deployed on ipfs