@figma/code-connect 1.0.5 → 1.1.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/README.md +2 -595
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/client/figma_client.d.ts +1 -1
- package/dist/client/figma_client.js +9 -7
- package/dist/client/figma_client.js.map +1 -1
- package/dist/commands/connect.d.ts +4 -2
- package/dist/commands/connect.d.ts.map +1 -1
- package/dist/commands/connect.js +97 -49
- package/dist/commands/connect.js.map +1 -1
- package/dist/connect/api.d.ts +143 -0
- package/dist/connect/api.d.ts.map +1 -0
- package/dist/connect/api.js +3 -0
- package/dist/connect/api.js.map +1 -0
- package/dist/connect/create.d.ts.map +1 -1
- package/dist/connect/create.js +4 -0
- package/dist/connect/create.js.map +1 -1
- package/dist/connect/create_common.d.ts +7 -0
- package/dist/connect/create_common.d.ts.map +1 -0
- package/dist/connect/create_common.js +19 -0
- package/dist/connect/create_common.js.map +1 -0
- package/dist/connect/external_types.d.ts +8 -0
- package/dist/connect/external_types.d.ts.map +1 -0
- package/dist/connect/external_types.js +31 -0
- package/dist/connect/external_types.js.map +1 -0
- package/dist/connect/figma_connect.d.ts +26 -0
- package/dist/connect/figma_connect.d.ts.map +1 -0
- package/dist/connect/figma_connect.js +3 -0
- package/dist/connect/figma_connect.js.map +1 -0
- package/dist/connect/figma_rest_api.d.ts +7 -0
- package/dist/connect/figma_rest_api.d.ts.map +1 -1
- package/dist/connect/figma_rest_api.js.map +1 -1
- package/dist/connect/index_common.d.ts +3 -0
- package/dist/connect/index_common.d.ts.map +1 -0
- package/dist/connect/index_common.js +23 -0
- package/dist/connect/index_common.js.map +1 -0
- package/dist/connect/intrinsics.d.ts +94 -0
- package/dist/connect/intrinsics.d.ts.map +1 -0
- package/dist/connect/intrinsics.js +401 -0
- package/dist/connect/intrinsics.js.map +1 -0
- package/dist/connect/parser_common.d.ts +144 -0
- package/dist/connect/parser_common.d.ts.map +1 -0
- package/dist/connect/parser_common.js +297 -0
- package/dist/connect/parser_common.js.map +1 -0
- package/dist/connect/parser_executable_types.d.ts +20 -23
- package/dist/connect/parser_executable_types.d.ts.map +1 -1
- package/dist/connect/parser_executable_types.js.map +1 -1
- package/dist/connect/parser_executables.js +1 -1
- package/dist/connect/parser_executables.js.map +1 -1
- package/dist/connect/project.d.ts +20 -5
- package/dist/connect/project.d.ts.map +1 -1
- package/dist/connect/project.js +79 -16
- package/dist/connect/project.js.map +1 -1
- package/dist/connect/upload.d.ts +1 -1
- package/dist/connect/upload.d.ts.map +1 -1
- package/dist/connect/validation.d.ts +1 -1
- package/dist/connect/validation.d.ts.map +1 -1
- package/dist/connect/wizard/helpers.d.ts +1 -0
- package/dist/connect/wizard/helpers.d.ts.map +1 -1
- package/dist/connect/wizard/helpers.js +27 -15
- package/dist/connect/wizard/helpers.js.map +1 -1
- package/dist/connect/wizard/prop_mapping.d.ts +12 -7
- package/dist/connect/wizard/prop_mapping.d.ts.map +1 -1
- package/dist/connect/wizard/prop_mapping.js +88 -89
- package/dist/connect/wizard/prop_mapping.js.map +1 -1
- package/dist/connect/wizard/run_wizard.d.ts.map +1 -1
- package/dist/connect/wizard/run_wizard.js +8 -3
- package/dist/connect/wizard/run_wizard.js.map +1 -1
- package/dist/connect/wizard/signature_extraction.d.ts +7 -0
- package/dist/connect/wizard/signature_extraction.d.ts.map +1 -0
- package/dist/connect/wizard/signature_extraction.js +46 -0
- package/dist/connect/wizard/signature_extraction.js.map +1 -0
- package/dist/html/__test__/parser/examples/NoConfigObject.figma.d.ts +2 -0
- package/dist/html/__test__/parser/examples/NoConfigObject.figma.d.ts.map +1 -0
- package/dist/html/__test__/parser/examples/NoConfigObject.figma.js +9 -0
- package/dist/html/__test__/parser/examples/NoConfigObject.figma.js.map +1 -0
- package/dist/html/__test__/parser/examples/NoExample.figma.d.ts +2 -0
- package/dist/html/__test__/parser/examples/NoExample.figma.d.ts.map +1 -0
- package/dist/html/__test__/parser/examples/NoExample.figma.js +9 -0
- package/dist/html/__test__/parser/examples/NoExample.figma.js.map +1 -0
- package/dist/html/__test__/parser/examples/RegularFunctionExampleWithExtraCode.figma.d.ts +2 -0
- package/dist/html/__test__/parser/examples/RegularFunctionExampleWithExtraCode.figma.d.ts.map +1 -0
- package/dist/html/__test__/parser/examples/RegularFunctionExampleWithExtraCode.figma.js +33 -0
- package/dist/html/__test__/parser/examples/RegularFunctionExampleWithExtraCode.figma.js.map +1 -0
- package/dist/html/__test__/parser/examples/WrongSignatureJsx.figma.d.ts +2 -0
- package/dist/html/__test__/parser/examples/WrongSignatureJsx.figma.d.ts.map +1 -0
- package/dist/html/__test__/parser/examples/WrongSignatureJsx.figma.js +15 -0
- package/dist/html/__test__/parser/examples/WrongSignatureJsx.figma.js.map +1 -0
- package/dist/html/__test__/parser/examples/WrongSignatureNoHtmlTag.figma.d.ts +2 -0
- package/dist/html/__test__/parser/examples/WrongSignatureNoHtmlTag.figma.d.ts.map +1 -0
- package/dist/html/__test__/parser/examples/WrongSignatureNoHtmlTag.figma.js +15 -0
- package/dist/html/__test__/parser/examples/WrongSignatureNoHtmlTag.figma.js.map +1 -0
- package/dist/html/__test__/parser/parser.test.d.ts +2 -0
- package/dist/html/__test__/parser/parser.test.d.ts.map +1 -0
- package/dist/html/__test__/parser/parser.test.js +50 -0
- package/dist/html/__test__/parser/parser.test.js.map +1 -0
- package/dist/html/create.d.ts +4 -0
- package/dist/html/create.d.ts.map +1 -0
- package/dist/html/create.js +81 -0
- package/dist/html/create.js.map +1 -0
- package/dist/html/external.d.ts +8 -0
- package/dist/html/external.d.ts.map +1 -0
- package/dist/html/external.js +25 -0
- package/dist/html/external.js.map +1 -0
- package/dist/html/index_html.d.ts +77 -0
- package/dist/html/index_html.d.ts.map +1 -0
- package/dist/html/index_html.js +42 -0
- package/dist/html/index_html.js.map +1 -0
- package/dist/html/parser.d.ts +19 -0
- package/dist/html/parser.d.ts.map +1 -0
- package/dist/html/parser.js +487 -0
- package/dist/html/parser.js.map +1 -0
- package/dist/html/parser_template_helpers.d.ts +2 -0
- package/dist/html/parser_template_helpers.d.ts.map +1 -0
- package/dist/html/parser_template_helpers.js +68 -0
- package/dist/html/parser_template_helpers.js.map +1 -0
- package/dist/html/template_literal.d.ts +5 -0
- package/dist/html/template_literal.d.ts.map +1 -0
- package/dist/html/template_literal.js +8 -0
- package/dist/html/template_literal.js.map +1 -0
- package/dist/parser_scripts/get_swift_parser_dir.d.ts +1 -1
- package/dist/parser_scripts/get_swift_parser_dir.d.ts.map +1 -1
- package/dist/parser_scripts/get_swift_parser_dir.js +38 -10
- package/dist/parser_scripts/get_swift_parser_dir.js.map +1 -1
- package/dist/react/create.d.ts +5 -0
- package/dist/react/create.d.ts.map +1 -1
- package/dist/react/create.js +144 -42
- package/dist/react/create.js.map +1 -1
- package/dist/react/external.d.ts +9 -0
- package/dist/react/external.d.ts.map +1 -0
- package/dist/react/external.js +45 -0
- package/dist/react/external.js.map +1 -0
- package/dist/react/index_react.d.ts +94 -0
- package/dist/react/index_react.d.ts.map +1 -0
- package/dist/react/index_react.js +39 -0
- package/dist/react/index_react.js.map +1 -0
- package/dist/react/parser.d.ts +6 -38
- package/dist/react/parser.d.ts.map +1 -1
- package/dist/react/parser.js +141 -298
- package/dist/react/parser.js.map +1 -1
- package/dist/react/parser_template_helpers.d.ts +15 -15
- package/dist/react/parser_template_helpers.d.ts.map +1 -1
- package/dist/react/parser_template_helpers.js +51 -35
- package/dist/react/parser_template_helpers.js.map +1 -1
- package/dist/storybook/convert.d.ts +1 -1
- package/dist/storybook/convert.d.ts.map +1 -1
- package/dist/storybook/convert.js +6 -4
- package/dist/storybook/convert.js.map +1 -1
- package/dist/storybook/external.d.ts +1 -1
- package/dist/storybook/external.d.ts.map +1 -1
- package/dist/typescript/compiler.d.ts +2 -2
- package/dist/typescript/compiler.d.ts.map +1 -1
- package/dist/typescript/compiler.js +51 -24
- package/dist/typescript/compiler.js.map +1 -1
- package/package.json +28 -8
package/README.md
CHANGED
|
@@ -1,596 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
See the [main README](../README.md) for Code Connect documentation.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
This documentation will help you connect your React (or React Native) components with Figma components using Code Connect. We'll cover basic setup to display your first connected code snippet, followed by making snippets dynamic by using property mappings. Code Connect for React works as both a standalone implementation and as an integration with existing Storybook files to enable easily maintaining both systems in parallel.
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
Code Connect is used through a command line interface (CLI). The CLI comes bundled with the `@figma/code-connect` package, which you'll need to install through `npm`. This package also includes helper functions and types associated with Code Connect.
|
|
10
|
-
|
|
11
|
-
```sh
|
|
12
|
-
npm install @figma/code-connect
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Basic setup
|
|
16
|
-
|
|
17
|
-
To connect your first component go to Dev Mode in Figma and right-click on the component you want to connect, then choose `Copy link to selection` from the menu. Make sure you are copying the link to a main component and not an instance of the component. The main component will typically be located in a centralized design system library file. Using this link, run `figma connect create` from inside your React project. Note that depending on what terminal software you're using, you might need to wrap the URL in quotes.
|
|
18
|
-
|
|
19
|
-
```sh
|
|
20
|
-
npx figma connect create "https://..." --token <auth token>
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
This will create a Code Connect file with some basic scaffolding for the component you want to connect. By default this file will be called `<component-name>.figma.tsx` based on the name of the component in Figma. However, you may rename this file as you see fit. The scaffolding that is generated is based on the interface of the component in Figma. Depending on how closely this matches your code component you'll need to make some edits to this file before you publish it.
|
|
24
|
-
|
|
25
|
-
Some CLI commands, like `create`, require a valid [authentication token](https://help.figma.com/hc/en-us/articles/8085703771159-Manage-personal-access-tokens) with write permission for the Code Connect scope as well as the read permission for the File content scope. You can either pass this via the `--token` flag, or set the `FIGMA_ACCESS_TOKEN` environment variable. The Figma CLI reads this from a `.env` file in the same folder, if it exists.
|
|
26
|
-
|
|
27
|
-
To keep things simple, we're going to start by replacing the contents of the generated file with the most basic Code Connect configuration possible to make sure everything is set up and working as expected. Replace the contents of the file with the following, replacing the `Button` reference with a reference to whatever component you are trying to connect. The object called by `figma.connect` is your Code Connect doc.
|
|
28
|
-
|
|
29
|
-
```tsx
|
|
30
|
-
import figma from '@figma/code-connect'
|
|
31
|
-
import { Button } from 'src/components'
|
|
32
|
-
|
|
33
|
-
figma.connect(Button, 'https://...', {
|
|
34
|
-
example: () => {
|
|
35
|
-
return <Button />
|
|
36
|
-
},
|
|
37
|
-
})
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Once you've made the edits you want to the Code Connect file you can simply publish it to Figma to have it show up when the corresponding component or instance is selected in Dev Mode.
|
|
41
|
-
|
|
42
|
-
```sh
|
|
43
|
-
npx figma connect publish --token <auth token>
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Now go back to Dev Mode in Figma and select the component that you just connected. You should see a connected code snippet show up with a simple reference to your component.
|
|
47
|
-
|
|
48
|
-
> [!NOTE]
|
|
49
|
-
> Code Connect files are not executed. While they're written using real components from your codebase, the Figma CLI essentially treats code snippets as strings. This means you can use, for example, hooks without needing to mock data. However, this also means that logical operators such as ternaries or conditionals will be output verbatim in your example code rather than executed to show the result. You also won't be able to dynamically construct `figma.connect` calls in a for-loop, as an example. If something you're trying to do is not possible because of this restriction in the API, we'd love to hear your feedback.
|
|
50
|
-
|
|
51
|
-
## Interactive setup
|
|
52
|
-
|
|
53
|
-
A step-by-step interactive flow is provided which makes it easier to connect a large codebase. Code Connect will attempt to automatically connect your codebase to your Figma design system components based on name, which you can then make any edits to before batch-creating Code Connect files.
|
|
54
|
-
|
|
55
|
-
To start the interactive setup, enter `figma connect` without any subcommands:
|
|
56
|
-
|
|
57
|
-
```sh
|
|
58
|
-
npx figma connect
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Integrating with Storybook
|
|
62
|
-
|
|
63
|
-
If you already have Storybook set up for your design system then we recommend using the Storybook integration that comes with Code Connect. Storybook and Code Connect complement each other nicely and with this integration they are easy to maintain in parallel. The syntax for integrating with Storybook is slightly different to ensure alignment with the Storybook API.
|
|
64
|
-
|
|
65
|
-
To define a Code Connect doc using Storybook simply add a `parameters` block to your story configuration object that references the Figma component you want to pull into Code Connect. This syntax is an extension of the [existing Storybook integration](https://help.figma.com/hc/en-us/articles/360045003494-Storybook-and-Figma) offered by Figma, so you'll automatically get all the benefits that come with that such as a Figma preview of the component embedded in your Storybook documentation.
|
|
66
|
-
|
|
67
|
-
```tsx
|
|
68
|
-
export default {
|
|
69
|
-
component: Button,
|
|
70
|
-
parameters: {
|
|
71
|
-
design: {
|
|
72
|
-
type: 'figma',
|
|
73
|
-
url: 'https://...',
|
|
74
|
-
examples: [ButtonExample],
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Existing story
|
|
80
|
-
export function ButtonExample() {
|
|
81
|
-
return <Button disabled />
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
## Publishing
|
|
86
|
-
|
|
87
|
-
To publish your connected components to Figma simply run `figma connect publish`. This will find all Code Connect files in your repository, parse them, and upload the necessary metadata to Figma for display in Dev Mode. Code Connect only uploads the explicit code snippets and metadata related to Code Connect. It does not upload any other parts of your source code.
|
|
88
|
-
|
|
89
|
-
```sh
|
|
90
|
-
npx figma connect publish --token <token>
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
To unpublish your connected components from Figma, you can run the `unpublish` command. This will find all the Code Connect files in your repository and remove the metadata from Figma.
|
|
94
|
-
|
|
95
|
-
```sh
|
|
96
|
-
npx figma connect unpublish --token <token>
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
`figma connect` as well as `figma connect publish` can accept a variety of flags to customize the behavior of these commands.
|
|
100
|
-
|
|
101
|
-
- `-t --token <access_token>` Specify the Figma auth token to use. Can also be specified using the `FIGMA_ACCESS_TOKEN` environment variable.
|
|
102
|
-
- `-c --config <path>` Path to config file (by default looks for "figma.config.json" in the current directory).
|
|
103
|
-
- `-r --dir <folder>` Directory to parse (uses current directory by default)
|
|
104
|
-
- `--dry-run` Perform a dry run of publishing, returning errors if any exist but does not publish your connected components.
|
|
105
|
-
- `--skip-validation` By default, `publish` will validate your Code Connect file with the Figma component to ensure that their properties match. This flag can be used to skip this validation.
|
|
106
|
-
- `--verbose` Enable verbose logging for debugging
|
|
107
|
-
- `--node <node-url>` For unpublishing only a single specific component with `unpublish`
|
|
108
|
-
- `--label <label>` For publishing or unpublishing under a custom label
|
|
109
|
-
|
|
110
|
-
## Configuration
|
|
111
|
-
|
|
112
|
-
To configure the behaviour of the CLI and Code Connect you can create a `figma.config.json` file. This file must be located in the project root, i.e. alongside your `package.json` file. This config file will automatically be picked up by the CLI if it's in the same folder where you run the commands, but you can also specify a path to the config file via the `--config` flag.
|
|
113
|
-
|
|
114
|
-
In addition to the [general configuration](../README.md#general-configuration) for the CLI, there is React-specific project configuration that can be specified in the configuration file. This configuration is mainly used to ensure Code Connect can correctly locate your imports as well as display the correct imports within Dev Mode.
|
|
115
|
-
|
|
116
|
-
```jsonp
|
|
117
|
-
{
|
|
118
|
-
"codeConnect": {
|
|
119
|
-
"include": [],
|
|
120
|
-
"exclude": ["test/**", "docs/**", "build/**"],
|
|
121
|
-
"importPaths": {
|
|
122
|
-
"src/components/*": "@ui/components"
|
|
123
|
-
},
|
|
124
|
-
"paths": {
|
|
125
|
-
"@ui/components/*": ["src/components/*"]
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### `importPaths`
|
|
132
|
-
|
|
133
|
-
`importPaths` maps relative imports to non-relative imports. This is useful for when you want users of your design system to import components from a specific package as opposed to using relative imports. The mapping uses the file location on disk. For example, if your Code Connect file looks like this:
|
|
134
|
-
|
|
135
|
-
```
|
|
136
|
-
import { Button } from './'
|
|
137
|
-
figma.connect(Button, 'https://...')
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
You can use `importPaths` by specifying where `Button` lives in your repo and map it to something else. You can use partial paths here, as it will
|
|
141
|
-
consider the full absolute path of the source file `Button.tsx`.
|
|
142
|
-
|
|
143
|
-
```
|
|
144
|
-
{
|
|
145
|
-
"codeConnect": {
|
|
146
|
-
"importPaths": {
|
|
147
|
-
"src/components/*": "@ui/components"
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
Which will end up changing your connected code snippet in Figma to
|
|
154
|
-
|
|
155
|
-
```
|
|
156
|
-
import { Button } from '@ui/components'
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
### `paths`
|
|
160
|
-
|
|
161
|
-
This is needed if you're using path aliases in your TypeScript project configuration, so Code Connect can know how to resolve your imports. It should match the `paths` object used in your tsconfig.json.
|
|
162
|
-
|
|
163
|
-
## Custom imports
|
|
164
|
-
|
|
165
|
-
You can override the generated import statements for a connected component by passing an array of `imports`. This might be useful if the automatic resolution does not work well for your use case.
|
|
166
|
-
|
|
167
|
-
```
|
|
168
|
-
figma.connect(Button, "https://...", {
|
|
169
|
-
imports: ["import { Button } from '@lib'"]
|
|
170
|
-
})
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
## Dynamic code snippets
|
|
174
|
-
|
|
175
|
-
With the basic setup as described above, you should have a connected code snippet visible in Dev Mode when inspecting instances of that component. However, the code snippet doesn't yet reflect the entirety of the design. For example, we see the same code snippet for a button whether it has the `type` variant set to `primary` or `secondary`.
|
|
176
|
-
|
|
177
|
-
To ensure the connected code snippet accurately reflects the design, we need to make use of property mappings. This enables you to link specific props in the design to props in code. In most cases, design and code props don't match 1:1, so it's necessary for us to configure this to ensure the correct code is shown in Dev Mode.
|
|
178
|
-
|
|
179
|
-
Here is a simple example for a button with a `label`, `disabled`, and `type` property.
|
|
180
|
-
|
|
181
|
-
```tsx
|
|
182
|
-
import figma from '@figma/code-connect'
|
|
183
|
-
|
|
184
|
-
figma.connect(Button, 'https://...', {
|
|
185
|
-
props: {
|
|
186
|
-
label: figma.string('Text Content'),
|
|
187
|
-
disabled: figma.boolean('Disabled'),
|
|
188
|
-
type: figma.enum('Type', {
|
|
189
|
-
Primary: 'primary',
|
|
190
|
-
Secondary: 'secondary',
|
|
191
|
-
}),
|
|
192
|
-
},
|
|
193
|
-
example: ({ disabled, label, type }) => {
|
|
194
|
-
return (
|
|
195
|
-
<Button disabled={disabled} type={type}>
|
|
196
|
-
{label}
|
|
197
|
-
</Button>
|
|
198
|
-
)
|
|
199
|
-
},
|
|
200
|
-
})
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
And this is how we would achieve the same thing using the Storybook integration. Notice how this works well with existing `args` configuration you may already be using in Storybook.
|
|
204
|
-
|
|
205
|
-
```tsx
|
|
206
|
-
import figma from "@figma/code-connect"
|
|
207
|
-
|
|
208
|
-
export default {
|
|
209
|
-
component: Button,
|
|
210
|
-
parameters: {
|
|
211
|
-
design: {
|
|
212
|
-
type: 'figma',
|
|
213
|
-
url: 'https://...',
|
|
214
|
-
examples: [ButtonExample],
|
|
215
|
-
props: {
|
|
216
|
-
label: figma.string('Text Content'),
|
|
217
|
-
disabled: figma.boolean('Disabled'),
|
|
218
|
-
type: figma.enum('Type', {
|
|
219
|
-
Primary: ButtonType.Primary,
|
|
220
|
-
Secondary: ButtonType.Secondary
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
},
|
|
224
|
-
argTypes: {
|
|
225
|
-
label: { control: 'string' },
|
|
226
|
-
disabled: { control: 'boolean' },
|
|
227
|
-
type: {
|
|
228
|
-
control: {
|
|
229
|
-
type: 'select',
|
|
230
|
-
options: [ButtonType.Primary, ButtonType.Secondary]
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
},
|
|
234
|
-
args: {
|
|
235
|
-
label: 'Hello world',
|
|
236
|
-
disabled: false,
|
|
237
|
-
type: ButtonType.Primary
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
export function ButtonExample({ label, disabled, type }) {
|
|
243
|
-
return <Button disabled={disabled} type={type}>{ label }</Button>
|
|
244
|
-
}
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
The `figma` import contains helpers for mapping all sorts of properties from design to code. They work for simple mappings where only the naming differs between Figma and code, as well as more complex mappings where the type differs. See the below reference for all the helpers that exist and the ways you can use them to connect Figma and code components using Code Connect.
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
### figma.connect
|
|
251
|
-
|
|
252
|
-
`figma.connect()` has two signatures for connecting components.
|
|
253
|
-
|
|
254
|
-
```
|
|
255
|
-
// connect a component in code to a Figma component
|
|
256
|
-
figma.connect(Button, "https://...")
|
|
257
|
-
|
|
258
|
-
// connect a Figma component to e.g a native element
|
|
259
|
-
figma.connect("https://...")
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
The second option is useful if you want to just render a HTML tag instead of a React component. The first argument is used to determine where your component lives in code, in order to generate an import statement for the component. This isn't needed if you just want to render e.g a `button` tag.
|
|
263
|
-
|
|
264
|
-
```
|
|
265
|
-
figma.connect("https://...", {
|
|
266
|
-
example: () => <button>click me</button>
|
|
267
|
-
})
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
### Strings
|
|
271
|
-
|
|
272
|
-
Strings are the simplest value to map from Figma to code. Simply call `figma.string` with the Figma prop name you want to reference as a parameter. This is useful for things like button labels, header titles, tooltips, etc.
|
|
273
|
-
|
|
274
|
-
```tsx
|
|
275
|
-
figma.string('Title')
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
### Booleans
|
|
279
|
-
|
|
280
|
-
Booleans work similar to strings. However Code Connect also provides helpers for mapping booleans in Figma to more complex types in code. For example you may want to map a Figma boolean to the existence of a specific sublayer in code. In addition to mapping boolean props, `figma.boolean` can be used to map boolean Variants in Figma. A boolean Variant is a Variant with only two options that are either "Yes"/"No", "True"/"False" or "On"/Off". For `figma.boolean` these values are normalized to `true` and `false`.
|
|
281
|
-
|
|
282
|
-
```tsx
|
|
283
|
-
// simple mapping of boolean from figma to code
|
|
284
|
-
figma.boolean('Has Icon')
|
|
285
|
-
|
|
286
|
-
// map a boolean value to one of two options of any type
|
|
287
|
-
figma.boolean('Has Icon', {
|
|
288
|
-
true: <Icon />,
|
|
289
|
-
false: <Spacer />,
|
|
290
|
-
})
|
|
291
|
-
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
In some cases, you only want to render a certain prop if it matches some value in Figma. You can do this either by passing a partial mapping object, or setting the value to `undefined`.
|
|
295
|
-
|
|
296
|
-
```tsx
|
|
297
|
-
// Don't render the prop if 'Has label' in figma is `false`
|
|
298
|
-
figma.boolean("Has label", {
|
|
299
|
-
true: figma.string("Label"),
|
|
300
|
-
false: undefined
|
|
301
|
-
})
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
### Enums
|
|
305
|
-
|
|
306
|
-
Variants (or enums) in Figma are commonly used to control the look and feel of components that require more complex options than a simple boolean toggle. Variant properties are always strings in Figma but they can be mapped to any type in code. The first parameter is the name of the Variant in Figma, and the second parameter is a value mapping. The _keys_ in this object should match the different options of that Variant in Figma, and the _value_ is whatever you want to output instead.
|
|
307
|
-
|
|
308
|
-
```tsx
|
|
309
|
-
// maps the 'Options' variant in Figma to enum values in code
|
|
310
|
-
figma.enum('Options', {
|
|
311
|
-
'Option 1': Option.first,
|
|
312
|
-
'Option 2': Option.second,
|
|
313
|
-
})
|
|
314
|
-
|
|
315
|
-
// maps the 'Options' variant in Figma to sub-component values in code
|
|
316
|
-
figma.enum('Options', {
|
|
317
|
-
'Option 1': <Icon />,
|
|
318
|
-
'Option 2': <IconButton />,
|
|
319
|
-
})
|
|
320
|
-
|
|
321
|
-
// result is true for disabled variants otherwise undefined
|
|
322
|
-
figma.enum('Variant', { Disabled: true })
|
|
323
|
-
|
|
324
|
-
// enums mappings can be used to show a component based on a Figma variant
|
|
325
|
-
figma.connect(Modal, 'https://...', {
|
|
326
|
-
props: {
|
|
327
|
-
cancelButton: figma.enum('Type', {
|
|
328
|
-
'Cancellable': <CancelButton />
|
|
329
|
-
}),
|
|
330
|
-
// ...
|
|
331
|
-
},
|
|
332
|
-
example: ({ cancelButton }) => {
|
|
333
|
-
return (
|
|
334
|
-
<Modal>
|
|
335
|
-
<Title>Title</Title>
|
|
336
|
-
<Content>Some content</Content>
|
|
337
|
-
{cancelButton}
|
|
338
|
-
</Modal>
|
|
339
|
-
)
|
|
340
|
-
},
|
|
341
|
-
})
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
Mapping objects for `figma.enum` as well as `figma.boolean` allows nested references, which is useful if you want to conditionally render a nested instance for example. (see the next section for how to use `figma.instance`)
|
|
345
|
-
|
|
346
|
-
```tsx
|
|
347
|
-
// maps the 'Options' variant in Figma to enum values in code
|
|
348
|
-
figma.enum('Type', {
|
|
349
|
-
WithIcon: figma.instance('Icon'),
|
|
350
|
-
WithoutIcon: undefined,
|
|
351
|
-
})
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
Note that in contrast to `figma.boolean`, values are _not_ normalized for `figma.enum`. You always need to pass the exact literal values to the mapping object.
|
|
355
|
-
|
|
356
|
-
```tsx
|
|
357
|
-
// These two are equivalent for a variant with the options "Yes" and "No"
|
|
358
|
-
disabled: figma.enum("Boolean Variant", {
|
|
359
|
-
Yes: // ...
|
|
360
|
-
No: // ...
|
|
361
|
-
})
|
|
362
|
-
disabled: figma.boolean("Boolean Variant", {
|
|
363
|
-
true: // ...
|
|
364
|
-
false: // ...
|
|
365
|
-
})
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
### Instances
|
|
369
|
-
|
|
370
|
-
Instances is a Figma term for nested component references. For example, in the case of a `Button` containing an `Icon` as a nested component, we would call the `Icon` an instance. In Figma instances can be properties, (that is, inputs to the component), just like we have render props in code. Similarly to how we can map booleans, enums, and strings from Figma to code, we can also map these to instance props.
|
|
371
|
-
|
|
372
|
-
To ensure instance properties are as useful as possible with Code Connect, it is advised that you also provide Code Connect for the common components which you would expect to be used as values to this property. Dev Mode will automatically hydrate the referenced component's connected code snippet example and how changes it in Dev Mode for instance props.
|
|
373
|
-
|
|
374
|
-
```tsx
|
|
375
|
-
// maps an instance-swap property from Figma
|
|
376
|
-
figma.instance('PropName')
|
|
377
|
-
```
|
|
378
|
-
|
|
379
|
-
The return value of `figma.instance` is a JSX component and can be used in your example like a typical JSX component prop would be in your codebase.
|
|
380
|
-
|
|
381
|
-
```tsx
|
|
382
|
-
figma.connect(Button, 'https://...', {
|
|
383
|
-
props: {
|
|
384
|
-
icon: figma.instance('Icon'),
|
|
385
|
-
},
|
|
386
|
-
example: ({ icon }) => {
|
|
387
|
-
return <Button icon={icon}>Instance prop Example</Button>
|
|
388
|
-
},
|
|
389
|
-
})
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
You should then have a separate `figma.connect` call that connects the Icon component with the nested Figma component. Make sure to connect the backing component of that instance, not the instance itself.
|
|
393
|
-
|
|
394
|
-
```tsx
|
|
395
|
-
figma.connect(Icon32Add, 'https://...')
|
|
396
|
-
```
|
|
397
|
-
|
|
398
|
-
### Instance children
|
|
399
|
-
|
|
400
|
-
It's common for components in Figma to have child instances that aren't bound to an instance-swap prop. Similarly to `figma.instance`, we can render the code snippets for these nested instances with `figma.children`. This helper takes the _name of the instance layer within the parent component_ as its parameter, rather than a Figma prop name.
|
|
401
|
-
|
|
402
|
-
To illustrate this, consider the layer hierarchy in a component vs an instance of that component:
|
|
403
|
-
|
|
404
|
-
Button (Component)
|
|
405
|
-
Icon (Instance) -- "Icon" is the original name of the layer, this is what you should pass to `figma.children()`
|
|
406
|
-
|
|
407
|
-
Button (Instance)
|
|
408
|
-
RenamedIcon (Instance) -- here the instance layer was renamed, which won't break the mapping since we're not using this name
|
|
409
|
-
|
|
410
|
-
Note that the nested instance also must be connected separately.
|
|
411
|
-
|
|
412
|
-
> Layer names may differ between variants in a component set. To ensure the component (Button) can render a nested instance (Icon) for any of those variants, you must either use the wildcard option `figma.children("*")` or ensure that the layer name representing the instance (Icon) is the same across all variants of your component set (Button).
|
|
413
|
-
|
|
414
|
-
```tsx
|
|
415
|
-
// map one child instance with the layer name "Tab"
|
|
416
|
-
figma.children('Tab')
|
|
417
|
-
|
|
418
|
-
// map multiple child instances by their layer names to a single prop
|
|
419
|
-
figma.children(['Tab 1', 'Tab 2'])
|
|
420
|
-
```
|
|
421
|
-
|
|
422
|
-
### Wildcard match
|
|
423
|
-
|
|
424
|
-
`figma.children()` can be used with a single wildcard '*' character, to partially match names or to render any nested child. Wildcards cannot be used with the array argument. Matches are case sensitive.
|
|
425
|
-
|
|
426
|
-
```tsx
|
|
427
|
-
// map any (all) child instances
|
|
428
|
-
figma.children('*')
|
|
429
|
-
|
|
430
|
-
// map any child instances that starts with "Icon"
|
|
431
|
-
figma.children('Icon*')
|
|
432
|
-
```
|
|
433
|
-
|
|
434
|
-
### Nested properties
|
|
435
|
-
|
|
436
|
-
In cases where you don't want to connect a child component, but instead map its properties on the parent level, you can use `figma.nestedProps()` to achieve this. This helper takes the name of the layer as it's first parameter, and a mapping object as the second parameter. These props can then be referenced in the example function. `nestedProps` will always select a **single** instance, and cannot be used to map multiple children.
|
|
437
|
-
|
|
438
|
-
```tsx
|
|
439
|
-
// map the properties of a nested instance named "Button Shape"
|
|
440
|
-
figma.connect(Button, "https://...", {
|
|
441
|
-
props: {
|
|
442
|
-
buttonShape: figma.nestedProps('Button Shape', {
|
|
443
|
-
size: figma.enum({ ... }),
|
|
444
|
-
})
|
|
445
|
-
},
|
|
446
|
-
example: ({ buttonShape }) => <Button size={buttonShape.size} />
|
|
447
|
-
}
|
|
448
|
-
```
|
|
449
|
-
|
|
450
|
-
### Text Content
|
|
451
|
-
|
|
452
|
-
A common pattern for design systems in Figma is to not use props for texts, but rather rely on instances overriding the text content. `figma.textContent()` allows you to select a child text layer and render its content. It takes a single parameter which is the name of the layer in the original component.
|
|
453
|
-
|
|
454
|
-
```tsx
|
|
455
|
-
figma.connect(Button, "https://...", {
|
|
456
|
-
props: {
|
|
457
|
-
label: figma.textContent("Text Layer")
|
|
458
|
-
},
|
|
459
|
-
example: ({ label }) => <Button>{label}</Button>
|
|
460
|
-
}
|
|
461
|
-
```
|
|
462
|
-
|
|
463
|
-
### className
|
|
464
|
-
|
|
465
|
-
For mapping figma properties to a className string, you can use the `figma.className` helper. It takes an array of strings and returns the concatenated string. Any other helper that returns a string (or undefined) can be used in conjunction with this. Undefined values or empty strings will be filtered out from the result
|
|
466
|
-
|
|
467
|
-
```tsx
|
|
468
|
-
figma.connect("https://...", {
|
|
469
|
-
props: {
|
|
470
|
-
className: figma.className([
|
|
471
|
-
'btn-base',
|
|
472
|
-
figma.enum("Size", { Large: 'btn-large' }),
|
|
473
|
-
figma.boolean("Disabled", { true: 'btn-disabled', false: '' }),
|
|
474
|
-
])
|
|
475
|
-
},
|
|
476
|
-
example: ({ className }) => <button className={className} />
|
|
477
|
-
}
|
|
478
|
-
```
|
|
479
|
-
|
|
480
|
-
In Dev Mode this will display as:
|
|
481
|
-
```
|
|
482
|
-
<button className="btn-base btn-large btn-disabled" />
|
|
483
|
-
```
|
|
484
|
-
|
|
485
|
-
## Variant restrictions
|
|
486
|
-
|
|
487
|
-
Sometimes a component in Figma is represented by more than one component in code. For example you may have a single `Button` in your Figma design system with a `type` property to switch between primary, secondary, and danger variants. However, in code this may be represented by three different components, a `PrimaryButton`, `SecondaryButton` and `DangerButton`.
|
|
488
|
-
|
|
489
|
-
To model this behaviour with Code Connect we can make use of something called variant restrictions. Variant restrictions allow you to provide entirely different code samples for different variants of a single Figma component. The keys and values used should match the name of the variant (or property) in Figma and it's options respectively.
|
|
490
|
-
|
|
491
|
-
```tsx
|
|
492
|
-
figma.connect(PrimaryButton, 'https://...', {
|
|
493
|
-
variant: { Type: 'Primary' },
|
|
494
|
-
example: () => <PrimaryButton />,
|
|
495
|
-
})
|
|
496
|
-
|
|
497
|
-
figma.connect(SecondaryButton, 'https://...', {
|
|
498
|
-
variant: { Type: 'Secondary' },
|
|
499
|
-
example: () => <SecondaryButton />,
|
|
500
|
-
})
|
|
501
|
-
|
|
502
|
-
figma.connect(DangerButton, 'https://...', {
|
|
503
|
-
variant: { Type: 'Danger' },
|
|
504
|
-
example: () => <DangerButton />,
|
|
505
|
-
})
|
|
506
|
-
```
|
|
507
|
-
|
|
508
|
-
This will also work for Figma properties that aren't variants (for example, boolean props).
|
|
509
|
-
|
|
510
|
-
```
|
|
511
|
-
figma.connect(IconButton, 'https://...', {
|
|
512
|
-
variant: { "Has Icon": true },
|
|
513
|
-
example: () => <IconButton />,
|
|
514
|
-
})
|
|
515
|
-
```
|
|
516
|
-
|
|
517
|
-
In some complex cases you may also want to map a code component to a combination of variants in Figma.
|
|
518
|
-
|
|
519
|
-
```tsx
|
|
520
|
-
figma.connect(DangerButton, 'https://...', {
|
|
521
|
-
variant: { Type: 'Danger', Disabled: true },
|
|
522
|
-
example: () => <DangerButton />,
|
|
523
|
-
})
|
|
524
|
-
```
|
|
525
|
-
|
|
526
|
-
You can achieve the same thing using the Storybook API.
|
|
527
|
-
|
|
528
|
-
```tsx
|
|
529
|
-
export default {
|
|
530
|
-
component: Button,
|
|
531
|
-
parameters: {
|
|
532
|
-
design: {
|
|
533
|
-
type: 'figma',
|
|
534
|
-
url: 'https://...',
|
|
535
|
-
examples: [
|
|
536
|
-
{ example: PrimaryButtonStory, variant: { Type: 'Primary' } },
|
|
537
|
-
{ example: SecondaryButtonStory, variant: { Type: 'Secondary' } },
|
|
538
|
-
{ example: DangerButtonStory, variant: { Type: 'Danger' } },
|
|
539
|
-
],
|
|
540
|
-
},
|
|
541
|
-
},
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
export function PrimaryButtonStory() {
|
|
545
|
-
return <PrimaryButton />
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
export function SecondaryButtonStory() {
|
|
549
|
-
return <SecondaryButton />
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
export function DangerButtonStory() {
|
|
553
|
-
return <DangerButton />
|
|
554
|
-
}
|
|
555
|
-
```
|
|
556
|
-
|
|
557
|
-
## Icons
|
|
558
|
-
|
|
559
|
-
For connecting a lot of icons, we recommend creating a script that pulls icons from a Figma file to generate an `icons.figma.tsx` file that includes all icons. You can use the script [here](./scripts/README.md) as a starting point. The script is marked with "EDIT THIS" in areas where you'll need to make edits for it to work with how your Figma design system is setup and how your icons are defined in code.
|
|
560
|
-
|
|
561
|
-
## CI / CD
|
|
562
|
-
|
|
563
|
-
The easiest way to get started using Code Connect is by using the CLI locally. However, once you have set up your first connected components it may be beneficial to integrate Code Connect with your CI/CD environment to simplify maintenance and to ensure component connections are always up to date. Using GitHub actions, we can specify that we want to publish new files when any PR is merged to the main branch. We recommend only running this on pull requests that are relevant to Code Connect to minimize impact on other pull requests.
|
|
564
|
-
|
|
565
|
-
```yml
|
|
566
|
-
on:
|
|
567
|
-
push:
|
|
568
|
-
paths:
|
|
569
|
-
- src/components/**/*.figma.tsx
|
|
570
|
-
branches:
|
|
571
|
-
- main
|
|
572
|
-
|
|
573
|
-
jobs:
|
|
574
|
-
code-connect:
|
|
575
|
-
name: Code Connect
|
|
576
|
-
runs-on: ubuntu-latest
|
|
577
|
-
steps:
|
|
578
|
-
- run: npx figma connect publish
|
|
579
|
-
```
|
|
580
|
-
|
|
581
|
-
## Co-locating Code Connect files
|
|
582
|
-
|
|
583
|
-
By default Code Connect creates a new file which lives alongside the components you want to connect to Figma. However, Code Connect may also be co-located with the component it is connecting in code. To do this, simply move the contents of the `<component-name>.figma.tsx` file into your component definition file.
|
|
584
|
-
|
|
585
|
-
```tsx
|
|
586
|
-
import figma from "@figma/code-connect"
|
|
587
|
-
|
|
588
|
-
interface ButtonProps { ... }
|
|
589
|
-
export function Button(props: ButtonProps) { ... }
|
|
590
|
-
|
|
591
|
-
figma.connect(Button, "https://...", {
|
|
592
|
-
example: () => {
|
|
593
|
-
return <Button />
|
|
594
|
-
}
|
|
595
|
-
})
|
|
596
|
-
```
|
|
3
|
+
This file gets replaced with the [main README](../README.md) when publishing to npm, so that users see those docs on the npm package page.
|
package/dist/cli.js
CHANGED
|
@@ -26,8 +26,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
const commander = __importStar(require("commander"));
|
|
28
28
|
const connect_1 = require("./commands/connect");
|
|
29
|
+
const helpers_1 = require("./connect/wizard/helpers");
|
|
29
30
|
require('dotenv').config();
|
|
30
31
|
async function run() {
|
|
32
|
+
(0, helpers_1.maybePrefillWizardQuestionsForTesting)();
|
|
31
33
|
const program = new commander.Command().version(require('./../package.json').version);
|
|
32
34
|
program.enablePositionalOptions();
|
|
33
35
|
(0, connect_1.addConnectCommandToProgram)(program);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,qDAAsC;AACtC,gDAA+D;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,qDAAsC;AACtC,gDAA+D;AAE/D,sDAAgF;AAEhF,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAA;AAE1B,KAAK,UAAU,GAAG;IAChB,IAAA,+CAAqC,GAAE,CAAA;IAEvC,MAAM,OAAO,GAAG,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,OAAO,CAAC,CAAA;IACrF,OAAO,CAAC,uBAAuB,EAAE,CAAA;IAEjC,IAAA,oCAA0B,EAAC,OAAO,CAAC,CAAA;IAEnC,8EAA8E;IAC9E,sCAAsC;IACtC;;;;;;;MAOE;IAEF,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3B,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,OAAO,CAAC,UAAU,EAAE,CAAA;QACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC;AAED,GAAG,EAAE,CAAA"}
|
|
@@ -29,7 +29,7 @@ export interface FigmaConnectClient {
|
|
|
29
29
|
export declare function getComponents(fileOrNode: string): Promise<{
|
|
30
30
|
fileKey: string;
|
|
31
31
|
figmaUrl: string;
|
|
32
|
-
componentPropertyDefinitions: {};
|
|
32
|
+
componentPropertyDefinitions: {} | undefined;
|
|
33
33
|
type: "COMPONENT" | "COMPONENT_SET";
|
|
34
34
|
name: string;
|
|
35
35
|
id: string;
|
|
@@ -33,13 +33,15 @@ async function getComponents(fileOrNode) {
|
|
|
33
33
|
...component,
|
|
34
34
|
fileKey,
|
|
35
35
|
figmaUrl: (0, helpers_1.figmaUrlOfComponent)(component, fileKey),
|
|
36
|
-
componentPropertyDefinitions:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
componentPropertyDefinitions: component.type === 'COMPONENT_SET'
|
|
37
|
+
? Object.keys(component.componentPropertyDefinitions).reduce((result, key) => {
|
|
38
|
+
return {
|
|
39
|
+
...result,
|
|
40
|
+
// this removes the ID prefix from property names e.g #123:name -> name
|
|
41
|
+
[(0, helpers_1.normalizePropName)(key)]: component.componentPropertyDefinitions[key],
|
|
42
|
+
};
|
|
43
|
+
}, {})
|
|
44
|
+
: undefined,
|
|
43
45
|
}));
|
|
44
46
|
}
|
|
45
47
|
exports.getComponents = getComponents;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"figma_client.js","sourceRoot":"","sources":["../../src/client/figma_client.ts"],"names":[],"mappings":";;;AAAA,8DAAgF;AAChF,gDAM2B;AAsB3B,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAA;AAE1B;;;;;;;;GAQG;AACI,KAAK,UAAU,aAAa,CAAC,UAAkB;IACpD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;IAClD,CAAC;IAED,MAAM,OAAO,GAAG,IAAA,sBAAY,EAAC,UAAU,CAAC,CAAA;IACxC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,2BAA2B,UAAU,oBAAoB,CAAC,CAAA;IAC5E,CAAC;IAED,MAAM,OAAO,GAAG,IAAA,sBAAY,EAAC,CAAC,UAAU,CAAC,CAAC,CAAA;IAC1C,IAAI,MAAM,GAAG,IAAA,0BAAS,EAAC,UAAU,IAAI,EAAE,CAAC,GAAG,UAAU,OAAO,EAAE,CAAA;IAC9D,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,QAAQ,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;IACvC,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,IAAA,4BAAW,EAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;IAErE,sFAAsF;IACtF,gFAAgF;IAChF,OAAO,IAAA,kCAAwB,EAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACvD,GAAG,SAAS;QACZ,OAAO;QACP,QAAQ,EAAE,IAAA,6BAAmB,EAAC,SAAS,EAAE,OAAO,CAAC;QACjD,4BAA4B,
|
|
1
|
+
{"version":3,"file":"figma_client.js","sourceRoot":"","sources":["../../src/client/figma_client.ts"],"names":[],"mappings":";;;AAAA,8DAAgF;AAChF,gDAM2B;AAsB3B,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAA;AAE1B;;;;;;;;GAQG;AACI,KAAK,UAAU,aAAa,CAAC,UAAkB;IACpD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;IAClD,CAAC;IAED,MAAM,OAAO,GAAG,IAAA,sBAAY,EAAC,UAAU,CAAC,CAAA;IACxC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,2BAA2B,UAAU,oBAAoB,CAAC,CAAA;IAC5E,CAAC;IAED,MAAM,OAAO,GAAG,IAAA,sBAAY,EAAC,CAAC,UAAU,CAAC,CAAC,CAAA;IAC1C,IAAI,MAAM,GAAG,IAAA,0BAAS,EAAC,UAAU,IAAI,EAAE,CAAC,GAAG,UAAU,OAAO,EAAE,CAAA;IAC9D,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,QAAQ,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;IACvC,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,IAAA,4BAAW,EAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;IAErE,sFAAsF;IACtF,gFAAgF;IAChF,OAAO,IAAA,kCAAwB,EAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACvD,GAAG,SAAS;QACZ,OAAO;QACP,QAAQ,EAAE,IAAA,6BAAmB,EAAC,SAAS,EAAE,OAAO,CAAC;QACjD,4BAA4B,EAC1B,SAAS,CAAC,IAAI,KAAK,eAAe;YAChC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;gBACzE,OAAO;oBACL,GAAG,MAAM;oBACT,uEAAuE;oBACvE,CAAC,IAAA,2BAAiB,EAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,4BAA4B,CAAC,GAAG,CAAC;iBACtE,CAAA;YACH,CAAC,EAAE,EAAE,CAAC;YACR,CAAC,CAAC,SAAS;KAChB,CAAC,CAAC,CAAA;AACL,CAAC;AAnCD,sCAmCC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as commander from 'commander';
|
|
2
2
|
import { ProjectInfo } from '../connect/project';
|
|
3
|
-
import { CodeConnectJSON } from '../
|
|
3
|
+
import { CodeConnectJSON } from '../connect/figma_connect';
|
|
4
4
|
export type BaseCommand = commander.Command & {
|
|
5
5
|
token: string;
|
|
6
6
|
verbose: boolean;
|
|
@@ -15,5 +15,7 @@ export type BaseCommand = commander.Command & {
|
|
|
15
15
|
export declare function addConnectCommandToProgram(program: commander.Command): void;
|
|
16
16
|
export declare function getAccessToken(cmd: BaseCommand): string;
|
|
17
17
|
export declare function getDir(cmd: BaseCommand): string;
|
|
18
|
-
export declare function getCodeConnectObjects(
|
|
18
|
+
export declare function getCodeConnectObjects(cmd: BaseCommand & {
|
|
19
|
+
label?: string;
|
|
20
|
+
}, projectInfo: ProjectInfo, silent?: boolean): Promise<CodeConnectJSON[]>;
|
|
19
21
|
//# sourceMappingURL=connect.d.ts.map
|