Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/boostcampwm-2024/web33-Nocta โ€ฆ
Browse files Browse the repository at this point in the history
โ€ฆinto Feature/#196_ํŽ˜์ด์ง€_title_์„œ๋ฒ„์ธ์Šคํ„ด์Šค์—_์ €์žฅ

- ๋ณ‘ํ•ฉํ•˜๋ฉฐ iconType interface ์ผ์น˜ํ™”
- build ์—๋Ÿฌ ์ˆ˜์ •

#196
  • Loading branch information
hyonun321 committed Nov 26, 2024
2 parents 10dcef1 + 21fcf25 commit 5cee5bc
Show file tree
Hide file tree
Showing 24 changed files with 612 additions and 86 deletions.
28 changes: 27 additions & 1 deletion @noctaCrdt/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,32 @@ export type BackgroundColorType =
| "brown"
| "transparent";

export type PageIconType =
// ๊ธฐ๋ณธ ๋ฌธ์„œ ํƒ€์ž…
| "Docs" // ์ผ๋ฐ˜ ๋ฌธ์„œ
| "Note" // ํ•„๊ธฐ/๋ฉ”๋ชจ
| "Wiki" // ์ง€์‹ ๋ฒ ์ด์Šค/์œ„ํ‚ค

// ์—…๋ฌด ๊ด€๋ จ
| "Project" // ํ”„๋กœ์ ํŠธ ๊ด€๋ จ
| "Meeting" // ํšŒ์˜๋ก
| "Task" // ํ• ์ผ/์ž‘์—…

// ๊ฐœ์ธ ํ™œ๋™
| "Diary" // ์ผ๊ธฐ/์ €๋„
| "Blog" // ๋ธ”๋กœ๊ทธ ํฌ์ŠคํŠธ
| "Entertain" // ์œ ํŠœ๋ธŒ, ๋„ทํ”Œ๋ฆญ์Šค ๋“ฑ

// ํ•™์Šต ๊ด€๋ จ
| "Study" // ํ•™์Šต ์ž๋ฃŒ
| "Research" // ์—ฐ๊ตฌ/์กฐ์‚ฌ
| "Book" // ๋…์„œ ๋…ธํŠธ

// ํ˜‘์—… ๊ด€๋ จ
| "Team" // ํŒ€ ๋ฌธ์„œ
| "Shared" // ๊ณต์œ  ๋ฌธ์„œ
| "Feedback"; // ํ”ผ๋“œ๋ฐฑ/๋ฆฌ๋ทฐ

export type TextColorType = Exclude<BackgroundColorType, "transparent">;

