Skip to content

Commit

Permalink
client: add validation, modify ui
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubham-Lal committed Jul 14, 2024
1 parent fe3f341 commit bf7bf84
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 43 deletions.
7 changes: 4 additions & 3 deletions client/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
}

#right-sidebar {
max-height: 100dvh;
/* max-height: 100dvh; */
max-height: 100svh;
}

#main {
/* padding: 20px; */
width: 40%;
height: 100dvh;
/* height: 100dvh; */
height: 100svh;
overflow-y: auto;
--dot-bg: var(--body_background);
--dot-color: #4C4E52;
Expand Down
6 changes: 4 additions & 2 deletions client/src/components/loading/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
}

.loading-component {
height: calc(100dvh - 40px);
/* height: calc(100dvh - 40px); */
height: calc(100svh - 40px);
display: grid;
place-items: center;
}
Expand Down Expand Up @@ -46,6 +47,7 @@

@media screen and (max-width: 480px) {
.loading-component {
height: calc(100dvh - 150px);
/* height: calc(100dvh - 150px); */
height: calc(100svh - 150px);
}
}
3 changes: 2 additions & 1 deletion client/src/components/modal/auth/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
top: 0;
left: 0;
right: 0;
height: 100dvh;
/* height: 100dvh; */
height: 100svh;
backdrop-filter: blur(8px);
display: flex;
align-items: center;
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/sidebar/left-sidebar.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
list-style: none;
max-width: fit-content;
height: 100%;
max-height: 100dvh;
/* max-height: 100dvh; */
max-height: 100svh;
margin: 0 auto;
display: flex;
flex-direction: column;
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/sidebar/right-sidebar.css
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@

#right-sidebar .expand-menu__background.expand {
z-index: 1;
height: 100dvh;
/* height: 100dvh; */
height: 100svh;
}

.right-sidebar__container {
Expand Down
4 changes: 2 additions & 2 deletions client/src/pages/create-debate/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ interface EditorProps {
rteValue?: string
isEditable: boolean
setDebateData?: React.Dispatch<React.SetStateAction<{
title: string;
body: string;
title: string
body: string
}>>
}

Expand Down
29 changes: 21 additions & 8 deletions client/src/pages/create-debate/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import "./style.css";
import { useRef, useState } from "react";
import { RichTextEditorComponent } from "@syncfusion/ej2-react-richtexteditor";
import Editor from "./editor";
import Preview from "./preview";
import "./style.css"
import { useRef, useState } from "react"
import { RichTextEditorComponent } from "@syncfusion/ej2-react-richtexteditor"
import { toast } from "sonner"
import Editor from "./editor"
import Preview from "./preview"

interface CreateProps {
isVisible: boolean;
Expand All @@ -11,7 +12,7 @@ interface CreateProps {

const CreateDebatePage: React.FC<CreateProps> = ({ isVisible, isFullscreen }) => {
const editorRef = useRef<RichTextEditorComponent>(null);
const [debateData, setDebateData] = useState({ title: 'Sony is the best camera of all time', body: '' });
const [debateData, setDebateData] = useState({ title: '', body: '' });
const [isPreview, setIsPreview] = useState<boolean>(false);

const handlePreviewToggle = () => {
Expand All @@ -21,6 +22,17 @@ const CreateDebatePage: React.FC<CreateProps> = ({ isVisible, isFullscreen }) =>
setDebateData({ ...debateData, body: content });
}
}

if (!debateData.title.trim()) return toast.warning("Enter debate title");

const tempDiv = document.createElement("div");
tempDiv.innerHTML = editorRef.current?.value || '';
const bodyText = tempDiv.textContent?.replace(/\u200B/g, '').trim();

if (!bodyText || bodyText === '<br>' || bodyText === '<br><br>' || bodyText === '<br><br><br>') {
return toast.warning("Enter debate body");
}

setIsPreview(!isPreview);
};

Expand All @@ -45,7 +57,6 @@ const CreateDebatePage: React.FC<CreateProps> = ({ isVisible, isFullscreen }) =>
setDebateData={setDebateData}
/>
</div>
<div className='space' />
</form>

<Preview isPreview={isPreview} editorRef={editorRef} debateData={debateData} />
Expand All @@ -57,7 +68,9 @@ const CreateDebatePage: React.FC<CreateProps> = ({ isVisible, isFullscreen }) =>
>
{isPreview ? 'BACK' : 'PREVIEW'}
</button>
<button type='submit' onClick={() => { }}>PUBLISH</button>
<button type='submit' onClick={() => toast.warning("Currently under development")}>
PUBLISH
</button>
</div>
</div>
);
Expand Down
12 changes: 5 additions & 7 deletions client/src/pages/create-debate/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@ import { RichTextEditorComponent } from "@syncfusion/ej2-react-richtexteditor"
import Editor from "./editor"

interface PreviewProps {
isPreview: boolean;
editorRef: React.RefObject<RichTextEditorComponent>;
isPreview: boolean
editorRef: React.RefObject<RichTextEditorComponent>
debateData: {
title: string;
body: string;
};
title: string
body: string
}
}

const Preview: React.FC<PreviewProps> = ({ isPreview, editorRef, debateData }) => {
console.log(debateData.body)

return (
<div className={`preview ${isPreview ? 'shift-left' : 'shift-right'}`}>
<h1>{debateData.title}</h1>
Expand Down
22 changes: 6 additions & 16 deletions client/src/pages/create-debate/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@

#create {
position: relative;
height: fit-content;
overflow: hidden;
}

#create-debate {
padding: 20px 0;
height: calc(100dvh - 83px);
height: calc(100svh - 82px);
display: flex;
flex-direction: column;
gap: 20px;
Expand All @@ -33,14 +32,14 @@
position: relative;
top: 0;
left: -100%;
transition: left 500ms ease-in-out;
transition: left 250ms ease-in-out;
}

#create-debate.shift-right {
position: relative;
top: 0;
left: 0;
transition: left 500ms ease-in-out;
transition: left 250ms ease-in-out;
}

.preview {
Expand All @@ -59,12 +58,12 @@

.preview.shift-left {
left: 0;
transition: left 500ms ease-in-out;
transition: left 250ms ease-in-out;
}

.preview.shift-right {
left: 100%;
transition: left 500ms ease-in-out;
transition: left 250ms ease-in-out;
}

#create h1 {
Expand Down Expand Up @@ -123,11 +122,6 @@
transition: background-color 0.2s ease-in-out;
}

.space {
width: 100%;
height: 50px;
}

.preview #toolsRTE_toolbar_wrapper {
display: none;
}
Expand Down Expand Up @@ -176,7 +170,7 @@
@media screen and (max-width: 480px) {
#create-debate {
padding: 10px 0;
height: calc(100dvh - 120px - 62px);
height: calc(100svh - 120px - 62px);
}

#create-debate .vertical-space {
Expand All @@ -198,10 +192,6 @@
transition: bottom 0.4s ease-out;
}

.space {
height: 30px;
}

.preview {
padding: 10px;
gap: 10px;
Expand Down
4 changes: 2 additions & 2 deletions client/src/pages/home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "./style.css"
import { AuthStatus, useAuthStore } from "../../store/useAuthStore"
import { useNavStore } from "../../store/useNavStore";
import ClaimUsername from "../../components/card/claim-username";
import { useNavStore } from "../../store/useNavStore"
import ClaimUsername from "../../components/card/claim-username"
import { ClosedDebateCard } from "../../components/card/closed-debate-card"
import { OpenDebateCard } from "../../components/card/open-debate-card"

Expand Down

0 comments on commit bf7bf84

Please sign in to comment.