Compare commits
11 Commits
react-app-
...
ui
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
42cdf6c788 | ||
|
|
de22b649a2 | ||
|
|
7bc236e7e7 | ||
|
|
db72085762 | ||
|
|
406a89db39 | ||
|
|
3f01282bcc | ||
|
|
998cf45a97 | ||
|
|
c474fe3792 | ||
|
|
64a9420b01 | ||
|
|
90d633ed23 | ||
|
|
5d3c81a650 |
@@ -3,13 +3,16 @@
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@material-ui/core": "^4.6.0",
|
||||
"firebase": "^7.2.2",
|
||||
"node-sass": "^4.13.0",
|
||||
"react": "^16.11.0",
|
||||
"react-dom": "^16.11.0",
|
||||
"react-redux": "^7.1.1",
|
||||
"react-scripts": "3.2.0",
|
||||
"redux": "^4.0.4",
|
||||
"redux-thunk": "^2.3.0"
|
||||
"redux-thunk": "^2.3.0",
|
||||
"uuid": "^3.3.3"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta
|
||||
name="viewport"
|
||||
content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no"
|
||||
/>
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
|
||||
22
src/App.css
22
src/App.css
@@ -1,22 +0,0 @@
|
||||
.App {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.App-logo {
|
||||
height: 40vmin;
|
||||
}
|
||||
|
||||
.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: #09d3ac;
|
||||
}
|
||||
53
src/App.js
53
src/App.js
@@ -1,12 +1,59 @@
|
||||
import React from "react";
|
||||
import { Provider } from "react-redux";
|
||||
import Boxes from "./boxes/Boxes";
|
||||
import styles from "./App.module.css";
|
||||
import {
|
||||
Grid,
|
||||
Paper,
|
||||
Container,
|
||||
Card,
|
||||
CardContent,
|
||||
Typography,
|
||||
CardActions,
|
||||
Button,
|
||||
AppBar,
|
||||
Toolbar,
|
||||
IconButton,
|
||||
Menu
|
||||
} from "@material-ui/core";
|
||||
import setupStore from "./store/setupStore.js";
|
||||
import CssBaseline from "@material-ui/core/CssBaseline";
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<Provider store={setupStore()}>
|
||||
<div>Yoooooo</div>
|
||||
</Provider>
|
||||
<CssBaseline>
|
||||
<Provider store={setupStore()}>
|
||||
<AppBar position="static">
|
||||
<Toolbar>
|
||||
<Typography variant="h6">
|
||||
Retro.d
|
||||
</Typography>
|
||||
</Toolbar>
|
||||
</AppBar>
|
||||
<Container fluid>
|
||||
<Grid fluid container spacing={3}>
|
||||
<Grid item xs={4}>
|
||||
<Card>xs=3</Card>
|
||||
</Grid>
|
||||
<Grid item xs={4}>
|
||||
<Card>xs=3</Card>
|
||||
</Grid>
|
||||
<Grid item xs={4}>
|
||||
<Card>
|
||||
<CardContent>
|
||||
<Typography component="p">
|
||||
well meaning and kindly.
|
||||
</Typography>
|
||||
<CardActions>
|
||||
<Button size="small">Dismiss</Button>
|
||||
</CardActions>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Container>
|
||||
</Provider>
|
||||
</CssBaseline>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
14
src/App.module.css
Normal file
14
src/App.module.css
Normal file
@@ -0,0 +1,14 @@
|
||||
.grid{
|
||||
display: grid;
|
||||
grid-template-columns: auto auto auto;
|
||||
grid-column-gap: 1em;
|
||||
margin: 1rem;
|
||||
}
|
||||
|
||||
.column {
|
||||
|
||||
}
|
||||
|
||||
/* .cssBaseline {
|
||||
padding: 0;
|
||||
} */
|
||||
9
src/Items/Items.js
Normal file
9
src/Items/Items.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import React from 'react';
|
||||
|
||||
export default function Item({ item }) {
|
||||
return (
|
||||
<div style={{ textDecoration: item.completed ? "line-through" : "" }}>
|
||||
{item.title}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
23
src/NewItem/NewItem.js
Normal file
23
src/NewItem/NewItem.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import React, {useState} from 'react';
|
||||
|
||||
export default function NewItem({ addItem }) {
|
||||
const [value, setValue ] = useState("");
|
||||
|
||||
const handleSubmit = e => {
|
||||
e.preventDefault();
|
||||
if(!value) return;
|
||||
|
||||
addItem(value);
|
||||
setValue("");
|
||||
}
|
||||
return (
|
||||
<form onSubmit={handleSubmit}>
|
||||
<input
|
||||
type="text"
|
||||
value={value}
|
||||
placeholder="stuff"
|
||||
onChange={e => setValue(e.target.value)}
|
||||
/>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
14
src/boxes/Boxes.js
Normal file
14
src/boxes/Boxes.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import React from 'react';
|
||||
import styles from './Boxes.module.css'
|
||||
import Cards from '../cards/Cards.js'
|
||||
|
||||
export default function Boxes({ sectionName }) {
|
||||
return (
|
||||
<div>
|
||||
<h3>{sectionName}</h3>
|
||||
<div className={styles.box}>
|
||||
<Cards />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
3
src/boxes/Boxes.module.css
Normal file
3
src/boxes/Boxes.module.css
Normal file
@@ -0,0 +1,3 @@
|
||||
.box{
|
||||
border: .15rem solid black;
|
||||
}
|
||||
56
src/cards/Cards.js
Normal file
56
src/cards/Cards.js
Normal file
@@ -0,0 +1,56 @@
|
||||
import React, { useState, useEffect, useMemo } from 'react';
|
||||
import { databaseRef } from '../store/firebase.js'
|
||||
import Item from '../Items/Items.js';
|
||||
import NewItem from '../NewItem/NewItem.js'
|
||||
import uuid from "uuid";
|
||||
|
||||
export function Cards({item, setItem}) {
|
||||
|
||||
const addItem = title => {
|
||||
const newItem = [...item, {title, completed: false, id: uuid.v4()}];
|
||||
setItem(newItem)
|
||||
}
|
||||
const deleteItem = id => {
|
||||
const deleted = item.reduce((acc, current) => {
|
||||
if(current.id !== id){
|
||||
return [...acc, current];
|
||||
}
|
||||
return [...acc, {...current, completed: true}]
|
||||
}, [])
|
||||
setItem(deleted)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{item.map((i, index) => (
|
||||
<div key={i.id}>
|
||||
<Item
|
||||
item={i}
|
||||
index={index}
|
||||
/>
|
||||
<button onClick={() => deleteItem(i.id) }>x</button>
|
||||
</div>
|
||||
))}
|
||||
<NewItem addItem={addItem} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default function FirebaseWrapper() {
|
||||
const [cards, setCards] = useState(null)
|
||||
const retroRef = useMemo(() => databaseRef.ref('retros/1'), []);
|
||||
useEffect(() => {
|
||||
retroRef.on('value', function(snapshot) {
|
||||
const values = Object.values(snapshot.val())
|
||||
setCards(values)
|
||||
});
|
||||
// this will be called when our component unmounts
|
||||
return () => {
|
||||
retroRef.off();
|
||||
}
|
||||
}, [retroRef]);
|
||||
if(!cards) {
|
||||
return <div>loading...</div>;
|
||||
};
|
||||
return <Cards item={cards} setItem={()=> {}}/>
|
||||
}
|
||||
0
src/cards/Cards.module.scss
Normal file
0
src/cards/Cards.module.scss
Normal file
12
src/deleteItem/DeleteItem.js
Normal file
12
src/deleteItem/DeleteItem.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import React, {useState} from 'react';
|
||||
|
||||
export default function DeleteItem({ deleteItem }) {
|
||||
|
||||
const handleClick = e => {
|
||||
deleteItem(value);
|
||||
setValue("");
|
||||
}
|
||||
return (
|
||||
<button onClick={handleClick}>x</button>
|
||||
)
|
||||
}
|
||||
17
src/hooks/useFirebase.js
Normal file
17
src/hooks/useFirebase.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { useState, useEffect, useMemo } from 'react';
|
||||
import { databaseRef } from '../store/firebase.js'
|
||||
export default function useFirebase(pathRef) {
|
||||
const [data, setData] = useState(null)
|
||||
const retroRef = useMemo(() => databaseRef.ref(pathRef), [pathRef]);
|
||||
useEffect(() => {
|
||||
retroRef.on('value', function(snapshot) {
|
||||
const values = Object.values(snapshot.val())
|
||||
setData(values)
|
||||
});
|
||||
// this will be called when our component unmounts
|
||||
return () => {
|
||||
retroRef.off();
|
||||
}
|
||||
}, [retroRef]);
|
||||
return [data]
|
||||
}
|
||||
7
src/store/firebase.js
Normal file
7
src/store/firebase.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import * as firebase from 'firebase';const config = {
|
||||
apiKey: "AIzaSyC5krz4RBiT87RK7cEidh3n-A4H63uGcyM",
|
||||
authDomain: "retrod-7e2cd.firebaseapp.com",
|
||||
databaseURL: "https://retrod-7e2cd.firebaseio.com/",
|
||||
}
|
||||
firebase.initializeApp(config);
|
||||
export const databaseRef = firebase.database();
|
||||
@@ -1,13 +1,14 @@
|
||||
import { createStore, applyMiddleware, compose } from "redux";
|
||||
import thunk from "redux-thunk";
|
||||
import rootReducer from "../reducers/main.js";
|
||||
const devTools = window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__();
|
||||
|
||||
export default function setupStore() {
|
||||
return createStore(
|
||||
rootReducer,
|
||||
compose(
|
||||
applyMiddleware(thunk),
|
||||
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
|
||||
(devTools || function(f) { return f; })
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user