Skip to content

Commit 9ae00ed

Browse files
committed
♻️ 노드 렌더러 수정
className을 style객체에서 직접 참조하도록 수정 -> 인라인 스타일로 변경할때 className을 제외하고 추출하기때문에 className은 style객체에서 직접 참조해야한다. style추출할때 processNodeStyles함수 사용하도록 수정완료
1 parent fc14d98 commit 9ae00ed

File tree

3 files changed

+38
-15
lines changed

3 files changed

+38
-15
lines changed

packages/ui/src/components/Heading.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import processNodeStyles from "utils/processNodeStyles";
12
import { NodeComponentProps } from "../types";
23
import { HeadingNode } from "../types/nodes";
3-
import applyStyles from "../utils/applyStyles";
44

55
export default function HeadingComponent({
66
node,
@@ -9,12 +9,17 @@ export default function HeadingComponent({
99
children,
1010
}: NodeComponentProps<HeadingNode>) {
1111
const { text, level = "h2" } = props;
12-
const inlineStyle = applyStyles(style);
12+
const nodeStyleObj = processNodeStyles(style);
13+
1314
const Tag = level;
1415

1516
return (
16-
<div data-component-id={node.id} className={style.className}>
17-
<Tag style={inlineStyle}>{text}</Tag>
17+
<div
18+
data-component-id={node.id}
19+
className={`${style.root?.className} flex h-full w-full items-center justify-center`}
20+
style={{ ...nodeStyleObj.root, width: "100%", height: "100%" }}
21+
>
22+
<Tag style={nodeStyleObj.heading}>{text}</Tag>
1823
{/* 컨테이너일 경우 이곳에 children이 렌더링 되야 한다. */}
1924
{children}
2025
</div>

packages/ui/src/components/Hero.tsx

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { NodeComponentProps } from "../types/component";
2-
import { HeroNode } from "../types/nodes";
31
import { useBuilderMode } from "context/builderMode";
42
import Image from "next/image";
5-
import processNodeStyles from "../utils/style";
3+
import processNodeStyles from "../utils/processNodeStyles";
4+
import { HeroNode, NodeComponentProps } from "types";
65

76
export default function HeroComponent({
87
node,
@@ -29,12 +28,20 @@ export default function HeroComponent({
2928
//TODO - 노드들이 드래그 앤 드롭될때 위치가 자유롭게 변하게 할 수 있어야한다.
3029
<section
3130
data-component-id={node.id}
32-
className={`${style.className} flex h-full w-full flex-col items-center justify-center gap-2 overflow-hidden`}
33-
style={nodeStyleObj.root}
31+
className={`${style.root?.className || ""} flex h-full w-full flex-col items-center justify-center gap-2 overflow-hidden`}
32+
style={{
33+
...nodeStyleObj.root,
34+
// ⚠️ 안전 장치: style 객체에 크기 정보가 있어도 무시하고 강제로 100%로 덮어씁니다.
35+
width: "100%",
36+
height: "100%",
37+
}}
3438
>
3539
{/* 배경 이미지 영역 */}
3640
{image?.url && (
37-
<div className={`absolute inset-0 z-0`} style={nodeStyleObj.image}>
41+
<div
42+
className={`${style.image?.className || ""} absolute inset-0 z-0`}
43+
style={nodeStyleObj.image}
44+
>
3845
<Image
3946
fill={true}
4047
className={"object-cover"}
@@ -51,15 +58,25 @@ export default function HeroComponent({
5158
className={"relative top-0 left-0 z-10 flex flex-col items-center p-4"}
5259
>
5360
<h1
61+
className={style.heading?.className || ""}
5462
style={nodeStyleObj.heading} // heading 스타일 적용 (폰트 크기, 색상)
5563
>
5664
{heading}
5765
</h1>
58-
{subHeading && <p style={nodeStyleObj.subHeading}>{subHeading}</p>}
66+
67+
{subHeading && (
68+
<p
69+
className={style.subHeading?.className || ""}
70+
style={nodeStyleObj.subHeading}
71+
>
72+
{subHeading}
73+
</p>
74+
)}
5975
{button && (
6076
<a
6177
href={button.link || "#"}
6278
style={nodeStyleObj.button}
79+
className={style.button?.className || ""}
6380
onClick={handleLinkClick}
6481
//백그라운드 사진 렌더링 필요
6582
>

packages/ui/src/components/Image.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
import Image from "next/image";
2-
import applyStyles from "../utils/applyStyles";
32
import { NodeComponentProps } from "../types/component";
43
import { ImageNode } from "../types/nodes";
4+
import processNodeStyles from "utils/processNodeStyles";
55

66
export default function ImageComponent({
77
node,
88
props,
99
style,
1010
}: NodeComponentProps<ImageNode>) {
1111
const { src, alt = "사용자의 이미지", caption } = props;
12-
const inlineStyles = applyStyles(style);
12+
const nodeStyleObj = processNodeStyles(style);
1313

1414
return (
1515
<div
1616
data-component-id={node.id}
17-
className={`${style.className} flex flex-col gap-1`}
17+
className={`${style.root?.className} flex flex-col gap-1`}
18+
style={{ ...nodeStyleObj.root, width: "100%", height: "100%" }}
1819
>
19-
<Image src={src} alt={alt} style={inlineStyles} />
20+
<Image src={src} alt={alt} style={nodeStyleObj.image} />
2021
{caption && <div>{caption}</div>}
2122
</div>
2223
);

0 commit comments

Comments
 (0)