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

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

.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
header h1 {
color: #fff;
font-family: 'McLaren', cursive;
font-weight: 200;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);

.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;
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
.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;
text-align: center;
}

.read-the-docs {
color: #888;
.error {
background: red;
color: white;
margin: 20px auto;
padding: 10px;
font-weight: 700;
width: 50%;
border-radius: 5px;
}
31 changes: 27 additions & 4 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
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 = (id) => {
setNotes((prevNotes) => {
return prevNotes.filter((prev) => {
return prev.id !== id;
});
});
};

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

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

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

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

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

const submitNote = (e) => {
e.preventDefault();
if (!newNote.title || !newNote.content) {
setErrorMessage('Both title and content are required');
return;
}
setErrorMessage('');
addNote({ ...newNote, id: new Date() });
setIsExpanded(false);
setNewNote({ title: '', content: '' });
};

return (
<div className='create-area'>
{errorMessage && (
<div className='alert'>
<div className='error'>{errorMessage}</div>
</div>
)}
<form className='create-note' onSubmit={submitNote}>
{isExpanded && (
<>
<input
name='title'
type='text'
value={newNote.title}
onChange={updateNewNoteValue}
placeholder='name'
/>
</>
)}
<textarea
name='content'
type='text'
value={newNote.content}
placeholder={
isExpanded ? 'Please enter note.' : 'Click to write note'
}
onChange={updateNewNoteValue}
onClick={() => {
setIsExpanded(true);
}}
rows={isExpanded ? 3 : 1}
/>
<Zoom in={isExpanded}>
<Fab onClick={submitNote}>
<AddIcon />
</Fab>
</Zoom>
</form>
</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;
18 changes: 18 additions & 0 deletions src/components/Note.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import DeleteIcon from '@mui/icons-material/Delete';

export default function Note({ noteItem, deleteNote }) {
return (
<div className='note'>
<h1>{noteItem.title}</h1>
<p>{noteItem.content}</p>
<button
onClick={() => {
deleteNote(noteItem.id);
}}
>
<DeleteIcon />
</button>
</div>
);
}
61 changes: 0 additions & 61 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,68 +1,7 @@
: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;
}
}