Skip to content

Commit 1cf4a0d

Browse files
part 1 - setting up notes component
1 parent a0e0931 commit 1cf4a0d

File tree

6 files changed

+83
-53
lines changed

6 files changed

+83
-53
lines changed

src/App.css

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,4 @@
1-
.App {
1+
.App{
2+
margin: 0 1rem;
23
text-align: center;
3-
}
4-
5-
.App-logo {
6-
height: 40vmin;
7-
pointer-events: none;
8-
}
9-
10-
@media (prefers-reduced-motion: no-preference) {
11-
.App-logo {
12-
animation: App-logo-spin infinite 20s linear;
13-
}
14-
}
15-
16-
.App-header {
17-
background-color: #282c34;
18-
min-height: 100vh;
19-
display: flex;
20-
flex-direction: column;
21-
align-items: center;
22-
justify-content: center;
23-
font-size: calc(10px + 2vmin);
24-
color: white;
25-
}
26-
27-
.App-link {
28-
color: #61dafb;
29-
}
30-
31-
@keyframes App-logo-spin {
32-
from {
33-
transform: rotate(0deg);
34-
}
35-
to {
36-
transform: rotate(360deg);
37-
}
38-
}
4+
}

src/App.tsx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
1-
import React from 'react';
2-
import logo from './logo.svg';
31
import './App.css';
2+
import Note from './components/notes/notes';
3+
import { Notes } from './components/notes/data';
44

55
function App() {
66
return (
77
<div className="App">
8-
<header className="App-header">
9-
<img src={logo} className="App-logo" alt="logo" />
10-
<p>
11-
Edit <code>src/App.tsx</code> and save to reload.
12-
</p>
13-
<a
14-
className="App-link"
15-
href="https://reactjs.org"
16-
target="_blank"
17-
rel="noopener noreferrer"
18-
>
19-
Learn React
20-
</a>
21-
</header>
8+
<h2>Notes App</h2>
9+
<div>
10+
{
11+
Notes.map(
12+
note=> <Note priority={note.priority} text={note.text}></Note>
13+
)
14+
}
15+
</div>
2216
</div>
2317
);
2418
}

src/components/notes/data.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import {NoteProps} from './notes-type';
2+
3+
export const Notes:NoteProps[] = [
4+
{
5+
id:1,
6+
text: "This is note 1",
7+
priority : "high"
8+
},
9+
{
10+
id:2,
11+
text: "This is note 2",
12+
priority : "low"
13+
},
14+
{
15+
id:3,
16+
text: "This is note 3",
17+
priority : "low"
18+
},
19+
{
20+
id:4,
21+
text: "This is note 4",
22+
priority : "medium"
23+
},
24+
{
25+
id:5,
26+
text: "This is note 5",
27+
priority : "medium"
28+
}
29+
]
30+

src/components/notes/notes-type.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export type NoteProps = {
2+
id?: number,
3+
text: string,
4+
priority? : 'high' | 'medium' | 'low'
5+
}

src/components/notes/notes.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.note{
2+
border: 1px solid grey;
3+
padding: 2rem;
4+
font-size: 1rem;
5+
color: #333;
6+
height: 10rem;
7+
border-radius: 0.5rem;
8+
background-color: burlywood;
9+
margin-top: 1rem;
10+
11+
}
12+
.high{
13+
background-color:rgb(246, 100, 92);
14+
color: white;
15+
}
16+
.medium{
17+
background-color:rgb(244, 158, 127);
18+
}
19+
.low{
20+
background-color: rgb(248, 249, 175);
21+
}

src/components/notes/notes.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import './notes.css'
2+
3+
import {NoteProps} from './notes-type';
4+
5+
function Note(props: NoteProps){
6+
return (
7+
<div className={`note ${props.priority}`}>
8+
{props.text}
9+
</div>
10+
)
11+
}
12+
13+
14+
export default Note;

0 commit comments

Comments
 (0)