Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
its-VinayKumar committed Jul 31, 2023
1 parent c04b203 commit 905dcdc
Show file tree
Hide file tree
Showing 10 changed files with 314 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "keeper-web-app",
"version": "1.0.0",
"description": "",
"keywords": [],
"main": "src/index.js",
"dependencies": {
"@material-ui/core": "4.6.1",
"@material-ui/icons": "4.5.1",
"react": "16.8.6",
"react-dom": "16.8.6",
"react-scripts": "3.2.0",
"uuid": "3.3.3"
},
"devDependencies": {
"typescript": "3.3.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
16 changes: 16 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Keeper App</title>
<link font-family: "Montserrat", sans-serif;
href="https://fonts.googleapis.com/css?family=McLaren|Montserrat&display=swap"
rel="stylesheet" />
<link rel="stylesheet" href="styles.css" />
<link id="external-css" rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Montserrat&amp;display=swap" media="all">
</head>

<body>
<div id="root"></div>
<script src="../src/index.js" type="text/jsx"></script>
</body>
</html>
103 changes: 103 additions & 0 deletions public/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
html {
font-family: "Montserrat", sans-serif;
}
body {
background: #eee;
background-image: url("https://www.transparenttextures.com/patterns/cubes.png");
padding: 0 16px;
}

header {
background-color: #f5ba13;
margin: auto -16px;
padding: 16px 32px;
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.3);
}

header h1 {
color: #fff;
font-family: "McLaren", cursive;
font-weight: 200;
}

footer {
position: absolute;
text-align: center;
bottom: 0;
width: 100%;
height: 2.5rem;
}

footer p {
color: #ccc;
}
.note {
background: #fff;
border-radius: 7px;
box-shadow: 0 2px 5px #ccc;
padding: 10px;
width: 240px;
margin: 16px;
float: left;
}
.note h1 {
font-size: 1.1em;
margin-bottom: 6px;
}
.note p {
font-size: 1.1em;
margin-bottom: 10px;
white-space: pre-wrap;
word-wrap: break-word;
}

.note button {
position: relative;
float: right;
margin-right: 10px;
color: #f5ba13;
border: none;
width: 36px;
height: 36px;
cursor: pointer;
outline: none;
}

form.create-note {
position: relative;
width: 480px;
margin: 30px auto 20px auto;
background: #fff;
padding: 15px;
border-radius: 7px;
box-shadow: 0 1px 5px rgb(138, 137, 137);
}
form.create-note input,
form.create-note textarea {
width: 100%;
border: none;
padding: 4px;
outline: none;
font-size: 1.2em;
font-family: inherit;
resize: none;
}
form.create-note button {
position: absolute;
right: 18px;
bottom: -18px;
background: #f5ba13;
color: #fff;
border: none;
border-radius: 50%;
width: 36px;
height: 36px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
cursor: pointer;
outline: none;
}
44 changes: 44 additions & 0 deletions src/components/App.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React, { useState } from "react";
import Header from "./Header";
import Footer from "./Footer";
import Note from "./Note";
import CreateArea from "./CreateArea";

function App() {
const [notes, setNotes] = useState([]);

function addNote(newNote) {
setNotes(prevNotes => {
return [...prevNotes, newNote];
});
}

function deleteNote(id) {
setNotes(prevNotes => {
return prevNotes.filter((noteItem, index) => {
return index !== id;
});
});
}

return (
<div>
<Header />
<CreateArea onAdd={addNote} />
{notes.map((noteItem, index) => {
return (
<Note
key={index}
id={index}
title={noteItem.title}
content={noteItem.content}
onDelete={deleteNote}
/>
);
})}
<Footer />
</div>
);
}

export default App;
68 changes: 68 additions & 0 deletions src/components/CreateArea.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import React, { useState } from "react";
import AddIcon from "@material-ui/icons/Add";
import Fab from "@material-ui/core/Fab";
import Zoom from "@material-ui/core/Zoom";

function CreateArea(props) {
const [isExpanded, setExpanded] = useState(false);

const [note, setNote] = useState({
title: "",
content: ""
});

function handleChange(event) {
const { name, value } = event.target;

setNote(prevNote => {
return {
...prevNote,
[name]: value
};
});
}

function submitNote(event) {
props.onAdd(note);
setNote({
title: "",
content: ""
});
event.preventDefault();
}

function expand() {
setExpanded(true);
}

return (
<div>
<form className="create-note">
{isExpanded && (
<input
name="title"
onChange={handleChange}
value={note.title}
placeholder="Title"
/>
)}

<textarea
name="content"
onClick={expand}
onChange={handleChange}
value={note.content}
placeholder="Take a note..."
rows={isExpanded ? 3 : 1}
/>
<Zoom in={isExpanded}>
<Fab onClick={submitNote}>
<AddIcon />
</Fab>
</Zoom>
</form>
</div>
);
}

export default CreateArea;
12 changes: 12 additions & 0 deletions src/components/Footer.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from "react";

function Footer() {
const year = new Date().getFullYear();
return (
<footer>
<p>Copyright ⓒ {year}</p>
</footer>
);
}

export default Footer;
15 changes: 15 additions & 0 deletions src/components/Header.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react";
import HighlightIcon from "@material-ui/icons/Highlight";

function Header() {
return (
<header>
<h1>
<HighlightIcon />
Keeper
</h1>
</header>
);
}

export default Header;
20 changes: 20 additions & 0 deletions src/components/Note.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from "react";
import DeleteIcon from "@material-ui/icons/Delete";

function Note(props) {
function handleClick() {
props.onDelete(props.id);
}

return (
<div className="note">
<h1>{props.title}</h1>
<p>{props.content}</p>
<button onClick={handleClick}>
<DeleteIcon />
</button>
</div>
);
}

export default Note;
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from "react";
import ReactDOM from "react-dom";
import App from "./components/App";

ReactDOM.render(<App />, document.getElementById("root"));

0 comments on commit 905dcdc

Please sign in to comment.