add base UI with library and renters pages fleshed out

This commit is contained in:
David Lick
2020-05-28 00:18:43 -04:00
parent 6fc929e38b
commit b644567f71
32 changed files with 1007 additions and 151 deletions
+9 -37
View File
@@ -1,38 +1,10 @@
.App {
text-align: center;
}
@import url('https://fonts.googleapis.com/css2?family=Dancing+Script:wght@700&display=swap');
.App-logo {
height: 40vmin;
pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
html,
body,
#root {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
-9
View File
@@ -1,9 +0,0 @@
import React from 'react';
import { render } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
const { getByText } = render(<App />);
const linkElement = getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
+15 -21
View File
@@ -1,26 +1,20 @@
import React from 'react';
import logo from './logo.svg';
import './App.css';
import styled from 'styled-components';
import Sidebar from './containers/Sidebar/Sidebar';
import Content from './containers/Content/Content';
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
const AppContainer = styled.div`
background: #13334A;
min-height: 100%;
display: flex;
`
const App: React.FC = () => (
<AppContainer>
<Sidebar/>
<Content />
</AppContainer>
)
export default App;
@@ -0,0 +1,24 @@
import React from 'react';
import styled from 'styled-components';
import { Route } from 'react-router';
import Header from './Header/Header';
import Library from './Library/Library';
import Renters from './Renters/Renters';
const ContentContainer = styled.div`
width: 100%;
flex: 4;
`
const Content: React.FC = () => (
<ContentContainer>
<Header />
<Route path="/" exact component={Library} />
<Route path="/library" component={Library} />
<Route path="/renters" component={Renters} />
<Route path="/return" component={Renters} />
</ContentContainer>
)
export default Content;
@@ -0,0 +1,33 @@
import React from 'react';
import styled from 'styled-components';
import { Link } from 'react-router-dom';
const StyledButton = styled(Link)`
border: 2px solid #13334A;
color: #13334A;
text-decoration: none;
font-family: 'Helvetica';
font-size: 13px;
text-align: center;
line-height: 38px;
border-radius: 28px;
box-shadow: 10px 5px 15px rgba(0,0,0,50);
background-color: #B4D6E9;
display: block;
width: 150px;
height: 38px;
`
type Props = {
text: string;
destination: string;
}
const Button: React.FC<Props> = ({ text, destination }) => (
<StyledButton to={destination}>
{text}
</StyledButton>
)
export default Button;
@@ -0,0 +1,28 @@
import React from 'react';
import styled from 'styled-components';
import Button from './Button/Button';
const ButtonBayContainer = styled.div`
display: flex;
justify-content: space-between;
align-items: center;
margin-left: 7.5px;
width: 320px;
height: 100%;
`
const ButtonBay: React.FC = () => (
<ButtonBayContainer>
<Button
text="Register new renter"
destination="/renters"
/>
<Button
text="Checkout"
destination="/checkout"
/>
</ButtonBayContainer>
)
export default ButtonBay;
@@ -0,0 +1,20 @@
import React from 'react';
import styled from 'styled-components';
import ButtonBay from './ButtonBay/ButtonBay';
import Search from './Search/Search';
const HeaderContainer = styled.div`
height: 60px;
display: flex;
justify-content: space-between;
`
const Header: React.FC = () => (
<HeaderContainer>
<ButtonBay />
<Search />
</HeaderContainer>
)
export default Header;
@@ -0,0 +1,42 @@
import React from 'react';
import styled from 'styled-components';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faSearch } from '@fortawesome/free-solid-svg-icons';
const SearchContainer = styled.div`
width: 250px;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
`
const StyledInput = styled.input`
background-color: #ECECEC;
border: 2px solid #13334A;
border-radius: 25px;
width: 210px;
height: 38px;
color: #13334A;
font-size: 1.25rem;
outline: none;
padding-left: 20px;
box-shadow: 10px 5px 15px rgba(0,0,0,50)
`
const StyledIcon = styled(FontAwesomeIcon)`
color: #D97925;
position: absolute;
right: 25px;
font-size: 20px;
`
const Search: React.FC = () => (
<SearchContainer>
<StyledInput />
<StyledIcon icon={faSearch} />
</SearchContainer>
)
export default Search;
@@ -0,0 +1,73 @@
import React from 'react';
import styled from 'styled-components';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faCartPlus } from '@fortawesome/free-solid-svg-icons';
const BookContainer = styled.div`
display: flex;
flex-direction: column;
margin: 20px;
padding: 10px;
background-color: #fff;
border: 0.1px solid #8C8C8C;
box-shadow: 10px 5px 15px rgba(0,0,0,50);
width: 200px;
height: 350px;
`
const IconContainer = styled.div`
display: block;
position: absolute;
`
const StyledIcon = styled(FontAwesomeIcon)`
color: #D97925;
position: absolute;
top: 0;
right: 0;
transform: translate(220px, -15px);
font-size: 38px;
`
const CoverImage = styled.img`
max-width: 90%;
width: auto;
height: auto;
object-fit: contain;
margin: 0 auto;
`
const Title = styled.div`
text-align: center;
font-family: 'Helvetica';
font-size: 1.25rem;
margin-bottom: 5px;
`
const Author = styled.div`
text-align: center;
font-family: 'Helvetica';
font-size: 0.85rem;
`
type Props = {
title: string;
author: string;
imageLink: string;
}
const Book: React.FC<Props> = ({ title, author, imageLink }) => (
<BookContainer>
<IconContainer>
<StyledIcon icon={faCartPlus} />
</IconContainer>
<CoverImage
src={imageLink}
/>
<Title>{title}</Title>
<Author>{author}</Author>
</BookContainer>
)
export default Book;
@@ -0,0 +1,42 @@
import React from 'react';
import styled from 'styled-components';
import Book from './Book/Book';
const LibraryContainer = styled.div`
display: flex;
flex-wrap: wrap;
justify-content: center;
`
const books = [
{title: "To Kill a Mockingbird", author: "Harper Lee", imageLink: "http://www.prepressure.com/images/book-cover-to-kill-a-mocking-bird.jpg"},
{title: "To Kill a Mockingbird", author: "Harper Lee", imageLink: "http://www.prepressure.com/images/book-cover-to-kill-a-mocking-bird.jpg"},
{title: "To Kill a Mockingbird", author: "Harper Lee", imageLink: "http://www.prepressure.com/images/book-cover-to-kill-a-mocking-bird.jpg"},
{title: "To Kill a Mockingbird", author: "Harper Lee", imageLink: "http://www.prepressure.com/images/book-cover-to-kill-a-mocking-bird.jpg"},
{title: "To Kill a Mockingbird", author: "Harper Lee", imageLink: "http://www.prepressure.com/images/book-cover-to-kill-a-mocking-bird.jpg"},
{title: "To Kill a Mockingbird", author: "Harper Lee", imageLink: "http://www.prepressure.com/images/book-cover-to-kill-a-mocking-bird.jpg"},
{title: "To Kill a Mockingbird", author: "Harper Lee", imageLink: "http://www.prepressure.com/images/book-cover-to-kill-a-mocking-bird.jpg"},
{title: "To Kill a Mockingbird", author: "Harper Lee", imageLink: "http://www.prepressure.com/images/book-cover-to-kill-a-mocking-bird.jpg"},
{title: "To Kill a Mockingbird", author: "Harper Lee", imageLink: "http://www.prepressure.com/images/book-cover-to-kill-a-mocking-bird.jpg"},
{title: "To Kill a Mockingbird", author: "Harper Lee", imageLink: "http://www.prepressure.com/images/book-cover-to-kill-a-mocking-bird.jpg"},
{title: "To Kill a Mockingbird", author: "Harper Lee", imageLink: "http://www.prepressure.com/images/book-cover-to-kill-a-mocking-bird.jpg"},
{title: "To Kill a Mockingbird", author: "Harper Lee", imageLink: "http://www.prepressure.com/images/book-cover-to-kill-a-mocking-bird.jpg"},
{title: "To Kill a Mockingbird", author: "Harper Lee", imageLink: "http://www.prepressure.com/images/book-cover-to-kill-a-mocking-bird.jpg"},
{title: "To Kill a Mockingbird", author: "Harper Lee", imageLink: "http://www.prepressure.com/images/book-cover-to-kill-a-mocking-bird.jpg"},
{title: "To Kill a Mockingbird", author: "Harper Lee", imageLink: "http://www.prepressure.com/images/book-cover-to-kill-a-mocking-bird.jpg"}
]
const Library: React.FC = () => (
<LibraryContainer>
{books.map(book => (
<Book
title={book.title}
author={book.author}
imageLink={book.imageLink}
/>
))}
</LibraryContainer>
)
export default Library;
@@ -0,0 +1,26 @@
import React from 'react';
import styled from 'styled-components';
const BookReturnContainer = styled.div`
display: inline-flex;
height: 135px;
float: right;
`
const CoverImage = styled.img`
height: 100px;
object-fit: contain;
margin: auto 15px;
`
type Props = {
imageLink: string;
}
const BookReturn: React.FC<Props> = ({ imageLink }) => (
<BookReturnContainer>
<CoverImage src={imageLink} />
</BookReturnContainer>
);
export default BookReturn;
@@ -0,0 +1,95 @@
import React from 'react';
import styled from 'styled-components';
import BookReturn from './BookReturn/BookReturn';
const RenterCardContainer = styled.div`
background-color: #fff;
display: flex;
border: 0.1px solid #f0f0f0;
box-shadow: 10px 5px 15px rgba(175,175,175,50);
height: 135px;
margin: 10px 0;
`
const RenterImageContainer = styled.div`
width: 135px;
height: 135px;
border: 0.1px solid #f0f0f0;
`
const RenterImagePlaceholder = styled.img`
display: block;
object-fit: contain;
width: 135px;
margin: auto auto;
`
const RenterInfoContainer = styled.div`
min-width: 300px;
font-family: 'Helvetica';
color: #13334A;
font-weight: 100;
`
const RenterName = styled.div`
height: 2.25rem;
font-size: 31px;
margin: 25px 0 0 10px;
`
const RenterPhone = styled.div`
height: 1.5rem;
font-size: 18px;
margin: 0 0 0 10px;
`
const RenterEmail = styled.div`
font-size: 18px;
margin: 0 0 0 10px;
`
const RenterReturnContainer = styled.div`
width: 100%;
height: 135px;
`
type Props = {
name: string;
phone: string;
email: string;
}
const books = [
{title: "To Kill a Mockingbird", author: "Harper Lee", imageLink: "http://www.prepressure.com/images/book-cover-to-kill-a-mocking-bird.jpg"},
{title: "To Kill a Mockingbird", author: "Harper Lee", imageLink: "http://www.prepressure.com/images/book-cover-to-kill-a-mocking-bird.jpg"}
]
const RenterCard: React.FC<Props> = ({ name, phone, email }) => (
<RenterCardContainer>
<RenterImageContainer>
<RenterImagePlaceholder
src="https://avatars3.githubusercontent.com/u/47925772?s=400&v=4" />
</RenterImageContainer>
<RenterInfoContainer>
<RenterName>
{name}
</RenterName>
<RenterPhone>
{phone}
</RenterPhone>
<RenterEmail>
{email}
</RenterEmail>
</RenterInfoContainer>
<RenterReturnContainer>
{books.map(book => (
<BookReturn
imageLink={book.imageLink}
/>
))}
</RenterReturnContainer>
</RenterCardContainer>
)
export default RenterCard;
@@ -0,0 +1,37 @@
import React from 'react';
// import styled from 'styled-components';
import Panel from '../../UIKit/Panel/Panel';
import RenterCard from './RenterCard/RenterCard';
const renters = [
{name: 'John Doe', phone: '555-555-5555', email: 'john@doe.com'},
{name: 'John Doe', phone: '555-555-5555', email: 'john@doe.com'},
{name: 'John Doe', phone: '555-555-5555', email: 'john@doe.com'},
{name: 'John Doe', phone: '555-555-5555', email: 'john@doe.com'},
{name: 'John Doe', phone: '555-555-5555', email: 'john@doe.com'},
{name: 'John Doe', phone: '555-555-5555', email: 'john@doe.com'},
{name: 'John Doe', phone: '555-555-5555', email: 'john@doe.com'},
{name: 'John Doe', phone: '555-555-5555', email: 'john@doe.com'},
{name: 'John Doe', phone: '555-555-5555', email: 'john@doe.com'},
{name: 'John Doe', phone: '555-555-5555', email: 'john@doe.com'}
]
const Renters: React.FC = () => (
<Panel style={{
display: 'flex',
flexDirection: 'column',
flexWrap: 'wrap',
justifyContent: 'center'
}}>
{renters.map(renter => (
<RenterCard
name={renter.name}
phone={renter.phone}
email={renter.email}
/>
))}
</Panel>
)
export default Renters;
@@ -0,0 +1,20 @@
import React from 'react';
import styled from 'styled-components';
import { Link } from 'react-router-dom';
const StyledLink = styled(Link)`
color: #D97925;
font-size: 3rem;
font-family: 'Dancing Script', cursive;
text-decoration: none;
`
const Logo: React.FC = () => (
<StyledLink
to="/"
>
bookish
</StyledLink>
)
export default Logo;
@@ -0,0 +1,37 @@
import React from 'react';
import styled from 'styled-components';
import MenuItem from './MenuItem/MenuItem';
import { faBookReader, faUser, faShoppingCart, faReply } from '@fortawesome/free-solid-svg-icons';
const MenuContainer = styled.div`
margin-top: 1rem;
display: flex;
flex-flow: column nowrap;
width: 275px;
`
export default () => (
<MenuContainer>
<MenuItem
title="Library"
destination="/library"
icon={faBookReader}
/>
<MenuItem
title="Renters"
destination="/renters"
icon={faUser}
/>
<MenuItem
title="Checkout"
destination="/checkout"
icon={faShoppingCart}
/>
<MenuItem
title="Return"
destination="/return"
icon={faReply}
/>
</MenuContainer>
)
@@ -0,0 +1,38 @@
import React from 'react';
import styled from 'styled-components';
import { Link } from 'react-router-dom';
import Icon from '../../../../hocs/Icon/Icon';
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
const MenuItemContainer = styled.div`
margin-top: 20px;
margin-left: 25px;
`
const MenuLink = styled(Link)`
color: #7C7C7C;
font-family: 'Helvetica';
font-size: 28px;
font-weight: 100;
text-decoration: none;
`
type OtherProps = {
title: string;
destination: string;
icon: IconDefinition;
}
const MenuItem: React.FC<OtherProps> = ({ title, destination, icon }) => (
<MenuItemContainer>
<MenuLink to={destination}>
<Icon
icon={icon}
/>{title}
</MenuLink>
</MenuItemContainer>
)
export default MenuItem;
@@ -0,0 +1,26 @@
import React from 'react';
import styled from 'styled-components';
import Logo from './Logo/Logo'
import Menu from './Menu/Menu'
const SidebarContainer = styled.div`
background: #011126;
box-shadow: 0px 0px 5px rgba(0,0,0,50);
padding-top: 2.5%;
min-width: 275px;
flex: 1;
display: flex;
flex-flow: column nowrap;
align-items: center;
float: left;
`
const Sidebar: React.FC = () => (
<SidebarContainer>
<Logo />
<Menu />
</SidebarContainer>
);
export default Sidebar;
@@ -0,0 +1,25 @@
import React from 'react';
import styled from 'styled-components';
import CSS from 'csstype';
const PanelContainer = styled.div`
background-color: #ECECEC;
border: 2px solid #13334A;
box-shadow: 10px 5px 15px rgba(0,0,0,50);
width: 90%;
margin: 10px auto;
padding: 20px;
`
type Props = {
children: React.ReactNode;
style: CSS.Properties;
}
const Panel: React.FC<Props> = ({ children, style }) => (
<PanelContainer style={style}>
{children}
</PanelContainer>
)
export default Panel;
+30
View File
@@ -0,0 +1,30 @@
import React from 'react';
import styled from 'styled-components';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
const IconContainer = styled.div`
display: inline-block;
text-align: center;
width: 100%;
margin-right: 30px;
width: 40px;
height: 40px;
`
const StyledIcon = styled(FontAwesomeIcon)`
font-size: 28px;
color: #D97925;
`
type OtherProps = {
icon: IconDefinition;
}
const Icon: React.FC<OtherProps> = ({ icon }) => (
<IconContainer>
<StyledIcon icon={icon} />
</IconContainer>
)
export default Icon;
-13
View File
@@ -1,13 +0,0 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
+5 -5
View File
@@ -1,17 +1,17 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import { BrowserRouter as Router } from 'react-router-dom';
ReactDOM.render(
<React.StrictMode>
<App />
<Router>
<App />
</Router>
</React.StrictMode>,
document.getElementById('root')
);
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
-7
View File
@@ -1,7 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3">
<g fill="#61DAFB">
<path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/>
<circle cx="420.9" cy="296.5" r="45.7"/>
<path d="M520.5 78.1z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.6 KiB

+1 -1
View File
@@ -2,4 +2,4 @@
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom/extend-expect';
// import '@testing-library/jest-dom/extend-expect';