Skip to content

Commit 1dc487f

Browse files
Merge pull request #170 from marcomontalbano/docs-readme
Update all README.md examples
2 parents de663da + 5765b11 commit 1dc487f

File tree

10 files changed

+89
-58
lines changed

10 files changed

+89
-58
lines changed

packages/cli/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ You can create you own:
6464

6565
```ts
6666
// with promise
67-
module.exports = options => {
67+
export default options => {
6868
return (svg) => new Promise((resolve, reject) => {
6969
resolve(svg);
7070
});
@@ -73,7 +73,7 @@ module.exports = options => {
7373

7474
```ts
7575
// with async/await
76-
module.exports = options => {
76+
export default options => {
7777
return async (svg) => {
7878
return svg;
7979
};
@@ -100,7 +100,7 @@ An output function receives a list of pages, in which each page contains compone
100100
You can create you own:
101101

102102
```ts
103-
module.exports = options => {
103+
export default options => {
104104
return async pages => {
105105
console.clear();
106106
console.log(JSON.stringify(pages));
@@ -144,7 +144,7 @@ An output function receives a list of styles.
144144
You can create you own:
145145

146146
```ts
147-
module.exports = options => {
147+
export default options => {
148148
return async styles => {
149149
console.clear();
150150
console.log(JSON.stringify(styles));

packages/output-components-as-es6/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ export const figmaLogo = `<svg width="40" height="60" viewBox="0 0 40 60" fill="
2727
You can easily add this outputter to your `.figmaexportrc.js`:
2828

2929
```js
30-
module.exports = {
30+
import asES6 from '@figma-export/output-components-as-es6'
31+
32+
export default {
3133
commands: [
3234
['components', {
3335
fileId: 'fzYhvQpqwhZDUImRz431Qo',
3436
onlyFromPages: ['icons', 'unit-test'],
3537
outputters: [
36-
require('@figma-export/output-components-as-es6')({
38+
asES6({
3739
output: './output'
3840
})
3941
]
@@ -47,11 +49,12 @@ module.exports = {
4749
`getVariableName`, `useBase64` and `useDataUrl` are **optional**.
4850

4951
```js
50-
const { camelCase } = require('@figma-export/utils');
52+
import asES6 from '@figma-export/output-components-as-es6'
53+
import { camelCase } from '@figma-export/utils'
5154

5255
...
5356

54-
require('@figma-export/output-components-as-es6')({
57+
asES6({
5558
output: './output',
5659
getVariableName: (options) => camelCase(options.componentName.trim()),
5760
useBase64: false,

packages/output-components-as-svg/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ $ tree output/
2929
You can easily add this outputter to your `.figmaexportrc.js`:
3030

3131
```js
32-
module.exports = {
32+
import asSvg from '@figma-export/output-components-as-svg'
33+
34+
export default {
3335
commands: [
3436
['components', {
3537
fileId: 'fzYhvQpqwhZDUImRz431Qo',
3638
onlyFromPages: ['icons', 'unit-test'],
3739
outputters: [
38-
require('@figma-export/output-components-as-svg')({
40+
asSvg({
3941
output: './output'
4042
})
4143
]
@@ -49,11 +51,12 @@ module.exports = {
4951
`getDirname` and `getBasename` are **optional**.
5052

5153
```js
52-
const path = require('path');
54+
import asSvg from '@figma-export/output-components-as-svg'
55+
import path from 'path'
5356

5457
...
5558

56-
require('@figma-export/output-components-as-svg')({
59+
asSvg({
5760
output: './output',
5861
getDirname: (options) => `${options.pageName}${path.sep}${options.dirname}`,
5962
getBasename: (options) => `${options.basename}.svg`,

packages/output-components-as-svgr/README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ $ tree output/
3434
You can easily add this outputter to your `.figmaexportrc.js`:
3535

3636
```js
37-
module.exports = {
37+
import asSvgr from '@figma-export/output-components-as-svgr'
38+
39+
export default {
3840
commands: [
3941
['components', {
4042
fileId: 'fzYhvQpqwhZDUImRz431Qo',
4143
onlyFromPages: ['icons', 'unit-test'],
4244
outputters: [
43-
require('@figma-export/output-components-as-svgr')({
45+
asSvgr({
4446
output: './output'
4547
})
4648
]
@@ -54,12 +56,13 @@ module.exports = {
5456
`getDirname`, `getComponentName`, `getComponentFilename`, `getFileExtension`, `getExportTemplate` and `getSvgrConfig` are **optional**.
5557

5658
```js
57-
const path = require('path');
58-
const { pascalCase } = require('@figma-export/utils');
59+
import asSvgr from '@figma-export/output-components-as-svgr'
60+
import { pascalCase } from '@figma-export/utils'
61+
import path from 'path'
5962

6063
...
6164

62-
require('@figma-export/output-components-as-svgr')({
65+
asSvgr({
6366
output: './output',
6467
getDirname: (options) => `${options.pageName}${path.sep}${options.dirname}`,
6568
getComponentName: (options) => `${pascalCase(options.basename)}`,
@@ -90,11 +93,12 @@ npm install --save-dev @svgr/plugin-jsx
9093

9194
```js
9295
// .figmaexportrc.js
96+
import asSvgr from '@figma-export/output-components-as-svgr'
9397

9498
...
9599

96100
outputters: [
97-
require('@figma-export/output-components-as-svgr')({
101+
asSvgr({
98102
output: './output/svgr',
99103
getSvgrConfig: () => ({
100104
plugins: ['@svgr/plugin-jsx']

packages/output-components-as-svgstore/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ You can read more on <a target="_blank" rel="noopener noreferrer" href="https://
2424
You can easily add this outputter to your `.figmaexportrc.js`:
2525

2626
```js
27-
module.exports = {
27+
import asSvgstore from '@figma-export/output-components-as-svgstore'
28+
29+
export default {
2830
commands: [
2931
['components', {
3032
fileId: 'fzYhvQpqwhZDUImRz431Qo',
3133
onlyFromPages: ['icons', 'unit-test'],
3234
outputters: [
33-
require('@figma-export/output-components-as-svgstore')({
35+
asSvgstore({
3436
output: './output'
3537
})
3638
]
@@ -44,7 +46,9 @@ module.exports = {
4446
`getIconId` and `svgstoreConfig` are **optional**.
4547

4648
```js
47-
require('@figma-export/output-components-as-svgstore')({
49+
import asSvgstore from '@figma-export/output-components-as-svgstore'
50+
51+
asSvgstore({
4852
output: './output',
4953
getIconId: (options) => `${options.pageName}/${options.componentName}`,
5054
svgstoreConfig: {},

packages/output-styles-as-css/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ $ tree output/
1818
You can easily add this outputter to your `.figmaexportrc.js`:
1919

2020
```js
21-
module.exports = {
21+
import asCss from '@figma-export/output-styles-as-css'
22+
23+
export default {
2224
commands: [
2325
['styles', {
2426
fileId: 'fzYhvQpqwhZDUImRz431Qo',
2527
outputters: [
26-
require('@figma-export/output-styles-as-css')({
28+
asCss({
2729
output: './output'
2830
})
2931
]
@@ -37,11 +39,12 @@ module.exports = {
3739
`getFilename` and `getVariableName` are **optional**.
3840

3941
```js
40-
const { kebabCase } = require('@figma-export/utils');
42+
import asCss from '@figma-export/output-styles-as-css'
43+
import { kebabCase } from '@figma-export/utils'
4144

4245
...
4346

44-
require('@figma-export/output-styles-as-css')({
47+
asCss({
4548
output: './output',
4649
getFilename: () => '_variables',
4750
getVariableName = (style, descriptor) => `${kebabCase(style.name).toLowerCase()}${descriptor != null ? `-${descriptor}` : ''}`,

packages/output-styles-as-less/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ $ tree output/
1818
You can easily add this outputter to your `.figmaexportrc.js`:
1919

2020
```js
21-
module.exports = {
21+
import asLess from '@figma-export/output-styles-as-less'
22+
23+
export default {
2224
commands: [
2325
['styles', {
2426
fileId: 'fzYhvQpqwhZDUImRz431Qo',
2527
outputters: [
26-
require('@figma-export/output-styles-as-less')({
28+
asLess({
2729
output: './output'
2830
})
2931
]
@@ -37,11 +39,12 @@ module.exports = {
3739
`getFilename` and `getVariableName` are **optional**.
3840

3941
```js
40-
const { kebabCase } = require('@figma-export/utils');
42+
import asLess from '@figma-export/output-styles-as-less'
43+
import { kebabCase } from '@figma-export/utils'
4144

4245
...
4346

44-
require('@figma-export/output-styles-as-less')({
47+
asLess({
4548
output: './output',
4649
getFilename: () => '_variables',
4750
getVariableName = (style, descriptor) => `${kebabCase(style.name).toLowerCase()}${descriptor != null ? `-${descriptor}` : ''}`,

packages/output-styles-as-sass/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ $ tree output/
1818
You can easily add this outputter to your `.figmaexportrc.js`:
1919

2020
```js
21-
module.exports = {
21+
import asSass from '@figma-export/output-styles-as-sass'
22+
23+
export default {
2224
commands: [
2325
['styles', {
2426
fileId: 'fzYhvQpqwhZDUImRz431Qo',
2527
outputters: [
26-
require('@figma-export/output-styles-as-sass')({
28+
asSass({
2729
output: './output'
2830
})
2931
]
@@ -37,11 +39,12 @@ module.exports = {
3739
`getExtension`, `getFilename` and `getVariableName` are **optional**.
3840

3941
```js
40-
const { kebabCase } = require('@figma-export/utils');
42+
import asSass from '@figma-export/output-styles-as-sass'
43+
import { kebabCase } from '@figma-export/utils'
4144

4245
...
4346

44-
require('@figma-export/output-styles-as-sass')({
47+
asSass({
4548
output: './output',
4649
getExtension: () => 'SCSS',
4750
getFilename: () => '_variables',

packages/output-styles-as-style-dictionary/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ $ tree output/
1818
You can easily add this outputter to your `.figmaexportrc.js`:
1919

2020
```js
21-
module.exports = {
21+
import asStyleDictionary from '@figma-export/output-styles-as-style-dictionary'
22+
23+
export default {
2224
commands: [
2325
['styles', {
2426
fileId: 'fzYhvQpqwhZDUImRz431Qo',
2527
outputters: [
26-
require('@figma-export/output-styles-as-style-dictionary')({
28+
asStyleDictionary({
2729
output: './output'
2830
})
2931
]
@@ -37,11 +39,12 @@ module.exports = {
3739
`getExtension`, `getFilename` and `getVariableName` are **optional**.
3840

3941
```js
40-
const { kebabCase } = require('@figma-export/utils');
42+
import asStyleDictionary from '@figma-export/output-styles-as-style-dictionary'
43+
import { kebabCase } from '@figma-export/utils'
4144

4245
...
4346

44-
require('@figma-export/output-styles-as-style-dictionary')({
47+
asStyleDictionary({
4548
output: './output',
4649
getExtension: () => 'JSON',
4750
getFilename: () => 'base',

packages/transform-svg-with-svgo/README.md

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,34 @@ yarn add @figma-export/transform-svg-with-svgo --dev
1818

1919
## Usage
2020

21-
You can use a custom configuration for svgo, creating a `.figmaexportrc.js` file and provide a `config` object for this package.
21+
You can transform an svg before exporting with svgo:
2222

2323
```js
24-
// .figmaexportrc.js
25-
26-
module.exports = {
27-
configs: [
28-
['@figma-export/transform-svg-with-svgo', {
29-
plugins: [
30-
{
31-
name: 'preset-default',
32-
params: {
33-
overrides: {
34-
removeViewBox: false,
24+
import transformSvgWithSvgo from '@figma-export/transform-svg-with-svgo'
25+
26+
export default {
27+
commands: [
28+
['components', {
29+
fileId: 'fzYhvQpqwhZDUImRz431Qo',
30+
onlyFromPages: ['icons', 'unit-test'],
31+
transformers: [
32+
transformSvgWithSvgo({
33+
plugins: [
34+
{
35+
name: 'preset-default',
36+
params: {
37+
overrides: {
38+
removeViewBox: false,
39+
}
40+
}
41+
},
42+
{
43+
name: 'removeDimensions'
3544
}
36-
}
37-
},
38-
{
39-
name: 'removeDimensions',
40-
active: true
41-
}
42-
]
43-
}]
45+
]
46+
})
47+
],
48+
}],
4449
]
45-
};
50+
}
4651
```

0 commit comments

Comments
 (0)