@seed-design/lynx-react 0.1.1-alpha.0
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/lib/components/ActionButton/ActionButton.d.ts +24 -0
- package/lib/components/ActionButton/ActionButton.d.ts.map +1 -0
- package/lib/components/ActionButton/ActionButton.jsx +21 -0
- package/lib/components/ActionButton/index.d.ts +2 -0
- package/lib/components/ActionButton/index.d.ts.map +1 -0
- package/lib/components/ActionButton/index.js +1 -0
- package/lib/components/Box/Box.d.ts +10 -0
- package/lib/components/Box/Box.d.ts.map +1 -0
- package/lib/components/Box/Box.jsx +19 -0
- package/lib/components/Box/index.d.ts +2 -0
- package/lib/components/Box/index.d.ts.map +1 -0
- package/lib/components/Box/index.js +1 -0
- package/lib/components/Flex/Flex.d.ts +33 -0
- package/lib/components/Flex/Flex.d.ts.map +1 -0
- package/lib/components/Flex/Flex.jsx +7 -0
- package/lib/components/Flex/index.d.ts +2 -0
- package/lib/components/Flex/index.d.ts.map +1 -0
- package/lib/components/Flex/index.js +1 -0
- package/lib/components/List/List.d.ts +9 -0
- package/lib/components/List/List.d.ts.map +1 -0
- package/lib/components/List/List.jsx +17 -0
- package/lib/components/List/index.d.ts +2 -0
- package/lib/components/List/index.d.ts.map +1 -0
- package/lib/components/List/index.js +1 -0
- package/lib/components/ListItem/ListItem.d.ts +8 -0
- package/lib/components/ListItem/ListItem.d.ts.map +1 -0
- package/lib/components/ListItem/ListItem.jsx +11 -0
- package/lib/components/ListItem/index.d.ts +2 -0
- package/lib/components/ListItem/index.d.ts.map +1 -0
- package/lib/components/ListItem/index.js +1 -0
- package/lib/components/ProgressCircle/ProgressCircle.d.ts +28 -0
- package/lib/components/ProgressCircle/ProgressCircle.d.ts.map +1 -0
- package/lib/components/ProgressCircle/ProgressCircle.jsx +292 -0
- package/lib/components/ProgressCircle/index.d.ts +2 -0
- package/lib/components/ProgressCircle/index.d.ts.map +1 -0
- package/lib/components/ProgressCircle/index.js +1 -0
- package/lib/components/ScrollView/ScrollView.d.ts +9 -0
- package/lib/components/ScrollView/ScrollView.d.ts.map +1 -0
- package/lib/components/ScrollView/ScrollView.jsx +17 -0
- package/lib/components/ScrollView/index.d.ts +2 -0
- package/lib/components/ScrollView/index.d.ts.map +1 -0
- package/lib/components/ScrollView/index.js +1 -0
- package/lib/components/Stack/Stack.d.ts +6 -0
- package/lib/components/Stack/Stack.d.ts.map +1 -0
- package/lib/components/Stack/Stack.jsx +10 -0
- package/lib/components/Stack/index.d.ts +2 -0
- package/lib/components/Stack/index.d.ts.map +1 -0
- package/lib/components/Stack/index.js +1 -0
- package/lib/components/Text/Text.d.ts +30 -0
- package/lib/components/Text/Text.d.ts.map +1 -0
- package/lib/components/Text/Text.jsx +49 -0
- package/lib/components/Text/index.d.ts +2 -0
- package/lib/components/Text/index.d.ts.map +1 -0
- package/lib/components/Text/index.js +1 -0
- package/lib/get-seed-class-name.d.ts +23 -0
- package/lib/get-seed-class-name.d.ts.map +1 -0
- package/lib/get-seed-class-name.js +39 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +4 -0
- package/lib/utils/dynamic-style.d.ts +13 -0
- package/lib/utils/dynamic-style.d.ts.map +1 -0
- package/lib/utils/dynamic-style.js +26 -0
- package/lib/utils/styled.d.ts +120 -0
- package/lib/utils/styled.d.ts.map +1 -0
- package/lib/utils/styled.jsx +131 -0
- package/package.json +51 -0
- package/src/components/ActionButton/ActionButton.tsx +62 -0
- package/src/components/ActionButton/index.ts +1 -0
- package/src/components/ProgressCircle/ProgressCircle.tsx +409 -0
- package/src/components/ProgressCircle/index.ts +1 -0
- package/src/get-seed-class-name.ts +52 -0
- package/src/index.ts +4 -0
- package/src/utils/dynamic-style.ts +26 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { Flex } from "../Flex/Flex";
|
|
3
|
+
export const VStack = forwardRef((props, ref) => {
|
|
4
|
+
return <Flex ref={ref} display="flex" flexDirection="column" {...props}/>;
|
|
5
|
+
});
|
|
6
|
+
VStack.displayName = "VStack";
|
|
7
|
+
export const HStack = forwardRef((props, ref) => {
|
|
8
|
+
return <Flex ref={ref} display="flex" flexDirection="row" {...props}/>;
|
|
9
|
+
});
|
|
10
|
+
HStack.displayName = "HStack";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Stack/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { VStack, HStack } from "./Stack";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { TextVariantProps } from "@seed-design/lynx-css/recipes/text";
|
|
2
|
+
import { type FontSize, type FontWeight, type LineHeight, type ScopedColorFg, type ScopedColorPalette } from "@seed-design/css/vars";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
export interface TextProps extends Pick<TextVariantProps, "textStyle"> {
|
|
5
|
+
/**
|
|
6
|
+
* The color of the text.
|
|
7
|
+
*/
|
|
8
|
+
color?: ScopedColorFg | ScopedColorPalette | (string & {});
|
|
9
|
+
/**
|
|
10
|
+
* The font size of the text. Partially overrides the textStyle.
|
|
11
|
+
*/
|
|
12
|
+
fontSize?: FontSize | (string & {});
|
|
13
|
+
/**
|
|
14
|
+
* The line height of the text. Partially overrides the textStyle.
|
|
15
|
+
*/
|
|
16
|
+
lineHeight?: LineHeight | (string & {});
|
|
17
|
+
/**
|
|
18
|
+
* The font weight of the text. Partially overrides the textStyle.
|
|
19
|
+
*/
|
|
20
|
+
fontWeight?: FontWeight;
|
|
21
|
+
/**
|
|
22
|
+
* The alignment of the text.
|
|
23
|
+
*/
|
|
24
|
+
align?: "left" | "center" | "right";
|
|
25
|
+
className?: string;
|
|
26
|
+
style?: React.CSSProperties;
|
|
27
|
+
children?: ReactNode;
|
|
28
|
+
}
|
|
29
|
+
export declare const Text: import("react").ForwardRefExoticComponent<TextProps & import("react").RefAttributes<any>>;
|
|
30
|
+
//# sourceMappingURL=Text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../src/components/Text/Text.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAqCvC,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,gBAAgB,EAAE,WAAW,CAAC;IACpE;;OAEG;IACH,KAAK,CAAC,EAAE,aAAa,GAAG,kBAAkB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAE3D;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAEpC;;OAEG;IACH,UAAU,CAAC,EAAE,UAAU,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAExC;;OAEG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IAEpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,IAAI,2FA0BhB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { text } from "@seed-design/lynx-css/recipes/text";
|
|
2
|
+
import { vars, } from "@seed-design/css/vars";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import { forwardRef, useMemo } from "react";
|
|
5
|
+
import { dynamicStyle } from "../../utils/dynamic-style";
|
|
6
|
+
function handleColor(color) {
|
|
7
|
+
if (!color) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
const [type, value] = color.split(".");
|
|
11
|
+
// @ts-expect-error
|
|
12
|
+
return vars.$color[type]?.[value] ?? color;
|
|
13
|
+
}
|
|
14
|
+
function handleFontWeight(fontWeight) {
|
|
15
|
+
if (!fontWeight) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
// @ts-expect-error
|
|
19
|
+
return vars.$fontWeight[fontWeight] ?? undefined;
|
|
20
|
+
}
|
|
21
|
+
function handleFontSize(size) {
|
|
22
|
+
if (!size) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
// @ts-expect-error
|
|
26
|
+
return vars.$fontSize[size] ?? size;
|
|
27
|
+
}
|
|
28
|
+
function handleLineHeight(lineHeight) {
|
|
29
|
+
if (!lineHeight) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
// @ts-expect-error
|
|
33
|
+
return vars.$lineHeight[lineHeight] ?? lineHeight;
|
|
34
|
+
}
|
|
35
|
+
export const Text = forwardRef(({ color, textStyle, fontSize, lineHeight, fontWeight, align, children, className, style }, ref) => {
|
|
36
|
+
const classes = useMemo(() => text({ textStyle }), [textStyle]);
|
|
37
|
+
const textStyleStr = dynamicStyle({
|
|
38
|
+
color: handleColor(color),
|
|
39
|
+
"font-size": handleFontSize(fontSize),
|
|
40
|
+
"line-height": handleLineHeight(lineHeight ?? fontSize),
|
|
41
|
+
"font-weight": handleFontWeight(fontWeight),
|
|
42
|
+
"text-align": align,
|
|
43
|
+
...style,
|
|
44
|
+
});
|
|
45
|
+
return (<text {...(ref ? { ref } : {})} className={clsx(classes.text, className)} style={textStyleStr}>
|
|
46
|
+
{children}
|
|
47
|
+
</text>);
|
|
48
|
+
});
|
|
49
|
+
Text.displayName = "Text";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Text } from "./Text";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type ColorMode = "system" | "light-only" | "dark-only";
|
|
2
|
+
/**
|
|
3
|
+
* Lynx 앱의 root `<page>` 요소에 적용할 SEED Design className을 반환한다.
|
|
4
|
+
*
|
|
5
|
+
* 테마(dark/light)와 플랫폼(iOS/Android)을 자동 감지하여
|
|
6
|
+
* 렌더링 전에 올바른 CSS 변수가 적용되도록 한다.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* import { getSeedClassName } from "@seed-design/lynx-react";
|
|
11
|
+
*
|
|
12
|
+
* root.render(
|
|
13
|
+
* <page className={getSeedClassName({ colorMode: "system" })}>
|
|
14
|
+
* <App />
|
|
15
|
+
* </page>
|
|
16
|
+
* );
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function getSeedClassName(options?: {
|
|
20
|
+
colorMode?: ColorMode;
|
|
21
|
+
}): string;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=get-seed-class-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-seed-class-name.d.ts","sourceRoot":"","sources":["../src/get-seed-class-name.ts"],"names":[],"mappings":"AAUA,KAAK,SAAS,GAAG,QAAQ,GAAG,YAAY,GAAG,WAAW,CAAC;AAEvD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG,MAAM,CAsB5E"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lynx 앱의 root `<page>` 요소에 적용할 SEED Design className을 반환한다.
|
|
3
|
+
*
|
|
4
|
+
* 테마(dark/light)와 플랫폼(iOS/Android)을 자동 감지하여
|
|
5
|
+
* 렌더링 전에 올바른 CSS 변수가 적용되도록 한다.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { getSeedClassName } from "@seed-design/lynx-react";
|
|
10
|
+
*
|
|
11
|
+
* root.render(
|
|
12
|
+
* <page className={getSeedClassName({ colorMode: "system" })}>
|
|
13
|
+
* <App />
|
|
14
|
+
* </page>
|
|
15
|
+
* );
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export function getSeedClassName(options) {
|
|
19
|
+
const { colorMode = "system" } = options ?? {};
|
|
20
|
+
// Theme — lynx.__globalProps.theme에서 시스템 테마 읽기
|
|
21
|
+
const systemTheme = lynx?.__globalProps?.["theme"];
|
|
22
|
+
let themeClass;
|
|
23
|
+
if (colorMode === "light-only") {
|
|
24
|
+
themeClass = "seed-user-color-scheme-light";
|
|
25
|
+
}
|
|
26
|
+
else if (colorMode === "dark-only") {
|
|
27
|
+
themeClass = "seed-user-color-scheme-dark";
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
themeClass =
|
|
31
|
+
systemTheme?.toLowerCase() === "dark"
|
|
32
|
+
? "seed-user-color-scheme-dark"
|
|
33
|
+
: "seed-user-color-scheme-light";
|
|
34
|
+
}
|
|
35
|
+
// Platform — SystemInfo.platform에서 디바이스 플랫폼 읽기
|
|
36
|
+
const platform = SystemInfo?.platform;
|
|
37
|
+
const platformClass = platform === "iOS" ? "seed-platform-ios" : "seed-platform-android";
|
|
38
|
+
return `${themeClass} ${platformClass}`;
|
|
39
|
+
}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ActionButton, type ActionButtonProps } from "./components/ActionButton";
|
|
2
|
+
export { ProgressCircle, type ProgressCircleProps } from "./components/ProgressCircle";
|
|
3
|
+
export { dynamicStyle } from "./utils/dynamic-style";
|
|
4
|
+
export { getSeedClassName } from "./get-seed-class-name";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a style object to a Lynx-compatible style string.
|
|
3
|
+
*
|
|
4
|
+
* Lynx compiles object-form `style` props into static CSS at build time,
|
|
5
|
+
* which drops dynamically-set CSS custom properties. Passing styles as a
|
|
6
|
+
* string literal preserves runtime values.
|
|
7
|
+
*
|
|
8
|
+
* Property names are converted from camelCase to kebab-case so that
|
|
9
|
+
* `React.CSSProperties` keys (e.g. `fontSize`) produce valid CSS
|
|
10
|
+
* (e.g. `font-size`).
|
|
11
|
+
*/
|
|
12
|
+
export declare function dynamicStyle(style: Record<string, unknown>): string;
|
|
13
|
+
//# sourceMappingURL=dynamic-style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-style.d.ts","sourceRoot":"","sources":["../../src/utils/dynamic-style.ts"],"names":[],"mappings":"AASA;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAKnE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert camelCase CSS property names to kebab-case.
|
|
3
|
+
* CSS custom properties (starting with `--`) are left unchanged.
|
|
4
|
+
*/
|
|
5
|
+
function toKebabCase(str) {
|
|
6
|
+
if (str.startsWith("--"))
|
|
7
|
+
return str;
|
|
8
|
+
return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Convert a style object to a Lynx-compatible style string.
|
|
12
|
+
*
|
|
13
|
+
* Lynx compiles object-form `style` props into static CSS at build time,
|
|
14
|
+
* which drops dynamically-set CSS custom properties. Passing styles as a
|
|
15
|
+
* string literal preserves runtime values.
|
|
16
|
+
*
|
|
17
|
+
* Property names are converted from camelCase to kebab-case so that
|
|
18
|
+
* `React.CSSProperties` keys (e.g. `fontSize`) produce valid CSS
|
|
19
|
+
* (e.g. `font-size`).
|
|
20
|
+
*/
|
|
21
|
+
export function dynamicStyle(style) {
|
|
22
|
+
return Object.entries(style)
|
|
23
|
+
.filter(([_, v]) => v != null)
|
|
24
|
+
.map(([k, v]) => `${toKebabCase(k)}: ${v}`)
|
|
25
|
+
.join("; ");
|
|
26
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { ScopedColorBg, ScopedColorFg, ScopedColorPalette, ScopedColorStroke, Dimension, Radius, SpacingX, SpacingY, Gradient, Shadow, ScopedColorBanner } from "@seed-design/css/vars";
|
|
2
|
+
export declare function handleColor(color: string | undefined): any;
|
|
3
|
+
export declare function handleDimension(dimension: string | 0 | undefined): string | undefined;
|
|
4
|
+
export declare function handlePaddingWithSafeArea(padding: string | 0 | undefined, direction: "top" | "bottom"): string | undefined;
|
|
5
|
+
export declare function handleRadius(radius: string | 0 | undefined): any;
|
|
6
|
+
export interface StyleProps {
|
|
7
|
+
/**
|
|
8
|
+
* Shorthand for `background`.
|
|
9
|
+
*/
|
|
10
|
+
bg?: ScopedColorBg | ScopedColorPalette | ScopedColorBanner | (string & {});
|
|
11
|
+
background?: ScopedColorBg | ScopedColorPalette | ScopedColorBanner | (string & {});
|
|
12
|
+
/**
|
|
13
|
+
* Shorthand for `backgroundGradient`.
|
|
14
|
+
*/
|
|
15
|
+
bgGradient?: Gradient;
|
|
16
|
+
backgroundGradient?: Gradient;
|
|
17
|
+
/**
|
|
18
|
+
* Shorthand for `backgroundGradientDirection`.
|
|
19
|
+
* e.g. `43deg`
|
|
20
|
+
*/
|
|
21
|
+
bgGradientDirection?: "to right" | "to left" | "to top" | "to bottom" | "to top right" | "to top left" | "to bottom right" | "to bottom left" | (string & {});
|
|
22
|
+
backgroundGradientDirection?: "to right" | "to left" | "to top" | "to bottom" | "to top right" | "to top left" | "to bottom right" | "to bottom left" | (string & {});
|
|
23
|
+
color?: ScopedColorFg | ScopedColorPalette | (string & {});
|
|
24
|
+
borderColor?: ScopedColorStroke | ScopedColorPalette | (string & {});
|
|
25
|
+
borderWidth?: 0 | 1 | (string & {});
|
|
26
|
+
borderTopWidth?: 0 | 1 | (string & {});
|
|
27
|
+
borderRightWidth?: 0 | 1 | (string & {});
|
|
28
|
+
borderBottomWidth?: 0 | 1 | (string & {});
|
|
29
|
+
borderLeftWidth?: 0 | 1 | (string & {});
|
|
30
|
+
borderRadius?: Radius | 0 | (string & {});
|
|
31
|
+
borderTopLeftRadius?: Radius | 0 | (string & {});
|
|
32
|
+
borderTopRightRadius?: Radius | 0 | (string & {});
|
|
33
|
+
borderBottomRightRadius?: Radius | 0 | (string & {});
|
|
34
|
+
borderBottomLeftRadius?: Radius | 0 | (string & {});
|
|
35
|
+
boxShadow?: Shadow | (string & {});
|
|
36
|
+
width?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
|
|
37
|
+
minWidth?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
|
|
38
|
+
maxWidth?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
|
|
39
|
+
height?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
|
|
40
|
+
minHeight?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
|
|
41
|
+
maxHeight?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
|
|
42
|
+
top?: 0 | (string & {});
|
|
43
|
+
left?: 0 | (string & {});
|
|
44
|
+
right?: 0 | (string & {});
|
|
45
|
+
bottom?: 0 | (string & {});
|
|
46
|
+
padding?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
47
|
+
/**
|
|
48
|
+
* Shorthand for `padding`.
|
|
49
|
+
*/
|
|
50
|
+
p?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
51
|
+
paddingX?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
52
|
+
/**
|
|
53
|
+
* Shorthand for `paddingX`.
|
|
54
|
+
*/
|
|
55
|
+
px?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
56
|
+
paddingY?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
57
|
+
/**
|
|
58
|
+
* Shorthand for `paddingY`.
|
|
59
|
+
*/
|
|
60
|
+
py?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
61
|
+
paddingTop?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | "safeArea" | (string & {});
|
|
62
|
+
/**
|
|
63
|
+
* Shorthand for `paddingTop`.
|
|
64
|
+
*/
|
|
65
|
+
pt?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | "safeArea" | (string & {});
|
|
66
|
+
paddingRight?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
67
|
+
/**
|
|
68
|
+
* Shorthand for `paddingRight`.
|
|
69
|
+
*/
|
|
70
|
+
pr?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
71
|
+
paddingBottom?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | "safeArea" | (string & {});
|
|
72
|
+
/**
|
|
73
|
+
* Shorthand for `paddingBottom`.
|
|
74
|
+
*/
|
|
75
|
+
pb?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | "safeArea" | (string & {});
|
|
76
|
+
paddingLeft?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
77
|
+
/**
|
|
78
|
+
* Shorthand for `paddingLeft`.
|
|
79
|
+
*/
|
|
80
|
+
pl?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
81
|
+
bleedX?: "asPadding" | Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
82
|
+
bleedY?: "asPadding" | Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
83
|
+
bleedTop?: "asPadding" | Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
84
|
+
bleedRight?: "asPadding" | Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
85
|
+
bleedBottom?: "asPadding" | Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
86
|
+
bleedLeft?: "asPadding" | Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
87
|
+
display?: "flex" | "none" | "block";
|
|
88
|
+
position?: "relative" | "absolute" | "fixed" | "sticky";
|
|
89
|
+
overflowX?: "visible" | "hidden";
|
|
90
|
+
overflowY?: "visible" | "hidden";
|
|
91
|
+
zIndex?: number | (string & {});
|
|
92
|
+
/**
|
|
93
|
+
* If true, flex-grow will be set to `1`.
|
|
94
|
+
*/
|
|
95
|
+
flexGrow?: 0 | 1 | (number & {}) | true;
|
|
96
|
+
/**
|
|
97
|
+
* If true, flex-shrink will be set to `1`.
|
|
98
|
+
*/
|
|
99
|
+
flexShrink?: 0 | (number & {}) | true;
|
|
100
|
+
flexDirection?: "row" | "column" | "row-reverse" | "column-reverse";
|
|
101
|
+
/**
|
|
102
|
+
* If true, flex-wrap will be set to `wrap`.
|
|
103
|
+
*/
|
|
104
|
+
flexWrap?: "wrap" | "wrap-reverse" | "nowrap" | true;
|
|
105
|
+
justifyContent?: "flex-start" | "flex-end" | "center" | "space-between" | "space-around";
|
|
106
|
+
justifySelf?: "center" | "start" | "end" | "stretch";
|
|
107
|
+
alignItems?: "flex-start" | "flex-end" | "center" | "stretch";
|
|
108
|
+
alignContent?: "flex-start" | "flex-end" | "center" | "stretch";
|
|
109
|
+
alignSelf?: "flex-start" | "flex-end" | "center" | "stretch";
|
|
110
|
+
gap?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
|
|
111
|
+
}
|
|
112
|
+
interface UseStyleProps extends StyleProps {
|
|
113
|
+
style?: React.CSSProperties;
|
|
114
|
+
}
|
|
115
|
+
export declare function useStyleProps<T extends UseStyleProps>(props: T): {
|
|
116
|
+
style: string;
|
|
117
|
+
restProps: Omit<T, keyof UseStyleProps>;
|
|
118
|
+
};
|
|
119
|
+
export {};
|
|
120
|
+
//# sourceMappingURL=styled.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../../src/utils/styled.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,SAAS,EACT,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,M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AAED,UAAU,aAAc,SAAQ,UAAU;IACxC,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED,wBAAgB,aAAa,CAAC,CAAC,SAAS,aAAa,EACnD,KAAK,EAAE,CAAC,GACP;IACD,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,IAAI,CAAC,CAAC,EAAE,MAAM,aAAa,CAAC,CAAC;CACzC,CAwIA"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StyleProps utilities for Lynx.
|
|
3
|
+
* Based on packages/react/src/utils/styled.tsx, adapted for Lynx environment.
|
|
4
|
+
*/
|
|
5
|
+
import { dynamicStyle } from "./dynamic-style";
|
|
6
|
+
import { vars } from "@seed-design/css/vars";
|
|
7
|
+
export function handleColor(color) {
|
|
8
|
+
if (!color) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
const [type, value] = color.split(".");
|
|
12
|
+
// @ts-expect-error
|
|
13
|
+
return vars.$color[type]?.[value] ?? color;
|
|
14
|
+
}
|
|
15
|
+
export function handleDimension(dimension) {
|
|
16
|
+
if (dimension == null) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
if (typeof dimension === "number") {
|
|
20
|
+
return `${dimension}px`;
|
|
21
|
+
}
|
|
22
|
+
if (dimension === "full") {
|
|
23
|
+
return "100%";
|
|
24
|
+
}
|
|
25
|
+
const [type, value] = dimension.split(".");
|
|
26
|
+
// @ts-expect-error
|
|
27
|
+
const resolved = vars.$dimension[dimension] ?? vars.$dimension[type]?.[value] ?? dimension;
|
|
28
|
+
// 숫자만으로 이루어진 string이면 px 단위 추가 (Lynx는 unitless length를 허용하지 않음)
|
|
29
|
+
if (typeof resolved === "string" && /^\d+(\.\d+)?$/.test(resolved)) {
|
|
30
|
+
return `${resolved}px`;
|
|
31
|
+
}
|
|
32
|
+
return resolved;
|
|
33
|
+
}
|
|
34
|
+
function handleBleed(dimension, direction) {
|
|
35
|
+
if (dimension === "asPadding") {
|
|
36
|
+
return `var(--seed-box-padding-${direction})`;
|
|
37
|
+
}
|
|
38
|
+
return handleDimension(dimension);
|
|
39
|
+
}
|
|
40
|
+
function handleShadow(shadow) {
|
|
41
|
+
if (!shadow) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
// @ts-expect-error
|
|
45
|
+
return vars.$shadow[shadow] ?? shadow;
|
|
46
|
+
}
|
|
47
|
+
export function handlePaddingWithSafeArea(padding, direction) {
|
|
48
|
+
if (padding === "safeArea") {
|
|
49
|
+
return `var(--seed-safe-area-${direction})`;
|
|
50
|
+
}
|
|
51
|
+
return handleDimension(padding);
|
|
52
|
+
}
|
|
53
|
+
export function handleRadius(radius) {
|
|
54
|
+
if (radius == null) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
// @ts-expect-error
|
|
58
|
+
return vars.$radius[radius] ?? radius;
|
|
59
|
+
}
|
|
60
|
+
function handleGradient(gradientToken, direction) {
|
|
61
|
+
if (!gradientToken || !direction) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
// @ts-expect-error
|
|
65
|
+
const colorStops = vars.$gradient[gradientToken];
|
|
66
|
+
if (!colorStops) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
return `linear-gradient(${direction}, ${colorStops})`;
|
|
70
|
+
}
|
|
71
|
+
export function useStyleProps(props) {
|
|
72
|
+
const { background, bg, bgGradient, backgroundGradient, bgGradientDirection, backgroundGradientDirection, color, borderColor, borderWidth, borderTopWidth, borderRightWidth, borderBottomWidth, borderLeftWidth, borderRadius, borderTopLeftRadius, borderTopRightRadius, borderBottomRightRadius, borderBottomLeftRadius, boxShadow, width, minWidth, maxWidth, height, minHeight, maxHeight, padding, paddingX, paddingY, paddingTop, paddingRight, paddingBottom, paddingLeft, p, px, py, pt, pr, pb, pl, bleedX, bleedY, bleedTop, bleedRight, bleedBottom, bleedLeft, bottom, left, right, top, display, position, overflowX, overflowY, zIndex, flexGrow, flexShrink, flexDirection, flexWrap, justifyContent, justifySelf, alignItems, alignContent, alignSelf, gap, style, ...restProps } = props;
|
|
73
|
+
const gradientValue = handleGradient(bgGradient ?? backgroundGradient, bgGradientDirection ?? backgroundGradientDirection);
|
|
74
|
+
const rawStyle = {
|
|
75
|
+
"--seed-box-background": handleColor(background ?? bg) ?? gradientValue,
|
|
76
|
+
"--seed-box-color": handleColor(color),
|
|
77
|
+
"--seed-box-border-color": handleColor(borderColor),
|
|
78
|
+
"--seed-box-border-width": borderWidth !== undefined ? `${borderWidth}px` : undefined,
|
|
79
|
+
"--seed-box-border-top-width": borderTopWidth !== undefined ? `${borderTopWidth}px` : undefined,
|
|
80
|
+
"--seed-box-border-right-width": borderRightWidth !== undefined ? `${borderRightWidth}px` : undefined,
|
|
81
|
+
"--seed-box-border-bottom-width": borderBottomWidth !== undefined ? `${borderBottomWidth}px` : undefined,
|
|
82
|
+
"--seed-box-border-left-width": borderLeftWidth !== undefined ? `${borderLeftWidth}px` : undefined,
|
|
83
|
+
"--seed-box-border-radius": handleRadius(borderRadius),
|
|
84
|
+
"--seed-box-border-top-left-radius": handleRadius(borderTopLeftRadius),
|
|
85
|
+
"--seed-box-border-top-right-radius": handleRadius(borderTopRightRadius),
|
|
86
|
+
"--seed-box-border-bottom-right-radius": handleRadius(borderBottomRightRadius),
|
|
87
|
+
"--seed-box-border-bottom-left-radius": handleRadius(borderBottomLeftRadius),
|
|
88
|
+
"--seed-box-box-shadow": handleShadow(boxShadow),
|
|
89
|
+
"--seed-box-width": handleDimension(width),
|
|
90
|
+
"--seed-box-min-width": handleDimension(minWidth),
|
|
91
|
+
"--seed-box-max-width": handleDimension(maxWidth),
|
|
92
|
+
"--seed-box-height": handleDimension(height),
|
|
93
|
+
"--seed-box-min-height": handleDimension(minHeight),
|
|
94
|
+
"--seed-box-max-height": handleDimension(maxHeight),
|
|
95
|
+
"--seed-box-padding": handleDimension(padding ?? p),
|
|
96
|
+
"--seed-box-padding-x": handleDimension(paddingX ?? px),
|
|
97
|
+
"--seed-box-padding-y": handleDimension(paddingY ?? py),
|
|
98
|
+
"--seed-box-padding-top": handlePaddingWithSafeArea(paddingTop ?? pt, "top"),
|
|
99
|
+
"--seed-box-padding-right": handleDimension(paddingRight ?? pr),
|
|
100
|
+
"--seed-box-padding-bottom": handlePaddingWithSafeArea(paddingBottom ?? pb, "bottom"),
|
|
101
|
+
"--seed-box-padding-left": handleDimension(paddingLeft ?? pl),
|
|
102
|
+
"--seed-box-bleed-top": handleBleed(bleedTop ?? bleedY, "top"),
|
|
103
|
+
"--seed-box-bleed-right": handleBleed(bleedRight ?? bleedX, "right"),
|
|
104
|
+
"--seed-box-bleed-bottom": handleBleed(bleedBottom ?? bleedY, "bottom"),
|
|
105
|
+
"--seed-box-bleed-left": handleBleed(bleedLeft ?? bleedX, "left"),
|
|
106
|
+
"--seed-box-top": top,
|
|
107
|
+
"--seed-box-left": left,
|
|
108
|
+
"--seed-box-right": right,
|
|
109
|
+
"--seed-box-bottom": bottom,
|
|
110
|
+
"--seed-box-gap": handleDimension(gap),
|
|
111
|
+
"--seed-box-display": display,
|
|
112
|
+
"--seed-box-position": position,
|
|
113
|
+
"--seed-box-overflow-x": overflowX,
|
|
114
|
+
"--seed-box-overflow-y": overflowY,
|
|
115
|
+
"--seed-box-z-index": zIndex,
|
|
116
|
+
"--seed-box-flex-grow": flexGrow === true ? 1 : flexGrow,
|
|
117
|
+
"--seed-box-flex-shrink": flexShrink === true ? 1 : flexShrink,
|
|
118
|
+
"--seed-box-flex-direction": flexDirection,
|
|
119
|
+
"--seed-box-flex-wrap": flexWrap === true ? "wrap" : flexWrap,
|
|
120
|
+
"--seed-box-justify-content": justifyContent,
|
|
121
|
+
"--seed-box-justify-self": justifySelf,
|
|
122
|
+
"--seed-box-align-items": alignItems,
|
|
123
|
+
"--seed-box-align-content": alignContent,
|
|
124
|
+
"--seed-box-align-self": alignSelf,
|
|
125
|
+
...style,
|
|
126
|
+
};
|
|
127
|
+
return {
|
|
128
|
+
style: dynamicStyle(rawStyle),
|
|
129
|
+
restProps: restProps,
|
|
130
|
+
};
|
|
131
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@seed-design/lynx-react",
|
|
3
|
+
"version": "0.1.1-alpha.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/daangn/seed-design.git",
|
|
7
|
+
"directory": "packages/lynx-react"
|
|
8
|
+
},
|
|
9
|
+
"sideEffects": [
|
|
10
|
+
"*.css"
|
|
11
|
+
],
|
|
12
|
+
"type": "module",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./lib/index.d.ts",
|
|
16
|
+
"import": "./lib/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./dynamic-style": {
|
|
19
|
+
"types": "./lib/utils/dynamic-style.d.ts",
|
|
20
|
+
"import": "./lib/utils/dynamic-style.js"
|
|
21
|
+
},
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"lib",
|
|
26
|
+
"src"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"clean": "rm -rf lib",
|
|
30
|
+
"build": "tsc",
|
|
31
|
+
"lint:publish": "bun publint"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@seed-design/css": ">=1.1.17",
|
|
35
|
+
"@seed-design/lynx-css": ">=0.1.1-alpha.0",
|
|
36
|
+
"@lynx-js/react": ">=0.100.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@lynx-js/react": "^0.116.3",
|
|
40
|
+
"@lynx-js/types": "^3.7.0",
|
|
41
|
+
"@types/react": "^19.2.2",
|
|
42
|
+
"react": "^19.1.0"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@seed-design/lynx-primitive": "0.1.1-alpha.0",
|
|
49
|
+
"clsx": "^2.1.1"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { actionButton } from "@seed-design/lynx-css/recipes/action-button";
|
|
2
|
+
import type { ActionButtonVariantProps } from "@seed-design/lynx-css/recipes/action-button";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @platform Lynx
|
|
8
|
+
*
|
|
9
|
+
* 미지원 기능 (Lynx 3.7 SVG 지원 후 추가 예정):
|
|
10
|
+
* - loading: SVG 기반 spinner 필요
|
|
11
|
+
* - layout: "iconOnly": SVG 아이콘 렌더링 필요
|
|
12
|
+
* - PrefixIcon / SuffixIcon: SVG 아이콘 렌더링 필요
|
|
13
|
+
*
|
|
14
|
+
* 웹 대비 미지원 기능:
|
|
15
|
+
* - color / fontWeight props: CSS variable 동적 주입 제한
|
|
16
|
+
* - bleedX / bleedY props: CSS variable 동적 주입 제한
|
|
17
|
+
*/
|
|
18
|
+
export interface ActionButtonProps extends Omit<ActionButtonVariantProps, "loading" | "layout"> {
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
className?: string;
|
|
22
|
+
flexGrow?: number;
|
|
23
|
+
bindtap?: () => void;
|
|
24
|
+
"main-thread:bindtap"?: () => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const ActionButton = React.forwardRef<unknown, ActionButtonProps>((props, ref) => {
|
|
28
|
+
const [variantProps, restProps] = actionButton.splitVariantProps(props);
|
|
29
|
+
const {
|
|
30
|
+
children,
|
|
31
|
+
className,
|
|
32
|
+
flexGrow,
|
|
33
|
+
bindtap,
|
|
34
|
+
"main-thread:bindtap": mainThreadBindtap,
|
|
35
|
+
...nativeProps
|
|
36
|
+
} = restProps;
|
|
37
|
+
|
|
38
|
+
const { disabled = false } = variantProps;
|
|
39
|
+
const classes = actionButton({
|
|
40
|
+
...variantProps,
|
|
41
|
+
layout: "withText",
|
|
42
|
+
disabled: disabled ? true : undefined,
|
|
43
|
+
});
|
|
44
|
+
const isInteractive = !disabled;
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<view
|
|
48
|
+
{...(ref ? { ref: ref as React.Ref<SVGViewElement> } : {})}
|
|
49
|
+
className={clsx(classes.root, className)}
|
|
50
|
+
style={flexGrow != null ? { flexGrow } : undefined}
|
|
51
|
+
{...(isInteractive && bindtap && { bindtap })}
|
|
52
|
+
{...(isInteractive &&
|
|
53
|
+
mainThreadBindtap && {
|
|
54
|
+
"main-thread:bindtap": mainThreadBindtap,
|
|
55
|
+
})}
|
|
56
|
+
{...nativeProps}
|
|
57
|
+
>
|
|
58
|
+
<text className={classes.text}>{children}</text>
|
|
59
|
+
</view>
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
ActionButton.displayName = "ActionButton";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ActionButton, type ActionButtonProps } from "./ActionButton";
|