Skip to content

Commit

Permalink
Create a basic layout component
Browse files Browse the repository at this point in the history
  • Loading branch information
ddrosario committed Mar 27, 2024
1 parent 0c6385b commit f53ee8e
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 6 deletions.
17 changes: 11 additions & 6 deletions client/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@ import React from 'react';
import { Routes, Route } from 'react-router-dom';
import Index from './pages';
import Login from './pages/login';
import NavBar from './components/NavBar';
import { Layout } from './stories/Layout/Layout';

/**
*
* @returns {React.ReactElement}
*/
function App() {
return (
<>
<NavBar />
<Routes>
<Route path="/" element={<Index />} />
<Route path="/login" element={<Login />} />
</Routes>
<Layout>
<Routes>
<Route path="/" element={<Index />} />
<Route path="/login" element={<Login />} />
</Routes>
</Layout>
</>
);
}
Expand Down
47 changes: 47 additions & 0 deletions client/src/stories/Footer/Footer.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Container, Group, Anchor } from '@mantine/core';
import './footer.css';

const links = [
{ link: '#', label: 'Contact' },
{ link: '#', label: 'Privacy' },
{ link: '#', label: 'Blog' },
{ link: '#', label: 'Careers' },
];

/**
* Footer
* @param {PropTypes.InferProps<typeof FooterProps>} props
*/
export const Footer = () => {
return (
<footer className="footer">
<Container>
<Group className="links">
{links.map((link) => (
<Anchor
c="dimmed"
key={link.label}
href={link.link}
onClick={(event) => event.preventDefault()}
size="sm"
>
{link.label}
</Anchor>
))}
</Group>
</Container>
</footer>
);
};

const FooterProps = {
children: PropTypes.node,
};

Footer.propTypes = FooterProps;

Footer.defaultProps = {
children: null,
};
14 changes: 14 additions & 0 deletions client/src/stories/Footer/Footer.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Footer } from './Footer';

export default {
title: 'Example/Footer',
component: Footer,
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
tags: ['autodocs'],
parameters: {
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
layout: 'fullscreen',
},
};

export const LoggedOut = {};
5 changes: 5 additions & 0 deletions client/src/stories/Footer/footer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.footer {
padding: 1rem 1rem;
width: fit-content;
margin: 0 auto;
}
35 changes: 35 additions & 0 deletions client/src/stories/Layout/Layout.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';
import PropTypes from 'prop-types';

import { Header } from '../Header/Header';
import { Footer } from '../Footer/Footer';

import './layout.css';

/**
* Main layout
* @param {PropTypes.InferProps<typeof LayoutProps>} props
*/
export const Layout = ({ children }) => {
return (
<div className="layout">
<div className="layout-header">
<Header />
</div>
<div className="layout-content">{children}</div>
<div className="layout-footer">
<Footer />
</div>
</div>
);
};

const LayoutProps = {
children: PropTypes.node,
};

Layout.propTypes = LayoutProps;

Layout.defaultProps = {
children: null,
};
24 changes: 24 additions & 0 deletions client/src/stories/Layout/layout.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.layout {
min-height: 100vh;
min-height: 100dvh;
width: 100vw;

display: grid;
grid-template-rows: 100% 1fr 100%;
grid-template-areas:
'head'
'main'
'foot';
}

.layout-header {
grid-area: head;
}

.layout-content {
grid-area: main;
}

.layout-footer {
grid-area: foot;
}

0 comments on commit f53ee8e

Please sign in to comment.