Skip to content

Commit

Permalink
Merge branch 'main' into 451-checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
ty2k committed Sep 10, 2024
2 parents f698dfe + 22ac1f3 commit afce1ce
Show file tree
Hide file tree
Showing 68 changed files with 5,973 additions and 3,611 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/publish_design_tokens.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Publish @bcgov/design-tokens to npm @next

on:
pull_request:
paths:
- packages/design-tokens/**
branches: [main]
types: [closed]

jobs:
publish-design-tokens:
name: Publish @bcgov/design-tokens@next
# Only run on merge, not close without merge AND
# only run in bcgov/design-system repo, not forks.
if: ${{ github.event.pull_request.merged == true && github.repository == 'bcgov/design-system' }}
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Read .nvmrc
run: echo "GITHUB_NVMRC_VERSION=$(cat .nvmrc)" >> $GITHUB_ENV
working-directory: ./packages/design-tokens

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.GITHUB_NVMRC_VERSION }}

- name: Install dependencies
run: npm install
working-directory: ./packages/design-tokens

- name: Install jq
run: sudo apt-get install -y jq

- name: Run build script
run: npm run build
working-directory: ./packages/design-tokens

- name: Prepare npm package for publishing
run: npm run prepare-npm-package
working-directory: ./packages/design-tokens

- name: Set up .npmrc configuration
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc

# Use `jq` to change the package.json version to look like:
#
# <version in package.json>-pr<PR # that caused the workflow run>
#
# So package.json version v1.2.3 with a run caused by merging PR #456 to
# `main` causes the version of the package on npm to look like:
#
# 1.2.3-pr456
#
# This is to ensure that it's easy to map an npm version to a particular PR.
#
- name: Update version in dist/package.json
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
CURRENT_VERSION=$(jq -r '.version' package.json)
NEW_VERSION="${CURRENT_VERSION}-pr${PR_NUMBER}"
jq --arg new_version "$NEW_VERSION" '.version = $new_version' package.json > tmp.json && mv tmp.json package.json
shell: bash
working-directory: ./packages/design-tokens/dist

- name: Publish to npm with @next tag
run: npm run publish-npm-package -- --access public --tag next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
working-directory: ./packages/design-tokens
38 changes: 38 additions & 0 deletions .github/workflows/test_design_tokens_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Test design tokens build script

on:
pull_request:
paths:
- packages/design-tokens/**
workflow_dispatch:

# Cancel any currently running builds to save GitHub Actions hours.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
run-tests:
name: Run tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Read .nvmrc
run: echo "GITHUB_NVMRC_VERSION=$(cat .nvmrc)" >> $GITHUB_ENV
working-directory: ./packages/design-tokens

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.GITHUB_NVMRC_VERSION }}

- name: Install dependencies
run: npm install
working-directory: ./packages/design-tokens

- name: Run test suite with npm script
run: npm run test
working-directory: ./packages/design-tokens
5 changes: 5 additions & 0 deletions .github/workflows/test_react_component_library.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ jobs:
run: npm install
working-directory: ./packages/react-components

# Errors in lint process will cause this job to fail
- name: Lint
run: npm run lint
working-directory: ./packages/react-components

- name: Run test suite with npm script
run: npm run test:ci
working-directory: ./packages/react-components
Expand Down
43 changes: 40 additions & 3 deletions packages/design-tokens/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,45 @@
# Changelog

## 3.1.1

### Changed

- `surface.color.tertiary.default` is fixed so it gets alpha channel data (`#FFFFFF` corrected to `#FFFFFF00`)

## 3.1.0

### Added

- Comments added to tokens to document intended usage
- `layout.padding.hair` added to match `layout.margin.hair`
- New color tokens added:
- `surface.color.primary.default`
- `surface.color.primary.hover`
- `surface.color.primary.pressed`
- `surface.color.primary.disabled`
- `surface.color.secondary.default`
- `surface.color.secondary.hover`
- `surface.color.secondary.pressed`
- `surface.color.secondary.disabled`
- `surface.color.tertiary.default`
- `surface.color.tertiary.hover`
- `surface.color.tertiary.pressed`
- `surface.color.tertiary.disabled`

## 3.0.1

### Changed

- `typography.fontWeights.italic` is marked as deprecated and will be removed in next major version

### Added

- `typography.fontWeights.italic.style` is added, replacing deprecated `typography.fontWeights.italic`
- `typography.fontWeights.italic.weight` is added, giving a default weight to italic type

## 3.0.0

## Changed
### Changed

- (breaking) Many tokens have been renamed to bring the generated tokens in line with the intended token names from Figma
- (breaking) `brand` color tokens renamed to `theme` to differentiate from [BC Visual Identity Program](https://www2.gov.bc.ca/gov/content?id=CCB4862101CD43C195FF395CAED00F95)
Expand All @@ -14,7 +51,7 @@
- (breaking) File names for JavaScript tokens are renamed from `variables.js` to `index.js` for shorter import statements
- Tokens in `layout` group use `rem` equivalent of previous `px` values where possible in Figma

## Added
### Added

- `primaryBlue` (equal to `blue100`) and `primaryGold` (equal to `gold100`) dedicated color tokens added
- `smallBody` font size added at 0.875rem (the old `label` size)
Expand All @@ -23,7 +60,7 @@
- TypeScript type definitions are shipped with the JavaScript tokens
- Heading level 6 `typography` group tokens added

## Removed
### Removed

- (breaking) Removed `surface.size` (legacy testing tokens)
- (breaking) Removed `surface.borderRadius` (these were duplicates from the `layout` group)
Expand Down
48 changes: 26 additions & 22 deletions packages/design-tokens/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Design Tokens for BC Design System
# Design Tokens for B.C. Design System

[![Lifecycle:Experimental](https://img.shields.io/badge/Lifecycle-Experimental-339999)](https://github.com/bcgov/repomountie/blob/master/doc/lifecycle-badges.md)
[![Lifecycle:Maturing](https://img.shields.io/badge/Lifecycle-Maturing-007EC6)](https://github.com/bcgov/repomountie/blob/master/doc/lifecycle-badges.md)

This package is used to export and publish design tokens from Figma to npm for the B.C. Design System. The tokens generated by this package are available for install from npm: [@bcgov/design-tokens](https://www.npmjs.com/package/@bcgov/design-tokens)

Questions? Please email the <a href="mailto:[email protected]">GDX OSS Design Team</a>.

## Tokens usage

See `dist/README.md` for how to use the design tokens in your project.
See `dist/README.md` (the README shipped with [the published package](https://www.npmjs.com/package/@bcgov/design-tokens)) for how to use the design tokens in your project.

## Development workflow

Expand All @@ -18,30 +18,34 @@ See `dist/README.md` for how to use the design tokens in your project.

## Steps to update and publish tokens

1. Update token data in the JSON file `input/tokens.json`.
1. Update token data in the JSON file `input/tokens.json` and the `version` field in `./package.json`.
2. Manually update composite tokens to include parent category. Ex: `{fontWeights.regular}` must become `{typography.fontWeights.regular}`.
3. Run `npm run build` to run Style Dictionary, transforming the raw JSON data into usable token formats.
4. Run `npm run prepare-npm-package` to copy the contents of `build` into `dist`.
5. Manually update the package version in `dist/package.json`.
6. Run `npm run publish-npm-package` to publish the contents of `dist` to npm.
4. [Ensure `jq` is installed](https://jqlang.github.io/jq/) on your system and then run `npm run prepare-npm-package` to copy the contents of `build` into `dist`.
5. Run `npm run publish-npm-package` to publish the contents of `dist` to npm (defaults to using the `latest` tag). If publishing to the pre-release `next` tag, use `npm run publish-npm-package -- --tag next`.

## Test the build script

A Node.js test script is included to confirm that the build script runs as intended: `npm run test`

## Folder structure

```
.
├── CHANGELOG.md - log of notable changes by version
├── README.md - this file
├── build - output of build script from style-dictionary
├── build-output.js - build script
├── dist - published to npm as @bcgov/design-tokens
│   ├── README.md - instructions for using @bcgov/design-tokens
│   ├── cjs - CommonJS tokens
│   ├── cjs-prefixed - CommonJS tokens with "bcds" added
│   ├── css - CSS tokens
│   ├── css-prefixed - CSS tokens with "bcds" added
│   ├── js - ECMAScript Module (ESM) tokens
│   ├── js-prefixed - ESM tokens with "bcds" added
│   └── package.json - package.json for @bcgov/design-tokens
├── input - raw design tokens JSON data from Tokens Studio for Figma
└── package.json - package.json for tokens transformation pipeline
├── CHANGELOG.md - log of notable changes by version
├── README.md - this file
├── build - output of build script from style-dictionary
├── build-output.js - build script
├── build-output.test.js - test suite for build script
├── dist - published to npm as @bcgov/design-tokens
│   ├── README.md - instructions for using @bcgov/design-tokens
│   ├── cjs - CommonJS tokens
│   ├── cjs-prefixed - CommonJS tokens with "bcds" added
│   ├── css - CSS tokens
│   ├── css-prefixed - CSS tokens with "bcds" added
│   ├── js - ECMAScript Module (ESM) tokens
│   ├── js-prefixed - ESM tokens with "bcds" added
│   └── package.json - package.json for @bcgov/design-tokens
├── input - raw design tokens JSON data from Tokens Studio for Figma
└── package.json - package.json for tokens transformation pipeline
```
Loading

0 comments on commit afce1ce

Please sign in to comment.