handoff-app 0.2.1 → 0.3.1
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/Changelog.md +45 -0
- package/docs/foundations.md +1 -1
- package/figma-exporter/api/dist/figma-exporter-api.cjs.dev.js +1 -1
- package/figma-exporter/api/dist/figma-exporter-api.cjs.prod.js +1 -1
- package/figma-exporter/dist/declarations/src/exporters/components/utils.d.ts +2 -1
- package/figma-exporter/dist/declarations/src/exporters/design.d.ts +1 -4
- package/figma-exporter/dist/declarations/src/transformers/css/design/colors.d.ts +2 -0
- package/figma-exporter/dist/declarations/src/transformers/css/design/effects.d.ts +2 -0
- package/figma-exporter/dist/declarations/src/transformers/css/design/typography.d.ts +2 -0
- package/figma-exporter/dist/declarations/src/transformers/css/index.d.ts +1 -0
- package/figma-exporter/dist/declarations/src/transformers/css/utils.d.ts +0 -1
- package/figma-exporter/dist/declarations/src/transformers/scss/design/colors.d.ts +2 -0
- package/figma-exporter/dist/declarations/src/transformers/scss/design/effects.d.ts +2 -0
- package/figma-exporter/dist/declarations/src/transformers/scss/design/typography.d.ts +2 -0
- package/figma-exporter/dist/declarations/src/transformers/scss/index.d.ts +1 -0
- package/figma-exporter/dist/declarations/src/types.d.ts +6 -5
- package/figma-exporter/dist/{documentation-object-22658761.cjs.dev.js → documentation-object-1ccc37b9.cjs.dev.js} +18 -13
- package/figma-exporter/dist/{documentation-object-4f3b8be5.cjs.prod.js → documentation-object-d7872020.cjs.prod.js} +18 -13
- package/figma-exporter/dist/figma-exporter.cjs.dev.js +83 -4
- package/figma-exporter/dist/figma-exporter.cjs.prod.js +83 -4
- package/figma-exporter/src/exporters/components/utils.ts +6 -2
- package/figma-exporter/src/exporters/design.ts +28 -24
- package/figma-exporter/src/index.ts +10 -0
- package/figma-exporter/src/transformers/css/design/colors.ts +15 -0
- package/figma-exporter/src/transformers/css/design/effects.ts +18 -0
- package/figma-exporter/src/transformers/css/design/typography.ts +27 -0
- package/figma-exporter/src/transformers/css/index.ts +11 -0
- package/figma-exporter/src/transformers/css/utils.ts +0 -15
- package/figma-exporter/src/transformers/scss/design/colors.ts +11 -0
- package/figma-exporter/src/transformers/scss/design/effects.ts +15 -0
- package/figma-exporter/src/transformers/scss/design/typography.ts +24 -0
- package/figma-exporter/src/transformers/scss/index.ts +12 -1
- package/figma-exporter/src/types.ts +6 -5
- package/figma-exporter/src/utils/convertColor.ts +3 -2
- package/installer/template/config.js +2 -2
- package/installer/template/package.json +1 -1
- package/package.json +1 -1
- package/pages/foundations/colors.tsx +1 -1
- package/pages/foundations/effects.tsx +4 -9
- package/public/assets/icons.html +38 -38
- package/public/assets/icons.svg +1 -1
package/Changelog.md
CHANGED
|
@@ -6,6 +6,51 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
6
6
|
and this project adheres to
|
|
7
7
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
8
8
|
|
|
9
|
+
## [0.3.1] - 2023-04-03
|
|
10
|
+
|
|
11
|
+
This release fixes two small bugs, one that throws an error on builds because
|
|
12
|
+
of a missing type declaration in the config.
|
|
13
|
+
|
|
14
|
+
### Bugfixes
|
|
15
|
+
|
|
16
|
+
- Builds against 0.3.0 are failing because of a missing type. Effects is missing
|
|
17
|
+
from the return type of the DocumentObjects. This adds that type to fix.
|
|
18
|
+
- RGBA Colors are listed on the foundations as percent instead of 255 values.
|
|
19
|
+
This changes the display values, without changing the generated tokens.
|
|
20
|
+
|
|
21
|
+
## [0.3.0] - 2023-03-31
|
|
22
|
+
|
|
23
|
+
This release creates base foundation tokens in the /exported directory. This
|
|
24
|
+
is a major step forward allowing projects to use color, typography and effects as
|
|
25
|
+
named tokens in projects in addition to component tokens.
|
|
26
|
+
|
|
27
|
+
### Changes
|
|
28
|
+
|
|
29
|
+
- Adds foundation token css and scss files so projects can reference colors,
|
|
30
|
+
typography and effects.
|
|
31
|
+
- Tokens are exported to the /exported folder
|
|
32
|
+
- Foundation token files follow the form - {type of foundation}.scss contains
|
|
33
|
+
the css vars and {type of foundation}\_vars.scss contains the scss variables
|
|
34
|
+
- Color tokens are either hex for solid colors or rgba for alpha channel colors
|
|
35
|
+
- Two color map arrays are provided $color-groups and $color-names
|
|
36
|
+
- Color tokens are in the form $color-{group}-{name}: {hex/rgba};
|
|
37
|
+
- Typography tokens support
|
|
38
|
+
- font-family
|
|
39
|
+
- font-size
|
|
40
|
+
- font-weight
|
|
41
|
+
- line-height
|
|
42
|
+
- letter-spacing
|
|
43
|
+
- paragraph-spacing
|
|
44
|
+
- One Typography map is provided $type-sizes
|
|
45
|
+
- Typography tokens are in the form $typography-{size}-{property}: {value}
|
|
46
|
+
- Effects are are currently limited to drop and inner shadows
|
|
47
|
+
- Effects include a map of effect names $effects
|
|
48
|
+
- Effects are in the form $effect-{name}: {shadow definition}
|
|
49
|
+
|
|
50
|
+
### Bugfixes
|
|
51
|
+
|
|
52
|
+
- Adds the proper sidebar menu icon for effects
|
|
53
|
+
|
|
9
54
|
## [0.2.1] - 2023-03-28
|
|
10
55
|
|
|
11
56
|
This release fixes a small typo in the installer. The version in the installed
|
package/docs/foundations.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var documentationObject = require('../../dist/documentation-object-
|
|
5
|
+
var documentationObject = require('../../dist/documentation-object-1ccc37b9.cjs.dev.js');
|
|
6
6
|
require('lodash/isEqual');
|
|
7
7
|
require('axios');
|
|
8
8
|
require('archiver');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var documentationObject = require('../../dist/documentation-object-
|
|
5
|
+
var documentationObject = require('../../dist/documentation-object-d7872020.cjs.prod.js');
|
|
6
6
|
require('lodash/isEqual');
|
|
7
7
|
require('axios');
|
|
8
8
|
require('archiver');
|
|
@@ -43,5 +43,6 @@ export declare function findChildNodeWithTypeAndName<Type extends FigmaTypes.Nod
|
|
|
43
43
|
}> | null;
|
|
44
44
|
export declare function getComponentNamePart(componentName: string, partKey: string): string | undefined;
|
|
45
45
|
export declare const isValidTheme: (theme: string) => theme is "light" | "dark";
|
|
46
|
-
export declare const isValidEffectType: (effect:
|
|
46
|
+
export declare const isValidEffectType: (effect: FigmaTypes.Effect['type']) => boolean;
|
|
47
|
+
export declare const isShadowEffectType: (effect: FigmaTypes.Effect['type']) => boolean;
|
|
47
48
|
export declare const normalizeNamePart: (namePart: string) => string;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { ColorObject, EffectObject, TypographyObject } from '../types';
|
|
2
2
|
declare const getFileDesignTokens: (fileId: string, accessToken: string) => Promise<{
|
|
3
3
|
color: ColorObject[];
|
|
4
|
-
effect: EffectObject[];
|
|
5
4
|
typography: TypographyObject[];
|
|
6
|
-
|
|
7
|
-
color: never[];
|
|
8
|
-
typography: never[];
|
|
5
|
+
effect: EffectObject[];
|
|
9
6
|
}>;
|
|
10
7
|
export default getFileDesignTokens;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DocumentationObject } from '../../types';
|
|
2
2
|
interface CssTransformerOutput {
|
|
3
3
|
components: Record<keyof DocumentationObject['components'], string>;
|
|
4
|
+
design: Record<'colors' | 'typography' | 'effects', string>;
|
|
4
5
|
}
|
|
5
6
|
export default function cssTransformer(documentationObject: DocumentationObject): CssTransformerOutput;
|
|
6
7
|
export {};
|
|
@@ -20,7 +20,6 @@ export declare const transformFigmaPaintToCssColor: (paint: FigmaTypes.Paint) =>
|
|
|
20
20
|
export declare const transformFigmaTextAlignToCss: (textAlign: FigmaTypes.TypeStyle['textAlignHorizontal']) => string;
|
|
21
21
|
export declare const transformFigmaTextDecorationToCss: (textDecoration: FigmaTypes.TypeStyle['textDecoration']) => string;
|
|
22
22
|
export declare const transformFigmaTextCaseToCssTextTransform: (textCase: FigmaTypes.TypeStyle['textCase']) => string;
|
|
23
|
-
export declare const transformFigmaEffectToCssBoxShadow: (effect: FigmaTypes.Effect) => string;
|
|
24
23
|
export interface AbstractComponent {
|
|
25
24
|
componentType?: string;
|
|
26
25
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DocumentationObject } from '../../types';
|
|
2
2
|
interface ScssTransformerOutput {
|
|
3
3
|
components: Record<keyof DocumentationObject['components'], string>;
|
|
4
|
+
design: Record<'colors' | 'typography' | 'effects', string>;
|
|
4
5
|
}
|
|
5
6
|
export default function scssTransformer(documentationObject: DocumentationObject): ScssTransformerOutput;
|
|
6
7
|
export {};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { DocumentComponentsObject } from './exporters/components';
|
|
2
|
+
import { Effect } from './figma/types';
|
|
2
3
|
export interface ColorGroup {
|
|
3
4
|
group: string;
|
|
4
5
|
colors: ColorObject[];
|
|
5
6
|
}
|
|
6
7
|
export interface EffectObject {
|
|
7
8
|
name: string;
|
|
9
|
+
machineName: string;
|
|
8
10
|
group: string;
|
|
9
11
|
effects: EffectParametersObject[];
|
|
10
12
|
}
|
|
@@ -15,6 +17,7 @@ export interface ColorObject {
|
|
|
15
17
|
hex: string;
|
|
16
18
|
rgb: RGBObject;
|
|
17
19
|
sass: string;
|
|
20
|
+
machineName: string;
|
|
18
21
|
}
|
|
19
22
|
export interface TypographyObject {
|
|
20
23
|
name: string;
|
|
@@ -23,11 +26,8 @@ export interface TypographyObject {
|
|
|
23
26
|
values: any;
|
|
24
27
|
}
|
|
25
28
|
export interface EffectParametersObject {
|
|
26
|
-
type: '
|
|
27
|
-
|
|
28
|
-
color: RGBObject;
|
|
29
|
-
offset: OffsetObject;
|
|
30
|
-
radius: number;
|
|
29
|
+
type: Effect['type'];
|
|
30
|
+
value: string;
|
|
31
31
|
}
|
|
32
32
|
export interface RGBObject {
|
|
33
33
|
r: number;
|
|
@@ -53,6 +53,7 @@ export interface DocumentationObject {
|
|
|
53
53
|
design: {
|
|
54
54
|
color: ColorObject[];
|
|
55
55
|
typography: TypographyObject[];
|
|
56
|
+
effect: EffectObject[];
|
|
56
57
|
};
|
|
57
58
|
components: DocumentComponentsObject;
|
|
58
59
|
assets: {
|
|
@@ -273,7 +273,10 @@ const isValidTheme = theme => {
|
|
|
273
273
|
return ['light', 'dark'].includes(theme);
|
|
274
274
|
};
|
|
275
275
|
const isValidEffectType = effect => {
|
|
276
|
-
return
|
|
276
|
+
return isShadowEffectType(effect);
|
|
277
|
+
};
|
|
278
|
+
const isShadowEffectType = effect => {
|
|
279
|
+
return ['DROP_SHADOW', 'INNER_SHADOW'].includes(effect);
|
|
277
280
|
};
|
|
278
281
|
const normalizeNamePart = namePart => {
|
|
279
282
|
return namePart.replace(/[^a-z0-9]+/gi, '-').replace(/^-/g, '').replace(/-$/g, '').toLowerCase();
|
|
@@ -1873,12 +1876,12 @@ const transformFigmaEffectToCssBoxShadow = effect => {
|
|
|
1873
1876
|
if (!visible) {
|
|
1874
1877
|
return '';
|
|
1875
1878
|
}
|
|
1876
|
-
if (type
|
|
1879
|
+
if (isShadowEffectType(type) && color && offset) {
|
|
1877
1880
|
const {
|
|
1878
1881
|
x,
|
|
1879
1882
|
y
|
|
1880
1883
|
} = offset;
|
|
1881
|
-
return `${x}px ${y}px ${radius ?? 0}px ${spread ? spread + 'px ' : ''}${transformFigmaColorToCssColor(color)}`;
|
|
1884
|
+
return `${x}px ${y}px ${radius ?? 0}px ${spread ? spread + 'px ' : ''}${transformFigmaColorToCssColor(color)}${type === 'INNER_SHADOW' ? ' inset' : ''}`;
|
|
1882
1885
|
}
|
|
1883
1886
|
return '';
|
|
1884
1887
|
};
|
|
@@ -1937,6 +1940,9 @@ function figmaColorToHex(color) {
|
|
|
1937
1940
|
return hex;
|
|
1938
1941
|
}
|
|
1939
1942
|
|
|
1943
|
+
const toMachineName = name => {
|
|
1944
|
+
return name.toLowerCase().replace(/[^a-z0-9\s\-]/gi, '').replace(/\s\-\s|\s+/gi, '-');
|
|
1945
|
+
};
|
|
1940
1946
|
const fieldData = name => {
|
|
1941
1947
|
let nameArray = name.split('/');
|
|
1942
1948
|
const data = {
|
|
@@ -1945,12 +1951,12 @@ const fieldData = name => {
|
|
|
1945
1951
|
group: ''
|
|
1946
1952
|
};
|
|
1947
1953
|
if (nameArray[1]) {
|
|
1948
|
-
data.group = nameArray[0]
|
|
1954
|
+
data.group = toMachineName(nameArray[0]);
|
|
1949
1955
|
data.name = nameArray[1];
|
|
1950
|
-
data.machine_name = data.name
|
|
1956
|
+
data.machine_name = toMachineName(data.name);
|
|
1951
1957
|
} else {
|
|
1952
1958
|
data.name = nameArray[0];
|
|
1953
|
-
data.machine_name = data.name
|
|
1959
|
+
data.machine_name = toMachineName(data.name);
|
|
1954
1960
|
}
|
|
1955
1961
|
return data;
|
|
1956
1962
|
};
|
|
@@ -1994,13 +2000,11 @@ const getFileDesignTokens = async (fileId, accessToken) => {
|
|
|
1994
2000
|
if (isArray(document.effects) && document.effects.length > 0) {
|
|
1995
2001
|
effectsArray.push({
|
|
1996
2002
|
name,
|
|
2003
|
+
machineName: machine_name,
|
|
1997
2004
|
group,
|
|
1998
|
-
effects: document.effects.filter(effect => isValidEffectType(effect.type)).map(effect => ({
|
|
2005
|
+
effects: document.effects.filter(effect => isValidEffectType(effect.type) && effect.visible).map(effect => ({
|
|
1999
2006
|
type: effect.type,
|
|
2000
|
-
|
|
2001
|
-
color: effect.color,
|
|
2002
|
-
offset: effect.offset,
|
|
2003
|
-
radius: effect.radius
|
|
2007
|
+
value: isShadowEffectType(effect.type) ? transformFigmaEffectToCssBoxShadow(effect) : ''
|
|
2004
2008
|
}))
|
|
2005
2009
|
});
|
|
2006
2010
|
} else if (isArray(document.fills) && document.fills[0] && document.fills[0].type === 'SOLID' && document.fills[0].color) {
|
|
@@ -2011,7 +2015,8 @@ const getFileDesignTokens = async (fileId, accessToken) => {
|
|
|
2011
2015
|
type: 'color',
|
|
2012
2016
|
hex: figmaColorToHex(color),
|
|
2013
2017
|
rgb: color,
|
|
2014
|
-
sass: `$color-${group}-${machine_name}
|
|
2018
|
+
sass: `$color-${group}-${machine_name}`,
|
|
2019
|
+
machineName: machine_name
|
|
2015
2020
|
});
|
|
2016
2021
|
}
|
|
2017
2022
|
}
|
|
@@ -2036,7 +2041,7 @@ const getFileDesignTokens = async (fileId, accessToken) => {
|
|
|
2036
2041
|
});
|
|
2037
2042
|
}
|
|
2038
2043
|
});
|
|
2039
|
-
|
|
2044
|
+
chalk__default["default"].green('Colors, Effects and Typography Exported');
|
|
2040
2045
|
const data = {
|
|
2041
2046
|
color: colorsArray,
|
|
2042
2047
|
effect: effectsArray,
|
|
@@ -273,7 +273,10 @@ const isValidTheme = theme => {
|
|
|
273
273
|
return ['light', 'dark'].includes(theme);
|
|
274
274
|
};
|
|
275
275
|
const isValidEffectType = effect => {
|
|
276
|
-
return
|
|
276
|
+
return isShadowEffectType(effect);
|
|
277
|
+
};
|
|
278
|
+
const isShadowEffectType = effect => {
|
|
279
|
+
return ['DROP_SHADOW', 'INNER_SHADOW'].includes(effect);
|
|
277
280
|
};
|
|
278
281
|
const normalizeNamePart = namePart => {
|
|
279
282
|
return namePart.replace(/[^a-z0-9]+/gi, '-').replace(/^-/g, '').replace(/-$/g, '').toLowerCase();
|
|
@@ -1873,12 +1876,12 @@ const transformFigmaEffectToCssBoxShadow = effect => {
|
|
|
1873
1876
|
if (!visible) {
|
|
1874
1877
|
return '';
|
|
1875
1878
|
}
|
|
1876
|
-
if (type
|
|
1879
|
+
if (isShadowEffectType(type) && color && offset) {
|
|
1877
1880
|
const {
|
|
1878
1881
|
x,
|
|
1879
1882
|
y
|
|
1880
1883
|
} = offset;
|
|
1881
|
-
return `${x}px ${y}px ${radius ?? 0}px ${spread ? spread + 'px ' : ''}${transformFigmaColorToCssColor(color)}`;
|
|
1884
|
+
return `${x}px ${y}px ${radius ?? 0}px ${spread ? spread + 'px ' : ''}${transformFigmaColorToCssColor(color)}${type === 'INNER_SHADOW' ? ' inset' : ''}`;
|
|
1882
1885
|
}
|
|
1883
1886
|
return '';
|
|
1884
1887
|
};
|
|
@@ -1937,6 +1940,9 @@ function figmaColorToHex(color) {
|
|
|
1937
1940
|
return hex;
|
|
1938
1941
|
}
|
|
1939
1942
|
|
|
1943
|
+
const toMachineName = name => {
|
|
1944
|
+
return name.toLowerCase().replace(/[^a-z0-9\s\-]/gi, '').replace(/\s\-\s|\s+/gi, '-');
|
|
1945
|
+
};
|
|
1940
1946
|
const fieldData = name => {
|
|
1941
1947
|
let nameArray = name.split('/');
|
|
1942
1948
|
const data = {
|
|
@@ -1945,12 +1951,12 @@ const fieldData = name => {
|
|
|
1945
1951
|
group: ''
|
|
1946
1952
|
};
|
|
1947
1953
|
if (nameArray[1]) {
|
|
1948
|
-
data.group = nameArray[0]
|
|
1954
|
+
data.group = toMachineName(nameArray[0]);
|
|
1949
1955
|
data.name = nameArray[1];
|
|
1950
|
-
data.machine_name = data.name
|
|
1956
|
+
data.machine_name = toMachineName(data.name);
|
|
1951
1957
|
} else {
|
|
1952
1958
|
data.name = nameArray[0];
|
|
1953
|
-
data.machine_name = data.name
|
|
1959
|
+
data.machine_name = toMachineName(data.name);
|
|
1954
1960
|
}
|
|
1955
1961
|
return data;
|
|
1956
1962
|
};
|
|
@@ -1994,13 +2000,11 @@ const getFileDesignTokens = async (fileId, accessToken) => {
|
|
|
1994
2000
|
if (isArray(document.effects) && document.effects.length > 0) {
|
|
1995
2001
|
effectsArray.push({
|
|
1996
2002
|
name,
|
|
2003
|
+
machineName: machine_name,
|
|
1997
2004
|
group,
|
|
1998
|
-
effects: document.effects.filter(effect => isValidEffectType(effect.type)).map(effect => ({
|
|
2005
|
+
effects: document.effects.filter(effect => isValidEffectType(effect.type) && effect.visible).map(effect => ({
|
|
1999
2006
|
type: effect.type,
|
|
2000
|
-
|
|
2001
|
-
color: effect.color,
|
|
2002
|
-
offset: effect.offset,
|
|
2003
|
-
radius: effect.radius
|
|
2007
|
+
value: isShadowEffectType(effect.type) ? transformFigmaEffectToCssBoxShadow(effect) : ''
|
|
2004
2008
|
}))
|
|
2005
2009
|
});
|
|
2006
2010
|
} else if (isArray(document.fills) && document.fills[0] && document.fills[0].type === 'SOLID' && document.fills[0].color) {
|
|
@@ -2011,7 +2015,8 @@ const getFileDesignTokens = async (fileId, accessToken) => {
|
|
|
2011
2015
|
type: 'color',
|
|
2012
2016
|
hex: figmaColorToHex(color),
|
|
2013
2017
|
rgb: color,
|
|
2014
|
-
sass: `$color-${group}-${machine_name}
|
|
2018
|
+
sass: `$color-${group}-${machine_name}`,
|
|
2019
|
+
machineName: machine_name
|
|
2015
2020
|
});
|
|
2016
2021
|
}
|
|
2017
2022
|
}
|
|
@@ -2036,7 +2041,7 @@ const getFileDesignTokens = async (fileId, accessToken) => {
|
|
|
2036
2041
|
});
|
|
2037
2042
|
}
|
|
2038
2043
|
});
|
|
2039
|
-
|
|
2044
|
+
chalk__default["default"].green('Colors, Effects and Typography Exported');
|
|
2040
2045
|
const data = {
|
|
2041
2046
|
color: colorsArray,
|
|
2042
2047
|
effect: effectsArray,
|
|
@@ -4,7 +4,7 @@ require('dotenv/config');
|
|
|
4
4
|
var path = require('path');
|
|
5
5
|
var fs = require('fs-extra');
|
|
6
6
|
var stream = require('node:stream');
|
|
7
|
-
var documentationObject = require('./documentation-object-
|
|
7
|
+
var documentationObject = require('./documentation-object-1ccc37b9.cjs.dev.js');
|
|
8
8
|
var capitalize = require('lodash/capitalize');
|
|
9
9
|
var lodash = require('lodash');
|
|
10
10
|
var Mustache = require('mustache');
|
|
@@ -4789,6 +4789,36 @@ const transformTooltipComponentTokensToScssVariables = ({
|
|
|
4789
4789
|
};
|
|
4790
4790
|
};
|
|
4791
4791
|
|
|
4792
|
+
function transformColors$1(colors) {
|
|
4793
|
+
const stringBuilder = [];
|
|
4794
|
+
colors.forEach(color => {
|
|
4795
|
+
stringBuilder.push(`$color-${color.group}-${color.machineName}: ${color.hex};`);
|
|
4796
|
+
});
|
|
4797
|
+
return stringBuilder.join('\n');
|
|
4798
|
+
}
|
|
4799
|
+
|
|
4800
|
+
function transformEffects$1(effects) {
|
|
4801
|
+
const stringBuilder = [];
|
|
4802
|
+
const validEffects = effects?.filter(effect => effect.effects && effect.effects.length > 0);
|
|
4803
|
+
if (validEffects) {
|
|
4804
|
+
validEffects.forEach(effect => {
|
|
4805
|
+
stringBuilder.push(`$effect-${effect.group}-${effect.machineName}: ${effect.effects.map(effect => effect.value).join(', ') || 'none'};`);
|
|
4806
|
+
});
|
|
4807
|
+
}
|
|
4808
|
+
return stringBuilder.join('\n');
|
|
4809
|
+
}
|
|
4810
|
+
|
|
4811
|
+
function transformTypography$1(typography) {
|
|
4812
|
+
const stringBuilder = [];
|
|
4813
|
+
typography.forEach(type => {
|
|
4814
|
+
stringBuilder.push([`$typography-${getTypeName$1(type)}-font-family: '${type.values.fontFamily}';`, `$typography-${getTypeName$1(type)}-font-size: ${type.values.fontSize}px;`, `$typography-${getTypeName$1(type)}-font-weight: ${type.values.fontWeight};`, `$typography-${getTypeName$1(type)}-line-height: ${(type.values.lineHeightPx / type.values.fontSize).toFixed(1)};`, `$typography-${getTypeName$1(type)}-letter-spacing: ${type.values.letterSpacing}px;`, `$typography-${getTypeName$1(type)}-paragraph-spacing: ${type.values.paragraphSpacing | 20}px;`].join('\n'));
|
|
4815
|
+
});
|
|
4816
|
+
return stringBuilder.join('\n');
|
|
4817
|
+
}
|
|
4818
|
+
function getTypeName$1(type) {
|
|
4819
|
+
return type.group ? `${type.group}-${type.machine_name}` : `${type.machine_name}`;
|
|
4820
|
+
}
|
|
4821
|
+
|
|
4792
4822
|
function scssTransformer(documentationObject) {
|
|
4793
4823
|
const components = {
|
|
4794
4824
|
// Buttons
|
|
@@ -4820,8 +4850,14 @@ ${Object.entries(transformPaginationComponentTokensToScssVariables(pagination)).
|
|
|
4820
4850
|
radios: documentationObject.components.radios.map(radio => `// ${capitalize__default["default"](radio.componentType === 'design' ? '' : radio.size)} pagination${radio.componentType === 'design' ? `, theme: ${capitalize__default["default"](radio.theme)}, state: ${capitalize__default["default"](radio.state)}` : ''}
|
|
4821
4851
|
${Object.entries(transformRadioComponentTokensToScssVariables(radio)).map(([variable, value]) => `${variable}: ${value.value};`).join('\n')}`).join('\n\n')
|
|
4822
4852
|
};
|
|
4853
|
+
const design = {
|
|
4854
|
+
colors: transformColors$1(documentationObject.design.color),
|
|
4855
|
+
typography: transformTypography$1(documentationObject.design.typography),
|
|
4856
|
+
effects: transformEffects$1(documentationObject.design.effect)
|
|
4857
|
+
};
|
|
4823
4858
|
return {
|
|
4824
|
-
components
|
|
4859
|
+
components,
|
|
4860
|
+
design
|
|
4825
4861
|
};
|
|
4826
4862
|
}
|
|
4827
4863
|
|
|
@@ -9324,6 +9360,43 @@ const transformTooltipComponentTokensToCssVariables = ({
|
|
|
9324
9360
|
};
|
|
9325
9361
|
};
|
|
9326
9362
|
|
|
9363
|
+
function transformColors(colors) {
|
|
9364
|
+
const stringBuilder = [];
|
|
9365
|
+
stringBuilder.push(`$color-groups: ( ${Array.from(new Set(colors.map(color => `"${color.group}"`))).join(', ')} );`);
|
|
9366
|
+
stringBuilder.push(`$color-names: ( ${colors.map(color => `"${color.group}-${color.machineName}"`).join(', ')} );`);
|
|
9367
|
+
stringBuilder.push(``);
|
|
9368
|
+
colors.forEach(color => {
|
|
9369
|
+
stringBuilder.push(`--color-${color.group}-${color.machineName}: ${color.hex};`);
|
|
9370
|
+
});
|
|
9371
|
+
return stringBuilder.join('\n');
|
|
9372
|
+
}
|
|
9373
|
+
|
|
9374
|
+
function transformEffects(effects) {
|
|
9375
|
+
const stringBuilder = [];
|
|
9376
|
+
const validEffects = effects?.filter(effect => effect.effects && effect.effects.length > 0);
|
|
9377
|
+
if (validEffects) {
|
|
9378
|
+
stringBuilder.push(`$effects: ( ${validEffects.map(effect => `"${effect.group}-${effect.machineName}"`).join(', ')} );`);
|
|
9379
|
+
stringBuilder.push(``);
|
|
9380
|
+
validEffects.forEach(effect => {
|
|
9381
|
+
stringBuilder.push(`--effect-${effect.group}-${effect.machineName}: ${effect.effects.map(effect => effect.value).join(', ') || 'none'};`);
|
|
9382
|
+
});
|
|
9383
|
+
}
|
|
9384
|
+
return stringBuilder.join('\n');
|
|
9385
|
+
}
|
|
9386
|
+
|
|
9387
|
+
function transformTypography(typography) {
|
|
9388
|
+
const stringBuilder = [];
|
|
9389
|
+
stringBuilder.push(`$type-sizes: ( ${typography.map(type => `"${getTypeName(type)}"`).join(', ')} );`);
|
|
9390
|
+
stringBuilder.push(``);
|
|
9391
|
+
typography.forEach(type => {
|
|
9392
|
+
stringBuilder.push([`--typography-${getTypeName(type)}-font-family: '${type.values.fontFamily}';`, `--typography-${getTypeName(type)}-font-size: ${type.values.fontSize}px;`, `--typography-${getTypeName(type)}-font-weight: ${type.values.fontWeight};`, `--typography-${getTypeName(type)}-line-height: ${(type.values.lineHeightPx / type.values.fontSize).toFixed(1)};`, `--typography-${getTypeName(type)}-letter-spacing: ${type.values.letterSpacing}px;`, `--typography-${getTypeName(type)}-paragraph-spacing: ${type.values.paragraphSpacing | 20}px;`].join('\n'));
|
|
9393
|
+
});
|
|
9394
|
+
return stringBuilder.join('\n');
|
|
9395
|
+
}
|
|
9396
|
+
function getTypeName(type) {
|
|
9397
|
+
return type.group ? `${type.group}-${type.machine_name}` : `${type.machine_name}`;
|
|
9398
|
+
}
|
|
9399
|
+
|
|
9327
9400
|
function cssTransformer(documentationObject) {
|
|
9328
9401
|
const components = {
|
|
9329
9402
|
// Buttons
|
|
@@ -9338,8 +9411,14 @@ function cssTransformer(documentationObject) {
|
|
|
9338
9411
|
tooltips: transformTooltipComponentsToCssVariables(documentationObject.components.tooltips),
|
|
9339
9412
|
radios: transformRadioComponentsToCssVariables(documentationObject.components.radios)
|
|
9340
9413
|
};
|
|
9414
|
+
const design = {
|
|
9415
|
+
colors: transformColors(documentationObject.design.color),
|
|
9416
|
+
typography: transformTypography(documentationObject.design.typography),
|
|
9417
|
+
effects: transformEffects(documentationObject.design.effect)
|
|
9418
|
+
};
|
|
9341
9419
|
return {
|
|
9342
|
-
components
|
|
9420
|
+
components,
|
|
9421
|
+
design
|
|
9343
9422
|
};
|
|
9344
9423
|
}
|
|
9345
9424
|
|
|
@@ -9444,7 +9523,7 @@ const buildPreview = async documentationObject => {
|
|
|
9444
9523
|
const buildStyles = async documentationObject => {
|
|
9445
9524
|
const cssFiles = cssTransformer(documentationObject);
|
|
9446
9525
|
const scssFiles = scssTransformer(documentationObject);
|
|
9447
|
-
await Promise.all([fs__namespace.ensureDir(variablesFilePath).then(() => Promise.all(Object.entries(cssFiles.components).map(([name, content]) => fs__namespace.writeFile(`${variablesFilePath}/${name}.scss`, content)))).then(() => Promise.all(Object.entries(scssFiles.components).map(([name, content]) => fs__namespace.writeFile(`${variablesFilePath}/${name}_vars.scss`, content))))]);
|
|
9526
|
+
await Promise.all([fs__namespace.ensureDir(variablesFilePath).then(() => Promise.all(Object.entries(cssFiles.components).map(([name, content]) => fs__namespace.writeFile(`${variablesFilePath}/${name}.scss`, content)))).then(() => Promise.all(Object.entries(cssFiles.design).map(([name, content]) => fs__namespace.writeFile(`${variablesFilePath}/${name}.scss`, content)))).then(() => Promise.all(Object.entries(scssFiles.components).map(([name, content]) => fs__namespace.writeFile(`${variablesFilePath}/${name}_vars.scss`, content)))).then(() => Promise.all(Object.entries(scssFiles.design).map(([name, content]) => fs__namespace.writeFile(`${variablesFilePath}/${name}_vars.scss`, content))))]);
|
|
9448
9527
|
};
|
|
9449
9528
|
/**
|
|
9450
9529
|
* Run the entire pipeline
|
|
@@ -4,7 +4,7 @@ require('dotenv/config');
|
|
|
4
4
|
var path = require('path');
|
|
5
5
|
var fs = require('fs-extra');
|
|
6
6
|
var stream = require('node:stream');
|
|
7
|
-
var documentationObject = require('./documentation-object-
|
|
7
|
+
var documentationObject = require('./documentation-object-d7872020.cjs.prod.js');
|
|
8
8
|
var capitalize = require('lodash/capitalize');
|
|
9
9
|
var lodash = require('lodash');
|
|
10
10
|
var Mustache = require('mustache');
|
|
@@ -4789,6 +4789,36 @@ const transformTooltipComponentTokensToScssVariables = ({
|
|
|
4789
4789
|
};
|
|
4790
4790
|
};
|
|
4791
4791
|
|
|
4792
|
+
function transformColors$1(colors) {
|
|
4793
|
+
const stringBuilder = [];
|
|
4794
|
+
colors.forEach(color => {
|
|
4795
|
+
stringBuilder.push(`$color-${color.group}-${color.machineName}: ${color.hex};`);
|
|
4796
|
+
});
|
|
4797
|
+
return stringBuilder.join('\n');
|
|
4798
|
+
}
|
|
4799
|
+
|
|
4800
|
+
function transformEffects$1(effects) {
|
|
4801
|
+
const stringBuilder = [];
|
|
4802
|
+
const validEffects = effects?.filter(effect => effect.effects && effect.effects.length > 0);
|
|
4803
|
+
if (validEffects) {
|
|
4804
|
+
validEffects.forEach(effect => {
|
|
4805
|
+
stringBuilder.push(`$effect-${effect.group}-${effect.machineName}: ${effect.effects.map(effect => effect.value).join(', ') || 'none'};`);
|
|
4806
|
+
});
|
|
4807
|
+
}
|
|
4808
|
+
return stringBuilder.join('\n');
|
|
4809
|
+
}
|
|
4810
|
+
|
|
4811
|
+
function transformTypography$1(typography) {
|
|
4812
|
+
const stringBuilder = [];
|
|
4813
|
+
typography.forEach(type => {
|
|
4814
|
+
stringBuilder.push([`$typography-${getTypeName$1(type)}-font-family: '${type.values.fontFamily}';`, `$typography-${getTypeName$1(type)}-font-size: ${type.values.fontSize}px;`, `$typography-${getTypeName$1(type)}-font-weight: ${type.values.fontWeight};`, `$typography-${getTypeName$1(type)}-line-height: ${(type.values.lineHeightPx / type.values.fontSize).toFixed(1)};`, `$typography-${getTypeName$1(type)}-letter-spacing: ${type.values.letterSpacing}px;`, `$typography-${getTypeName$1(type)}-paragraph-spacing: ${type.values.paragraphSpacing | 20}px;`].join('\n'));
|
|
4815
|
+
});
|
|
4816
|
+
return stringBuilder.join('\n');
|
|
4817
|
+
}
|
|
4818
|
+
function getTypeName$1(type) {
|
|
4819
|
+
return type.group ? `${type.group}-${type.machine_name}` : `${type.machine_name}`;
|
|
4820
|
+
}
|
|
4821
|
+
|
|
4792
4822
|
function scssTransformer(documentationObject) {
|
|
4793
4823
|
const components = {
|
|
4794
4824
|
// Buttons
|
|
@@ -4820,8 +4850,14 @@ ${Object.entries(transformPaginationComponentTokensToScssVariables(pagination)).
|
|
|
4820
4850
|
radios: documentationObject.components.radios.map(radio => `// ${capitalize__default["default"](radio.componentType === 'design' ? '' : radio.size)} pagination${radio.componentType === 'design' ? `, theme: ${capitalize__default["default"](radio.theme)}, state: ${capitalize__default["default"](radio.state)}` : ''}
|
|
4821
4851
|
${Object.entries(transformRadioComponentTokensToScssVariables(radio)).map(([variable, value]) => `${variable}: ${value.value};`).join('\n')}`).join('\n\n')
|
|
4822
4852
|
};
|
|
4853
|
+
const design = {
|
|
4854
|
+
colors: transformColors$1(documentationObject.design.color),
|
|
4855
|
+
typography: transformTypography$1(documentationObject.design.typography),
|
|
4856
|
+
effects: transformEffects$1(documentationObject.design.effect)
|
|
4857
|
+
};
|
|
4823
4858
|
return {
|
|
4824
|
-
components
|
|
4859
|
+
components,
|
|
4860
|
+
design
|
|
4825
4861
|
};
|
|
4826
4862
|
}
|
|
4827
4863
|
|
|
@@ -9324,6 +9360,43 @@ const transformTooltipComponentTokensToCssVariables = ({
|
|
|
9324
9360
|
};
|
|
9325
9361
|
};
|
|
9326
9362
|
|
|
9363
|
+
function transformColors(colors) {
|
|
9364
|
+
const stringBuilder = [];
|
|
9365
|
+
stringBuilder.push(`$color-groups: ( ${Array.from(new Set(colors.map(color => `"${color.group}"`))).join(', ')} );`);
|
|
9366
|
+
stringBuilder.push(`$color-names: ( ${colors.map(color => `"${color.group}-${color.machineName}"`).join(', ')} );`);
|
|
9367
|
+
stringBuilder.push(``);
|
|
9368
|
+
colors.forEach(color => {
|
|
9369
|
+
stringBuilder.push(`--color-${color.group}-${color.machineName}: ${color.hex};`);
|
|
9370
|
+
});
|
|
9371
|
+
return stringBuilder.join('\n');
|
|
9372
|
+
}
|
|
9373
|
+
|
|
9374
|
+
function transformEffects(effects) {
|
|
9375
|
+
const stringBuilder = [];
|
|
9376
|
+
const validEffects = effects?.filter(effect => effect.effects && effect.effects.length > 0);
|
|
9377
|
+
if (validEffects) {
|
|
9378
|
+
stringBuilder.push(`$effects: ( ${validEffects.map(effect => `"${effect.group}-${effect.machineName}"`).join(', ')} );`);
|
|
9379
|
+
stringBuilder.push(``);
|
|
9380
|
+
validEffects.forEach(effect => {
|
|
9381
|
+
stringBuilder.push(`--effect-${effect.group}-${effect.machineName}: ${effect.effects.map(effect => effect.value).join(', ') || 'none'};`);
|
|
9382
|
+
});
|
|
9383
|
+
}
|
|
9384
|
+
return stringBuilder.join('\n');
|
|
9385
|
+
}
|
|
9386
|
+
|
|
9387
|
+
function transformTypography(typography) {
|
|
9388
|
+
const stringBuilder = [];
|
|
9389
|
+
stringBuilder.push(`$type-sizes: ( ${typography.map(type => `"${getTypeName(type)}"`).join(', ')} );`);
|
|
9390
|
+
stringBuilder.push(``);
|
|
9391
|
+
typography.forEach(type => {
|
|
9392
|
+
stringBuilder.push([`--typography-${getTypeName(type)}-font-family: '${type.values.fontFamily}';`, `--typography-${getTypeName(type)}-font-size: ${type.values.fontSize}px;`, `--typography-${getTypeName(type)}-font-weight: ${type.values.fontWeight};`, `--typography-${getTypeName(type)}-line-height: ${(type.values.lineHeightPx / type.values.fontSize).toFixed(1)};`, `--typography-${getTypeName(type)}-letter-spacing: ${type.values.letterSpacing}px;`, `--typography-${getTypeName(type)}-paragraph-spacing: ${type.values.paragraphSpacing | 20}px;`].join('\n'));
|
|
9393
|
+
});
|
|
9394
|
+
return stringBuilder.join('\n');
|
|
9395
|
+
}
|
|
9396
|
+
function getTypeName(type) {
|
|
9397
|
+
return type.group ? `${type.group}-${type.machine_name}` : `${type.machine_name}`;
|
|
9398
|
+
}
|
|
9399
|
+
|
|
9327
9400
|
function cssTransformer(documentationObject) {
|
|
9328
9401
|
const components = {
|
|
9329
9402
|
// Buttons
|
|
@@ -9338,8 +9411,14 @@ function cssTransformer(documentationObject) {
|
|
|
9338
9411
|
tooltips: transformTooltipComponentsToCssVariables(documentationObject.components.tooltips),
|
|
9339
9412
|
radios: transformRadioComponentsToCssVariables(documentationObject.components.radios)
|
|
9340
9413
|
};
|
|
9414
|
+
const design = {
|
|
9415
|
+
colors: transformColors(documentationObject.design.color),
|
|
9416
|
+
typography: transformTypography(documentationObject.design.typography),
|
|
9417
|
+
effects: transformEffects(documentationObject.design.effect)
|
|
9418
|
+
};
|
|
9341
9419
|
return {
|
|
9342
|
-
components
|
|
9420
|
+
components,
|
|
9421
|
+
design
|
|
9343
9422
|
};
|
|
9344
9423
|
}
|
|
9345
9424
|
|
|
@@ -9444,7 +9523,7 @@ const buildPreview = async documentationObject => {
|
|
|
9444
9523
|
const buildStyles = async documentationObject => {
|
|
9445
9524
|
const cssFiles = cssTransformer(documentationObject);
|
|
9446
9525
|
const scssFiles = scssTransformer(documentationObject);
|
|
9447
|
-
await Promise.all([fs__namespace.ensureDir(variablesFilePath).then(() => Promise.all(Object.entries(cssFiles.components).map(([name, content]) => fs__namespace.writeFile(`${variablesFilePath}/${name}.scss`, content)))).then(() => Promise.all(Object.entries(scssFiles.components).map(([name, content]) => fs__namespace.writeFile(`${variablesFilePath}/${name}_vars.scss`, content))))]);
|
|
9526
|
+
await Promise.all([fs__namespace.ensureDir(variablesFilePath).then(() => Promise.all(Object.entries(cssFiles.components).map(([name, content]) => fs__namespace.writeFile(`${variablesFilePath}/${name}.scss`, content)))).then(() => Promise.all(Object.entries(cssFiles.design).map(([name, content]) => fs__namespace.writeFile(`${variablesFilePath}/${name}.scss`, content)))).then(() => Promise.all(Object.entries(scssFiles.components).map(([name, content]) => fs__namespace.writeFile(`${variablesFilePath}/${name}_vars.scss`, content)))).then(() => Promise.all(Object.entries(scssFiles.design).map(([name, content]) => fs__namespace.writeFile(`${variablesFilePath}/${name}_vars.scss`, content))))]);
|
|
9448
9527
|
};
|
|
9449
9528
|
/**
|
|
9450
9529
|
* Run the entire pipeline
|
|
@@ -73,8 +73,12 @@ export const isValidTheme = (theme: string): theme is 'light' | 'dark' => {
|
|
|
73
73
|
return ['light', 'dark'].includes(theme);
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
export const isValidEffectType = (effect:
|
|
77
|
-
return
|
|
76
|
+
export const isValidEffectType = (effect: FigmaTypes.Effect['type']): boolean => {
|
|
77
|
+
return isShadowEffectType(effect);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const isShadowEffectType = (effect: FigmaTypes.Effect['type']): boolean => {
|
|
81
|
+
return ['DROP_SHADOW', 'INNER_SHADOW'].includes(effect);
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
export const normalizeNamePart = (namePart: string) => {
|