Skip to content

Commit 2d76967

Browse files
committed
refactor(#90): 타입 확정 및 불필요한 타입 확인 제거
1 parent 531183a commit 2d76967

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed
Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { assignInlineVars } from "@vanilla-extract/dynamic";
2+
import { type HTMLAttributes } from "react";
23

34
import { coerceCssRemValue } from "@/lib/utils/coerceCssRemValue";
45

@@ -11,9 +12,9 @@ export type SkeletonProps = {
1112
/** 스켈레톤 높이 */
1213
height: number;
1314

14-
/** border-radius(px 또는 string) */
15+
/** border-radius(px, rem, %, 토큰 모두 가능) */
1516
radius?: number | string;
16-
};
17+
} & HTMLAttributes<HTMLDivElement>;
1718

1819
/**
1920
* Skeleton 컴포넌트
@@ -22,13 +23,21 @@ export type SkeletonProps = {
2223
* <Skeleton width={120} height={24} radius={8} />
2324
* ```
2425
*/
25-
export const Skeleton = ({ width, height, radius }: SkeletonProps) => {
26-
const style = assignInlineVars({
27-
[styles.widthVar]: coerceCssRemValue(width),
28-
[styles.heightVar]: coerceCssRemValue(height),
29-
[styles.radiusVar]:
30-
typeof radius === "number" ? coerceCssRemValue(radius) : radius,
31-
});
26+
export const Skeleton = ({
27+
width,
28+
height,
29+
radius,
30+
style: customStyle,
31+
...rest
32+
}: SkeletonProps) => {
33+
const style = {
34+
...assignInlineVars({
35+
[styles.widthVar]: coerceCssRemValue(width),
36+
[styles.heightVar]: coerceCssRemValue(height),
37+
[styles.radiusVar]: radius ? coerceCssRemValue(radius) : undefined,
38+
}),
39+
...customStyle,
40+
};
3241

33-
return <div className={styles.wrapper} style={style} />;
42+
return <div className={styles.wrapper} style={style} {...rest} />;
3443
};

0 commit comments

Comments
 (0)