video 블록 및 리펙터링
CI / pr_and_merge (push) Has been skipped
CI / test (push) Failing after 46m46s
CI / test (pull_request) Failing after 43m8s
CI / pr_and_merge (pull_request) Has been skipped

This commit is contained in:
2025-11-27 10:07:59 +09:00
parent 672cca5271
commit 48e13d2a75
223 changed files with 8979 additions and 2125 deletions
+137
View File
@@ -0,0 +1,137 @@
import type { CSSProperties } from "react";
import type { DividerBlockProps } from "@/features/editor/state/editorStore";
export interface DividerEscapers {
escapeAttr: (value: string) => string;
}
export interface DividerExportTokens {
style: string;
}
export const computeDividerExportTokens = (
props: DividerBlockProps,
escapers: DividerEscapers,
): DividerExportTokens => {
const { escapeAttr } = escapers;
const thickness = props.thickness === "medium" ? "2px" : "1px";
const colorRaw = typeof props.colorHex === "string" ? props.colorHex.trim() : "";
const color = colorRaw !== "" ? colorRaw : "#475569";
const marginY = typeof props.marginYPx === "number" && props.marginYPx > 0 ? props.marginYPx : 16;
const style = `border:0;border-bottom:${thickness} solid ${escapeAttr(color)};margin:${marginY}px 0;`;
return { style };
};
export interface DividerEditorTokens {
thicknessClass: string;
innerWidthClass: string;
widthPx?: number;
borderColor: string;
marginPx: number;
}
export const computeDividerEditorTokens = (props: DividerBlockProps): DividerEditorTokens => {
const thicknessClass = props.thickness === "medium" ? "border-t-2" : "border-t";
const colorRaw = typeof props.colorHex === "string" ? props.colorHex.trim() : "";
const borderColor = colorRaw !== "" ? colorRaw : "#475569";
const widthMode = props.widthMode ?? "full";
let innerWidthClass = "w-full";
let widthPx: number | undefined;
if (widthMode === "auto") {
innerWidthClass = "w-1/2";
} else if (widthMode === "fixed") {
innerWidthClass = "";
if (typeof props.widthPx === "number" && props.widthPx > 0) {
widthPx = props.widthPx;
} else {
widthPx = 320;
}
}
const marginPx =
typeof props.marginYPx === "number"
? props.marginYPx
: props.marginY === "sm"
? 8
: props.marginY === "lg"
? 24
: 16;
return {
thicknessClass,
innerWidthClass,
widthPx,
borderColor,
marginPx,
};
};
export interface DividerPublicTokens {
alignClass: string;
thicknessClass: string;
innerWidthClass: string;
wrapperMarginEm: string;
innerStyle: CSSProperties;
lineStyle: CSSProperties;
}
const pxToEm = (px: number, base = 16) => `${px / base}em`;
export const computeDividerPublicTokens = (props: DividerBlockProps): DividerPublicTokens => {
const alignClass =
props.align === "center"
? "items-center"
: props.align === "right"
? "items-end"
: "items-start";
const thicknessClass = props.thickness === "medium" ? "h-[2px]" : "h-px";
const marginPx =
typeof props.marginYPx === "number"
? props.marginYPx
: props.marginY === "sm"
? 8
: props.marginY === "lg"
? 24
: 16;
const wrapperMarginEm = pxToEm(marginPx);
const colorRaw = typeof props.colorHex === "string" ? props.colorHex.trim() : "";
const backgroundColor = colorRaw !== "" ? colorRaw : "#475569";
const widthMode = props.widthMode ?? "full";
const innerStyle: CSSProperties = {};
let innerWidthClass = "w-full";
const lineStyle: CSSProperties = {
backgroundColor,
};
if (widthMode === "auto") {
innerWidthClass = "w-1/2";
} else if (widthMode === "fixed") {
innerWidthClass = "";
innerStyle.width = "auto";
if (typeof props.widthPx === "number" && props.widthPx > 0) {
lineStyle.width = pxToEm(props.widthPx);
} else {
lineStyle.width = pxToEm(320);
}
}
return {
alignClass,
thicknessClass,
innerWidthClass,
wrapperMarginEm,
innerStyle,
lineStyle,
};
};