Skip to content

Commit

Permalink
fix: Fix colors with opacity
Browse files Browse the repository at this point in the history
  • Loading branch information
RayRedGoose committed Apr 18, 2024
1 parent 06af676 commit 620bf1b
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 3 deletions.
39 changes: 39 additions & 0 deletions packages/canvas-tokens-docs/stories/system/ColorShadow.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {Meta, Unstyled} from '@storybook/blocks';

import {ShadowColors} from './examples/Color/Shadow';

<Meta title="Docs/System Tokens/Color/Shadow" />

<Unstyled>

# System Shadow Color Tokens

System shadow color tokens provide values for box shadow.

## Usage

```ts
// styles.ts
import {system} from '@workday/canvas-tokens-web';

const styles = {
boxShadow: `0 0 0 var(${system.color.shadow['1']})`,
};
```

```css
// styles.css
.card-text {
boxshadow: 0 0 0 var(--cnvs-sys-color-shadow-1);
}
```

---

## Tokens

<ShadowColors />

---

</Unstyled>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as React from 'react';
import {system} from '@workday/canvas-tokens-web';

import {
buildPaletteGroup,
ColorGrid,
sortSystemColorPalette,
} from '../../../../components/ColorGrid';

const statusPalettes = buildPaletteGroup(
'system.color.shadow',
{
default: system.color.shadow.default,
'1': system.color.shadow['1'],
'2': system.color.shadow['2'],
},
sortSystemColorPalette
);

export const ShadowColors = () => <ColorGrid name="Text Status Colors" palette={statusPalettes} />;
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import {
BackgroundColors,
BackgroundAlternateColors,
BackgroundMutedColors,
BackgroundContrastColors,
BackgroundStatusColors,
} from '../examples/Color/Background';
import {
BorderColors,
BorderContrastColors,
BorderInputColors,
BorderStatusColors,
} from '../examples/Color/Border';
import {ForegroundColors, ForegroundStatusColors} from '../examples/Color/Foreground';
import {IconColors, IconPrimaryColors, IconStatusColors} from '../examples/Color/Icon';
import {ShadowColors} from '../examples/Color/Shadow';
import {StaticColors} from '../examples/Color/Static';
import {TextColors, TextStatusColors} from '../examples/Color/Text';

export default {
title: 'Visual Tests/System Tokens/Colors',
parameters: {
chromatic: {disableSnapshot: false},
},
};

// BACKGROUND COLORS TESTS
export const Background = {
render: BackgroundColors,
};

export const BackgroundAlternate = {
render: BackgroundAlternateColors,
};

export const BackgroundMuted = {
render: BackgroundMutedColors,
};

export const BackgroundContrast = {
render: BackgroundContrastColors,
};

export const BackgroundStatus = {
render: BackgroundStatusColors,
};

// BORDER COLORS TESTS
export const Border = {
render: BorderColors,
};
export const BorderContrast = {
render: BorderContrastColors,
};
export const BorderInput = {
render: BorderInputColors,
};
export const BorderStatus = {
render: BorderStatusColors,
};

// FOREGROUND COLORS TESTS

export const Foreground = {
render: ForegroundColors,
};
export const ForegroundStatus = {
render: ForegroundStatusColors,
};

// ICON COLORS TESTS

export const Icon = {
render: IconColors,
};
export const IconPrimary = {
render: IconPrimaryColors,
};
export const IconStatus = {
render: IconStatusColors,
};

// SHADOW COLORS TESTS
export const Shadow = {
render: ShadowColors,
};

// STATIC COLORS TESTS
export const Static = {
render: StaticColors,
};

// TEXT COLORS TESTS
export const Text = {
render: TextColors,
};

export const TextStatus = {
render: TextStatusColors,
};
6 changes: 3 additions & 3 deletions packages/canvas-tokens/tokens/web/sys.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"description": "Main background color\n"
},
"transparent": {
"value": "rgba({palette.french-vanilla.100}, 0)",
"value": "rgba({palette.french-vanilla.100},0)",
"type": "color",
"description": "Transparent background"
},
Expand All @@ -18,7 +18,7 @@
"description": "Overlay background"
},
"translucent": {
"value": "rgba({palette.black-pepper.600} ,{opacity.500})",
"value": "rgba({palette.black-pepper.600},{opacity.500})",
"type": "color",
"description": "Tooltip, Status Indicator"
},
Expand Down Expand Up @@ -448,7 +448,7 @@
}
},
"transparent": {
"value": "rgba({color.static.white}, 0%)",
"value": "rgba({color.static.white},0)",
"type": "color",
"description": "Transparent"
},
Expand Down
6 changes: 6 additions & 0 deletions packages/canvas-tokens/utils/tokenStudioParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ const mapObjectContent = (fn: (token: DesignToken) => DesignToken, obj: DesignTo

const transformExtensions = (token: DesignToken) => {
if (token['$extensions']) {
const {modify} = token['$extensions']['studio.tokens'];

if (modify && modify.type === 'alpha') {
token.value = `rgba(${token.value},${modify.value})`;
}

delete token['$extensions'];
}
};

0 comments on commit 620bf1b

Please sign in to comment.