export interface InsertOperation {
Expand Down Expand Up @@ -125,7 +151,7 @@ export interface RemotePageUpdateOperation {
pageId: string;
clientId: number;
title?: string;
icon?: string;
icon?: PageIconType;
}
export interface WorkSpaceSerializedProps {
id: string;
Expand Down
10 changes: 5 additions & 5 deletions @noctaCrdt/Page.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { EditorCRDT } from "./Crdt";
import { Block } from "./Node";
import { CRDTSerializedProps } from "./Interfaces";
import { CRDTSerializedProps, PageIconType } from "./Interfaces";

export interface PageSerializedProps {
id: string;
title: string;
icon: string;
icon: PageIconType;
crdt: CRDTSerializedProps<Block>; // EditorCRDT์˜ ์ง๋ ฌํ™”๋œ ๋ฐ์ดํ„ฐ ํƒ€์ž…
}

export class Page {
id: string;
title: string;
icon: string;
icon: PageIconType;
crdt: EditorCRDT;

constructor(
id: string = crypto.randomUUID(), // ๊ณ ์œ ํ•œ ID ์ƒ์„ฑ
title: string = "Untitled",
icon: string = "๐Ÿ“„",
icon: PageIconType = "Docs",
editorCRDT: EditorCRDT = new EditorCRDT(0),
) {
this.id = id;
Expand All @@ -33,7 +33,7 @@ export class Page {
}

// ์•„์ด์ฝ˜ ์—…๋ฐ์ดํŠธ
updateIcon(newIcon: string): void {
updateIcon(newIcon: PageIconType): void {
this.icon = newIcon;
}

Expand Down
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"framer-motion": "^11.11.11",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-icons": "^5.3.0",
"socket.io-client": "^4.8.1",
"vite-plugin-svgr": "^4.3.0",
"zustand": "^5.0.1"
Expand Down
11 changes: 7 additions & 4 deletions client/src/components/button/IconButton.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { iconButtonContainer, iconBox } from "./IconButton.style";
import { PageIconType } from "@noctaCrdt/Interfaces";
import { iconComponents, IconConfig } from "@src/constants/PageIconButton.config";
import { iconButtonContainer } from "./IconButton.style";

interface IconButtonProps {
icon: string;
icon: PageIconType | "plus";
size: "sm" | "md";
onClick?: () => void;
}

export const IconButton = ({ icon, size, onClick }: IconButtonProps) => {
// TODO ์ถ”ํ›„ svg ํŒŒ์ผ์„ ๋ฐ›์•„์˜ฌ ์ˆ˜ ์žˆ๋„๋ก ์ˆ˜์ • (์‚ฌ์ด๋“œ๋ฐ” - ํŽ˜์ด์ง€ ์ถ”๊ฐ€ ๋ฒ„ํŠผ)
const { icon: IconComponent, color: defaultColor }: IconConfig = iconComponents[icon];

return (
<button className={iconButtonContainer({ size })} onClick={onClick}>
<span className={iconBox({ size })}>{icon}</span>
<IconComponent color={defaultColor} size="24px" />
</button>
);
};
28 changes: 0 additions & 28 deletions client/src/components/sidebar/PageItem.tsx

This file was deleted.

6 changes: 3 additions & 3 deletions client/src/components/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { AuthButton } from "@src/features/auth/AuthButton";
import { useSocketStore } from "@src/stores/useSocketStore";
import { Page } from "@src/types/page";
import { useIsSidebarOpen, useSidebarActions } from "@stores/useSidebarStore";
import { MenuButton } from "./MenuButton";
import { PageItem } from "./PageItem";
import { animation, contentVariants, sidebarVariants } from "./Sidebar.animation";
import {
sidebarContainer,
Expand All @@ -18,6 +16,8 @@ import {
sidebarToggleButton,
placeholderMessage,
} from "./Sidebar.style";
import { MenuButton } from "./components/menuButton/MenuButton";
import { PageItem } from "./components/pageItem/PageItem";

export const Sidebar = ({
pages,
Expand Down Expand Up @@ -106,7 +106,7 @@ export const Sidebar = ({
)}
</motion.nav>
<motion.div className={plusIconBox} variants={contentVariants}>
<IconButton icon="โž•" onClick={handleAddPageButtonClick} size="sm" />
<IconButton icon="plus" onClick={handleAddPageButtonClick} size="sm" />
<AuthButton />
</motion.div>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { css } from "@styled-system/css";

export const IconBox = css({
display: "flex",
position: "relative",
justifyContent: "center",
alignItems: "center",
borderRadius: "4px",
width: "24px",
height: "24px",

cursor: "pointer",
"&:hover": {
transform: "scale(1.05)",
opacity: 0.8,
},
});

export const IconModal = css({
zIndex: 1001,
borderRadius: "4px",
minWidth: "120px", // 3x3 ๊ทธ๋ฆฌ๋“œ๋ฅผ ์œ„ํ•œ ์ตœ์†Œ ๋„ˆ๋น„
padding: "4px",
backgroundColor: "white",
boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
});

export const IconModalContainer = css({
display: "grid",
gap: "4px",
gridTemplateColumns: "repeat(3, 1fr)",
width: "100%",
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { PageIconType } from "@noctaCrdt/Interfaces";
import { iconComponents, IconConfig } from "@constants/PageIconButton.config";
import { IconBox } from "./PageIconButton.style";

interface PageIconButtonProps {
type: PageIconType;
onClick: (e: React.MouseEvent) => void;
}

export const PageIconButton = ({ type, onClick }: PageIconButtonProps) => {
const { icon: IconComponent, color: defaultColor }: IconConfig = iconComponents[type];

return (
<div style={{ position: "relative" }}>
<div className={IconBox} onClick={(e) => onClick(e)}>
<IconComponent color={defaultColor} size="24px" />
</div>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { PageIconType } from "@noctaCrdt/Interfaces";
import { RiCloseLine } from "react-icons/ri";
import { iconGroups, iconComponents } from "@constants/PageIconButton.config";
import { css } from "@styled-system/css";
import {
IconModal,
IconModalContainer,
IconModalClose,
IconName,
IconButton,
} from "./pageIconModal.style";

export interface PageIconModalProps {
isOpen: boolean;
onClose: (e: React.MouseEvent) => void;
onSelect: (e: React.MouseEvent, type: PageIconType) => void;
currentType: PageIconType;
}

export const PageIconModal = ({ onClose, onSelect, currentType }: PageIconModalProps) => {
return (
<div className={IconModal} onClick={onClose}>
<div className={IconModalContainer} onClick={onClose}>
<button onClick={onClose} className={IconModalClose}>
<RiCloseLine width={16} height={16} />
</button>
<div>
{iconGroups.map((group) => (
<div
key={group.title}
className={css({
marginBottom: "12px",
})}
>
<h3 className={IconName}>{group.title}</h3>
<div
className={css({
display: "grid",
gap: "8px",
gridTemplateColumns: "repeat(3, 1fr)",
})}
>
{group.icons.map((iconType) => {
const { icon: IconComponent, color } = iconComponents[iconType];
const isSelected = currentType === iconType;

return (
<button
key={iconType}
onClick={(e) => onSelect(e, iconType)}
className={IconButton(isSelected)}
>
<IconComponent color={color} size="24px" />
<span
className={css({
color: "gray.600",
fontSize: "xs",
})}
>
{iconType}
</span>
</button>
);
})}
</div>
</div>
))}
</div>
</div>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { css } from "@styled-system/css";

export const IconModal = css({
zIndex: 9000,
position: "absolute",
top: 14,
left: 14,
});

export const IconModalContainer = css({
zIndex: 1001,
position: "relative",
borderRadius: "4px",
width: "100%",
maxHeight: "80vh",
padding: "16px",
backgroundColor: "white",
boxShadow: "lg",
overflowY: "auto",
});

export const IconModalClose = css({
display: "flex",
position: "absolute",
top: "8px",
right: "8px",
justifyContent: "center",
alignItems: "center",
border: "none",
borderRadius: "md",
width: "24px",
height: "24px",
backgroundColor: "transparent",
cursor: "pointer",
_hover: {
backgroundColor: "gray.100",
},
});

export const IconName = css({
marginBottom: "8px",
color: "gray.600",
fontSize: "sm",
fontWeight: "medium",
});

export const IconButton = (isSelected: boolean) =>
css({
display: "flex",
gap: "4px",
flexDirection: "column",
justifyContent: "space-between",
alignItems: "center",
border: "none",
borderRadius: "md",
padding: "8px",
backgroundColor: isSelected ? "gray.100" : "transparent",
cursor: "pointer",
_hover: {
backgroundColor: isSelected ? "gray.100" : "gray.50",
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { css } from "@styled-system/css";

export const pageItemContainer = css({
display: "flex",
position: "relative",
gap: "sm",
alignItems: "center",
width: "100%",
Expand Down Expand Up @@ -42,7 +43,6 @@ export const iconBox = css({
width: "44px",
height: "44px",
fontSize: "24px",
background: "white",
});

export const textBox = css({
Expand Down
Loading

0 comments on commit 5cee5bc

Please sign in to comment.