Skip to content
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

Merged
merged 4 commits into from
Sep 3, 2020
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
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"react/jsx-filename-extension": "off",
"react/jsx-props-no-spreading": "off",
"react/forbid-prop-types": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"import/prefer-default-export": "off",
"react/prop-types": [
2,
{
Expand Down
2 changes: 2 additions & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import FormLayout from './FormLayout';
import InputField from './InputField';
import Loading from './Loading';
import { ButtonWithConfirmationModal, ButtonWithAlertModal } from './modals';
import { PublicPageLayout } from './layouts';
import NavBar from './NavBar';
import Table from './Table';
import Tags from './Tags';
Expand All @@ -25,4 +26,5 @@ export {
NavBar,
Table,
Tags,
PublicPageLayout,
};
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>
),
};
27 changes: 27 additions & 0 deletions src/components/layouts/PublicPageLayout/PublicPageLayout.tsx
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'
Copy link
Collaborator

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?

Copy link
Collaborator Author

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 :)

justify='center'
alignItems='center'
>
<Grid item className={classes.children}>
{children}
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it'll just be one thing

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good to me : )

</Grid>
</Grid>
);
}

export default withStyles(styles)(PublicPageLayout);
3 changes: 3 additions & 0 deletions src/components/layouts/PublicPageLayout/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import PublicPageLayout from './PublicPageLayout';

export default PublicPageLayout;
17 changes: 17 additions & 0 deletions src/components/layouts/PublicPageLayout/styles.ts
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;
3 changes: 3 additions & 0 deletions src/components/layouts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import PublicPageLayout from './PublicPageLayout';

export { PublicPageLayout };
2 changes: 2 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const config = {

firebase.initializeApp(config);

document.body.style.height = '100%';
document.body.style.margin = '0';
ReactDOM.render(<App />, document.getElementById('root'));

serviceWorker.unregister();
8 changes: 3 additions & 5 deletions src/pages/EventRsvpPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import EventRsvpForm from './components/EventRsvpForm';
import styles from './styles';

import HKN_TRIDENT_LOGO from '@Images/hkn-trident.png';
import { Loading } from '@SharedComponents';
import { Loading, PublicPageLayout } from '@SharedComponents';
import { getEventById } from '@Services/events';

class EventRsvpPage extends React.Component {
Expand Down Expand Up @@ -39,8 +39,6 @@ class EventRsvpPage extends React.Component {
}

handleSubmit = (values, setSubmitting) => {
console.log(values);

setSubmitting(false);
};

Expand All @@ -52,7 +50,7 @@ class EventRsvpPage extends React.Component {
eventInfo == null ? (
<Loading />
) : (
<div className={classes.root}>
<PublicPageLayout>
<Card className={classes.eventRsvpCard}>
<Grid container direction='column' alignItems='center' spacing={3}>
<Grid item>
Expand Down Expand Up @@ -87,7 +85,7 @@ class EventRsvpPage extends React.Component {
</Grid>
</Grid>
</Card>
</div>
</PublicPageLayout>
);

return EventRsvp;
Expand Down
8 changes: 3 additions & 5 deletions src/pages/EventSignInPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import EventSignInForm from './components/EventSignInForm';
import styles from './styles';

import HKN_TRIDENT_LOGO from '@Images/hkn-trident.png';
import { Loading } from '@SharedComponents';
import { Loading, PublicPageLayout } from '@SharedComponents';
import { getEventById } from '@Services/events';
import { signInToEvent } from '@Services/ApiEvents';

Expand Down Expand Up @@ -42,8 +42,6 @@ class EventSignInPage extends React.Component {
handleSubmit = (values, setSubmitting) => {
const { eventId } = this.state;

console.log(values);

signInToEvent(eventId, values);

setSubmitting(false);
Expand All @@ -57,7 +55,7 @@ class EventSignInPage extends React.Component {
eventInfo == null ? (
<Loading />
) : (
<div className={classes.root}>
<PublicPageLayout>
<Card className={classes.eventSignInCard}>
<Grid container direction='column' alignItems='center' spacing={3}>
<Grid item>
Expand Down Expand Up @@ -92,7 +90,7 @@ class EventSignInPage extends React.Component {
</Grid>
</Grid>
</Card>
</div>
</PublicPageLayout>
);

return EventSignIn;
Expand Down
47 changes: 20 additions & 27 deletions src/pages/SignUpPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { withStyles } from '@material-ui/core/styles';
import SignUpForm from './components/SignUpForm';
import styles from './styles';

import { PublicPageLayout } from '@SharedComponents/layouts';
import { createUserAccountFromSignup } from '@Services/auth';
import HKN_TRIDENT_LOGO from '@Images/hkn-trident.png';

Expand All @@ -31,34 +32,26 @@ class SignUpPage extends React.Component {
const { classes } = this.props;

return (
<Grid
className={classes.root}
container
direction='row'
justify='center'
alignItems='center'
>
<Grid item>
<Card elevation={3} className={classes.card}>
<CardContent>
<Grid
container
className={classes.cardContent}
alignItems='center'
direction='column'
spacing={2}
>
<Grid item>
<Avatar className={classes.logo} src={HKN_TRIDENT_LOGO} />
</Grid>
<Grid item>
<SignUpForm handleSubmit={this.handleSubmit} />
</Grid>
<PublicPageLayout>
<Card elevation={3} className={classes.card}>
<CardContent>
<Grid
container
className={classes.cardContent}
alignItems='center'
direction='column'
spacing={2}
>
<Grid item>
<Avatar className={classes.logo} src={HKN_TRIDENT_LOGO} />
</Grid>
</CardContent>
</Card>
</Grid>
</Grid>
<Grid item>
<SignUpForm handleSubmit={this.handleSubmit} />
</Grid>
</Grid>
</CardContent>
</Card>
</PublicPageLayout>
);
}
}
Expand Down