Skip to content

Commit 301051a

Browse files
authored
Merge branch 'main' into contrast-poc
2 parents 6441ce6 + 534e304 commit 301051a

File tree

300 files changed

+414
-703
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

300 files changed

+414
-703
lines changed

.changeset/quiet-cougars-glow.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 13 additions & 0 deletions

docs/storybook/package-lock.json

Lines changed: 8 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/storybook/stories/Color/DataVis/Charts.stories.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default {
1818

1919
export const HighchartsAccentColors = () => {
2020
const data = getTokensByName(colorTokens, 'data')
21-
.filter(({type}) => type === 'color')
21+
.filter(({type, name}) => type === 'color' && !name.includes('muted'))
2222
.map(token => {
2323
return {
2424
id: token.name,
@@ -64,12 +64,10 @@ export const HighchartsAccentColors = () => {
6464
)
6565
}
6666

67-
export const HighchartsGradients = () => {
67+
export const HighchartsMutedColors = () => {
6868
const data = getTokensByName(colorTokens, 'data')
69-
.filter(({type}) => type === 'gradient')
69+
.filter(({type, name}) => type === 'color' && name.includes('muted'))
7070
.map(token => {
71-
console.log(token)
72-
7371
return {
7472
id: token.name,
7573
...token,
@@ -78,7 +76,7 @@ export const HighchartsGradients = () => {
7876
return (
7977
<Table.Container>
8078
<Table.Title as="h1" id="pattern">
81-
Data visualization gradients
79+
Data visualization colors
8280
</Table.Title>
8381
<DataTable
8482
aria-labelledby="pattern"
@@ -89,7 +87,7 @@ export const HighchartsGradients = () => {
8987
field: 'name',
9088
rowHeader: true,
9189
renderCell: row => {
92-
return <ColorTokenSwatch gradientStops={row.value} />
90+
return <ColorTokenSwatch bgColor={row.name} />
9391
},
9492
},
9593
{
@@ -105,7 +103,7 @@ export const HighchartsGradients = () => {
105103
field: 'value',
106104
rowHeader: true,
107105
renderCell: row => {
108-
return <p>{row.value.map(({color, position}) => `${color} ${position * 100}%`).join(', ')}</p>
106+
return <p>{row.value}</p>
109107
},
110108
},
111109
]}

docs/storybook/stories/StorybookComponents/ColorTokenSwatch/ColorTokenSwatch.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ export type ColorTokenSwatchProps = {
88
shadowColor?: string
99
outlineColor?: string
1010
selectionColor?: string
11-
gradientStops?: Record<string, number>[]
12-
gradientAngle?: number
1311
size?: 'default' | 'large'
1412
}
1513

@@ -20,8 +18,6 @@ export function ColorTokenSwatch({
2018
shadowColor,
2119
outlineColor,
2220
selectionColor,
23-
gradientStops,
24-
gradientAngle = 180,
2521
size = 'default',
2622
}: ColorTokenSwatchProps) {
2723
return (
@@ -33,14 +29,6 @@ export function ColorTokenSwatch({
3329
)}
3430
{borderColor && <div style={{borderColor: `var(--${borderColor})`}} className="ColorTokenSwatch-border"></div>}
3531
{bgColor && <div style={{backgroundColor: `var(--${bgColor})`}} className="ColorTokenSwatch-bg"></div>}
36-
{gradientStops && (
37-
<div
38-
style={{
39-
background: `linear-gradient(${gradientAngle}deg, ${gradientStops.map(({color, position}) => `${color} ${position * 100}%`).join(', ')})`,
40-
}}
41-
className="ColorTokenSwatch-bg"
42-
></div>
43-
)}
4432
{shadowColor && <div style={{boxShadow: `var(--${shadowColor})`}} className="ColorTokenSwatch-shadow"></div>}
4533
{outlineColor && (
4634
<div style={{outlineColor: `var(--${outlineColor})`}} className="ColorTokenSwatch-outline"></div>

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@primer/primitives",
3-
"version": "10.5.0",
3+
"version": "10.6.0",
44
"description": "Typography, spacing, and color primitives for Primer design system",
55
"type": "module",
66
"files": [

playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default defineConfig({
99
testDir: 'e2e',
1010
fullyParallel: true,
1111
forbidOnly: !!process.env.CI,
12-
retries: process.env.CI ? 2 : 0,
12+
retries: 0,
1313
workers: process.env.CI ? 1 : undefined,
1414
reporter: [
1515
['line'],

src/filters/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ export {isNumber} from './isNumber.js'
1212
export {isShadow} from './isShadow.js'
1313
export {isSource} from './isSource.js'
1414
export {isTypography} from './isTypography.js'
15+
export {isTransition} from './isTransition.js'

src/filters/isTransition.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import {getMockToken} from '../test-utilities/index.js'
2+
import {isTransition} from './isTransition.js'
3+
4+
describe('Filter: isTransition', () => {
5+
it('returns true if $type property is `transition`', () => {
6+
expect(isTransition(getMockToken({$type: 'transition'}))).toStrictEqual(true)
7+
})
8+
9+
it('returns false if $type property is not `transition`', () => {
10+
expect(isTransition(getMockToken({$type: 'pumpkin'}))).toStrictEqual(false)
11+
})
12+
13+
it('returns false if $type property is missing', () => {
14+
expect(isTransition(getMockToken({alpha: 0.4}))).toStrictEqual(false)
15+
})
16+
17+
it('returns false if $type property is falsy', () => {
18+
expect(isTransition(getMockToken({$type: false}))).toStrictEqual(false)
19+
expect(isTransition(getMockToken({$type: undefined}))).toStrictEqual(false)
20+
expect(isTransition(getMockToken({$type: null}))).toStrictEqual(false)
21+
})
22+
})

src/filters/isTransition.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type {TransformedToken} from 'style-dictionary/types'
2+
3+
/**
4+
* @description Checks if token is of $type `transition`
5+
* @param token [TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
6+
* @returns boolean
7+
*/
8+
export const isTransition = (token: TransformedToken): boolean => {
9+
return token.$type === 'transition'
10+
}

src/platforms/css.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const css: PlatformInitializer = (outputFile, prefix, buildPath, options)
3535
'shadow/css',
3636
'border/css',
3737
'typography/css',
38+
'transition/css',
3839
'fontFamily/css',
3940
'fontWeight/number',
4041
'gradient/css',

src/platforms/figma.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ export const figma: PlatformInitializer = (outputFile, prefix, buildPath, option
4242
options: {
4343
basePxFontSize: 16,
4444
fontFamilies: {
45-
'fontStack/system': 'SF Pro Text',
46-
'fontStack/sansSerif': 'SF Pro Text',
47-
'fontStack/sansSerifDisplay': 'SF Pro Display',
48-
'fontStack/monospace': 'SF Mono',
45+
system: 'SF Pro Text',
46+
sansSerif: 'SF Pro Text',
47+
sansSerifDisplay: 'SF Pro Display',
48+
monospace: 'SF Mono',
4949
},
5050
// should this object be spread here?
5151
...options,

src/primerStyleDictionary.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
dimensionToRemPxArray,
2626
floatToPixel,
2727
floatToPixelUnitless,
28+
transitionToCss,
2829
} from './transformers/index.js'
2930
import {
3031
javascriptCommonJs,
@@ -152,6 +153,8 @@ PrimerStyleDictionary.registerTransform(borderToCss)
152153

153154
PrimerStyleDictionary.registerTransform(typographyToCss)
154155

156+
PrimerStyleDictionary.registerTransform(transitionToCss)
157+
155158
PrimerStyleDictionary.registerTransform(fontWeightToNumber)
156159

157160
PrimerStyleDictionary.registerTransform(fontFamilyToCss)

src/schemas/designToken.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {shadowToken} from './shadowToken.js'
1313
import {durationToken} from './durationToken.js'
1414
import {cubicBezierToken} from './cubicBezierToken.js'
1515
import {gradientToken} from './gradientToken.js'
16+
import {transitionToken} from './transitionToken.js'
1617

1718
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1819
// @ts-ignore: TODO: fix this
@@ -34,6 +35,7 @@ export const designToken = z.record(
3435
numberToken,
3536
durationToken,
3637
stringToken,
38+
transitionToken,
3739
]),
3840
designToken,
3941
])

src/schemas/dimensionToken.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const dimensionToken = baseToken
2020
'gap',
2121
'radius',
2222
'borderColor',
23+
'borderWidth',
2324
'effectFloat',
2425
'fontSize',
2526
'letterSpacing',

src/schemas/scopeTokenSchema.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ const validScopes: ValidScope[] = [
66
'bgColor',
77
'fgColor',
88
'borderColor',
9+
'borderWidth',
910
'size',
1011
'gap',
1112
'radius',
1213
'effectColor',
14+
'effectFloat',
1315
'opacity',
1416
'fontFamily',
1517
'fontStyle',
@@ -28,10 +30,12 @@ describe('Schema: scopes', () => {
2830
expect(scopeSchema.safeParse(['bgColor']).success).toStrictEqual(true)
2931
expect(scopeSchema.safeParse(['fgColor']).success).toStrictEqual(true)
3032
expect(scopeSchema.safeParse(['borderColor']).success).toStrictEqual(true)
33+
expect(scopeSchema.safeParse(['borderWidth']).success).toStrictEqual(true)
3134
expect(scopeSchema.safeParse(['size']).success).toStrictEqual(true)
3235
expect(scopeSchema.safeParse(['gap']).success).toStrictEqual(true)
3336
expect(scopeSchema.safeParse(['radius']).success).toStrictEqual(true)
3437
expect(scopeSchema.safeParse(['effectColor']).success).toStrictEqual(true)
38+
expect(scopeSchema.safeParse(['effectFloat']).success).toStrictEqual(true)
3539
expect(scopeSchema.safeParse(['opacity']).success).toStrictEqual(true)
3640
expect(scopeSchema.safeParse(['fontFamily']).success).toStrictEqual(true)
3741
expect(scopeSchema.safeParse(['fontStyle']).success).toStrictEqual(true)
@@ -47,10 +51,12 @@ describe('Schema: scopes', () => {
4751
'bgColor',
4852
'fgColor',
4953
'borderColor',
54+
'borderWidth',
5055
'size',
5156
'gap',
5257
'radius',
5358
'effectColor',
59+
'effectFloat',
5460
'opacity',
5561
'fontFamily',
5662
'fontStyle',

src/schemas/transitionToken.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {z} from 'zod'
2+
import {baseToken} from './baseToken.js'
3+
import {referenceValue} from './referenceValue.js'
4+
import {durationToken} from './durationToken.js'
5+
import {cubicBezierToken} from './cubicBezierToken.js'
6+
import {tokenType} from './tokenType.js'
7+
8+
export const transitionToken = baseToken
9+
.extend({
10+
$value: z.union([
11+
z.object({
12+
duration: z.union([durationToken.shape.$value, referenceValue]),
13+
timingFunction: z.union([cubicBezierToken.shape.$value, referenceValue]),
14+
delay: z.union([durationToken.shape.$value, referenceValue]).optional(),
15+
}),
16+
referenceValue,
17+
]),
18+
$type: tokenType('transition'),
19+
})
20+
.strict()

0 commit comments

Comments
 (0)