Skip to content

Commit

Permalink
Chore/kawaii (#1029)
Browse files Browse the repository at this point in the history
* 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
dmtrKovalenko committed May 6, 2019
1 parent 269329d commit 1d002f0
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 8 deletions.
45 changes: 45 additions & 0 deletions docs/_shared/svgIcons/KawaiiIcon.tsx
@@ -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;
4 changes: 3 additions & 1 deletion docs/package.json
Expand Up @@ -19,7 +19,7 @@
"@date-io/luxon": "^1.2.0",
"@date-io/moment": "^1.3.0",
"@mapbox/rehype-prism": "^0.3.1",
"@material-ui/core": "^4.0.0-alpha.7",
"@material-ui/core": "^4.0.0-beta.1",
"@material-ui/icons": "^3.0.2",
"@material-ui/pickers": "^3.0.0-alpha.1",
"@material-ui/styles": "^4.0.0-alpha.7",
Expand All @@ -29,6 +29,7 @@
"@types/prismjs": "^1.9.1",
"@types/react": "^16.8.13",
"@types/react-jss": "^8.6.2",
"@types/react-kawaii": "^0.11.0",
"@types/styled-jsx": "^2.2.8",
"@types/w3c-permissions": "^1.0.1",
"@zeit/next-bundle-analyzer": "^0.1.2",
Expand Down Expand Up @@ -58,6 +59,7 @@
"react-docgen-typescript": "^1.12.3",
"react-dom": "^16.8.2",
"react-jss": "^8.6.1",
"react-kawaii": "^0.12.0",
"remark-slug": "^5.1.1",
"safe-json-stringify": "^1.2.0",
"typescript": "^3.4.4",
Expand Down
41 changes: 41 additions & 0 deletions docs/pages/_error.tsx
@@ -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;
29 changes: 24 additions & 5 deletions docs/pages/api/props.tsx
Expand Up @@ -2,12 +2,25 @@ import * as React from 'react';
import Ad from '_shared/Ad';
import Code from '_shared/Code';
import PropTypesTable from '_shared/PropTypesTable';
import KawaiiIcon from '_shared/svgIcons/KawaiiIcon';
import { PageMeta } from '_shared/PageMeta';
import { Typography } from '@material-ui/core';
import { WithRouterProps, withRouter } from 'next/router';
import { Typography, Grid, makeStyles } from '@material-ui/core';

const internalComponents = ['Calendar', 'TimePickerView'];
const useStyles = makeStyles(theme => ({
kawaiiIcon: {
marginTop: 48,
},
title: {
[theme.breakpoints.down('xs')]: {
order: 2,
},
},
}));

const Docs: React.FC<WithRouterProps> = ({ router }) => {
const classes = useStyles();
const componentName = router!.query!.component! as any; // just crash if name is invalid

const title = `${componentName} API`;
Expand All @@ -17,10 +30,16 @@ const Docs: React.FC<WithRouterProps> = ({ router }) => {
<>
<PageMeta title={title} description={description} />

<h2>{title}</h2>
<p>{description}</p>

<Ad />
<Grid container justify="space-between" alignItems="center">
<Grid item md={6} className={classes.title}>
<h3>{title}</h3>
<p>{description}</p>
<Ad />
</Grid>
<Grid item md={6} container alignItems="flex-end" justify="center">
<KawaiiIcon className={classes.kawaiiIcon} size={220} />
</Grid>
</Grid>

<h4> Import </h4>
<Code language="jsx">{`import { ${componentName} } from '@material-ui/pickers'`}</Code>
Expand Down
9 changes: 8 additions & 1 deletion docs/pages/index/Landing.tsx
Expand Up @@ -5,6 +5,7 @@ import Logo from '_shared/svgIcons/Logo';
import Code from '@material-ui/icons/Code';
import Alarm from '@material-ui/icons/Alarm';
import GitHub from '_shared/svgIcons/GithubIcon';
import KawaiiIcon from '_shared/svgIcons/KawaiiIcon';
import Devices from '@material-ui/icons/DevicesOther';
import PatreonSponsors from '_shared/PatreonSponsors';
import { GITHUB_URL } from '_constants';
Expand Down Expand Up @@ -37,7 +38,7 @@ const useStyles = makeStyles<Theme>(theme => ({
alignItems: 'center',
backgroundColor: theme.palette.primary.main,
color: theme.palette.getContrastText(theme.palette.primary.main),
padding: '160px 20px 100px',
padding: '160px 20px 60px',
[theme.breakpoints.down('sm')]: {
paddingTop: 100,
},
Expand Down Expand Up @@ -74,13 +75,17 @@ const useStyles = makeStyles<Theme>(theme => ({
backgroundColor: theme.palette.background.default,
marginBottom: -50,
},
kawaiiIcon: {
marginBottom: 32,
},
content: {
padding: '80px 16px 0',
backgroundColor: theme.palette.background.default,
minHeight: 'calc(100vh - 63px)',
maxWidth: 1100,
margin: '0 auto',
display: 'flex',
alignItems: 'center',
flexDirection: 'column',
'@media(max-width: 600px)': {
minHeight: 'calc(100vh - 55px)',
Expand Down Expand Up @@ -168,6 +173,8 @@ const Landing = () => {
</Toolbar>

<div className={classes.content}>
<KawaiiIcon className={classes.kawaiiIcon} />

<Typography gutterBottom variant="h4" align="center">
Support @material-ui/pickers
</Typography>
Expand Down
4 changes: 4 additions & 0 deletions docs/utils/helpers.ts
Expand Up @@ -40,3 +40,7 @@ export function loadScript(src: string, position: Element) {

return script;
}

export function getRandomItem<T>(arr: T[]): T {
return arr[Math.floor(Math.random() * arr.length)];
}
16 changes: 15 additions & 1 deletion yarn.lock
Expand Up @@ -1073,7 +1073,7 @@
refractor "^2.3.0"
unist-util-visit "^1.1.3"

"@material-ui/core@^4.0.0-alpha.7", "@material-ui/core@^4.0.0-beta.0":
"@material-ui/core@^4.0.0-beta.0", "@material-ui/core@^4.0.0-beta.1":
version "4.0.0-beta.1"
resolved "https://registry.yarnpkg.com/@material-ui/core/-/core-4.0.0-beta.1.tgz#5f8f47b66e92f266abbad6cfcc9efa6e5d87e54c"
integrity sha512-QuUKg7+myF+UdBs1MrCNo5N02sbXgfji7OQ8ImWzQRcwhB0uVqmGhB7rPiQnq8yb32e1X37btCinjE+gxdY1XA==
Expand Down Expand Up @@ -1421,6 +1421,13 @@
"@types/theming" "*"
csstype "^2.0.0"

"@types/react-kawaii@^0.11.0":
version "0.11.0"
resolved "https://registry.yarnpkg.com/@types/react-kawaii/-/react-kawaii-0.11.0.tgz#99e8454c006f9e163f2910d44d15c0f3908ffcaf"
integrity sha512-SgasNJZL2DaHt//sxWWDHv1j4HAznkUpHfYh9BGOsDku/DDu6dDATUQSkTYan6883YYSEP+nJM8F0FGxhrCUSg==
dependencies:
"@types/react" "*"

"@types/react-loadable@*":
version "5.5.1"
resolved "https://registry.yarnpkg.com/@types/react-loadable/-/react-loadable-5.5.1.tgz#f04a262f16e9f088098ddad1aa50682ad0984aa7"
Expand Down Expand Up @@ -9200,6 +9207,13 @@ react-jss@^8.6.1:
prop-types "^15.6.0"
theming "^1.3.0"

react-kawaii@^0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/react-kawaii/-/react-kawaii-0.12.0.tgz#e1eeb5bc3818d91bb609f5bf2992ce9bbea738ed"
integrity sha512-qcRhCy8+8CFWw9VZu2pY9eMsjcaB83ZmJ6sH+BqyeaZnA0YlEzB3oPGVBJEX4KYd7/Dj/dB/7R98OnSixIY5Wg==
dependencies:
prop-types "^15.6.2"

react-lifecycles-compat@^3.0.2:
version "3.0.4"
resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"
Expand Down

1 comment on commit 1d002f0

@vercel
Copy link

@vercel vercel bot commented on 1d002f0 May 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.