Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update packages * Fix rollup errors, enable umd bundle * Remove unused deps from lib/package.json * Use rollup-plugin-terser instead of uglify * [docs] Add react-kawaii svg to add some spice :3 * [docs] Add custom _error page for next.js
- Loading branch information
1 parent
269329d
commit 1d002f0
Showing
7 changed files
with
140 additions
and
8 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,45 @@ | ||
import * as React from 'react'; | ||
import useMediaQuery from '@material-ui/core/useMediaQuery'; | ||
import { NoSsr } from '@material-ui/core'; | ||
import { getRandomItem } from 'utils/helpers'; | ||
import { useTheme } from '@material-ui/core/styles'; | ||
import { Backpack, Ghost, Cat, IceCream, Browser, SpeechBubble, KawaiiProps } from 'react-kawaii'; | ||
|
||
const icons = { | ||
ghost: Ghost, | ||
cat: Cat, | ||
backpack: Backpack, | ||
iceCream: IceCream, | ||
browser: Browser, | ||
bubble: SpeechBubble, | ||
}; | ||
|
||
function getRandomIcon() { | ||
const icon = getRandomItem(Object.keys(icons)); | ||
// @ts-ignore | ||
return icons[icon]; | ||
} | ||
|
||
interface KawaiiIconProps extends KawaiiProps { | ||
icon?: keyof typeof icons; | ||
className?: string; | ||
} | ||
|
||
const KawaiiIcon: React.FunctionComponent<KawaiiIconProps> = ({ icon, size, ...other }) => { | ||
const theme = useTheme(); | ||
const dimensionXs = useMediaQuery(theme.breakpoints.down('xs')); | ||
const calculatedSize = size || dimensionXs ? 230 : 320; | ||
const Component = React.useMemo(() => (icon ? icons[icon] : getRandomIcon()), [icon]); | ||
|
||
return ( | ||
<NoSsr> | ||
<Component size={calculatedSize} color={theme.palette.primary.main} {...other} /> | ||
</NoSsr> | ||
); | ||
}; | ||
|
||
KawaiiIcon.defaultProps = { | ||
mood: 'excited', | ||
}; | ||
|
||
export default KawaiiIcon; |
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,41 @@ | ||
import React from 'react'; | ||
import KawaiiIcon from '_shared/svgIcons/KawaiiIcon'; | ||
import { styled } from '@material-ui/styles'; | ||
import { Grid, Typography, NoSsr } from '@material-ui/core'; | ||
|
||
const CenteredGrid = styled(Grid)({ | ||
position: 'relative', | ||
top: '15vh', | ||
}); | ||
|
||
const KawaiiIconWithMargin = styled(KawaiiIcon)({ | ||
marginBottom: 65, | ||
}); | ||
|
||
class Error extends React.Component<{ statusCode: number }> { | ||
static getInitialProps({ res, err }: any) { | ||
const statusCode = res ? res.statusCode : err ? err.statusCode : null; | ||
return { statusCode }; | ||
} | ||
|
||
render() { | ||
const { statusCode } = this.props; | ||
|
||
return ( | ||
<CenteredGrid container direction="row" alignItems="center" justify="center"> | ||
<NoSsr> | ||
<Grid item container xs={12} justify="center"> | ||
<KawaiiIconWithMargin mood={Math.random() > 0.33 ? 'sad' : 'shocked'} /> | ||
</Grid> | ||
<Grid item xs={12}> | ||
<Typography align="center" variant="h1"> | ||
Error {statusCode} | ||
</Typography> | ||
</Grid> | ||
</NoSsr> | ||
</CenteredGrid> | ||
); | ||
} | ||
} | ||
|
||
export default Error; |
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
1d002f0
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.
Successfully aliased the URL https://material-ui-pickers-3yr2djwmi.now.sh to the following aliases.