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
129 changes: 100 additions & 29 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,42 +1,113 @@
#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);

/* Some notes are too long */
.note {
overflow: hidden;
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;
}

.read-the-docs {
color: #888;
.error {
background: #fff3cd;
color: #856404;
margin: 20px auto;
padding: 12px 16px;
font-weight: 600;
width: 50%;
border-radius: 8px;
border: 3px solid #e4606d;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
text-align: center;
}
24 changes: 22 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
import './App.css'
import Header from './components/Header'
import CreateNote from './components/CreateNote'
import Note from './components/Note'
import {useState} from 'react'

function App() {

const [notes, setNotes] = useState([{id: new Date, title:'test title', content:'test contend'}]);
const deleteNote = (deletedItemId) =>{
setNotes((prevNotes)=>{
return prevNotes.filter((noteItem) => {
return deletedItemId !== noteItem.id
})
})
}
const addNote = (newNote) =>{
setNotes([...notes, newNote])
}
return (
<>
notes keeper
<Header/>
<div>
<CreateNote addNote={addNote}/>
{notes.map((noteItem, index)=>(
<Note key={noteItem.id} noteItem={noteItem} deleteNote={deleteNote}/>
))}
</div>
</>
)
}
Expand Down
62 changes: 62 additions & 0 deletions src/components/CreateNote.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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 [isExpanded, setIsExpanded] = useState(false);
const [newNote, setNewNote] = useState({ title: '', content: '' });
const [errorMessage, setErrorMessage] = useState('');

const handleClick = (e) => {
if (!newNote.title || !newNote.content) {
setErrorMessage('Title and content are required.');
} else {
addNote({ ...newNote, id: Date.now() });
setNewNote({ title: '', content: '' });
setIsExpanded(false);
setErrorMessage('');
}
e.preventDefault();
};

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

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

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

const Header = () => {
return (
<header className='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 className="note-content">{noteItem.content}</p>
<button className="delete-note" onClick={()=>deleteNote(noteItem.id)}>
<DeleteIcon/>
</button>
</div>
)
}

export default Note
68 changes: 0 additions & 68 deletions src/index.css

This file was deleted.

1 change: 0 additions & 1 deletion src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.jsx'

createRoot(document.getElementById('root')).render(
Expand Down