Skip to content

Commit 93bdeb6

Browse files
Version 1.0.0
1 parent ae5a38c commit 93bdeb6

28 files changed

+683
-382
lines changed

components/Components.module.css

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,20 @@
7676

7777
.sidebar_profile {
7878
display: flex;
79-
justify-content: flex-end;
79+
justify-content: space-between;
8080
align-items: center;
8181
margin: 15px 5px 50px;
8282
}
8383

84+
.sidebar_profile h2 {
85+
color: orange;
86+
}
87+
88+
.sidebar_profile div {
89+
padding: 5px 10px;
90+
border-radius: 15px;
91+
}
92+
8493
.sidebar_link_container_closed {
8594
display: flex;
8695
justify-content: space-between;
@@ -121,4 +130,34 @@
121130
font-size: 0.8rem;
122131
}
123132

133+
.control_pannel {
134+
display: flex;
135+
justify-content: flex-start;
136+
align-items: center;
137+
gap: 5px;
138+
padding: 15px;
139+
font-size: 1rem;
140+
}
141+
142+
.functions {
143+
gap: 20px !important;
144+
}
145+
146+
.functions {
147+
font-size: 1.1rem !important;
148+
background-color: transparent;
149+
border-radius: 10px;
150+
margin-top: 10px;
151+
border: none;
152+
outline: none;
153+
color: white;
154+
cursor: pointer;
155+
width: 100%;
156+
transition: all .5s ease-in-out;
157+
}
158+
159+
.functions:hover {
160+
background-color: brown;
161+
}
162+
124163
/* Basic editor styles */

components/LoginForm.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React, { FormEvent, useEffect } from "react";
22
import Input from "./Input";
33
import { ErrorTypo } from "../pages";
4+
import Router from "next/router";
5+
import { userService } from "../services/user-service";
46

