@tide-tds/components 0.2.0 → 0.2.1

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.
@@ -0,0 +1,26 @@
1
+ import { Color, FillVariant, Size } from "./types.js";
2
+ import { ComponentProps, ReactElement, ReactNode } from "react";
3
+ /** Badge의 채움 방식. 상호작용이 없어 테두리·투명 채움(`outline`·`ghost`)은 받지 않는다. */
4
+ type BadgeVariant = Extract<FillVariant, "subtle" | "solid">;
5
+ /** Badge의 size. 조작 요소가 아니라 높이가 size 표보다 한 단계 작다(`sm` 20px, `md` 24px). */
6
+ type BadgeSize = Extract<Size, "sm" | "md">;
7
+ export interface BadgeProps extends Omit<ComponentProps<"span">, "color" | "children"> {
8
+ /** 상태를 말하는 텍스트. 필수다. 색만으로 상태를 전하지 않기 위해서다(WCAG 1.4.1). */
9
+ children: ReactNode;
10
+ /** `subtle`(옅은 배경, 기본값)과 `solid`(진한 배경). 같은 화면 안에서는 한 가지로 맞춘다. */
11
+ variant?: BadgeVariant;
12
+ /** `sm` 높이 20px·`label-sm`, `md` 높이 24px·`label-md`. 기본값은 `md`다. */
13
+ size?: BadgeSize;
14
+ /**
15
+ * 색 이름. 상태는 Role(Tide Role 6개와 앱이 `RoleRegistry`에 더한 Role), 뜻 없는 분류는 색 계열 이름
16
+ * (Tide 색 계열 6개와 앱이 `ColorFamilyRegistry`에 더한 계열)을 쓴다(ADR 0016·0017). 기본값은 `neutral`이다.
17
+ * 루트에 `data-color`로 붙고 바깥 요소의 색을 물려받지 않는다.
18
+ */
19
+ color?: Color;
20
+ }
21
+ /**
22
+ * 상태나 분류를 짧은 텍스트로 보여 주는 라벨. 누르거나 고르는 동작이 없다.
23
+ * 상태는 Role, 분류는 색 계열 이름으로 색을 고르고, 뜻은 반드시 텍스트로 적는다. 서버 컴포넌트로 쓸 수 있다.
24
+ */
25
+ export declare function Badge({ variant, size, color, className, ...props }: BadgeProps): ReactElement;
26
+ export {};
package/dist/Badge.js ADDED
@@ -0,0 +1,27 @@
1
+ import { cn } from "./cn.js";
2
+ import { jsx } from "react/jsx-runtime";
3
+
4
+ // src/Badge.tsx
5
+ const variantClass = {
6
+ subtle: "bg-accent-subtle text-accent",
7
+ solid: "bg-accent-solid text-accent-on-solid"
8
+ };
9
+ /** 높이는 border 1px를 포함한다. 글자 줄 높이(label-sm 16px, label-md 20px) + border 2px + 세로 여백이다. */
10
+ const sizeClass = {
11
+ sm: "h-5 gap-1 px-1.5 text-label-sm",
12
+ md: "h-6 gap-1 px-2 text-label-md"
13
+ };
14
+ const baseClass = "inline-flex max-w-full shrink-0 items-center rounded-sm border border-transparent align-middle whitespace-nowrap [&_svg]:size-3 [&_svg]:shrink-0";
15
+ /**
16
+ * 상태나 분류를 짧은 텍스트로 보여 주는 라벨. 누르거나 고르는 동작이 없다.
17
+ * 상태는 Role, 분류는 색 계열 이름으로 색을 고르고, 뜻은 반드시 텍스트로 적는다. 서버 컴포넌트로 쓸 수 있다.
18
+ */
19
+ function Badge({ variant = "subtle", size = "md", color = "neutral", className, ...props }) {
20
+ return /* @__PURE__ */ jsx("span", {
21
+ ...props,
22
+ "data-color": color,
23
+ className: cn(baseClass, variantClass[variant], sizeClass[size], className)
24
+ });
25
+ }
26
+
27
+ export { Badge };
package/dist/Card.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { ComponentProps, ReactElement } from "react";
2
+ export interface CardProps extends ComponentProps<"div"> {
3
+ /**
4
+ * 다른 요소로 렌더한다. 예: `render={<article />}`, `render={<li />}`.
5
+ * 묶음의 뜻이 있으면 그 요소를 고른다. props, ref, className을 그 요소에 병합한다.
6
+ */
7
+ render?: ReactElement;
8
+ }
9
+ /**
10
+ * 관련 내용을 한 덩어리로 묶는 surface 표면 컨테이너. 경계만 있고 그림자는 없다.
11
+ * 기본 요소는 `div`이고, `render`로 `article`·`section`·`li` 등을 쓴다. 서버 컴포넌트로 쓸 수 있다.
12
+ */
13
+ export declare function Card({ render, ...props }: CardProps): ReactElement;
package/dist/Card.js ADDED
@@ -0,0 +1,18 @@
1
+ import { renderElement } from "./render.js";
2
+
3
+ // src/Card.tsx
4
+ const baseClass = "rounded-lg border border-default bg-surface p-4 text-default";
5
+ /**
6
+ * 관련 내용을 한 덩어리로 묶는 surface 표면 컨테이너. 경계만 있고 그림자는 없다.
7
+ * 기본 요소는 `div`이고, `render`로 `article`·`section`·`li` 등을 쓴다. 서버 컴포넌트로 쓸 수 있다.
8
+ */
9
+ function Card({ render, ...props }) {
10
+ return renderElement({
11
+ defaultElement: "div",
12
+ render,
13
+ baseClassName: baseClass,
14
+ props
15
+ });
16
+ }
17
+
18
+ export { Card };
@@ -0,0 +1,18 @@
1
+ import { ComponentProps, ReactElement } from "react";
2
+ /** Separator의 방향 */
3
+ type SeparatorOrientation = "horizontal" | "vertical";
4
+ export interface SeparatorProps extends Omit<ComponentProps<"hr">, "children" | "role"> {
5
+ /** `horizontal`(기본값)은 위아래 내용을, `vertical`은 한 줄 안의 양옆 내용을 나눈다. */
6
+ orientation?: SeparatorOrientation;
7
+ /**
8
+ * 보기만 나누는 선이면 `true`. `role="none"`이 붙어 보조 기술에서 빠진다. 기본값은 `false`(separator 역할)다.
9
+ * 내용의 주제가 바뀌는 곳이면 `false`로 둔다.
10
+ */
11
+ decorative?: boolean;
12
+ }
13
+ /**
14
+ * 내용 묶음 사이를 선으로 나눈다. 기본은 의미 구분(separator 역할)이고, `decorative`면 보조 기술에서 빠진다.
15
+ * 서버 컴포넌트로 쓸 수 있다.
16
+ */
17
+ export declare function Separator({ orientation, decorative, className, ...props }: SeparatorProps): ReactElement;
18
+ export {};
@@ -0,0 +1,24 @@
1
+ import { cn } from "./cn.js";
2
+ import { jsx } from "react/jsx-runtime";
3
+
4
+ // src/Separator.tsx
5
+ const orientationClass = {
6
+ horizontal: "h-0 w-full border-t",
7
+ vertical: "h-auto w-0 self-stretch border-s"
8
+ };
9
+ const baseClass = "m-0 shrink-0 border-0 border-default";
10
+ /**
11
+ * 내용 묶음 사이를 선으로 나눈다. 기본은 의미 구분(separator 역할)이고, `decorative`면 보조 기술에서 빠진다.
12
+ * 서버 컴포넌트로 쓸 수 있다.
13
+ */
14
+ function Separator({ orientation = "horizontal", decorative = false, className, ...props }) {
15
+ return /* @__PURE__ */ jsx("hr", {
16
+ ...props,
17
+ role: decorative ? "none" : void 0,
18
+ "aria-orientation": !decorative && orientation === "vertical" ? "vertical" : void 0,
19
+ "data-orientation": orientation,
20
+ className: cn(baseClass, orientationClass[orientation], className)
21
+ });
22
+ }
23
+
24
+ export { Separator };
package/dist/index.d.ts CHANGED
@@ -13,5 +13,8 @@ import { CheckboxGroup, CheckboxGroupProps, ChoiceOrientation } from "./Checkbox
13
13
  import { Radio, RadioProps } from "./Radio.js";
