Skip to content

feat: move design tokens in to packages directory#128

Merged
georgewrmarshall merged 15 commits into
mainfrom
fix/126/migrate-design-tokens
Nov 21, 2024
Merged

feat: move design tokens in to packages directory#128
georgewrmarshall merged 15 commits into
mainfrom
fix/126/migrate-design-tokens

Conversation

@georgewrmarshall

@georgewrmarshall georgewrmarshall commented Nov 18, 2024

Copy link
Copy Markdown
Contributor

Description

This pull request moves the design tokens from the merged-packages/ directory to the packages/ directory in the design system monorepo following steps 1-5 of Phase C: Integration into the metamask module template's packages/ directory.

Steps Performed

  • Moved design-tokens directory from merged-packages/ to packages/.
  • Ran yarn install in the root directory to update dependencies.
  • Verified tests in the design-tokens package by executing yarn workspace @metamask/design-tokens test.
  • Updated tsconfig.json and tsconfig.build.json in the root directory with reference paths to design-tokens to avoid build failures during release workflows.
  • Updated the design-tokens version across downstream packages and root to workspace version
  • Applied yarn constraints --fix to the design-tokens package.json.
  • Included the changelog:validate build script in the package.json.
  • For complex type issues, annotated with // TODO: Replace any types with proper types https://github.com/MetaMask/metamask-design-system/issues/127
  • Documented changes in the migration target's downstream packages under the ## [Unreleased] heading in their respective CHANGELOG files.

Related Issues

Manual Testing Steps

  1. Run yarn install, yarn test and yarn build in the root directory to confirm the migration does not break the build.
  2. Verify downstream dependencies reference the correct paths and versions.
  3. Check CHANGELOG updates for consistency.
  4. Check storybook works for web and ios yarn storybook yarn storybook:ios

Screenshots/Screen recordings

After

Storybook works for both web and ios

after.mov
after.storybook720.mov

Pre-merge Author Checklist

  • Followed MetaMask Contributor Docs.
  • Ensured all PR status checks passed at least once.
  • Updated relevant CHANGELOG files.
  • Applied appropriate labels and linked issues.

Pre-merge Reviewer Checklist

  • Verified manual tests for the build and migration.
  • Reviewed CHANGELOG entries and downstream dependency updates.
  • Checked for unresolved TODOs in the codebase.

"@metamask/design-system-react-native": "workspace:^",
"@metamask/design-system-twrnc-preset": "workspace:^",
"@metamask/design-tokens": "^4.1.0",
"@metamask/design-tokens": "workspace:^",

@georgewrmarshall georgewrmarshall Nov 18, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating to workspace version of design tokens by running yarn constraints --fix

Storybook react native still working

after.mov

'../stories/**/*.mdx',
'../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)',
'../../../packages/design-system-react/src/**/*.stories.@(js|jsx|ts|tsx)',
'../../../packages/design-tokens/stories/**/*.stories.@(js|jsx|ts|tsx)',

@georgewrmarshall georgewrmarshall Nov 18, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including design token stories. I’ve created an issue to improve the display and categorization of stories in Storybook, as well as Storybook React overall. These updates will be included in a separate PR shortly after this one is merged: #129

