-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 텍스트 스타일: 기존 레이아웃과 동일 - 텍스트 색상: 버튼에 hover하면 서브 모달 생성. 서브 모달에서 색상 클릭하면 색상 적용 - 배경 색상: 버튼에 hover하면 서브 모달 생성. 서브 모달에서 색상 클릭하면 배경 색상 적욕
- Loading branch information
Showing
6 changed files
with
419 additions
and
4 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
client/src/features/editor/components/ColorOptionModal/BackgroundColorOptionModal.style.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { BackgroundColorType } from "@noctaCrdt/Interfaces"; | ||
import { css, cva } from "@styled-system/css"; | ||
|
||
type ColorVariants = { | ||
[K in BackgroundColorType]: { backgroundColor: string }; | ||
}; | ||
|
||
export const colorPaletteModal = css({ | ||
zIndex: 1001, | ||
borderRadius: "4px", | ||
minWidth: "120px", // 3x3 그리드를 위한 최소 너비 | ||
padding: "4px", | ||
backgroundColor: "white", | ||
boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)", | ||
}); | ||
|
||
export const colorPaletteContainer = css({ | ||
display: "grid", | ||
gap: "4px", | ||
gridTemplateColumns: "repeat(3, 1fr)", | ||
width: "100%", | ||
}); | ||
|
||
export const colorOptionButton = css({ | ||
display: "flex", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
border: "none", | ||
borderRadius: "4px", | ||
width: "28px", | ||
height: "28px", | ||
margin: "0 2px", | ||
padding: "2px", | ||
transition: "transform 0.2s", | ||
cursor: "pointer", | ||
"&:hover": { | ||
transform: "scale(1.1)", | ||
}, | ||
}); | ||
|
||
const colorVariants: ColorVariants = { | ||
transparent: { backgroundColor: "#C1D7F4" }, | ||
black: { backgroundColor: "#2B4158" }, | ||
red: { backgroundColor: "#F24150" }, | ||
green: { backgroundColor: "#1BBF44" }, | ||
blue: { backgroundColor: "#4285F4" }, | ||
yellow: { backgroundColor: "#FEA642" }, | ||
purple: { backgroundColor: "#A142FE" }, | ||
brown: { backgroundColor: "#8B4513" }, | ||
white: { backgroundColor: "#EEEEEE" }, | ||
}; | ||
|
||
export const backgroundColorIndicator = cva({ | ||
base: { | ||
borderRadius: "3px", | ||
width: "100%", | ||
height: "100%", | ||
transition: "all 0.2s", | ||
}, | ||
variants: { | ||
color: colorVariants, | ||
}, | ||
}); |
52 changes: 52 additions & 0 deletions
52
client/src/features/editor/components/ColorOptionModal/BackgroundColorOptionModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { BackgroundColorType } from "@noctaCrdt/Interfaces"; | ||
import { | ||
backgroundColorIndicator, | ||
colorOptionButton, | ||
colorPaletteContainer, | ||
colorPaletteModal, | ||
} from "./BackgroundColorOptionModal.style.ts"; | ||
|
||
const COLORS: BackgroundColorType[] = [ | ||
"black", | ||
"red", | ||
"blue", | ||
"green", | ||
"yellow", | ||
"purple", | ||
"brown", | ||
"white", | ||
"transparent", | ||
]; | ||
|
||
interface BackgroundColorOptionModalProps { | ||
onColorSelect: (color: BackgroundColorType) => void; | ||
position: { top: number; left: number }; | ||
} | ||
|
||
export const BackgroundColorOptionModal = ({ | ||
onColorSelect, | ||
position, | ||
}: BackgroundColorOptionModalProps) => { | ||
return ( | ||
<div | ||
className={colorPaletteModal} | ||
style={{ | ||
position: "absolute", | ||
top: position.top, | ||
left: position.left, | ||
}} | ||
> | ||
<div className={colorPaletteContainer}> | ||
{COLORS.map((color) => ( | ||
<button | ||
key={`bg-${color}`} | ||
className={colorOptionButton} | ||
onClick={() => onColorSelect(color)} | ||
> | ||
<div className={backgroundColorIndicator({ color })} /> | ||
</button> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; |
65 changes: 65 additions & 0 deletions
65
client/src/features/editor/components/ColorOptionModal/TextColorOptionModal.style.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { TextColorType } from "@noctaCrdt/Interfaces"; | ||
import { css, cva } from "@styled-system/css"; | ||
|
||
type ColorVariants = { | ||
[K in TextColorType]: { color: string }; | ||
}; | ||
|
||
export const colorPaletteModal = css({ | ||
zIndex: 1001, | ||
borderRadius: "4px", | ||
minWidth: "120px", // 3x3 그리드를 위한 최소 너비 | ||
padding: "4px", | ||
backgroundColor: "white", | ||
boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)", | ||
}); | ||
|
||
export const colorPaletteContainer = css({ | ||
display: "grid", | ||
gap: "4px", | ||
gridTemplateColumns: "repeat(3, 1fr)", | ||
width: "100%", | ||
}); | ||
|
||
export const colorOptionButton = css({ | ||
display: "flex", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
border: "none", | ||
borderRadius: "4px", | ||
width: "28px", | ||
height: "28px", | ||
margin: "0 2px", | ||
padding: "2px", | ||
transition: "transform 0.2s", | ||
cursor: "pointer", | ||
"&:hover": { | ||
transform: "scale(1.1)", | ||
}, | ||
}); | ||
|
||
const colorVariants: ColorVariants = { | ||
black: { color: "#2B4158" }, | ||
red: { color: "#F24150" }, | ||
green: { color: "#1BBF44" }, | ||
blue: { color: "#4285F4" }, | ||
yellow: { color: "#FEA642" }, | ||
purple: { color: "#A142FE" }, | ||
brown: { color: "#8B4513" }, | ||
white: { color: "#C1D7F4" }, | ||
}; | ||
|
||
export const textColorIndicator = cva({ | ||
base: { | ||
display: "flex", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
width: "100%", | ||
height: "100%", | ||
fontSize: "16px", | ||
fontWeight: "bold", | ||
}, | ||
variants: { | ||
color: colorVariants, | ||
}, | ||
}); |
48 changes: 48 additions & 0 deletions
48
client/src/features/editor/components/ColorOptionModal/TextColorOptionModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { TextColorType } from "@noctaCrdt/Interfaces"; | ||
import { | ||
colorOptionButton, | ||
colorPaletteContainer, | ||
colorPaletteModal, | ||
textColorIndicator, | ||
} from "./TextColorOptionModal.style.ts"; | ||
|
||
const COLORS: TextColorType[] = [ | ||
"black", | ||
"red", | ||
"blue", | ||
"green", | ||
"yellow", | ||
"purple", | ||
"brown", | ||
"white", | ||
]; | ||
|
||
interface TextColorOptionModalProps { | ||
onColorSelect: (color: TextColorType) => void; | ||
position: { top: number; left: number }; | ||
} | ||
|
||
export const TextColorOptionModal = ({ onColorSelect, position }: TextColorOptionModalProps) => { | ||
return ( | ||
<div | ||
className={colorPaletteModal} | ||
style={{ | ||
position: "absolute", | ||
top: position.top, | ||
left: position.left, | ||
}} | ||
> | ||
<div className={colorPaletteContainer}> | ||
{COLORS.map((color) => ( | ||
<button | ||
key={`text-${color}`} | ||
className={colorOptionButton} | ||
onClick={() => onColorSelect(color)} | ||
> | ||
<span className={textColorIndicator({ color })}>A</span> | ||
</button> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.