Skip to content

Commit

Permalink
fix schema
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann committed Dec 13, 2024
1 parent 0e18c9e commit 4d5e6f9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
12 changes: 8 additions & 4 deletions scripts/validateTokenJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,19 @@ if (getFlag('--silent') === null) {
console.log('++++++++++++++++++++++++++++++')
// eslint-disable-next-line no-console
console.log(`\u001b[36;1m\u001b[1m${fail.fileName}\u001b[0m`)

console.log(fail.errorsByPath['diffBlob'])

Check failure on line 67 in scripts/validateTokenJson.ts

View workflow job for this annotation

GitHub Actions / Test & Lint

Unexpected console statement
for (const path of Object.keys(fail.errorsByPath)) {
// eslint-disable-next-line no-console
console.log(`\nPath: \u001b[34;1m\u001b[1m${path}\u001b[0m`)
// eslint-disable-next-line no-console

fail.errorsByPath[path].forEach(({message, code, unionErrors}) => {

Check failure on line 72 in scripts/validateTokenJson.ts

View workflow job for this annotation

GitHub Actions / Test & Lint

Prefer for...of instead of Array.forEach

Check failure on line 72 in scripts/validateTokenJson.ts

View workflow job for this annotation

GitHub Actions / Test & Lint

'message' is defined but never used. Allowed unused args must match /^_/u

Check failure on line 72 in scripts/validateTokenJson.ts

View workflow job for this annotation

GitHub Actions / Test & Lint

'code' is defined but never used. Allowed unused args must match /^_/u
console.log(unionErrors)

Check failure on line 73 in scripts/validateTokenJson.ts

View workflow job for this annotation

GitHub Actions / Test & Lint

Unexpected console statement
})
console.log(

Check failure on line 75 in scripts/validateTokenJson.ts

View workflow job for this annotation

GitHub Actions / Test & Lint

Unexpected console statement
fail.errorsByPath[path]
.map(({message}) =>
message.replace(/\*\*(.*?)\*\*/g, '- \u001b[31;1m\u001b[1m$1\u001b[0m').replace(/\n(?!-)/g, '\n ↳ '),
.map(
({message, code}) =>
`${message.replace(/\*\*(.*?)\*\*/g, '- \u001b[31;1m\u001b[1m$1\u001b[0m').replace(/\n(?!-)/g, '\n ↳ ')}, code: ${code}`,
)
.join('\n'),
'\n',
Expand Down
30 changes: 17 additions & 13 deletions src/schemas/colorToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ import {collection, mode} from './collections.js'
import {scopes} from './scopes.js'
import {tokenType} from './tokenType.js'

export const colorToken = baseToken
const baseColorToken = baseToken.extend({
$value: z.union([colorHexValue, referenceValue]),
alpha: alphaValue.optional().nullable(),
})

const override = z.union([colorHexValue, referenceValue, baseColorToken.partial()]).optional()

export const colorToken = baseColorToken
.extend({
$value: z.union([colorHexValue, referenceValue]),
$type: tokenType('color'),
alpha: alphaValue.optional().nullable(),
$extensions: z
.object({
'org.primer.figma': z
Expand Down Expand Up @@ -43,15 +48,15 @@ export const colorToken = baseToken
'org.primer.overrides': z
.object(
{
light: z.union([colorHexValue, referenceValue]).optional(),
'light-tritanopia': z.union([colorHexValue, referenceValue]).optional(),
'light-deutranopia-protanopia': z.union([colorHexValue, referenceValue]).optional(),
'light-high-contrast': z.union([colorHexValue, referenceValue]).optional(),
dark: z.union([colorHexValue, referenceValue]).optional(),
'dark-tritanopia': z.union([colorHexValue, referenceValue]).optional(),
'dark-deutranopia-protanopia': z.union([colorHexValue, referenceValue]).optional(),
'dark-high-contrast': z.union([colorHexValue, referenceValue]).optional(),
'dark-dimmed': z.union([colorHexValue, referenceValue]).optional(),
light: override,
'light-tritanopia': override,
'light-deutranopia-protanopia': override,
'light-high-contrast': override,
dark: override,
'dark-tritanopia': override,
'dark-deutranopia-protanopia': override,
'dark-high-contrast': override,
'dark-dimmed': override,
},
{
errorMap: e => {
Expand All @@ -64,7 +69,6 @@ export const colorToken = baseToken
},
},
)
.strict()
.optional(),
})
.strict()
Expand Down
6 changes: 0 additions & 6 deletions src/tokens/component/diffBlob.json5
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
$value: '{bgColor.success.muted}',
alpha: 0.2,
},
'light-protanopia-deuteranopia': {},
'light-tritanopia': {},
'light-high-contrast': {},
'dark-protanopia-deuteranopia': {},
'dark-tritanopia': {},
dark: {
alpha: 0.15,
},
Expand Down Expand Up @@ -192,7 +187,6 @@
'light-tritanopia': '{base.color.red.1}',
'light-high-contrast': '{base.color.red.5}',
'dark-high-contrast': '{bgColor.danger.emphasis}',
'dark-protanopia-deuteranopia': {},
dark: {
$value: '{base.color.red.4}',
alpha: 0.4,
Expand Down
2 changes: 1 addition & 1 deletion src/transformers/colorAlphaToCss.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Transform, TransformedToken} from 'style-dictionary/types'
import type {Transform, TransformedToken} from 'style-dictionary/types'
import {isColorWithAlpha} from '../filters/isColorWithAlpha.js'
import {getTokenValue} from './utilities/getTokenValue.js'

Expand Down

0 comments on commit 4d5e6f9

Please sign in to comment.