-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.figmaexportrc.js
82 lines (81 loc) · 2.39 KB
/
.figmaexportrc.js
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* Copyright Oxide Computer Company
*/
import svgOutputter from '@figma-export/output-components-as-svg'
import svgrOutputter from '@figma-export/output-components-as-svgr'
import svgoTransformer from '@figma-export/transform-svg-with-svgo'
import { pascalCase } from '@figma-export/utils'
export default {
commands: [
[
'components',
{
fileId: 'iMVpYGoNGpwMEL9gd0oeYF',
onlyFromPages: ['Icons'],
transformers: [
svgoTransformer({
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeViewBox: false,
},
},
},
{
name: 'removeAttrs',
params: {
attrs: 'svg:fill:none',
},
},
],
}),
],
outputters: [
svgOutputter({
output: './icons/svg',
getDirname: () => '',
getBasename: ({ basename, dirname }) => {
if (basename.includes('Direction=')) {
basename = `carat-${basename.split('=')[1].toLowerCase()}-12`
}
if (!isNaN(parseInt(dirname))) {
return `${basename}-${dirname}.svg`
}
return `${basename}.svg`
},
}),
svgrOutputter({
output: './icons/react',
getFileExtension: () => '.tsx',
getDirname: () => '',
getComponentName: ({ componentName }) =>
pascalCase(
componentName
.split('/')
.map((n) => `${n[0].toUpperCase()}${n.slice(1)}`)
.reverse()
.join('') + 'Icon',
),
getSvgrConfig: () => ({
jsxRuntime: 'automatic',
typescript: true,
titleProp: true,
plugins: ['@svgr/plugin-jsx'],
svgProps: {
role: 'img',
},
expandProps: 'end',
exportType: 'default',
}),
}),
],
},
],
],
}