Skip to content

Commit

Permalink
write 0 length values as 0 (without px suffix)
Browse files Browse the repository at this point in the history
  • Loading branch information
gossi committed May 27, 2020
1 parent d285252 commit fa81881
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/tools/style-dictionary/writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ export default class StyleDictionaryWriter {
const shadows = [];
for (const shadow of token.shadows) {
shadows.push(
`${shadow.inner ? 'inset ' : ''}${shadow.x} ${shadow.y} ${
`${shadow.inner ? 'inset ' : ''}${this.getLength(
shadow.x
)} ${this.getLength(shadow.y)} ${this.getLength(
shadow.radius
} ${this.getColor(shadow.color)}`
)} ${this.getColor(shadow.color)}`
);
}

Expand All @@ -88,6 +90,10 @@ export default class StyleDictionaryWriter {
return token.value ?? '';
}

private getLength(value: number): string {
return value === 0 ? '0' : `${value}px`;
}

private getColor(color: TokenColor): string {
if (color.visible === false) {
return 'transparent';
Expand Down

0 comments on commit fa81881

Please sign in to comment.