-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
# @figspec/components
CustomElements renders given Figma API's result into a rich preview.
## Installation
```sh
$ yarn add @figspec/components
# or
$ npm i @figspec/components
```
## Usage
Import the entry script (`import '@figspec/components'`) and it'll register our custom elements.
Then you can now use these on your page.
```js
// your script.js
import "@figspec/components";
// ...
```
```html
<body>
<figspec-frame-viewer nodes="..." rendered-image="..."></figspec-frame-viewer>
</body>
```
To display an entire Figma File, use `<figspec-file-viewer>` instead.
```html
<body>
<figspec-file-viewer
document-node="..."
rendered-images="..."
></figspec-file-viewer>
</body>
```
To see examples and API docs, please check out [Storybook](https://figspec.netlify.app/?path=/docs/components-figspec-viewer--defaults).
NOTE: We don't provide bundled scripts yet. If you want to put the script in head tag, please build the files at your own.
## TypeScript support
This package ships with TypeScript definition file.
One of our "typing dependencies" is missing from `package.json#dependencies`, because it's not our "runtime dependency".
So, you need to install that package in order to get full types (otherwise some properties turns into `any`).
```sh
# By installing this package, FileNode related properties will get correct types.
yarn add -D figma-js
```
## Browser supports
Browsers supporting WebComponents v1 spec and ES2015 or later.
The bundled codes are emitted under `esm/es2015` and `cjs/es2016`.
## Related packages
- [`@figspec/react`](https://github.com/pocka/figspec-react) ... React bindings for this package.