@seed-design/figma 0.1.13 → 0.1.14
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/codegen/index.cjs +81 -58
- package/lib/codegen/index.d.ts +84 -55
- package/lib/codegen/index.d.ts.map +1 -1
- package/lib/codegen/index.js +81 -58
- package/lib/codegen/targets/react/index.cjs +127 -76
- package/lib/codegen/targets/react/index.d.ts.map +1 -1
- package/lib/codegen/targets/react/index.js +127 -76
- package/lib/index.cjs +81 -58
- package/lib/index.js +81 -58
- package/package.json +2 -2
- package/src/codegen/component-properties.ts +9 -2
- package/src/codegen/targets/react/component/handlers/page-banner.ts +101 -0
- package/src/codegen/targets/react/component/index.ts +2 -2
- package/src/entities/data/__generated__/component-sets/avatar-stack.d.ts +2 -1
- package/src/entities/data/__generated__/component-sets/avatar-stack.mjs +2 -1
- package/src/entities/data/__generated__/component-sets/avatar.d.ts +2 -1
- package/src/entities/data/__generated__/component-sets/avatar.mjs +2 -1
- package/src/entities/data/__generated__/component-sets/badge.d.ts +4 -3
- package/src/entities/data/__generated__/component-sets/badge.mjs +4 -3
- package/src/entities/data/__generated__/component-sets/divider.d.ts +10 -0
- package/src/entities/data/__generated__/component-sets/divider.mjs +10 -0
- package/src/entities/data/__generated__/component-sets/index.d.ts +1 -1
- package/src/entities/data/__generated__/component-sets/index.mjs +1 -1
- package/src/entities/data/__generated__/component-sets/page-banner.d.ts +50 -0
- package/src/entities/data/__generated__/component-sets/page-banner.mjs +50 -0
- package/src/codegen/targets/react/component/handlers/inline-banner.ts +0 -75
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type { InlineBannerProperties } from "@/codegen/component-properties";
|
|
2
|
-
import { defineComponentHandler } from "@/codegen/core";
|
|
3
|
-
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
4
|
-
import type { NormalizedInstanceNode, NormalizedTextNode } from "@/normalizer";
|
|
5
|
-
import { findOne } from "@/utils/figma-node";
|
|
6
|
-
import { camelCase } from "change-case";
|
|
7
|
-
import { createLocalSnippetHelper } from "../../element-factories";
|
|
8
|
-
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
9
|
-
import { match } from "ts-pattern";
|
|
10
|
-
|
|
11
|
-
const { createLocalSnippetElement } = createLocalSnippetHelper("inline-banner");
|
|
12
|
-
|
|
13
|
-
export const createInlineBannerHandler = (ctx: ComponentHandlerDeps) =>
|
|
14
|
-
defineComponentHandler<InlineBannerProperties>(metadata.inlineBanner.key, (node) => {
|
|
15
|
-
const { componentProperties: props } = node;
|
|
16
|
-
|
|
17
|
-
const tag = match(props.Interaction.value)
|
|
18
|
-
.with("Default", () => "InlineBanner")
|
|
19
|
-
.with("Actionable", () => "ActionableInlineBanner")
|
|
20
|
-
.with("Dismissible", () => "DismissibleInlineBanner")
|
|
21
|
-
.with("Link", () => "InlineBanner")
|
|
22
|
-
.exhaustive();
|
|
23
|
-
|
|
24
|
-
const textNode = findOne(
|
|
25
|
-
node,
|
|
26
|
-
(child) => child.type === "TEXT" && child.name === "Label",
|
|
27
|
-
) as NormalizedTextNode | null;
|
|
28
|
-
|
|
29
|
-
if (!textNode) {
|
|
30
|
-
return createLocalSnippetElement(tag, undefined, undefined, {
|
|
31
|
-
comment: "내용을 제공해주세요.",
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const slices = textNode.segments;
|
|
36
|
-
|
|
37
|
-
let title: string | undefined;
|
|
38
|
-
let description: string | undefined;
|
|
39
|
-
|
|
40
|
-
switch (slices.length) {
|
|
41
|
-
case 1: {
|
|
42
|
-
description = slices[0]?.characters.trim();
|
|
43
|
-
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
case 2: {
|
|
47
|
-
title = slices[0]?.characters.trim();
|
|
48
|
-
description = slices[1]?.characters.trim();
|
|
49
|
-
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const iconNode = findOne(
|
|
55
|
-
node,
|
|
56
|
-
(child) => child.type === "INSTANCE" && child.name === "icon",
|
|
57
|
-
) as NormalizedInstanceNode | null;
|
|
58
|
-
|
|
59
|
-
const showIcon = props["Show Icon#11840:27"] && iconNode;
|
|
60
|
-
const prefixIcon = showIcon ? ctx.iconHandler.transform(iconNode) : undefined;
|
|
61
|
-
|
|
62
|
-
const commonProps = {
|
|
63
|
-
variant: camelCase(props.Variant.value),
|
|
64
|
-
title,
|
|
65
|
-
description,
|
|
66
|
-
...(props.Interaction.value === "Link" && {
|
|
67
|
-
linkProps: {
|
|
68
|
-
children: props["Link Label#1547:81"].value,
|
|
69
|
-
},
|
|
70
|
-
}),
|
|
71
|
-
prefixIcon,
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
return createLocalSnippetElement(tag, commonProps);
|
|
75
|
-
});
|