'@metamask/design-tokens': path.resolve(
__dirname,
'../../../node_modules/@metamask/design-tokens',
'../../../packages/design-tokens',

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating reference, this can possibly be removed. Will update in #129

@@ -1,5 +1,5 @@
import React from 'react';
import '@metamask/design-tokens/dist/styles.css';
import '@metamask/design-tokens/src/css/index.css';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating to workspace version

"@chromatic-com/storybook": "^1.9.0",
"@metamask/design-system-tailwind-preset": "workspace:^",
"@metamask/design-tokens": "^4.1.0",
"@metamask/design-tokens": "workspace:^",

@georgewrmarshall georgewrmarshall Nov 18, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating to workspace version of design tokens by running yarn constraints --fix

@georgewrmarshall georgewrmarshall Nov 18, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aligning LICENSE with packages so it passes yarn constraints. I've created an issue to update our licenses across the monorepo to align with legal here #130

Comment on lines +18 to +20
coveragePathIgnorePatterns: [
'packages/design-tokens/src/js/colors/colors.ts',
],

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this

@@ -15,31 +15,38 @@ import postcss from 'postcss';
export const getDesignTokenVariables = async (

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating this test util to use the workspace version of the design tokens stylesheet. We can also refactor this now that we can access the css locally

Comment on lines +10 to +13
### Added

- Migrate `@metamask/design-tokens` into the design system monorepo ([128](https://github.com/MetaMask/metamask-design-system/pull/128))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -1,6 +1,6 @@
MIT License

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aligning LICENSE with packages so it passes yarn constraints. I've created an issue to update our licenses across the monorepo to align with legal here #130

Comment on lines -29 to -31
// In jest.config.packages.js we are ignoring all index.ts files e.g. coveragePathIgnorePatterns: ['./src/index.ts'],
// We want to include index.ts in coverage so we override the coveragePathIgnorePatterns
coveragePathIgnorePatterns: [],

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was for design-system-tailwind-preset updated now to ignore index files

Before

Screenshot 2024-11-18 at 2 33 41 PM

After

Screenshot 2024-11-18 at 2 34 07 PM

@@ -6,15 +6,15 @@
"MetaMask",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yarn constraint fixes by running yarn constraints --fix

Comment thread packages/design-tokens/package.json
@@ -0,0 +1,32 @@
import { lightTheme, darkTheme } from '../themes';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improving test coverage for this file was failing before

@@ -1,8 +1,7 @@
/* eslint-disable @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports */
import * as designTokens from '../../figma/tokens.json';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint fix that disallows require

@@ -1,8 +1,7 @@
/* eslint-disable @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports */
import * as designTokens from '../../figma/tokens.json';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint fix that disallows require

@@ -1,8 +1,7 @@
/* eslint-disable @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports */
import * as designTokens from '../../figma/tokens.json';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint fix that disallows require

@@ -1,8 +1,7 @@
/* eslint-disable @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports */
import * as designTokens from '../../figma/tokens.json';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint fix that disallows require

@@ -1,8 +1,7 @@
/* eslint-disable @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports */
import * as designTokens from '../../figma/tokens.json';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint fix that disallows require

/* eslint-disable @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports */
/* eslint-disable @typescript-eslint/no-explicit-any */
// TODO: Replace any types with proper types https://github.com/MetaMask/metamask-design-system/issues/127
import * as designTokens from '../../figma/tokens.json';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint fix that disallows require

Comment thread merged-packages/design-tokens/docs/fonts/Euclid/EuclidCircularB-Bold-WebXL.ttf Outdated
Comment thread yarn.config.cjs
Comment on lines +99 to +111
if (workspace.ident !== '@metamask/design-tokens') {
expectWorkspaceField(
workspace,
'scripts.build',
'ts-bridge --project tsconfig.build.json --verbose --clean --no-references',
);
} else if (workspace.ident === '@metamask/design-tokens') {
expectWorkspaceField(
workspace,
'scripts.build',
'ts-bridge --project tsconfig.build.json --verbose --clean --no-references && yarn build:css',
);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating yarn constraints so the build of the css file doesn't get overridden in the design tokens package

@georgewrmarshall georgewrmarshall changed the title feat: migate design tokens in to packages feat: move design tokens in to packages Nov 18, 2024
@georgewrmarshall georgewrmarshall changed the title feat: move design tokens in to packages feat: move design tokens in to packages directory Nov 18, 2024
georgewrmarshall added a commit that referenced this pull request Nov 19, 2024
## **Description**

As part of the design tokens migration, this pull request removes the
unused `fonts` folder and files from the `merged-packages/design-tokens`
directory. These fonts were previously used for Storybook, but they are
now duplicated and unnecessary because the `storybook-react` application
(`apps/storybook-react/fonts`) provides the required fonts.

## **Related**

- #128

## **Manual Testing Steps**

1. Ensure `fonts/` folder and files have been removed from
`merged-packages/design-tokens`
2. Ensure there are no references to
`merge-packages/design-tokens/docs/fonts` folder or files in the
codebase

## **Screenshots**

Ensuring `merge-packages/design-tokens/docs/fonts` folder is not
referenced in the codebase

![Screenshot 2024-11-18 at 3 03
41 PM](https://github.com/user-attachments/assets/d1f6d355-abb2-4ecf-82a6-ef557dc30eec)


## **Pre-merge Author Checklist**
- [x] Followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs).
- [x] Ensured all PR status checks passed at least once.
- [x] Updated relevant CHANGELOG files.
- [x] Applied appropriate labels and linked issues.

## **Pre-merge Reviewer Checklist**
- [ ] Verified manual tests for the build and migration.
- [ ] Reviewed CHANGELOG entries and downstream dependency updates.
- [ ] Checked for unresolved TODOs in the codebase.
@georgewrmarshall georgewrmarshall force-pushed the fix/126/migrate-design-tokens branch from 5e739fd to 3402845 Compare November 19, 2024 23:37
Comment on lines +59 to +60
"postcss": "^8.4.47",
"react": "^18.2.0",

@georgewrmarshall georgewrmarshall Nov 19, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

postcss is used for getCSSVariablesFromStylesheet in packages/design-tokens/stories/test-utils/getCSSVariablesFromStylesheet.ts and react for stories

@georgewrmarshall georgewrmarshall marked this pull request as ready for review November 19, 2024 23:47
@georgewrmarshall georgewrmarshall requested a review from a team as a code owner November 19, 2024 23:47
@georgewrmarshall georgewrmarshall merged commit 5783e60 into main Nov 21, 2024
@georgewrmarshall georgewrmarshall deleted the fix/126/migrate-design-tokens branch November 21, 2024 20:28
@georgewrmarshall georgewrmarshall mentioned this pull request Dec 11, 2024
5 tasks
georgewrmarshall added a commit that referenced this pull request Dec 11, 2024
# Release 1.0.0

## Description
This PR prepares the release of version 1.0.0 of the design system
packages.

## Changes

- feat: color updates to the design tokens package
([#230](#230))

- `@metamask/design-tokens` package migrated from standalone repository
into the design system monorepo
([128](#128))

## Release Process Checklist
- [x] Branch named `release/1.0.0` created
- [x] Changelogs updated and validated
- [x] Dependencies updated to latest versions (`yarn constraints --fix
&& yarn && yarn dedupe`)
- [x] PR review and testing completed
- [x] Ready for "Squash & Merge" with commit message "Release 1.0.0"

## Post-Merge Steps
1. The `publish-release` GitHub Action will tag the release
2. NPM publishing requires approval from the `npm-publishers` team
3. Verify package publication on
[NPM](https://npms.io/search?q=scope%3Ametamask)
georgewrmarshall added a commit that referenced this pull request Feb 25, 2026
Address PR review feedback from georgewrmarshall:
- Add ADR links in Purpose section of component-architecture.md
- Update all ADR references from PR links to main branch document links
- Ensures documentation remains accessible even after PRs are merged

Changes:
- component-architecture.md: Added clickable ADR links in Purpose section (lines 9-10)
- Updated ADR-0003 reference from PR #127 to document link (line 58)
- Updated ADR-0004 reference from PR #128 to document link (line 166)
- Updated References section ADR links (lines 398-399)
- component-creation.md: Updated ADR links in MetaMask Standards section
- component-migration.md: Updated ADR links in Architecture Decision Records section
- component-enum-union-migration.md: Updated ADR links in Architecture Decision Records section

All ADR references now point to:
- https://github.com/MetaMask/decisions/blob/main/decisions/design-system/0003-enum-to-string-union-migration.md
- https://github.com/MetaMask/decisions/blob/main/decisions/design-system/0004-centralized-types-architecture.md

Related: #911 (review comments)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move design-tokens into packages directory

2 participants