Skip to content

Commit

Permalink
merged main and fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann committed Jun 29, 2022
1 parent 1909d80 commit efbf128
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/extractor/extractColors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const transparentFill: fillValuesType = {
fill: {
value: { r: 0, g: 0, b: 0, a: 0 },
type: 'color',
blendMode: 'NORMAL'
blendMode: 'normal'
}
}

Expand Down Expand Up @@ -61,7 +61,7 @@ const extractFills = (paint): fillValuesType | gradientValuesType => {
fill: {
value: convertPaintToRgba(paint),
type: 'color' as PropertyType,
blendMode: paint.blendMode.toLowerCase()
blendMode: paint.blendMode?.toLowerCase() || 'normal'
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/transformer/standardTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ const fillValueTransformer = (token): StandardTokenDataInterface | StandardToken
if (token.extensions && token.extensions[config.key.extensionPluginData] && token.extensions[config.key.extensionPluginData].alias) {
return {
type: Object.hasOwnProperty.call(token.values[0], 'fill') ? 'color' : 'custom-gradient',
value: `{${token.extensions[config.key.extensionPluginData].alias}}`
value: `{${token.extensions[config.key.extensionPluginData].alias}}`,
blendMode: token.values[0]?.fill?.blendMode?.toLowerCase() || 'normal'
}
}
// no alias, use value
Expand Down
1 change: 1 addition & 0 deletions tests/integration/data/original.variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
--color-colors-ref-blue: #044aff; /* Some other description */
--color-colors-special-characters: #40df50; /* Emoji */
--color-colors-special-characters-nderung: #3456af;
--color-invalid-empty: rgba(0, 0, 0, 0);
--grid-multiple-0-pattern: columns;
--grid-multiple-0-section-size: 1;
--grid-multiple-0-gutter-size: 20;
Expand Down
1 change: 1 addition & 0 deletions tests/integration/data/standard.variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
--color-colors-ref-blue: rgb(4, 74, 255); /* Some other description */
--color-colors-special-characters: rgb(64, 223, 80); /* Emoji */
--color-colors-special-characters-nderung: rgb(52, 86, 175);
--color-invalid-empty: rgba(0, 0, 0, 0);
--grid-multiple-0: [object Object];
--grid-multiple-1: [object Object];
--grid-multiple-2: [object Object];
Expand Down
16 changes: 11 additions & 5 deletions tests/unit/data/extractedFigmaTokens.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,8 @@ export const extractedFigmaTokens = {
{
fill: {
value: { r: 255, g: 230, b: 0, a: 1 },
type: 'color'
type: 'color',
blendMode: 'NORMAL'
}
}
],
Expand All @@ -594,6 +595,7 @@ export const extractedFigmaTokens = {
category: 'color' as tokenCategoryType,
exportKey: 'color' as tokenExportKeyType,
description: 'a color token',
blendMode: 'NORMAL',
values: [
{
fill: {
Expand All @@ -618,13 +620,15 @@ export const extractedFigmaTokens = {
{
fill: {
value: { r: 255, g: 230, b: 0, a: 1 },
type: 'color'
type: 'color',
blendMode: 'NORMAL'
}
},
{
fill: {
value: { r: 0, g: 100, b: 255, a: 0.5 },
type: 'color'
type: 'color',
blendMode: 'NORMAL'
}
}
],
Expand Down Expand Up @@ -730,7 +734,8 @@ export const extractedFigmaTokens = {
{
fill: {
value: { r: 0, g: 100, b: 255, a: 0.5 },
type: 'color'
type: 'color',
blendMode: 'normal'
}
}
],
Expand All @@ -749,7 +754,8 @@ export const extractedFigmaTokens = {
{
fill: {
value: { r: 255, g: 230, b: 0, a: 1 },
type: 'color'
type: 'color',
blendMode: 'normal'
}
},
{
Expand Down
14 changes: 10 additions & 4 deletions tests/unit/data/transformedStandardTokens.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ export const transformedStandardTokens = {
description: 'a color token',
type: 'color',
value: '#ffe600ff',
blendMode: 'normal',
extensions: {
'org.lukasoppermann.figmaDesignTokens': {
exportKey: 'color'
Expand All @@ -343,6 +344,7 @@ export const transformedStandardTokens = {
description: 'a color token',
type: 'color',
value: '{{color}}',
blendMode: 'normal',
extensions: {
'org.lukasoppermann.figmaDesignTokens': {
exportKey: 'color',
Expand All @@ -360,11 +362,13 @@ export const transformedStandardTokens = {
description: 'a multi color token',
0: {
type: 'color',
value: '#ffe600ff'
value: '#ffe600ff',
blendMode: 'normal'
},
1: {
type: 'color',
value: '#0064ff80'
value: '#0064ff80',
blendMode: 'normal'
}
},
/**
Expand Down Expand Up @@ -394,7 +398,8 @@ export const transformedStandardTokens = {
},
1: {
value: '#0064ff80',
type: 'color'
type: 'color',
blendMode: 'normal'
}
},
colorAndGradient: {
Expand All @@ -407,7 +412,8 @@ export const transformedStandardTokens = {
description: 'a color and gradient token',
0: {
value: '#ffe600ff',
type: 'color'
type: 'color',
blendMode: 'normal'
},
1: {
type: 'custom-gradient',
Expand Down
24 changes: 16 additions & 8 deletions tests/unit/extractColors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ describe('extracting color fills', () => {
b: 186,
g: 26,
r: 255
}
},
blendMode: 'normal'
}
}]
},
Expand All @@ -47,7 +48,8 @@ describe('extracting color fills', () => {
b: 186,
g: 26,
r: 255
}
},
blendMode: 'normal'
}
}]
},
Expand All @@ -70,7 +72,8 @@ describe('extracting color fills', () => {
b: 0,
g: 0,
r: 0
}
},
blendMode: 'normal'
}
}]
},
Expand All @@ -93,7 +96,8 @@ describe('extracting color fills', () => {
b: 255,
g: 255,
r: 255
}
},
blendMode: 'normal'
}
}]
},
Expand All @@ -116,7 +120,8 @@ describe('extracting color fills', () => {
b: 186,
g: 26,
r: 255
}
},
blendMode: 'normal'
}
}, {
gradientType: {
Expand Down Expand Up @@ -234,7 +239,8 @@ describe('extracting color fills', () => {
b: 230,
g: 128,
r: 51
}
},
blendMode: 'normal'
}
}
]
Expand Down Expand Up @@ -262,7 +268,8 @@ describe('extracting color fills', () => {
b: 186,
g: 26,
r: 255
}
},
blendMode: 'normal'
}
}]
},
Expand All @@ -286,7 +293,8 @@ describe('extracting color fills', () => {
b: 186,
g: 26,
r: 255
}
},
blendMode: 'normal'
}
}]
}
Expand Down
2 changes: 1 addition & 1 deletion types/valueTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export type ColorRgba = {
a: number
}

export type BlendType = 'NORMAL' | 'DARKEN' | 'MULTIPLY' | 'COLOR_BURN' | 'LIGHTEN' | 'SCREEN' | 'COLOR_DODGE' | 'OVERLAY' | 'SOFT_LIGHT' | 'HARD_LIGHT' | 'DIFFERENCE' | 'EXCLUSION' | 'HUE' | 'SATURATION' | 'COLOR' | 'LUMINOSITY'
export type BlendType = 'normal' | 'darken' | 'multiply' | 'color_burn' | 'lighten' | 'screen' | 'color_dodge' | 'overlay' | 'soft_light' | 'hard_light' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'color' | 'luminosity'

export type GradientType = 'linear' | 'radial' | 'angular' | 'diamond'

Expand Down

0 comments on commit efbf128

Please sign in to comment.