-
Notifications
You must be signed in to change notification settings - Fork 2
/
.figmaexportrc.js
85 lines (80 loc) · 2.43 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
83
84
85
/*
* 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
*/
// @ts-check
const { pascalCase } = require('@figma-export/utils')
module.exports = {
commands: [
[
'components',
{
fileId: 'iMVpYGoNGpwMEL9gd0oeYF',
onlyFromPages: ['Icons'],
transformers: [
require('@figma-export/transform-svg-with-svgo')({
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeViewBox: false,
},
},
},
{
name: 'removeAttrs',
params: {
attrs: 'svg:fill:none',
},
},
],
}),
],
outputters: [
require('@figma-export/output-components-as-svg')({
output: './icons/svg',
getDirname: () => '',
getBasename: ({ basename, dirname }) => {
// Special handing for the directional arrows which have an odd export naming convention
if (basename.includes('Direction=')) {
basename = `carat-${basename.split('=')[1].toLowerCase()}-12`
}
// Add the icon's size category as a postfix, if present
if (!isNaN(parseInt(dirname))) {
return `${basename}-${dirname}.svg`
}
return `${basename}.svg`
},
}),
require('@figma-export/output-components-as-svgr')({
output: './icons/react',
getFileExtension: () => '.tsx',
getDirname: () => '',
getComponentName: ({ componentName }) =>
pascalCase(
componentName
.split('/')
.map((n) => `${n[0].toUpperCase()}${n.slice(1)}`)
.reverse()
.join('') + 'Icon',
),
getSvgrConfig: () => {
return {
jsxRuntime: 'automatic',
typescript: true,
titleProp: true,
svgProps: {
role: 'img',
},
}
},
}),
],
},
],
],
}