Skip to content

Commit

Permalink
removing mix
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann committed Dec 12, 2024
1 parent faa6588 commit bd89c37
Show file tree
Hide file tree
Showing 34 changed files with 285 additions and 631 deletions.
21 changes: 0 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,6 @@ You can create color tokens that inherit a color but have a different alpha valu
}
```

#### Mix

In rare cases, you may need to create a color between two steps in the color scale, e.g. between `gray.4` and `gray.5`. A common example are interactive states, like `hover` where a full step on the color scale would be to much. For those cases you can use the `mix` property.

The `mix` proeprty mixes the color it gets into the main color from the `$value` attribute. The amount added is controlled by the `weight`. A weight of `0.1` adds 10% of the color, and a weight of `0.75` adds 75%.

A `mix` proprty must always have a `color` and a `weight` child. `color` can be a `hex` value or a reference to a valid color. The `weight` property must receive a value between `0.0` and `1`.

```json5
{
control: {
$value: '{base.color.gray.4}', // main color
$type: 'color',
mix: {
color: '{base.color.gray.5}', // color to mix into the main color
weight: 0.2, // amount of the mix color that is added === 20% of gray.5 is mix into gray.4
},
},
}
```

#### Extensions property

According to the [w3c design token specs](https://design-tokens.github.io/community-group/format/#design-token), the [`$extensions`](https://design-tokens.github.io/community-group/format/#extensions) property is used for additional meta data.
Expand Down
4 changes: 0 additions & 4 deletions integration/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ describe('PrimerStyleDictionary', async () => {
transforms: [
'name/pathToKebabCase',
'color/hex',
'color/hexMix',
'dimension/rem',
'duration/css',
'shadow/css',
Expand All @@ -40,7 +39,6 @@ describe('PrimerStyleDictionary', async () => {
usesDtcg: true,
transforms: [
'color/hex',
'color/hexMix',
'dimension/rem',
'shadow/css',
'border/css',
Expand All @@ -65,7 +63,6 @@ describe('PrimerStyleDictionary', async () => {
buildPath: `${buildPath}/js/`,
transforms: [
'color/hex',
'color/hexMix',
'dimension/rem',
'shadow/css',
'border/css',
Expand Down Expand Up @@ -112,7 +109,6 @@ describe('PrimerStyleDictionary', async () => {
buildPath: `${buildPath}/json/`,
transforms: [
'color/hex',
'color/hexMix',
'dimension/rem',
'shadow/css',
'border/css',
Expand Down
2 changes: 1 addition & 1 deletion scripts/diffTokenProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type DiffItem = {

const isToken = (obj: Record<string, unknown>): boolean => Object.prototype.hasOwnProperty.call(obj, '$value')

const diffProps = (diffArray: DiffItem[], propsToCheck = ['mix', 'alpha']) => {
const diffProps = (diffArray: DiffItem[], propsToCheck = ['alpha']) => {
const diff = []
// iterate over each theme
for (const {mainThemeName, mainThemeDir, mainFiles, overridesDir} of diffArray) {
Expand Down
1 change: 0 additions & 1 deletion src/filters/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export {isBorder} from './isBorder.js'
export {isColor} from './isColor.js'
export {isColorWithAlpha} from './isColorWithAlpha.js'
export {isColorWithMix} from './isColorWithMix.js'
export {isDimension} from './isDimension.js'
export {isDeprecated} from './isDeprecated.js'
export {isDuration} from './isDuration.js'
Expand Down
108 changes: 0 additions & 108 deletions src/filters/isColorWithMix.test.ts

This file was deleted.

33 changes: 0 additions & 33 deletions src/filters/isColorWithMix.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/formats/jsonFigma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const jsonFigma: FormatFn = async ({dictionary, file: _file, platform}: F
// loop through tokens sorted by reference
for (const token of sortedTokens) {
// deconstruct token
const {attributes, $value: value, $type, $description: description, original, alpha, mix} = token
const {attributes, $value: value, $type, $description: description, original, alpha} = token
const {mode, collection, scopes, group, codeSyntax} = attributes || {}
// early escape if no type is present
if (!$type) return
Expand Down Expand Up @@ -115,7 +115,6 @@ export const jsonFigma: FormatFn = async ({dictionary, file: _file, platform}: F
value,
type: getFigmaType($type),
alpha,
isMix: mix ? true : undefined,
description,
refId: [collection, token.name].filter(Boolean).join('/'),
reference: getReference(dictionary, original.$value, platform),
Expand Down
1 change: 0 additions & 1 deletion src/platforms/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const css: PlatformInitializer = (outputFile, prefix, buildPath, options)
transforms: [
'name/pathToKebabCase',
'color/hex',
'color/hexMix',
'cubicBezier/css',
'dimension/rem',
'duration/css',
Expand Down
1 change: 0 additions & 1 deletion src/platforms/docJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const docJson: PlatformInitializer = (outputFile, prefix, buildPath, opti
transforms: [
'name/pathToKebabCase',
'color/hex',
'color/hexMix',
'dimension/rem',
'shadow/css',
'border/css',
Expand Down
1 change: 0 additions & 1 deletion src/platforms/fallbacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const fallbacks: PlatformInitializer = (outputFile, prefix, buildPath): P
transforms: [
'name/pathToKebabCase',
'color/hex',
'color/hexMix',
'dimension/rem',
'shadow/css',
'border/css',
Expand Down
1 change: 0 additions & 1 deletion src/platforms/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const javascript: PlatformInitializer = (outputFile, prefix, buildPath, o
preprocessors: ['themeOverrides'],
transforms: [
'color/hex',
'color/hexMix',
'dimension/rem',
'shadow/css',
'border/css',
Expand Down
1 change: 0 additions & 1 deletion src/platforms/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const json: PlatformInitializer = (outputFile, prefix, buildPath, options
preprocessors: ['themeOverrides'],
transforms: [
'color/hex',
'color/hexMix',
'dimension/rem',
'shadow/css',
'border/css',
Expand Down
1 change: 0 additions & 1 deletion src/platforms/styleLint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const styleLint: PlatformInitializer = (outputFile, prefix, buildPath, op
transforms: [
'name/pathToKebabCase',
'color/hex',
'color/hexMix',
'dimension/remPxArray',
'shadow/css',
'border/css',
Expand Down
1 change: 0 additions & 1 deletion src/platforms/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const typescript: PlatformInitializer = (outputFile, prefix, buildPath, o
preprocessors: ['themeOverrides'],
transforms: [
'color/hex',
'color/hexMix',
'dimension/rem',
'shadow/css',
'border/css',
Expand Down
3 changes: 0 additions & 3 deletions src/primerStyleDictionary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
borderToCss,
colorToRgbAlpha,
colorToHex,
colorToHexMix,
colorToRgbaFloat,
cubicBezierToCss,
dimensionToRem,
Expand Down Expand Up @@ -109,8 +108,6 @@ PrimerStyleDictionary.registerTransform(colorToRgbAlpha)

PrimerStyleDictionary.registerTransform(colorToRgbaFloat)

PrimerStyleDictionary.registerTransform(colorToHexMix)

PrimerStyleDictionary.registerTransform(colorToHex)

PrimerStyleDictionary.registerTransform(cubicBezierToCss)
Expand Down
7 changes: 0 additions & 7 deletions src/schemas/colorToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ export const colorToken = baseToken
$value: z.union([colorHexValue, referenceValue]),
$type: tokenType('color'),
alpha: alphaValue.optional().nullable(),
mix: z
.object({
color: z.string(),
weight: z.number().min(0).max(1),
})
.nullable()
.optional(),
$extensions: z
.object({
alpha: z.number().min(0).max(1).optional().nullable(),
Expand Down
2 changes: 0 additions & 2 deletions src/tokens/functional/color/dark/app-dark.json5
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
},
},
alpha: 0.15,
mix: null,
},
},
additionWord: {
Expand Down Expand Up @@ -153,7 +152,6 @@
scopes: ['bgColor'],
},
},
mix: null,
},
},
deletionWord: {
Expand Down
Loading

0 comments on commit bd89c37

Please sign in to comment.