57
type Props = {
68
mode: string;
@@ -19,6 +21,11 @@ type Props = {
1921

2022
function LoginForm({ mode, onSubmit, errors, Login_props, seterrors }: Props) {
2123

24+
function enterAsGuest() {
25+
userService.asGuest()
26+
Router.push('/home')
27+
}
28+
2229
return (
2330
<form onSubmit={onSubmit}>
2431
<div className="form-block__input-wrapper">
@@ -75,9 +82,10 @@ function LoginForm({ mode, onSubmit, errors, Login_props, seterrors }: Props) {
7582
</button>
7683
{mode === "login" ? (
7784
<button
85+
onClick={enterAsGuest}
7886
className="button button--secondary full-width"
7987
style={{ marginTop: "0.7rem", fontSize: ".8rem" }}
80-
type="submit"
88+
type="button"
8189
>
8290
Enter As Guest...
8391
</button>

components/Menubar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { AiOutlineUnorderedList } from "react-icons/ai";
77
import { BiUndo, BiRedo } from "react-icons/bi";
88

99
type MenuProps = {
10-
editor: Editor;
10+
editor: Editor
1111
};
1212

1313
const MenuBar = ({ editor }: MenuProps) => {

components/Note.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import useStatus from "../hooks/useStatus";
88
import { v4 as uuid } from "uuid";
99

1010
type Props = {
11-
note?: Note;
11+
note?: Note
1212
id?: string;
1313
redirect: string;
1414
};

components/NoteCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import TextStyle from "@tiptap/extension-text-style";
99
import { Color } from "@tiptap/extension-color";
1010
import useIsToday from "../hooks/useIsToday";
1111
import BulletList from "@tiptap/extension-bullet-list";
12-
import ListItem from "@tiptap/extension-list-item";
12+
import ListItem from "@tiptap/extension-list-item"
1313

1414
type NoteCardProps = {
1515
selectedNotes: Note[] | undefined;
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React, { useEffect, useState } from "react";
2-
import styles from "./Home.module.css";
2+
import styles from "../pages/home/Home.module.css";
33
import Image from "next/image";
4-
import NoteCard from "../../components/NoteCard";
4+
import NoteCard from "./NoteCard";
55
import Router from "next/router";
6-
import SideBar from "../../components/SideBar";
7-
import { Note } from "../_types";
6+
import SideBar from "./SideBar";
7+
import { Note } from "../pages/_types";
88
import { AiOutlineDelete, AiOutlineStar } from "react-icons/ai";
99
import { MdOutlineRestoreFromTrash } from "react-icons/md";
1010

@@ -98,6 +98,8 @@ function NotesContainer({ Notes, title, setNotes }: Props) {
9898
}
9999
}
100100

101+
console.log(Notes.length)
102+
101103
return (
102104
<div
103105
className={
@@ -119,9 +121,7 @@ function NotesContainer({ Notes, title, setNotes }: Props) {
119121
<small>
120122
{Notes.length > 0
121123
? Notes.length == 1
122-
? Notes.length + title == "Recycle bin"
123-
? "deleted"
124-
: "" + " note"
124+
? Notes.length + (title === "Recycle bin" ? " deleted": "") + " note"
125125
: Notes.length +
126126
(title == "Recycle bin" ? " deleted" : "") +
127127
" notes"
@@ -302,7 +302,7 @@ function NotesContainer({ Notes, title, setNotes }: Props) {
302302
+
303303
</button>
304304
))}
305-
{title == "Recycle bin" && (
305+
{title == "Recycle bin" && Notes.length > 0 && (
306306
<button
307307
className={styles.delete_btn}
308308
style={{ backgroundColor: "greenyellow" }}

components/SideBar.tsx

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,31 @@ import React, { useEffect, useState } from "react";
22
import styles from "./Components.module.css";
33
import SideBarLink from "./SideBarLink";
44
import Image from "next/image";
5+
import { User } from "../pages/_types";
6+
import Router from "next/router";
7+
import { FcSynchronize } from "react-icons/fc";
8+
import { CgProfile } from "react-icons/cg";
9+
import Link from "next/link"
10+
511

612
type Props = {
713
showSidebar: boolean;
814
};
915

1016
function SideBar({ showSidebar }: Props) {
11-
12-
const [storedNotesCount, setstoredNotesCount] = useState("")
13-
const [deletedNotesCount, setdeletedNotesCount] = useState("")
17+
const [storedNotesCount, setstoredNotesCount] = useState("");
18+
const [deletedNotesCount, setdeletedNotesCount] = useState("");
19+
const [User, setUser] = useState<User>();
1420

1521
useEffect(() => {
16-
const Notes = JSON.parse(localStorage.getItem("NOTES")!)
17-
const deletedNotes = JSON.parse(localStorage.getItem("DELETED_NOTES")!)
22+
const Notes = JSON.parse(localStorage.getItem("NOTES")!);
23+
const deletedNotes = JSON.parse(localStorage.getItem("DELETED_NOTES")!);
24+
const user = JSON.parse(localStorage.getItem("user")!);
1825

19-
setstoredNotesCount(Notes?.length)
20-
setdeletedNotesCount(deletedNotes?.length)
21-
},[])
26+
setstoredNotesCount(Notes?.length);
27+
setdeletedNotesCount(deletedNotes?.length);
28+
setUser(user as User);
29+
}, []);
2230

2331
return (
2432
<div
@@ -30,10 +38,46 @@ function SideBar({ showSidebar }: Props) {
3038
>
3139
<div className={styles.sidebar_wrapper}>
3240
<div className={styles.sidebar_profile}>
33-
<Image src="/Images/Icons/person.png" width={30} height={30} alt="person"/>
41+
<h2>{User?.username}</h2>
42+
<div>
43+
<Image
44+
src="/Images/Icons/person.png"
45+
width={30}
46+
height={30}
47+
alt="person"
48+
/>
49+
</div>
3450
</div>
35-
<SideBarLink path="/home" showSidebar={showSidebar} value="All notes" icon="/Images/Icons/notes.png" count={storedNotesCount} />
36-
<SideBarLink path="/recycle" showSidebar={showSidebar} value="Recycle bin" icon="/Images/Icons/recycle.png" count={deletedNotesCount} />
51+
<SideBarLink
52+
path="/home"
53+
showSidebar={showSidebar}
54+
value="All notes"
55+
icon="/Images/Icons/notes.png"
56+
count={storedNotesCount}
57+
/>
58+
<SideBarLink
59+
path="/recycle"
60+
showSidebar={showSidebar}
61+
value="Recycle bin"
62+
icon="/Images/Icons/recycle.png"
63+
count={deletedNotesCount}
64+
/>
65+
<hr />
66+
{User?.guest ? (
67+
<div className={styles.control_pannel}>
68+
<CgProfile size={25} color="white" />
69+
<Link href={'/'} style={{color: "white"}}>
70+
Create Account for Free or SignIn
71+
</Link>
72+
</div>
73+
) : (
74+
<div>
75+
<button className={`${styles.control_pannel} ${styles.functions}`}>
76+
<FcSynchronize size={25} color="white" />
77+
<div>Sync Notes</div>
78+
</button>
79+
</div>
80+
)}
3781
</div>
3882
</div>
3983
);

components/SideBarLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type Props = {
88
value: string;
99
count: string;
1010
showSidebar: boolean;
11-
path: string;
11+
path: string
1212
};
1313

1414
function SideBarLink({ icon, value, count, showSidebar, path }: Props) {

0 commit comments

Comments
 (0)