-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Public page layout component #146
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
import { Card, CardContent } from '@material-ui/core'; | ||
import { Story, Meta } from '@storybook/react'; | ||
|
||
import PublicPageLayout, { PublicPageLayoutProps } from './PublicPageLayout'; | ||
|
||
export default { | ||
title: 'Layouts/PublicPageLayout', | ||
component: PublicPageLayout, | ||
} as Meta; | ||
|
||
const Template: Story<PublicPageLayoutProps> = args => { | ||
const { children } = args; | ||
return <PublicPageLayout>{children}</PublicPageLayout>; | ||
}; | ||
|
||
export const SamplePublicPageLayout = Template.bind({}); | ||
SamplePublicPageLayout.args = { | ||
children: ( | ||
<Card> | ||
<CardContent> | ||
<h1>Title</h1> | ||
</CardContent> | ||
</Card> | ||
), | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import { Grid, WithStyles, withStyles } from '@material-ui/core'; | ||
|
||
import styles from './styles'; | ||
|
||
export interface PublicPageLayoutProps extends WithStyles<typeof styles> { | ||
children: JSX.Element; | ||
} | ||
|
||
function PublicPageLayout(props: PublicPageLayoutProps): JSX.Element { | ||
const { children, classes } = props; | ||
return ( | ||
<Grid | ||
className={classes.root} | ||
container | ||
direction='row' | ||
justify='center' | ||
alignItems='center' | ||
> | ||
<Grid item className={classes.children}> | ||
{children} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, is this grid item going to hold all of children, even when children can have multiple components? I thought grid item is usually used for only one component. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it'll just be one thing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good to me : ) |
||
</Grid> | ||
</Grid> | ||
); | ||
} | ||
|
||
export default withStyles(styles)(PublicPageLayout); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import PublicPageLayout from './PublicPageLayout'; | ||
|
||
export default PublicPageLayout; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Theme } from '@material-ui/core'; | ||
|
||
const styles = (theme: Theme) => ({ | ||
root: { | ||
[theme.breakpoints.up('sm')]: { | ||
marginTop: '8vh', | ||
}, | ||
[theme.breakpoints.only('xs')]: { | ||
marginTop: '3vh', | ||
}, | ||
}, | ||
children: { | ||
margin: theme.spacing(2), | ||
}, | ||
}); | ||
|
||
export default styles; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import PublicPageLayout from './PublicPageLayout'; | ||
|
||
export { PublicPageLayout }; |
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.
Just curious as to why you picked direction row here. Is it so that the whole screen is utilized, at least horizontally, if there are multiple children? Or does it just make sense from a design standpoint?
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.
great question
idk
it looks fine and will be encapsulated anyways :)