@uniai-fe/uds-primitives 0.2.10 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/info-box/img/ban.svg +5 -0
- package/src/components/info-box/img/caution.svg +5 -0
- package/src/components/info-box/img/check.svg +4 -0
- package/src/components/info-box/img/info.svg +6 -0
- package/src/components/info-box/index.scss +1 -0
- package/src/components/info-box/index.tsx +4 -0
- package/src/components/info-box/markup/Icon.tsx +14 -0
- package/src/components/info-box/markup/InfoBox.tsx +65 -0
- package/src/components/info-box/markup/index.ts +2 -0
- package/src/components/info-box/styles/index.scss +2 -0
- package/src/components/info-box/styles/info-box.scss +61 -0
- package/src/components/info-box/styles/variables.scss +33 -0
- package/src/components/info-box/types/index.ts +1 -0
- package/src/components/info-box/types/props.ts +34 -0
- package/src/index.tsx +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<circle cx="12" cy="12" r="9.2" fill="#313235" stroke="#313235" stroke-width="1.6"/>
|
|
3
|
+
<path d="M9.00005 9L15 14.9999" stroke="white" stroke-width="1.6" stroke-linecap="round"/>
|
|
4
|
+
<path d="M15 9L9.00001 14.9999" stroke="white" stroke-width="1.6" stroke-linecap="round"/>
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<circle cx="12" cy="12" r="10" fill="#313235"/>
|
|
3
|
+
<path d="M12 8V13" stroke="white" stroke-width="1.6" stroke-linecap="round"/>
|
|
4
|
+
<circle cx="12" cy="16" r="1" fill="white"/>
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<circle cx="12" cy="12" r="10" fill="#313235"/>
|
|
3
|
+
<path d="M7.75735 11.3032L10.9393 14.4852L16.2426 9.1819" stroke="white" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<circle cx="12" cy="12" r="10" fill="#1A6AFF"/>
|
|
3
|
+
<path d="M12 17V10H10" stroke="white" stroke-width="1.6"/>
|
|
4
|
+
<path d="M10.5 17H13.5" stroke="white" stroke-width="1.6" stroke-linecap="square" stroke-linejoin="round"/>
|
|
5
|
+
<circle cx="12" cy="7" r="0.5" fill="white" stroke="white"/>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@use "./styles/index.scss";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import BanIcon from "../img/ban.svg";
|
|
2
|
+
import CautionIcon from "../img/caution.svg";
|
|
3
|
+
import CheckIcon from "../img/check.svg";
|
|
4
|
+
import InfoIcon from "../img/info.svg";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* InfoBox Icon Set; 상태별 아이콘 컴포넌트 맵
|
|
8
|
+
*/
|
|
9
|
+
export const InfoBoxIcon = {
|
|
10
|
+
info: InfoIcon,
|
|
11
|
+
check: CheckIcon,
|
|
12
|
+
caution: CautionIcon,
|
|
13
|
+
ban: BanIcon,
|
|
14
|
+
} as const;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
import { createElement, forwardRef } from "react";
|
|
3
|
+
import type { InfoBoxProps } from "../types";
|
|
4
|
+
import { InfoBoxIcon } from "./Icon";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* InfoBox Component; 안내 메시지 전용 정보 박스
|
|
8
|
+
* @component
|
|
9
|
+
* @param {InfoBoxProps} props
|
|
10
|
+
* @param {"info"} [props.state="info"] 현재는 info 상태만 지원한다.
|
|
11
|
+
* @param {React.ReactNode} [props.heading] 상단 제목 영역.
|
|
12
|
+
* @param {React.ReactNode} [props.children] 본문 콘텐츠.
|
|
13
|
+
* @param {string} [props.className] 루트 section className.
|
|
14
|
+
* @example
|
|
15
|
+
* <InfoBox heading="안내">설정 후 저장 버튼을 눌러주세요.</InfoBox>
|
|
16
|
+
*/
|
|
17
|
+
const InfoBox = forwardRef<HTMLElementTagNameMap["section"], InfoBoxProps>(
|
|
18
|
+
(
|
|
19
|
+
{ state = "info", heading, children, className, role, ...restProps },
|
|
20
|
+
ref,
|
|
21
|
+
) => {
|
|
22
|
+
return (
|
|
23
|
+
<section
|
|
24
|
+
{...restProps}
|
|
25
|
+
ref={ref}
|
|
26
|
+
className={clsx("info-box", className)}
|
|
27
|
+
data-state={state}
|
|
28
|
+
// 변경: 기본 role은 인라인으로 note를 적용한다.
|
|
29
|
+
role={role ?? "note"}
|
|
30
|
+
>
|
|
31
|
+
{/* 변경: 아이콘은 figure 래퍼 내부에서 상태별 Icon.tsx 맵으로 렌더링한다. */}
|
|
32
|
+
<figure className="info-box-icon" aria-hidden="true">
|
|
33
|
+
{createElement(
|
|
34
|
+
// 변경: InfoBoxState(success/error)를 아이콘 키(check/ban)와 명시적으로 매핑한다.
|
|
35
|
+
InfoBoxIcon[
|
|
36
|
+
state === "success" ? "check" : state === "error" ? "ban" : state
|
|
37
|
+
],
|
|
38
|
+
)}
|
|
39
|
+
</figure>
|
|
40
|
+
<div className="info-box-content">
|
|
41
|
+
{heading ? (
|
|
42
|
+
["string", "number"].includes(typeof heading) ? (
|
|
43
|
+
// 변경: 텍스트 heading은 p 태그로 감싼다.
|
|
44
|
+
<p className="info-box-heading">{heading}</p>
|
|
45
|
+
) : (
|
|
46
|
+
heading
|
|
47
|
+
)
|
|
48
|
+
) : null}
|
|
49
|
+
{children ? (
|
|
50
|
+
["string", "number"].includes(typeof children) ? (
|
|
51
|
+
// 변경: 텍스트 본문은 p 태그로 감싼다.
|
|
52
|
+
<p className="info-box-body">{children}</p>
|
|
53
|
+
) : (
|
|
54
|
+
<div className="info-box-body">{children}</div>
|
|
55
|
+
)
|
|
56
|
+
) : null}
|
|
57
|
+
</div>
|
|
58
|
+
</section>
|
|
59
|
+
);
|
|
60
|
+
},
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
InfoBox.displayName = "InfoBox.Root";
|
|
64
|
+
|
|
65
|
+
export default InfoBox;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
.info-box {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: flex-start;
|
|
4
|
+
gap: var(--info-box-gap-icon);
|
|
5
|
+
width: 100%;
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
margin: 0;
|
|
8
|
+
padding: var(--info-box-padding-block) var(--info-box-padding-inline);
|
|
9
|
+
border: 1px solid var(--info-box-border-color);
|
|
10
|
+
border-radius: var(--info-box-radius);
|
|
11
|
+
background-color: var(--info-box-background-color);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.info-box:where([data-state="info"]) {
|
|
15
|
+
// 변경: 기본 border 톤(color-mix)을 유지하고 아이콘/heading 컬러만 state로 고정한다.
|
|
16
|
+
--info-box-icon-color: var(--color-feedback-information);
|
|
17
|
+
--info-box-heading-color: var(--color-feedback-information);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.info-box-icon {
|
|
21
|
+
display: inline-flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
margin: 0;
|
|
25
|
+
width: var(--info-box-icon-size);
|
|
26
|
+
height: var(--info-box-icon-size);
|
|
27
|
+
color: var(--info-box-icon-color);
|
|
28
|
+
flex-shrink: 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.info-box-icon svg {
|
|
32
|
+
display: block;
|
|
33
|
+
width: 100%;
|
|
34
|
+
height: 100%;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.info-box-content {
|
|
38
|
+
display: flex;
|
|
39
|
+
flex: 1;
|
|
40
|
+
min-width: 0;
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
gap: var(--info-box-gap-contents);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.info-box-heading {
|
|
46
|
+
margin: 0;
|
|
47
|
+
color: var(--info-box-heading-color);
|
|
48
|
+
font-size: var(--info-box-heading-font-size);
|
|
49
|
+
line-height: var(--info-box-heading-line-height);
|
|
50
|
+
letter-spacing: var(--info-box-heading-letter-spacing);
|
|
51
|
+
font-weight: var(--info-box-heading-font-weight);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.info-box-body {
|
|
55
|
+
margin: 0;
|
|
56
|
+
color: var(--info-box-body-color);
|
|
57
|
+
font-size: var(--info-box-body-font-size);
|
|
58
|
+
line-height: var(--info-box-body-line-height);
|
|
59
|
+
letter-spacing: var(--info-box-body-letter-spacing);
|
|
60
|
+
font-weight: var(--info-box-body-font-weight);
|
|
61
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
// 변경: 실사용 캡처 톤에 맞춰 info 배경/보더 대비를 부드럽게 조정한다.
|
|
3
|
+
--info-box-background-color: color-mix(
|
|
4
|
+
in srgb,
|
|
5
|
+
var(--color-feedback-information) 9%,
|
|
6
|
+
var(--color-common-100)
|
|
7
|
+
);
|
|
8
|
+
--info-box-border-color: color-mix(
|
|
9
|
+
in srgb,
|
|
10
|
+
var(--color-feedback-information) 24%,
|
|
11
|
+
var(--color-common-100)
|
|
12
|
+
);
|
|
13
|
+
--info-box-icon-color: var(--color-feedback-information);
|
|
14
|
+
--info-box-heading-color: var(--color-feedback-information);
|
|
15
|
+
--info-box-body-color: var(--color-label-strong);
|
|
16
|
+
|
|
17
|
+
--info-box-radius: var(--theme-radius-120x120);
|
|
18
|
+
--info-box-padding-block: var(--spacing-padding-6);
|
|
19
|
+
--info-box-padding-inline: var(--spacing-padding-6);
|
|
20
|
+
--info-box-gap-icon: var(--spacing-gap-4);
|
|
21
|
+
--info-box-gap-contents: var(--spacing-gap-3);
|
|
22
|
+
--info-box-icon-size: 24px;
|
|
23
|
+
|
|
24
|
+
--info-box-heading-font-size: var(--font-heading-xsmall-size);
|
|
25
|
+
--info-box-heading-line-height: var(--font-heading-xsmall-line-height);
|
|
26
|
+
--info-box-heading-letter-spacing: var(--font-heading-xsmall-letter-spacing);
|
|
27
|
+
--info-box-heading-font-weight: var(--font-heading-xsmall-weight);
|
|
28
|
+
|
|
29
|
+
--info-box-body-font-size: var(--font-body-small-size);
|
|
30
|
+
--info-box-body-line-height: var(--font-body-small-line-height);
|
|
31
|
+
--info-box-body-letter-spacing: var(--font-body-small-letter-spacing);
|
|
32
|
+
--info-box-body-font-weight: var(--font-body-small-weight);
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./props";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
// 변경: 단일 state 단계에서는 리터럴 유니온 타입으로 직접 선언한다.
|
|
4
|
+
export type InfoBoxState = "info" | "caution" | "success" | "error";
|
|
5
|
+
|
|
6
|
+
type NativeSectionProps = Omit<ComponentPropsWithoutRef<"section">, "title">;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* InfoBox Props; info-box 루트 속성
|
|
10
|
+
* @property {"info" | "caution" | "success" | "error"} [state] state 값. 현재는 info만 허용한다.
|
|
11
|
+
* @property {ReactNode} [heading] 상단 제목 콘텐츠
|
|
12
|
+
* @property {ReactNode} [children] 본문 콘텐츠
|
|
13
|
+
* @property {string} [className] 루트 section className
|
|
14
|
+
* @see React.ComponentPropsWithoutRef<"section">
|
|
15
|
+
*/
|
|
16
|
+
export interface InfoBoxProps extends Omit<NativeSectionProps, "children"> {
|
|
17
|
+
/**
|
|
18
|
+
* state 값. 현재는 info만 허용한다.
|
|
19
|
+
* - info, caution, success, error
|
|
20
|
+
*/
|
|
21
|
+
state?: InfoBoxState;
|
|
22
|
+
/**
|
|
23
|
+
* 상단 제목 콘텐츠
|
|
24
|
+
*/
|
|
25
|
+
heading?: ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* 본문 콘텐츠
|
|
28
|
+
*/
|
|
29
|
+
children?: ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* 루트 section className
|
|
32
|
+
*/
|
|
33
|
+
className?: string;
|
|
34
|
+
}
|
package/src/index.tsx
CHANGED