Skip to content

Commit a744da9

Browse files
css fixes and layout changes
1 parent 1448e50 commit a744da9

File tree

8 files changed

+76
-44
lines changed

8 files changed

+76
-44
lines changed

db.json

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77
"createdAt": "2022-09-17T16:15:54.984Z",
88
"updatedAt": "2022-09-17T16:21:15.119Z"
99
},
10-
{
11-
"text": "note 2 (updated now)",
12-
"priority": "low",
13-
"id": "7f77e872-f7f8-4617-ab9d-8f32a46780fb",
14-
"createdAt": "2022-09-17T16:15:59.545Z",
15-
"updatedAt": "2022-09-17T18:08:23.343Z"
16-
},
1710
{
1811
"text": "note 3 (updated)",
1912
"priority": "high",
@@ -22,25 +15,18 @@
2215
"updatedAt": "2022-09-17T16:18:04.640Z"
2316
},
2417
{
25-
"text": "asdasdsad\nAsadasds\nasdasdasdad",
26-
"priority": "low",
27-
"id": "52ceb228-fc3b-440e-b849-31351a188498",
28-
"createdAt": "2022-09-17T19:00:58.267Z",
29-
"updatedAt": "2022-09-17T19:00:58.267Z"
30-
},
31-
{
32-
"text": "line 1\nline 2\nline 3\nline 4\n",
33-
"priority": "low",
34-
"id": "a1ad66bb-7f36-48f2-b6b0-e21dfadd5d63",
35-
"createdAt": "2022-09-17T19:01:13.245Z",
36-
"updatedAt": "2022-09-17T19:01:13.245Z"
18+
"text": "medium note",
19+
"priority": "medium",
20+
"id": "882bbdfa-0beb-4fde-8c7b-72b52327a5fb",
21+
"createdAt": "2022-09-18T16:31:15.376Z",
22+
"updatedAt": "2022-09-18T16:31:15.376Z"
3723
},
3824
{
39-
"text": "sdasdadasd asdasd sad asda. asd as das d asd as das d das d sa dd asd das dd\n a sd sa d asdsad \n sad sadas d asd sad\n a sd sa das d asdsa\n\n\nasdsdasdasd",
25+
"text": "a note with \nlong \nlong\nlong\ndata\nasdasd\nasd\nasd\nsad\nasd\nsad\nsa\nd\nas\nd\nas\ndas\nd\ndas\na\nda\ndas\ndsa\ndasda\nd\nasd",
4026
"priority": "low",
41-
"id": "32a0c88d-45cc-4997-bc03-9c5dd31093aa",
42-
"createdAt": "2022-09-17T19:02:48.509Z",
43-
"updatedAt": "2022-09-17T19:02:48.509Z"
27+
"id": "2503cd96-fb40-4750-8b4f-8791b4d329c6",
28+
"createdAt": "2022-09-18T16:32:22.138Z",
29+
"updatedAt": "2022-09-18T16:32:22.138Z"
4430
}
4531
]
4632
}

src/App.css

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
.react-switch{
22
position: absolute !important;
33
right:0;
4-
}
4+
}
5+
6+
.App.light{
7+
background-color: white;
8+
color: black;
9+
}
10+
11+
.App.dark{
12+
background-color: #333;
13+
color: white;
14+
}
15+

