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

.error-message {
color: red;
font-weight: bold;
text-align: center;
margin-top: 10px;
}
26 changes: 25 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
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([{id: new Date(), title: 'test Title', content: 'test Content'}]);
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) => {
return (
<Note key={noteItem.id} noteItem={noteItem} deleteNote={deleteNote}/>
)
})}


</>
)
}
Expand Down
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';



const CreateNote = ({addNote}) => {
const [isExpanded, setIsExpanded] = useState(false)
const [newNote, setNewNote] = useState({title: '', content: ''})
const [errorMessage, setErrorMessage] = useState('')
const submitNote = (e) => {
e.preventDefault()
if (!newNote.title || !newNote.content) {
setErrorMessage('Title and content are required!')
} else {
addNote({...newNote, id:new Date()})
setNewNote({title: '', content: ''})
setIsExpanded(false)
}
}
const handleChange = (e) => {
const { name, value } = e.target
setNewNote({...newNote, [name]: value})
}

return (
<div className='create-area'>
<form className='create-note'>
{isExpanded && (
<input
className='title'
type="text"
name='title'
onChange={handleChange}
value={newNote.title}
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 onClick={submitNote}>
<AddIcon />
</Fab>
</Zoom>
</form>

<div className='error-message'>
{errorMessage && <p>{errorMessage}</p>}
</div>

</div>
)
}

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


const Header = () => {
return (

<header>
<h1>
<NoteIcon/> Keeper
</h1>
</header>


)
}

export default Header
15 changes: 15 additions & 0 deletions src/components/Note.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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>
)
}
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