Skip to content
Open
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
727 changes: 697 additions & 30 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"preview": "vite preview"
},
"dependencies": {
"@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.0",
"@mui/icons-material": "^7.1.0",
"@mui/material": "^7.1.0",
"react": "^19.1.0",
"react-dom": "^19.1.0"
},
Expand Down
124 changes: 95 additions & 29 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,42 +1,108 @@
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
* {
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;
}

.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
header {
background-color: #f5ba13;
margin: auto -16px;
padding: 16px 32px;
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.3);
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);

header h1 {
color: #fff;
font-family: "McLaren", cursive;
font-weight: 200;
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);


.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;
}

@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
.note button {
position: relative;
float: right;
margin-right: 10px;
color: #f5ba13;
border: none;
width: 36px;
height: 36px;
cursor: pointer;
outline: none;
background: none;
}

@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
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;
}

.card {
padding: 2em;
.alert {
display: block;
}

.read-the-docs {
color: #888;
.error {
background: red;
color: white;
margin: 20px auto;
padding: 10px;
font-weight: 700;
width: 50%;
border-radius: 5px;
}
29 changes: 25 additions & 4 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
import './App.css'
import { useState } from "react";
import "./App.css";
import Note from "./components/Note";
import Header from "./components/Header";
import CreateNote from "./components/CreateNote";

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

const deleteNote = itemToDeleteId => {
setNotes(prevNotes => {
return prevNotes.filter(noteItem => {
return itemToDeleteId !== noteItem.id;
});
});
};

const addNote = newNote => {
setNotes([...notes, newNote]);
};

return (
<>
notes keeper
<Header />
<CreateNote addNote={addNote} />
{notes.map(noteItem => (
<Note key={noteItem.id} noteItem={noteItem} deleteNote={deleteNote} />
))}
</>
)
);
}

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

const CreateNote = ({ addNote }) => {
const [isExpanded, setIsExpanded] = useState(false);
const [newNote, setNewNote] = useState({ title: "", content: "" });
const [errorMessage, setErrorMessage] = useState("");

const submitNote = e => {
if (!newNote.title || !newNote.content) {
setErrorMessage("Please fill in all fields");
} else {
addNote({ ...newNote, id: new Date() });
setNewNote({ title: "", content: "" });
setIsExpanded(false);
setErrorMessage("");
}
e.preventDefault();
};

const handleChange = e => {
const { name, value } = e.target;
setNewNote({ ...newNote, [name]: value });
};

return (
<div className="create-area" onSubmit={submitNote}>
<form className="create-note">
{isExpanded && (
<input
className="title"
type="text"
name="title"
value={newNote.title}
onChange={handleChange}
placeholder="Title"
/>
)}
<textarea
className="textarea"
name="content"
value={newNote.content}
onChange={handleChange}
onClick={() => setIsExpanded(true)}
placeholder="Take a note..."
rows={isExpanded ? 3 : 1}
/>
<Zoom in={isExpanded}>
<Fab type="submit">
<AddIcon />
</Fab>
</Zoom>
</form>
<Fade in={errorMessage}>
<p className="error">{errorMessage}</p>
</Fade>
</div>
);
};

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

const Header = () => {
return (
<header>
<h1>
<NoteIcon /> Keeper
</h1>
</header>
);
};

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

const Note = ({ noteItem, deleteNote }) => {
return (
<div className="note">
<h1>{noteItem.title}</h1>
<p>{noteItem.content}</p>
<button onClick={() => deleteNote(noteItem.id)}>
<DeleteIcon />
</button>
</div>
);
};

export default Note;
68 changes: 0 additions & 68 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,68 +0,0 @@
:root {
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;

color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;

font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}

body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}

h1 {
font-size: 3.2em;
line-height: 1.1;
}

button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}

@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}
13 changes: 6 additions & 7 deletions src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.jsx'
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import App from "./App.jsx";

createRoot(document.getElementById('root')).render(
createRoot(document.getElementById("root")).render(
<StrictMode>
<App />
</StrictMode>,
)
</StrictMode>
);