-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Christmas logo and change show switcher (#77)
- Loading branch information
1 parent
13e6c02
commit 9c75c5c
Showing
6 changed files
with
65 additions
and
88 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, { memo } from 'react'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import Fab from '@material-ui/core/Fab'; | ||
import AcUnitIcon from '@material-ui/icons/AcUnit'; | ||
import { useSnowflakes } from './hooks/useSnowflakes'; | ||
import clsx from 'clsx'; | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
fab: { | ||
position: 'absolute', | ||
bottom: theme.spacing(2), | ||
right: theme.spacing(3), | ||
backgroundColor: 'white', | ||
}, | ||
snowing: { | ||
backgroundColor: '#F2E14C', | ||
}, | ||
})); | ||
|
||
export const SnowSwitcher = memo(function SnowSwitcher() { | ||
const classes = useStyles(); | ||
const { isSnowing, handleSnowSwitch } = useSnowflakes(); | ||
|
||
return ( | ||
<Fab | ||
className={clsx(classes.fab, { [classes.snowing]: isSnowing })} | ||
size="medium" | ||
onClick={handleSnowSwitch} | ||
> | ||
<AcUnitIcon /> | ||
</Fab> | ||
); | ||
}); |
102 changes: 19 additions & 83 deletions
102
apps/js-machine-front/src/app/components/Snowflakes.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 |
---|---|---|
@@ -1,89 +1,25 @@ | ||
import React from 'react'; | ||
|
||
import Switch from '@material-ui/core/Switch'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
|
||
import { useSnowflakes } from './hooks/useSnowflakes'; | ||
|
||
const MAIN_YELLOW = '#F2E14C'; | ||
|
||
const useStyles = makeStyles( theme => ({ | ||
snow: { | ||
position: 'fixed', | ||
height: '100%', | ||
width: '100%', | ||
zIndex: 1, | ||
pointerEvents: 'none', | ||
}, | ||
snowSwitcher: { | ||
display: 'flex', | ||
color: 'white', | ||
position: 'absolute', | ||
zIndex: 1101, | ||
[theme.breakpoints.up('md')]: { | ||
top: '29px', | ||
left: '38px', | ||
}, | ||
[theme.breakpoints.down('sm')]: { | ||
top: '18px', | ||
left: '24px', | ||
}, | ||
[theme.breakpoints.down('xs')]: { | ||
top: '-2px', | ||
left: '-4px', | ||
flexDirection: 'row-reverse', | ||
}, | ||
}, | ||
snowSwitcherLabel: { | ||
fontSize: '0.9rem', | ||
}, | ||
|
||
colorSecondary: { | ||
'&$checked': { | ||
color: MAIN_YELLOW, | ||
}, | ||
}, | ||
switchBase: { | ||
color: 'white', | ||
'&$checked': { | ||
color: 'white', | ||
'& + $track': { | ||
backgroundColor: MAIN_YELLOW, | ||
opacity: 1, | ||
}, | ||
"&:hover": { | ||
backgroundColor: '#f2e14c4d', | ||
}, | ||
}, | ||
}, | ||
track: {}, | ||
checked: {}, | ||
const useStyles = makeStyles(theme => ({ | ||
snow: { | ||
position: 'fixed', | ||
height: '100%', | ||
width: '100%', | ||
zIndex: 1, | ||
pointerEvents: 'none', | ||
}, | ||
})); | ||
|
||
export function Snowflakes() { | ||
|
||
const {isSnowing, handleSnowSwitch} = useSnowflakes(); | ||
|
||
const classes = useStyles(); | ||
|
||
return ( | ||
<> | ||
<div className={classes.snowSwitcher}> | ||
<span className={classes.snowSwitcherLabel}>Happy New Year</span> | ||
<Switch | ||
classes={{ | ||
colorSecondary: classes.colorSecondary, | ||
switchBase: classes.switchBase, | ||
track: classes.track, | ||
checked: classes.checked, | ||
}} | ||
size='small' | ||
checked={isSnowing} | ||
value={isSnowing} | ||
onClick={handleSnowSwitch}> | ||
</Switch> | ||
</div> | ||
<canvas id='snow' className={classes.snow} width={window.innerWidth} height={window.innerHeight}></canvas> | ||
</> | ||
); | ||
} | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<canvas | ||
id="snow" | ||
className={classes.snow} | ||
width={window.innerWidth} | ||
height={window.innerHeight} | ||
/> | ||
); | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.