Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
pipisebastian committed Dec 5, 2024
2 parents e12110b + c03d86c commit 27ed1c2
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 18 deletions.
2 changes: 2 additions & 0 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { WorkSpace } from "@features/workSpace/WorkSpace";
import { useErrorStore } from "@stores/useErrorStore";
import { useUserInfo } from "@stores/useUserStore";
import { useSocketStore } from "./stores/useSocketStore";
import { BackgroundImage } from "./components/backgroundImage/BackgroundImage";

const App = () => {
// TODO ๋ผ์šฐํ„ฐ, react query ์„ค์ •
Expand All @@ -25,6 +26,7 @@ const App = () => {

return (
<>
<BackgroundImage />
{isErrorModalOpen && <ErrorModal errorMessage={errorMessage} />}
<WorkSpace />
</>
Expand Down
28 changes: 28 additions & 0 deletions client/src/components/backgroundImage/BackgroundImage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import backgroundPNG from "@assets/images/background.png";
import backgroundWEBP from "@assets/images/background.webp";
import backgroundAVIF from "@assets/images/background.avif";

export const BackgroundImage = () => (
<picture
style={{
position: "fixed",
top: 0,
left: 0,
width: "100%",
height: "100%",
zIndex: -1,
}}
>
<source srcSet={backgroundAVIF} type="image/avif" />
<source srcSet={backgroundWEBP} type="image/webp" />
<img
src={backgroundPNG}
alt="background"
style={{
width: "100%",
height: "100%",
objectFit: "cover",
}}
/>
</picture>
);
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const MenuButton = () => {
onClick={handleMenuClick}
data-onboarding="menu-button"
>
<button className={menuItemWrapper}>
<div className={menuItemWrapper} role="button">
<MenuIcon />
<p className={textBox}>{name ?? "Nocta"}</p>
{/* <div className={nameWrapper}>
Expand All @@ -122,7 +122,7 @@ export const MenuButton = () => {
</div>
)}
</div> */}
</button>
</div>
<WorkspaceSelectModal isOpen={isOpen} userName={name} onInviteClick={handleInviteModal} />
<InviteModal
isOpen={isInviteModalOpen}
Expand Down
1 change: 1 addition & 0 deletions client/src/features/editor/hooks/useCopyAndPaste.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export const useCopyAndPaste = ({
}
currentBlockIndex += 1;
});
editorCRDT.LinkedList.updateAllOrderedListIndices();
} else {
// ํ…์ŠคํŠธ๋ฅผ ํ•œ ๊ธ€์ž์”ฉ ์ˆœ์ฐจ์ ์œผ๋กœ ์‚ฝ์ž…
text.split("").forEach((char, index) => {
Expand Down
61 changes: 56 additions & 5 deletions client/src/features/workSpace/hooks/usePagesManage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useEffect, useState, useRef, useCallback } from "react";
import { useSocketStore } from "@src/stores/useSocketStore";
import { useToastStore } from "@src/stores/useToastStore";
import { Page } from "@src/types/page";
import { PAGE, SIDE_BAR } from "@src/constants/size";

const PAGE_OFFSET = 60;

Expand Down Expand Up @@ -86,6 +87,42 @@ export const usePagesManage = (workspace: WorkSpace | null, clientId: number | n
return Math.max(0, ...pages.map((page) => page.zIndex)) + 1;
};

const adjustPagePosition = (page: Page) => {
const PADDING = 20;
const maxWidth = window.innerWidth - SIDE_BAR.WIDTH - PADDING * 2;
const maxHeight = window.innerHeight - PADDING * 2;

// ํŽ˜์ด์ง€๊ฐ€ ์ตœ์†Œ ํฌ๊ธฐ๋ณด๋‹ค ์ž‘์•„์ง€์ง€ ์•Š๋„๋ก ๋ณด์žฅ
const width = PAGE.WIDTH;
const height = PAGE.HEIGHT;

// ์ƒˆ๋กœ์šด ์œ„์น˜ ๊ณ„์‚ฐ
let newX = page.x;
let newY = page.y;

// ์˜ค๋ฅธ์ชฝ ๊ฒฝ๊ณ„๋ฅผ ๋ฒ—์–ด๋‚˜๋Š” ๊ฒฝ์šฐ
if (newX + width > maxWidth) {
newX = Math.max(0, maxWidth - width);
}

// ์™ผ์ชฝ ๊ฒฝ๊ณ„๋ฅผ ๋ฒ—์–ด๋‚˜๋Š” ๊ฒฝ์šฐ
if (newX < 0) {
newX = 0;
}

// ์•„๋ž˜์ชฝ ๊ฒฝ๊ณ„๋ฅผ ๋ฒ—์–ด๋‚˜๋Š” ๊ฒฝ์šฐ
if (newY + height > maxHeight) {
newY = Math.max(0, maxHeight - height);
}

// ์œ„์ชฝ ๊ฒฝ๊ณ„๋ฅผ ๋ฒ—์–ด๋‚˜๋Š” ๊ฒฝ์šฐ
if (newY < 0) {
newY = 0;
}

return { x: newX, y: newY };
};

const fetchPage = () => {
const operation = {
type: "pageCreate",
Expand Down Expand Up @@ -170,11 +207,25 @@ export const usePagesManage = (workspace: WorkSpace | null, clientId: number | n

// ํŽ˜์ด์ง€๋ฅผ ํ™œ์„ฑํ™”ํ•˜๊ณ  ํ‘œ์‹œ
setPages((prevPages) =>
prevPages.map((p) =>
p.id === pageId
? { ...p, isActive: true, isVisible: true, zIndex: getZIndex() }
: { ...p, isActive: false },
),
prevPages.map((p) => {
if (p.id === pageId) {
// isLoaded๊ฐ€ false์ผ ๋•Œ๋งŒ ์œ„์น˜ ์žฌ์กฐ์ •
if (!p.isLoaded) {
const adjustedPosition = adjustPagePosition(p);
return {
...p,
isActive: true,
isVisible: true,
zIndex: getZIndex(),
x: adjustedPosition.x,
y: adjustedPosition.y,
};
}
// ์ด๋ฏธ ๋กœ๋“œ๋œ ํŽ˜์ด์ง€๋Š” ์œ„์น˜ ์œ ์ง€
return { ...p, isActive: true, isVisible: true, zIndex: getZIndex() };
}
return { ...p, isActive: false };
}),
);

setTimeout(() => {
Expand Down
11 changes: 0 additions & 11 deletions client/src/styles/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@ export const globalStyles = defineGlobalStyles({
},

"html, body": {
// ๊ธฐ๋ณธ ์ด๋ฏธ์ง€
backgroundImage: 'url("./assets/images/background.jpg")',
// WebP ์ง€์›
"@supports (background-image: url('./assets/images/background.webp'))": {
backgroundImage: 'url("./assets/images/background.webp")',
},
// AVIF ์ง€์›
"@supports (background-image: url('./assets/images/background.avif'))": {
backgroundImage: 'url("./assets/images/background.avif")',
},
backgroundSize: "cover",
fontFamily: "Pretendard, sans-serif",
boxSizing: "border-box",
},
Expand Down

0 comments on commit 27ed1c2

Please sign in to comment.