Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions components/atoms/SpacingPaper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Paper } from "@material-ui/core"
import { createStyles, makeStyles, Theme } from "@material-ui/core/styles"

const useStyles = makeStyles<Theme, IProps>((theme: Theme) =>
createStyles({
root: (props: IProps) => ({
padding: props.noPadding === true ? theme.spacing(0) : theme.spacing(2),
marginBottom: theme.spacing(2),
}),
})
)

interface IProps {
/**
* shildren
*/
children: React.ReactNode
/**
* zero-padding flag
*/
noPadding?: boolean
}

/**
* Paper with spacing
* @param props IProps
*/
export const SpacingPaper = (props: IProps) => {
const { children } = props
const classes = useStyles(props)
return (
<Paper className={classes.root} elevation={6}>
{children}
</Paper>
)
}
1 change: 1 addition & 0 deletions components/atoms/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./SpacingPaper"
11 changes: 4 additions & 7 deletions pages/about.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Paper, Typography } from "@material-ui/core"
import { Typography } from "@material-ui/core"
import { createStyles, makeStyles, Theme } from "@material-ui/core/styles"
import React from "react"
import { SpacingPaper } from "../components/atoms"
import { HeaderArticleContainer } from "../components/organisms"
import { Layout } from "../components/templates"
import { Page } from "../constants"
Expand All @@ -9,10 +10,6 @@ import { IPagePayload, PageActions } from "../store/actions"
const useStyles = makeStyles((theme: Theme) =>
createStyles({
root: {},
mainContainer: {
padding: theme.spacing(2),
marginBottom: theme.spacing(1),
},
})
)

Expand All @@ -21,9 +18,9 @@ function About() {
return (
<Layout>
<HeaderArticleContainer>
<Paper className={classes.mainContainer}>
<SpacingPaper>
<Typography variant="h5">About page !!</Typography>
</Paper>
</SpacingPaper>
</HeaderArticleContainer>
</Layout>
)
Expand Down
18 changes: 11 additions & 7 deletions pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { Paper, Typography } from "@material-ui/core"
import { Typography } from "@material-ui/core"
import { createStyles, makeStyles, Theme } from "@material-ui/core/styles"
import { SpacingPaper } from "../components/atoms"
import { HeaderArticleContainer } from "../components/organisms"
import { Layout } from "../components/templates"

const useStyles = makeStyles((theme: Theme) =>
createStyles({
root: {},
mainContainer: {
padding: theme.spacing(2),
marginBottom: theme.spacing(1),
},
})
)

Expand All @@ -18,9 +15,16 @@ function Index() {
return (
<Layout>
<HeaderArticleContainer>
<Paper className={classes.mainContainer}>
<SpacingPaper>
<Typography variant="h5">Hello Next.js 👋</Typography>
</Paper>
</SpacingPaper>

<SpacingPaper noPadding>
<Typography variant="h5">zero padding paper</Typography>
<Typography variant="h6">
This component use makeStyles refer to Theme and Props.
</Typography>
</SpacingPaper>
</HeaderArticleContainer>
</Layout>
)
Expand Down
14 changes: 5 additions & 9 deletions pages/redux.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import {
Avatar,
Button,
FormControl,
Paper,
TextField,
Typography,
} from "@material-ui/core"
import { createStyles, makeStyles, Theme } from "@material-ui/core/styles"
import React, { useState } from "react"
import { useDispatch, useSelector } from "react-redux"
import { SpacingPaper } from "../components/atoms"
import { HeaderArticleContainer } from "../components/organisms"
import { Layout } from "../components/templates"
import { Page } from "../constants"
Expand All @@ -23,10 +23,6 @@ const useStyles = makeStyles((theme: Theme) =>
backgroundColor: theme.palette.primary.main,
color: theme.palette.primary.contrastText,
},
mainContainer: {
padding: theme.spacing(2),
marginBottom: theme.spacing(1),
},
title: {
fontSize: "2em",
},
Expand Down Expand Up @@ -80,7 +76,7 @@ function Redux() {
return (
<Layout>
<HeaderArticleContainer>
<Paper className={classes.mainContainer}>
<SpacingPaper>
<Typography variant="h2" gutterBottom className={classes.title}>
Increment / Decrement
</Typography>
Expand All @@ -92,9 +88,9 @@ function Redux() {
<Button variant="contained" color="primary" onClick={handleDecrement}>
- 1
</Button>
</Paper>
</SpacingPaper>

<Paper className={classes.mainContainer}>
<SpacingPaper>
<FormControl>
<Typography variant="h2" gutterBottom className={classes.title}>
Calculate
Expand All @@ -118,7 +114,7 @@ function Redux() {
calculate
</Button>
</FormControl>
</Paper>
</SpacingPaper>
</HeaderArticleContainer>
</Layout>
)
Expand Down