src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ function App() {
102102
return (
103103
<StateContext.Provider value={{ state, dispatch }}>
104104
<ThemeContext.Provider value={theme}>
105+
<div className={`App ${theme}`}>
105106
<Switch
106107
onChange={changeHandler}
107108
checked={checked}
@@ -126,6 +127,7 @@ function App() {
126127
></Switch>
127128
{/* here we want router */}
128129
<RouterProvider router={router} />
130+
</div>
129131
</ThemeContext.Provider>
130132
</StateContext.Provider>
131133
);

src/components/note/note-type.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ export type NoteType = {
99
}
1010

1111
export enum ColorLight{
12-
high='rgb(246, 100, 92)',
13-
medium='rgb(244, 158, 127)',
14-
low='rgb(248, 249, 175)'
12+
high='#FFAEAE',
13+
medium='#FFEC94',
14+
low='#B0E57C'
1515
}
1616

1717
export enum ColorDark{
18-
high='rgb(143, 66, 61)',
19-
medium='rgb(190, 131, 79)',
20-
low='rgb(151, 151, 98)'
18+
high='#D70000',
19+
medium='#CC9933',
20+
low='#77A600'
2121
}

src/components/note/note.tsx

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { ThemeContext } from '../../context/theme/theme';
88
import { StateContext } from '../../context/state/state';
99
import { DELETE_NOTE, SET_EDIT_MODE, SET_NOTE_FOR_EDIT } from '../../actions';
1010
import { deleteNote } from '../../services/notes-service';
11-
import { Link } from "react-router-dom";
11+
import { Link } from 'react-router-dom';
1212

1313
type NoteProps = {
1414
id: string;
@@ -18,7 +18,7 @@ type NoteProps = {
1818
updatedAt: Date;
1919
note: NoteType;
2020
isDetailed?: boolean;
21-
height?:string;
21+
height?: string;
2222
};
2323

2424
function Note(props: NoteProps) {
@@ -34,8 +34,8 @@ function Note(props: NoteProps) {
3434
console.log(await deleteNote(props.id));
3535
dispatch({ type: DELETE_NOTE, payload: props.id });
3636
};
37-
38-
const optionalProps = props.height ? {height:props.height}:{}
37+
38+
const optionalProps = props.height ? { height: props.height } : {};
3939
return (
4040
<Card
4141
bgColor={
@@ -46,17 +46,35 @@ function Note(props: NoteProps) {
4646
padding="1"
4747
{...optionalProps}
4848
>
49-
<>
50-
<Link to={props.id} style={{textDecoration:'none',
51-
color:`${theme === 'dark'? 'white':'black'}`}}>
52-
<div className={props.isDetailed?'text':'text text-hide'}>{props.text}</div>
53-
</Link>
49+
<>
50+
{props.isDetailed ? (
51+
<div className={props.isDetailed ? 'text' : 'text text-hide'}>
52+
{props.text}
53+
</div>
54+
) : (
55+
<Link
56+
to={props.id}
57+
style={{
58+
textDecoration: 'none',
59+
color: `${theme === 'dark' ? 'white' : 'black'}`,
60+
}}
61+
>
62+
<div className={props.isDetailed ? 'text' : 'text text-hide'}>
63+
{props.text}
64+
</div>
65+
</Link>
66+
)}
5467

55-
<div className='left-corner date'>{props.updatedAt.toLocaleString()}</div>
56-
<div className="right-corner">
68+
<div className="left-corner date">
69+
{props.updatedAt.toLocaleString()}
70+
</div>
71+
{
72+
props.isDetailed ? null: <div className="right-corner">
5773
<FaEdit onClick={() => editNote(props.note)}></FaEdit>
5874
<FaTrash onClick={handleDelete}></FaTrash>
5975
</div>
76+
}
77+
6078
</>
6179
</Card>
6280
);

src/pages/detailed-note/detailed-note.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
.detailed-note{
2-
margin: 0;
2+
margin: auto;
3+
max-width: 20rem;
34
text-align: center;
45
padding-top:1rem;
6+
min-height: 100vh;
57
}
68

79
.detailed-note.light{

src/pages/detailed-note/detailed-note.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import Note from '../../components/note/note';
33
import { useContext } from 'react';
44
import { ThemeContext } from '../../context/theme/theme';
55
import { StateContext } from '../../context/state/state';
6-
import { useParams } from 'react-router-dom';
6+
import { Link, useParams } from 'react-router-dom';
7+
import { FaHome } from 'react-icons/fa';
78

89
function DetailedNote() {
910
const theme = useContext(ThemeContext);
@@ -12,6 +13,15 @@ function DetailedNote() {
1213
const note = state.notes.find(n=>n.id===id);
1314
return (
1415
<div className={`detailed-note ${theme}`}>
16+
<Link to="/" style={{
17+
textDecoration: 'none',
18+
color: `${theme === 'dark' ? 'white' : 'black'}`,
19+
float:'left',
20+
marginTop:'-0.5rem',
21+
marginLeft:'0.5rem'
22+
}}>
23+
<FaHome ></FaHome>
24+
</Link>
1525
<div>
1626
{note && <Note
1727
key={note.id}

src/pages/home/home.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
.home{
2-
margin: 0;
2+
margin: auto;
3+
max-width: 20rem;
34
text-align: center;
45
padding-top:1rem;
6+
min-height: 100vh;
7+
58
}
69
.home h2{
710
margin: 0;

0 commit comments

Comments
 (0)