14
14
  import { RadioGroup, RadioGroupProps } from "./RadioGroup.js";
15
15
  import { Switch, SwitchProps } from "./Switch.js";
16
+ import { Badge, BadgeProps } from "./Badge.js";
17
+ import { Card, CardProps } from "./Card.js";
18
+ import { Separator, SeparatorProps } from "./Separator.js";
16
19
  import { Color, ColorFamilyName, ColorFamilyRegistry, FillVariant, Role, RoleRegistry, Size } from "./types.js";
17
- export { Button, type ButtonProps, Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, type ChoiceOrientation, type Color, type ColorFamilyName, type ColorFamilyRegistry, Field, type FieldProps, type FillVariant, IconButton, type IconButtonProps, Input, type InputProps, Link, type LinkProps, Radio, RadioGroup, type RadioGroupProps, type RadioProps, type Role, type RoleRegistry, type Size, Spinner, type SpinnerProps, Switch, type SwitchProps, Textarea, type TextareaProps, Typography, type TypographyProps, VisuallyHidden, type VisuallyHiddenProps, cn };
20
+ export { Badge, type BadgeProps, Button, type ButtonProps, Card, type CardProps, Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, type ChoiceOrientation, type Color, type ColorFamilyName, type ColorFamilyRegistry, Field, type FieldProps, type FillVariant, IconButton, type IconButtonProps, Input, type InputProps, Link, type LinkProps, Radio, RadioGroup, type RadioGroupProps, type RadioProps, type Role, type RoleRegistry, Separator, type SeparatorProps, type Size, Spinner, type SpinnerProps, Switch, type SwitchProps, Textarea, type TextareaProps, Typography, type TypographyProps, VisuallyHidden, type VisuallyHiddenProps, cn };
package/dist/index.js CHANGED
@@ -13,5 +13,8 @@ import { CheckboxGroup } from "./CheckboxGroup.js";
13
13
  import { Radio } from "./Radio.js";
