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
127 changes: 97 additions & 30 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,42 +1,109 @@
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}

.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
html {
font-family: "Montserrat", sans-serif;
}
body {
background: #eee;
background-image: url("https://www.transparenttextures.com/patterns/cubes.png");
padding: 0 16px;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);

header {
background-color: #f5ba13;
margin: auto -16px;
padding: 16px 32px;
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.3);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);

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

@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}

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

@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
.note button {
position: relative;
float: right;
margin-right: 10px;
color: #f5ba13;
border: none;
width: 36px;
height: 36px;
cursor: pointer;
outline: none;
background: none;
}

.card {
padding: 2em;
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;
}

.read-the-docs {
color: #888;
.alert {
display: block;
}

.error {
background: red;
color: white;
margin: 20px auto;
padding: 10px;
font-weight: 700;
width: 50%;
border-radius: 5px;
text-align: center;
}
24 changes: 23 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
import './App.css'
import { useState } from 'react'
import Header from './components/Header'
import Note from './components/Note'
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
66 changes: 66 additions & 0 deletions src/components/CreateNote.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React, { useState } from 'react'
import AddIcon from '@mui/icons-material/Add';
import Zoom from '@mui/material/Zoom';
import Fab from '@mui/material/Fab';
export default function CreateNote({addNote}) {
const [isExpanded, setIsExpanded] = useState(false)
const [newNote, setNewNote] = useState({
title: '',
content: ''
})
const [errowMessage, setErrowMessage] = useState('')
const submitNote = (e) =>{
e.preventDefault()
if(!newNote.title || !newNote.content){
setErrowMessage('Please fill all the fields')
} else {
addNote({...newNote, id:new Date()})
setNewNote({title: '', content: ''})
setIsExpanded(false)
setErrowMessage('')
}
console.log(newNote)
}
const handleChange = (e) => {
const {name, value} = e.target
setNewNote({...newNote, [name]: value})
}

const errorstate = () =>{
if(errowMessage){
return <p className='error'>{errowMessage}</p>
}
}
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>
{errorstate()}
</div>
)
}
12 changes: 12 additions & 0 deletions src/components/Header.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react'
import NoteIcon from '@mui/icons-material/Note';

export default function Header() {
return (
<header>
<h1>
<NoteIcon />Keeper
</h1>
</header>
)
}
14 changes: 14 additions & 0 deletions src/components/Note.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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