Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: primer/primitives
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v7.15.7
Choose a base ref
...
head repository: primer/primitives
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v7.15.8
Choose a head ref
  • 2 commits
  • 10 files changed
  • 2 contributors

Commits on Feb 20, 2024

  1. Adding all color modes to figma export (#805)

    * adding color modes
    
    * update schema validation
    lukasoppermann authored Feb 20, 2024

    Unverified

    This user has not yet uploaded their public signing key.
    Copy the full SHA
    6e59707 View commit details
  2. Version Packages (#807)

    Add all color modes to Figma export
    primer[bot] authored Feb 20, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    0bc0855 View commit details
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @primer/primitives

## 7.15.8

### Patch Changes

- [#805](https://github.com/primer/primitives/pull/805) [`6e59707`](https://github.com/primer/primitives/commit/6e597077a16cdde21c68713968ff53dedad2c674) Thanks [@lukasoppermann](https://github.com/lukasoppermann)! - Adding exports for all colormodes for Figma

## 7.15.7

### Patch Changes
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@primer/primitives",
"version": "7.15.7",
"version": "7.15.8",
"description": "Typography, spacing, and color primitives for Primer design system",
"files": [
"dist",
46 changes: 33 additions & 13 deletions scripts/buildPlatforms/buildFigma.ts
Original file line number Diff line number Diff line change
@@ -14,10 +14,22 @@ export const buildFigma = (buildOptions: ConfigGeneratorOptions): void => {
name: 'light',
source: [`src/tokens/base/color/light/light.json5`],
},
{
name: 'light-high-constrast',
source: [`src/tokens/base/color/light/light.json5`, `src/tokens/base/color/light/light.high-contrast.json5`],
},
{
name: 'dark',
source: [`src/tokens/base/color/dark/dark.json5`],
},
{
name: 'dark-high-constrast',
source: [`src/tokens/base/color/dark/dark.json5`, `src/tokens/base/color/dark/dark.high-contrast.json5`],
},
{
name: 'dark-dimmed',
source: [`src/tokens/base/color/dark/dark.json5`, `src/tokens/base/color/dark/dark.dimmed.json5`],
},
]

for (const {name, source} of baseScales) {
@@ -30,18 +42,16 @@ export const buildFigma = (buildOptions: ConfigGeneratorOptions): void => {
}
//
for (const {filename, source, include} of themes) {
if (['light', 'dark'].includes(filename)) {
// build functional scales
PrimerStyleDictionary.extend({
source,
include,
platforms: {
figma: figma(`figma/themes/${filename}.json`, buildOptions.prefix, buildOptions.buildPath, {
mode: filename,
}),
},
}).buildAllPlatforms()
}
// build functional scales
PrimerStyleDictionary.extend({
source,
include,
platforms: {
figma: figma(`figma/themes/${filename}.json`, buildOptions.prefix, buildOptions.buildPath, {
mode: filename.replaceAll('-', ' '),
}),
},
}).buildAllPlatforms()
}
/** -----------------------------------
* Size tokens
@@ -109,7 +119,17 @@ export const buildFigma = (buildOptions: ConfigGeneratorOptions): void => {

// define the order of the modes
// we inverse it to deal with the -1 of the indexOf if item is not found in the array: basically anything that is not in the list should come last
const modeOrder = ['light', 'dark'].reverse()
const modeOrder = [
'light',
'dark',
'dark dimmed',
'light high contrast',
'dark high contrast',
'light colorblind',
'dark colorblind',
'light tritanopia',
'dark tritanopia',
].reverse()
// sort modes in the order defined above
for (const collection in collections) {
collections[collection].modes.sort((a, b) => modeOrder.indexOf(b) - modeOrder.indexOf(a))
14 changes: 13 additions & 1 deletion src/schemas/collectionSchema.test.ts
Original file line number Diff line number Diff line change
@@ -3,8 +3,10 @@ import {collection, mode} from './collections'
describe('Schema: collection', () => {
const collections = collection([
'base/color/light',
'base/color/light-high-contrast',
'base/color/dark',
'base/color/dark-dimmed',
'base/color/dark-high-contrast',
'mode',
'pattern/mode',
])
@@ -26,7 +28,17 @@ describe('Schema: collection', () => {
})

describe('Schema: mode', () => {
const modes = mode(['light', 'dark'])
const modes = mode([
'light',
'dark',
'dark dimmed',
'light high contrast',
'dark high contrast',
'light colorblind',
'dark colorblind',
'light tritanopia',
'dark tritanopia',
])

it('passes on valid values', () => {
expect(modes.safeParse('light').success).toStrictEqual(true)
13 changes: 12 additions & 1 deletion src/schemas/collections.ts
Original file line number Diff line number Diff line change
@@ -4,8 +4,10 @@ import {schemaErrorMessage} from '../utilities/schemaErrorMessage'

type Collections =
| 'base/color/light'
| 'base/color/light-high-contrast'
| 'base/color/dark'
| 'base/color/dark-dimmed'
| 'base/color/dark-high-contrast'
| 'mode'
| 'pattern/mode'
| 'base/size'
@@ -24,7 +26,16 @@ export const collection = (collections: Collections[]) => {
)
}

type Modes = 'light' | 'dark'
type Modes =
| 'light'
| 'dark'
| 'dark dimmed'
| 'light high contrast'
| 'dark high contrast'
| 'light colorblind'
| 'dark colorblind'
| 'light tritanopia'
| 'dark tritanopia'

export const mode = (modes: Modes[]) => {
return z.string().refine(
14 changes: 13 additions & 1 deletion src/schemas/colorToken.ts
Original file line number Diff line number Diff line change
@@ -24,12 +24,24 @@ export const colorToken = baseToken
'org.primer.figma': z.object({
collection: collection([
'base/color/light',
'base/color/light-high-contrast',
'base/color/dark',
'base/color/dark-dimmed',
'base/color/dark-high-contrast',
'mode',
'pattern/mode',
]).optional(),
mode: mode(['light', 'dark']).optional(),
mode: mode([
'light',
'dark',
'dark dimmed',
'light high contrast',
'dark high contrast',
'light colorblind',
'dark colorblind',
'light tritanopia',
'dark tritanopia',
]).optional(),
scopes: scopes(['all', 'bgColor', 'fgColor', 'borderColor']).optional(),
}),
})
4 changes: 2 additions & 2 deletions src/schemas/scopes.ts
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@ import {z} from 'zod'
import {joinFriendly} from '../utilities/joinFriendly'
import {schemaErrorMessage} from '../utilities/schemaErrorMessage'

export type ValidScope = 'all' | 'bgColor' | 'fgColor' | 'borderColor' | 'size' | 'gap' | 'radius'
const validScopes: ValidScope[] = ['all', 'bgColor', 'fgColor', 'borderColor', 'size', 'gap', 'radius']
export type ValidScope = 'all' | 'bgColor' | 'fgColor' | 'borderColor' | 'size' | 'gap' | 'radius' | 'effectColor'
const validScopes: ValidScope[] = ['all', 'bgColor', 'fgColor', 'borderColor', 'size', 'gap', 'radius', 'effectColor']

export const scopes = (scopeSubset?: ValidScope[]) => {
const scopeArray = scopeSubset ?? validScopes
Loading