14
14
  import { RadioGroup } from "./RadioGroup.js";
15
15
  import { Switch } from "./Switch.js";
16
+ import { Badge } from "./Badge.js";
17
+ import { Card } from "./Card.js";
18
+ import { Separator } from "./Separator.js";
16
19
 
17
- export { Button, Checkbox, CheckboxGroup, Field, IconButton, Input, Link, Radio, RadioGroup, Spinner, Switch, Textarea, Typography, VisuallyHidden, cn };
20
+ export { Badge, Button, Card, Checkbox, CheckboxGroup, Field, IconButton, Input, Link, Radio, RadioGroup, Separator, Spinner, Switch, Textarea, Typography, VisuallyHidden, cn };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tide-tds/components",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Tide 디자인 시스템의 React Component",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -23,8 +23,8 @@
23
23
  "./styles.css": "./dist/styles.css"
24
24
  },
25
25
  "dependencies": {
26
- "@tide-tds/foundation": "0.2.0",
27
- "@tide-tds/icons": "0.2.0",
26
+ "@tide-tds/foundation": "0.2.1",
27
+ "@tide-tds/icons": "0.2.1",
28
28
  "clsx": "^2.1.1",
29
29
  "react-aria": "^3.53.1",
30
30
  "react-stately": "^3.51.0",