From e7fb55b88eb4d7e090b47f521486caf823bf2666 Mon Sep 17 00:00:00 2001 From: Daniel Del Core Date: Thu, 3 Dec 2026 09:50:43 +1100 Subject: [PATCH] Build Precursor around composable themes and primitives --- .changeset/README.md | 17 + .changeset/config.json | 2 +- .changeset/four-theme-slots.md | 37 + .changeset/full-width-grid-rows.md | 5 + .changeset/native-overlays-and-variants.md | 10 + .changeset/static-precursor-styles.md | 35 + .changeset/trousers-named-insets.md | 37 + .changeset/workspace-package-exports.md | 7 + .eslintrc.js | 37 - .github/workflows/release.yml | 42 +- .github/workflows/test.yml | 27 - .github/workflows/validate.yml | 25 +- .gitignore | 6 +- .node-version | 1 + .oxfmtrc.json | 12 + .oxlintrc.json | 9 + .prettierignore | 1 - .prettierrc.js | 7 - .storybook/addons.js | 0 .storybook/config.js | 6 - .storybook/main.ts | 59 + .storybook/webpack.config.js | 17 - .vscode/extensions.json | 3 + .vscode/settings.json | 34 + .yarnrc.yml | 10 + README.md | 148 +- docs/theming-brief.md | 61 + .../{0_Palette.tsx => Palette.stories.tsx} | 370 +- fixtures/Box.tsx | 33 +- fixtures/Container.tsx | 7 +- fixtures/ThemeEditor.tsx | 232 - fixtures/index.ts | 2 - fixtures/themeSchema.ts | 135 - jest.config.js | 21 - package.json | 113 +- .../common/copy-to-clipboard/package.json | 29 +- .../common/copy-to-clipboard/tsconfig.json | 5 +- packages/common/types/package.json | 29 +- packages/common/types/tsconfig.json | 5 +- packages/components/avatar/Avatar.spec.tsx | 13 +- packages/components/avatar/Avatar.tsx | 28 +- packages/components/avatar/package.json | 45 +- packages/components/avatar/tsconfig.json | 9 +- packages/components/badge/Badge.tsx | 58 +- packages/components/badge/package.json | 45 +- packages/components/badge/tsconfig.json | 5 +- packages/components/button/Button.tsx | 165 +- packages/components/button/package.json | 45 +- packages/components/button/tsconfig.json | 12 +- packages/components/checkbox/Checkbox.tsx | 115 +- packages/components/checkbox/package.json | 47 +- packages/components/checkbox/tsconfig.json | 11 +- packages/components/code/Code.tsx | 58 +- packages/components/code/package.json | 45 +- packages/components/code/tsconfig.json | 9 +- packages/components/image/Image.tsx | 17 +- packages/components/image/package.json | 44 +- packages/components/image/tsconfig.json | 5 +- packages/components/input/Input.tsx | 102 +- packages/components/input/package.json | 46 +- packages/components/input/tsconfig.json | 9 +- packages/components/keyboard/Keyboard.tsx | 18 +- packages/components/keyboard/package.json | 45 +- packages/components/keyboard/tsconfig.json | 9 +- packages/components/label/Label.tsx | 25 +- packages/components/label/package.json | 44 +- packages/components/label/tsconfig.json | 9 +- packages/components/lozenge/Lozenge.tsx | 62 +- packages/components/lozenge/package.json | 45 +- packages/components/lozenge/tsconfig.json | 5 +- packages/components/message/Message.tsx | 56 +- packages/components/message/package.json | 45 +- packages/components/message/tsconfig.json | 9 +- packages/components/modal/Modal.tsx | 144 +- packages/components/modal/ModalBody.tsx | 31 +- packages/components/modal/ModalContext.ts | 5 + packages/components/modal/ModalFooter.tsx | 17 +- packages/components/modal/ModalHeader.tsx | 32 +- packages/components/modal/package.json | 51 +- packages/components/modal/tsconfig.json | 12 +- packages/components/overlay/Overlay.tsx | 33 +- packages/components/overlay/package.json | 34 +- packages/components/overlay/tsconfig.json | 5 +- packages/components/panel/Panel.tsx | 21 +- packages/components/panel/package.json | 45 +- packages/components/panel/tsconfig.json | 9 +- packages/components/popup/Popup.tsx | 42 + packages/components/popup/index.ts | 1 + packages/components/popup/package.json | 49 + packages/components/popup/tsconfig.json | 10 + packages/components/radio/Radio.tsx | 152 +- packages/components/radio/package.json | 45 +- packages/components/radio/tsconfig.json | 17 +- packages/components/range/Range.tsx | 39 +- packages/components/range/Slider.tsx | 70 +- packages/components/range/Track.tsx | 47 +- packages/components/range/package.json | 45 +- packages/components/range/tsconfig.json | 9 +- packages/components/select/Select.tsx | 161 +- packages/components/select/package.json | 47 +- packages/components/select/tsconfig.json | 9 +- packages/components/skeleton/Skeleton.tsx | 66 +- packages/components/skeleton/package.json | 44 +- packages/components/skeleton/tsconfig.json | 9 +- packages/components/spinner/Spinner.tsx | 94 +- packages/components/spinner/package.json | 44 +- packages/components/spinner/tsconfig.json | 9 +- packages/components/tabs/Tab.tsx | 44 +- packages/components/tabs/TabList.tsx | 30 +- packages/components/tabs/TabPanel.tsx | 2 - packages/components/tabs/Tabs.tsx | 52 +- packages/components/tabs/TabsContext.ts | 3 + packages/components/tabs/index.ts | 1 + packages/components/tabs/package.json | 46 +- packages/components/tabs/tsconfig.json | 15 +- packages/components/textarea/TextArea.tsx | 108 +- packages/components/textarea/package.json | 45 +- packages/components/textarea/tsconfig.json | 9 +- packages/components/toggle/Toggle.tsx | 167 +- packages/components/toggle/package.json | 45 +- packages/components/toggle/tsconfig.json | 17 +- packages/elements/blockquote/Blockquote.tsx | 25 +- packages/elements/blockquote/package.json | 45 +- packages/elements/blockquote/tsconfig.json | 9 +- packages/elements/divider/Divider.tsx | 34 + packages/elements/divider/index.ts | 1 + packages/elements/divider/package.json | 49 + packages/elements/divider/tsconfig.json | 10 + packages/elements/emoji/Emoji.tsx | 3 +- packages/elements/emoji/package.json | 34 +- packages/elements/emoji/tsconfig.json | 5 +- packages/elements/heading/Heading.tsx | 104 +- packages/elements/heading/package.json | 46 +- packages/elements/heading/tsconfig.json | 13 +- packages/elements/list/List.tsx | 13 +- packages/elements/list/package.json | 45 +- packages/elements/list/tsconfig.json | 5 +- packages/elements/text/Text.tsx | 26 +- packages/elements/text/package.json | 45 +- packages/elements/text/tsconfig.json | 13 +- packages/layout/bleed/Bleed.tsx | 35 + packages/layout/bleed/index.ts | 1 + packages/layout/bleed/package.json | 50 + packages/layout/bleed/tsconfig.json | 15 + packages/layout/grid/Column.tsx | 5 +- packages/layout/grid/Grid.tsx | 35 +- packages/layout/grid/Row.tsx | 24 +- packages/layout/grid/package.json | 46 +- packages/layout/grid/tsconfig.json | 9 +- packages/layout/inline/Inline.tsx | 45 +- packages/layout/inline/package.json | 45 +- packages/layout/inline/tsconfig.json | 9 +- packages/layout/stack/Stack.tsx | 21 +- packages/layout/stack/package.json | 45 +- packages/layout/stack/tsconfig.json | 9 +- packages/theming/theme/Globals.tsx | 50 +- packages/theming/theme/Theme.spec.tsx | 124 + packages/theming/theme/ThemeProvider.tsx | 202 +- packages/theming/theme/index.ts | 18 +- packages/theming/theme/loadTheme.ts | 128 + packages/theming/theme/package.json | 45 +- packages/theming/theme/theme.ts | 157 - packages/theming/theme/tsconfig.json | 9 +- packages/theming/tokens/index.ts | 15 +- packages/theming/tokens/package.json | 38 +- .../tokens/themes/color/dark/dark.json | 125 + .../tokens/themes/color/light/light.json | 125 + .../theming/tokens/themes/shape/rounded.json | 26 + .../theming/tokens/themes/shape/sharp.json | 26 + .../tokens/themes/spacing/comfortable.json | 56 + .../tokens/themes/spacing/compact.json | 56 + .../tokens/themes/spacing/spacious.json | 56 + .../tokens/themes/typography/monospace.json | 84 + .../tokens/themes/typography/sans-serif.json | 84 + .../tokens/themes/typography/serif.json | 84 + packages/theming/tokens/tokens.ts | 131 - packages/theming/tokens/tsconfig.json | 5 +- scripts/build-tokens.mjs | 257 + scripts/build.mjs | 91 + tsconfig.examples.json | 19 + tsconfig.json | 188 +- vitest.config.mts | 8 + yarn.lock | 18087 +++++----------- 183 files changed, 11273 insertions(+), 14913 deletions(-) create mode 100644 .changeset/four-theme-slots.md create mode 100644 .changeset/full-width-grid-rows.md create mode 100644 .changeset/native-overlays-and-variants.md create mode 100644 .changeset/static-precursor-styles.md create mode 100644 .changeset/trousers-named-insets.md create mode 100644 .changeset/workspace-package-exports.md delete mode 100644 .eslintrc.js delete mode 100644 .github/workflows/test.yml create mode 100644 .node-version create mode 100644 .oxfmtrc.json create mode 100644 .oxlintrc.json delete mode 100644 .prettierignore delete mode 100644 .prettierrc.js delete mode 100644 .storybook/addons.js delete mode 100644 .storybook/config.js create mode 100644 .storybook/main.ts delete mode 100644 .storybook/webpack.config.js create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100644 .yarnrc.yml create mode 100644 docs/theming-brief.md rename examples/{0_Palette.tsx => Palette.stories.tsx} (80%) delete mode 100644 fixtures/ThemeEditor.tsx delete mode 100644 fixtures/themeSchema.ts delete mode 100644 jest.config.js create mode 100644 packages/components/modal/ModalContext.ts create mode 100644 packages/components/popup/Popup.tsx create mode 100644 packages/components/popup/index.ts create mode 100644 packages/components/popup/package.json create mode 100644 packages/components/popup/tsconfig.json create mode 100644 packages/elements/divider/Divider.tsx create mode 100644 packages/elements/divider/index.ts create mode 100644 packages/elements/divider/package.json create mode 100644 packages/elements/divider/tsconfig.json create mode 100644 packages/layout/bleed/Bleed.tsx create mode 100644 packages/layout/bleed/index.ts create mode 100644 packages/layout/bleed/package.json create mode 100644 packages/layout/bleed/tsconfig.json create mode 100644 packages/theming/theme/Theme.spec.tsx create mode 100644 packages/theming/theme/loadTheme.ts delete mode 100644 packages/theming/theme/theme.ts create mode 100644 packages/theming/tokens/themes/color/dark/dark.json create mode 100644 packages/theming/tokens/themes/color/light/light.json create mode 100644 packages/theming/tokens/themes/shape/rounded.json create mode 100644 packages/theming/tokens/themes/shape/sharp.json create mode 100644 packages/theming/tokens/themes/spacing/comfortable.json create mode 100644 packages/theming/tokens/themes/spacing/compact.json create mode 100644 packages/theming/tokens/themes/spacing/spacious.json create mode 100644 packages/theming/tokens/themes/typography/monospace.json create mode 100644 packages/theming/tokens/themes/typography/sans-serif.json create mode 100644 packages/theming/tokens/themes/typography/serif.json delete mode 100644 packages/theming/tokens/tokens.ts create mode 100644 scripts/build-tokens.mjs create mode 100644 scripts/build.mjs create mode 100644 tsconfig.examples.json create mode 100644 vitest.config.mts diff --git a/.changeset/README.md b/.changeset/README.md index 4f3b76b..a1622eb 100644 --- a/.changeset/README.md +++ b/.changeset/README.md @@ -6,3 +6,20 @@ find the full documentation for it [in our repository](https://github.com/change We have a quick list of common questions to get you started engaging with this project in [our documentation](https://github.com/changesets/changesets/blob/master/docs/common-questions.md) + +## npm Trusted Publishing + +The release workflow uses GitHub Actions OIDC. In the npm settings for each +published `@precursor/*` package, configure a GitHub Actions trusted publisher +for owner `danieldelcore`, repository `precursor`, and workflow `release.yml`. +Allow direct npm publishing and leave the environment field blank. In the +repository's Actions settings, allow GitHub Actions to create pull requests. + +Once the release PR is merged, the workflow publishes the updated packages. +Use the Release workflow's manual dispatch on `master` to retry a release. + +For new packages such as `@precursor/divider`, `@precursor/bleed`, and `@precursor/popup`, an npm +maintainer must publish an initial version before the package can be configured +for Trusted Publishing. Use a bootstrap version below the planned release +version and a separate dist-tag so the version selected by Changesets remains +available for the first CI release. diff --git a/.changeset/config.json b/.changeset/config.json index 09890ec..ea58bd3 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://unpkg.com/@changesets/config@1.0.1/schema.json", + "$schema": "https://unpkg.com/@changesets/config@4.1.0/schema.json", "changelog": "@changesets/cli/changelog", "commit": false, "access": "public", diff --git a/.changeset/four-theme-slots.md b/.changeset/four-theme-slots.md new file mode 100644 index 0000000..ba7edab --- /dev/null +++ b/.changeset/four-theme-slots.md @@ -0,0 +1,37 @@ +--- +'@precursor/badge': patch +'@precursor/bleed': minor +'@precursor/blockquote': patch +'@precursor/button': patch +'@precursor/checkbox': patch +'@precursor/code': patch +'@precursor/divider': minor +'@precursor/grid': patch +'@precursor/heading': minor +'@precursor/inline': patch +'@precursor/input': patch +'@precursor/keyboard': patch +'@precursor/label': patch +'@precursor/lozenge': patch +'@precursor/message': patch +'@precursor/modal': patch +'@precursor/panel': patch +'@precursor/radio': patch +'@precursor/range': patch +'@precursor/select': patch +'@precursor/skeleton': patch +'@precursor/spinner': patch +'@precursor/stack': patch +'@precursor/tabs': patch +'@precursor/text': minor +'@precursor/textarea': patch +'@precursor/theme': major +'@precursor/toggle': patch +'@precursor/tokens': major +--- + +Generate theme variants at build time with Style Dictionary. Select color, spacing, shape, and typography through ThemeProvider's `selection` prop. For synchronous SSR, prepare `initialTheme` with `loadTheme`. The color slot has independent light and dark palettes. The separate `colorMode` setting defaults to `auto` and follows the browser preference before hydration. + +Grid, Stack, Inline, Text, and Heading now use the generated tokens. Divider and Bleed are available as new primitives. The component catalog uses the new token contract through the existing exports. + +Use `--spacing-gap-*` for margins and gaps and `--spacing-inset-*` for padding. The previous step spacing tokens are removed. Use `--spacing-inline` between inline elements. Squish remains available as `--spacing-inset-squish`. diff --git a/.changeset/full-width-grid-rows.md b/.changeset/full-width-grid-rows.md new file mode 100644 index 0000000..e3ff44d --- /dev/null +++ b/.changeset/full-width-grid-rows.md @@ -0,0 +1,5 @@ +--- +'@precursor/grid': patch +--- + +Span each Row across the parent Grid and align its columns with the parent tracks. A single child fills the row by default. diff --git a/.changeset/native-overlays-and-variants.md b/.changeset/native-overlays-and-variants.md new file mode 100644 index 0000000..a175eea --- /dev/null +++ b/.changeset/native-overlays-and-variants.md @@ -0,0 +1,10 @@ +--- +'@precursor/button': minor +'@precursor/checkbox': minor +'@precursor/modal': minor +'@precursor/popup': minor +'@precursor/tabs': minor +'@precursor/tokens': minor +--- + +Add pill tabs, a monospace typography theme, and a themed checkbox with native form behavior. Add Popup using the native Popover API and support popover targets on Button. Modal now uses the native modal dialog API for focus and dismissal. diff --git a/.changeset/static-precursor-styles.md b/.changeset/static-precursor-styles.md new file mode 100644 index 0000000..e92a319 --- /dev/null +++ b/.changeset/static-precursor-styles.md @@ -0,0 +1,35 @@ +--- +'@precursor/avatar': major +'@precursor/badge': major +'@precursor/blockquote': major +'@precursor/button': major +'@precursor/checkbox': major +'@precursor/code': major +'@precursor/emoji': major +'@precursor/grid': major +'@precursor/heading': major +'@precursor/image': major +'@precursor/inline': major +'@precursor/input': major +'@precursor/keyboard': major +'@precursor/label': major +'@precursor/list': major +'@precursor/lozenge': major +'@precursor/message': major +'@precursor/modal': major +'@precursor/overlay': major +'@precursor/panel': major +'@precursor/radio': major +'@precursor/range': major +'@precursor/select': major +'@precursor/skeleton': major +'@precursor/spinner': major +'@precursor/stack': major +'@precursor/tabs': major +'@precursor/text': major +'@precursor/textarea': major +'@precursor/theme': major +'@precursor/toggle': major +--- + +Require React 19 and ship styles compiled by Trousers 4. Browser-aware bundlers load the styles with each component. For server-rendered apps, include the generated CSS in the client bundle. Render a ThemeProvider around styled components to supply the default or a custom theme. diff --git a/.changeset/trousers-named-insets.md b/.changeset/trousers-named-insets.md new file mode 100644 index 0000000..9bdf397 --- /dev/null +++ b/.changeset/trousers-named-insets.md @@ -0,0 +1,37 @@ +--- +'@precursor/avatar': patch +'@precursor/badge': patch +'@precursor/bleed': patch +'@precursor/blockquote': patch +'@precursor/button': patch +'@precursor/checkbox': patch +'@precursor/code': patch +'@precursor/divider': patch +'@precursor/grid': patch +'@precursor/heading': patch +'@precursor/image': patch +'@precursor/inline': patch +'@precursor/input': patch +'@precursor/keyboard': patch +'@precursor/label': patch +'@precursor/list': patch +'@precursor/lozenge': patch +'@precursor/message': patch +'@precursor/modal': patch +'@precursor/panel': patch +'@precursor/popup': patch +'@precursor/radio': patch +'@precursor/range': patch +'@precursor/select': patch +'@precursor/skeleton': patch +'@precursor/spinner': patch +'@precursor/stack': patch +'@precursor/tabs': patch +'@precursor/text': patch +'@precursor/textarea': patch +'@precursor/theme': patch +'@precursor/toggle': patch +'@precursor/tokens': minor +--- + +Update the Trousers runtime and compiler to 4.1.0. Add a large inset token and use Trousers named inset variants in the Storybook layout examples. diff --git a/.changeset/workspace-package-exports.md b/.changeset/workspace-package-exports.md new file mode 100644 index 0000000..cd732e0 --- /dev/null +++ b/.changeset/workspace-package-exports.md @@ -0,0 +1,7 @@ +--- +'@precursor/copy-to-clipboard': patch +'@precursor/tokens': patch +'@precursor/types': patch +--- + +Publish JavaScript and types for both ESM and CommonJS consumers. Remove a trailing semicolon from the default font-family token so it can be applied as an inline style. diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 28be629..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,37 +0,0 @@ -module.exports = { - root: true, - parser: '@typescript-eslint/parser', - extends: [ - 'plugin:react/recommended', - 'plugin:@typescript-eslint/recommended', - 'prettier/@typescript-eslint', - 'plugin:prettier/recommended', - 'plugin:jsx-a11y/recommended', - ], - plugins: ['import', 'jsx-a11y', 'react', 'react-hooks'], - parserOptions: { - ecmaVersion: 2018, - sourceType: 'module', - project: './tsconfig.json', - ecmaFeatures: { - jsx: true, - }, - }, - rules: { - 'react-hooks/rules-of-hooks': 'error', - 'react-hooks/exhaustive-deps': 'warn', - 'react/prop-types': 'off', - 'react/display-name': 'off', - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/explicit-member-accessibility': 'off', - '@typescript-eslint/no-non-null-assertion': 'off', - '@typescript-eslint/no-parameter-properties': 'off', - }, - settings: { - react: { - version: 'detect', - }, - }, - ignorePatterns: ['dist', 'node_modules'], -}; diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6ffc4d5..8512603 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,33 +2,33 @@ name: Release on: push: - branches: - - master + branches: [master] + workflow_dispatch: + +concurrency: + group: release-${{ github.ref }} + cancel-in-progress: false jobs: release: - name: Release + if: github.ref == 'refs/heads/master' runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + id-token: write steps: - - name: Checkout Repo - uses: actions/checkout@master + - uses: actions/checkout@v7 with: - # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits fetch-depth: 0 - - - name: Setup Node.js 12.x - uses: actions/setup-node@master + persist-credentials: false + - uses: actions/setup-node@v6 with: - node-version: 12.x - - - name: Install Dependencies - run: yarn - - - name: Create Release Pull Request or Publish to npm - uses: changesets/action@master + node-version-file: .node-version + - run: npm install --global corepack@0.36.0 + - run: corepack enable + - run: yarn install --immutable + - uses: changesets/action@v2.1.2 with: - # this expects you to have a script called release which does a build for your packages and calls changeset publish - publish: yarn release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + version-script: yarn version:packages + publish-script: yarn release diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 81a1566..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Test - -on: - push: - branches: [master] - pull_request: - branches: [master] - -jobs: - build: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [12.x] - - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: npm install -g yarn - - run: yarn install --frozen-lockfile - - run: yarn test - env: - CI: true diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 5a53604..d5dee42 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -6,22 +6,19 @@ on: pull_request: branches: [master] +permissions: + contents: read + jobs: - build: + validate: runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [12.x] - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + - uses: actions/checkout@v7 + - uses: actions/setup-node@v6 with: - node-version: ${{ matrix.node-version }} - - run: npm install -g yarn - - run: yarn install --frozen-lockfile + node-version-file: .node-version + - run: npm install --global corepack@0.36.0 + - run: corepack enable + - run: yarn install --immutable - run: yarn validate - env: - CI: true + - run: yarn storybook build diff --git a/.gitignore b/.gitignore index 8fa0575..586dfe9 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,10 @@ lib dist .site .DS_Store -.vscode +**/.vscode/* +!/.vscode/settings.json +!/.vscode/extensions.json storybook-static tsconfig.tsbuildinfo +.yarn/install-state.gz +/packages/theming/tokens/theme-registry.generated.ts diff --git a/.node-version b/.node-version new file mode 100644 index 0000000..a45fd52 --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +24 diff --git a/.oxfmtrc.json b/.oxfmtrc.json new file mode 100644 index 0000000..a815363 --- /dev/null +++ b/.oxfmtrc.json @@ -0,0 +1,12 @@ +{ + "$schema": "./node_modules/oxfmt/configuration_schema.json", + "singleQuote": true, + "tabWidth": 4, + "printWidth": 80, + "ignorePatterns": [ + "**/dist/**", + "storybook-static/**", + "coverage/**", + "**/CHANGELOG.md" + ] +} diff --git a/.oxlintrc.json b/.oxlintrc.json new file mode 100644 index 0000000..2f81429 --- /dev/null +++ b/.oxlintrc.json @@ -0,0 +1,9 @@ +{ + "$schema": "./node_modules/oxlint/configuration_schema.json", + "plugins": ["typescript", "react", "jsx-a11y"], + "ignorePatterns": ["**/dist/**", "storybook-static/**", "coverage/**"], + "rules": { + "react/rules-of-hooks": "error", + "react/exhaustive-deps": "error" + } +} diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 1521c8b..0000000 --- a/.prettierignore +++ /dev/null @@ -1 +0,0 @@ -dist diff --git a/.prettierrc.js b/.prettierrc.js deleted file mode 100644 index 773948a..0000000 --- a/.prettierrc.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - semi: true, - trailingComma: 'all', - singleQuote: true, - printWidth: 80, - tabWidth: 4, -}; diff --git a/.storybook/addons.js b/.storybook/addons.js deleted file mode 100644 index e69de29..0000000 diff --git a/.storybook/config.js b/.storybook/config.js deleted file mode 100644 index b7a148a..0000000 --- a/.storybook/config.js +++ /dev/null @@ -1,6 +0,0 @@ -import { configure } from '@storybook/react'; - -configure( - require.context('../examples', true, /\.(js|jsx|ts|tsx|md|mdx)$/), - module, -); diff --git a/.storybook/main.ts b/.storybook/main.ts new file mode 100644 index 0000000..fc73cda --- /dev/null +++ b/.storybook/main.ts @@ -0,0 +1,59 @@ +import { relative, resolve, sep } from 'node:path'; +import type { StorybookConfig } from '@storybook/react-vite'; +import { mergeConfig, type Plugin } from 'vite'; +import { buildPackage } from '../scripts/build.mjs'; +import { buildTokens } from '../scripts/build-tokens.mjs'; + +function watchPackages(): Plugin { + return { + name: 'precursor-workspaces', + configureServer(server) { + let pending = Promise.resolve(); + server.watcher.on('change', (file) => { + const path = relative(process.cwd(), file).split(sep).join('/'); + const match = + /^(packages\/[^/]+\/[^/]+|fixtures)\/[^/]+\.tsx?$/.exec( + path, + ); + const isTokenSource = + /^packages\/theming\/tokens\/themes\/(?:[^/]+\/)+[^/]+\.json$/.test( + path, + ); + if ((!match && !isTokenSource) || path.endsWith('.spec.tsx')) + return; + + pending = pending + .then(() => + isTokenSource ? buildTokens() : buildPackage(match![1]), + ) + .then(() => server.ws.send({ type: 'full-reload' })) + .catch((error) => + server.config.logger.error(String(error)), + ); + }); + }, + }; +} + +export default { + framework: '@storybook/react-vite', + stories: ['../examples/**/*.stories.tsx'], + staticDirs: ['../assets'], + typescript: { reactDocgen: false }, + core: { disableTelemetry: true }, + async viteFinal(config, { configType }) { + await buildPackage('fixtures'); + + return mergeConfig(config, { + resolve: { + alias: [ + { + find: /^\.\.\/fixtures$/, + replacement: resolve('fixtures/dist/browser.mjs'), + }, + ], + }, + plugins: configType === 'DEVELOPMENT' ? [watchPackages()] : [], + }); + }, +} satisfies StorybookConfig; diff --git a/.storybook/webpack.config.js b/.storybook/webpack.config.js deleted file mode 100644 index b59c7cd..0000000 --- a/.storybook/webpack.config.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = ({ config }) => { - config.module.rules.push({ - test: /\.(ts|tsx)$/, - use: [ - { - loader: require.resolve('ts-loader'), - options: { - transpileOnly: true, - }, - }, - ], - }); - - config.resolve.extensions.push('.ts', '.tsx'); - - return config; -}; diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..9d5eb3d --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["oxc.oxc-vscode"] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..1d9dd69 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,34 @@ +{ + "editor.detectIndentation": false, + "editor.insertSpaces": true, + "editor.tabSize": 4, + "editor.formatOnSave": true, + "editor.formatOnSaveMode": "file", + "[css]": { + "editor.defaultFormatter": "oxc.oxc-vscode" + }, + "[javascript]": { + "editor.defaultFormatter": "oxc.oxc-vscode" + }, + "[javascriptreact]": { + "editor.defaultFormatter": "oxc.oxc-vscode" + }, + "[json]": { + "editor.defaultFormatter": "oxc.oxc-vscode" + }, + "[jsonc]": { + "editor.defaultFormatter": "oxc.oxc-vscode" + }, + "[markdown]": { + "editor.defaultFormatter": "oxc.oxc-vscode" + }, + "[typescript]": { + "editor.defaultFormatter": "oxc.oxc-vscode" + }, + "[typescriptreact]": { + "editor.defaultFormatter": "oxc.oxc-vscode" + }, + "[yaml]": { + "editor.defaultFormatter": "oxc.oxc-vscode" + } +} diff --git a/.yarnrc.yml b/.yarnrc.yml new file mode 100644 index 0000000..52ee0b7 --- /dev/null +++ b/.yarnrc.yml @@ -0,0 +1,10 @@ +nodeLinker: node-modules + +npmPublishRegistry: 'https://registry.npmjs.org' + +npmPublishProvenance: true + +packageExtensions: + 'storybook@11.0.0': + peerDependencies: + react: '^18.0.0 || ^19.0.0' diff --git a/README.md b/README.md index 2295959..b860db7 100644 --- a/README.md +++ b/README.md @@ -4,45 +4,147 @@ # Precursor -Start your projects with a minimalistic, composable, lightweight and themable component library. - -## Layout & Composability πŸ’Ž - -## Theming πŸ’… +Precursor provides design tokens and React primitives for building interfaces. +Grid, Stack, Inline, Text, Heading, Divider, and Bleed are available as +individual packages. See the [implementation brief](docs/theming-brief.md) +for the full design. + +## Component design rules + +- **Control appearance through variants.** Expose supported visual options as + variants and keep `className` out of the public styling API. This keeps each + visual combination within the component's design constraints. +- **Use purpose-built layout primitives.** Keep generic `Box` primitives out of + the library. A catch-all component with arbitrary styling props turns into a + CSS-in-JS API. Compose Grid, Stack, Inline, and Bleed for layout. + +## Theming + +Use React 19 and render a `ThemeProvider` around Precursor components. Each +provider selects color, spacing, shape, and typography independently. Its +tokens apply to its descendants, including Precursor modals in a portal. + +```tsx +import Button from '@precursor/button'; +import { ThemeProvider } from '@precursor/theme'; + + + +; +``` + +Choose light and dark palettes independently under `selection.color`. +`selection.colorMode` controls which slot is shown. It defaults to `auto`, +which follows the browser's color preference before and after hydration. +Explicit `light` or `dark` keeps the corresponding slot active and loads +only its palette. The other slots default to comfortable spacing, rounded +shapes, and sans-serif typography. The previous selection stays active +until the new styles load. Use `onLoadError(error, retry)` to handle failures. + +Replace the old `theme` object prop and token-object imports with named +variants. Edit the JSON token sources in `packages/theming/tokens/themes` to +define or change variants. Keep color palettes in `color/light` and `color/dark`. +Style Dictionary generates the published styles +and loaders at the start of `yarn build`. Storybook and releases use that +same build. + +Precursor extracts CSS at build time using [Trousers 4](https://github.com/danieldelcore/trousers). +Bundlers that resolve the browser export include the styles for each imported +component and its styled dependencies. If your bundler uses a server export +for the client build, enable browser resolution or import the required styles +from `@precursor//styles.css` in the client entry. + +## Component variants and overlays + +Set `` to style a tab group as pills. Select +`typography: 'monospace'` in the theme selection to use the monospace theme. + +Use `Popup` for non-modal content and give a `Button` the matching +`popoverTarget`. The browser manages toggling, Escape, and outside dismissal. +Use `Modal` for content that requires modal focus and an inert background. ## Iconography πŸ‘Ύ Precursor does not export its own set of iconography in order to try to remain agnostic. However, it does make use of a few icons from the wonderful [Feather Icons](https://feathericons.com/) project. -## SSR πŸ€– +## Server rendering + +For synchronous SSR, call `loadTheme(selection)` on the server before +rendering. Pass the result as `initialTheme` on the server and on the first +client render. Serialize that result with your framework's ordinary +serialization mechanism. The provider reuses the inline styles on hydration. +For streaming SSR, the provider can resolve the initial selection through +Suspense. Keep the themed content inside the same Suspense boundary as the +provider. + +```tsx +import { loadTheme, ThemeProvider } from '@precursor/theme'; + +const selection = { colorMode: 'auto', typography: 'serif' } as const; +const initialTheme = await loadTheme(selection); + + + +; +``` -Under the hood, precursor uses [trousers πŸ‘–](https://github.com/danieldelcore/trousers) for styling. Trousers requires that you do some configuration to enable SSR. Please follow the guide there for more information: [Server side rendering with trousers](https://github.com/danieldelcore/trousers#server-side-rendering-ssr-) +The inline styles contain the theme variables. Include the client bundle's +component CSS in your HTML so each component has its layout styles before +hydration. The inline CSS for auto color covers both light and dark. ## Folder structure πŸ“‚ -Precursor uses [yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/) as the base of the monorepo. Each component can be found as it's own stand-alone package, allowing installation of a sub-set of the components you might need for your project. +Precursor uses [yarn workspaces](https://yarnpkg.com/features/workspaces) as the base of the monorepo. Each component can be found as it's own stand-alone package, allowing installation of a sub-set of the components you might need for your project. Components are categorized into several 'groups': -- `packages/common`: Shared utilities -- `packages/components`: Stand-alone components -- `packages/elements`: Primitive components intended for use in new compositions -- `packages/layout`: Primitives for arranging components together -- `packages/theming`: Themes, tokens and other APIs indended for customization +- `packages/common`: Shared utilities +- `packages/components`: Stand-alone components +- `packages/elements`: Primitive components intended for use in new compositions +- `packages/layout`: Primitives for arranging components together +- `packages/theming`: Themes, tokens and other APIs intended for customization + +## Development + +Use Node.js 24.15 or later in the 24.x line. The `.node-version` file selects +Node 24 for version managers such as fnm. With fnm, run `fnm install` and +`fnm use` from the repository root. + +```sh +corepack enable +yarn --version +yarn install --immutable +yarn start:stories +``` + +`yarn --version` should print `4.19.0`. If your shell still resolves a global +Yarn 1 executable, run `corepack yarn start:stories` to use the pinned version +directly. + +Use `yarn validate` for the build, types, lint, +formatting, workspace checks, and tests. Run `yarn format` to fix formatting, +`yarn start` to open the component palette in Storybook, or `yarn stories:build` +to produce a static Storybook build. ## Inspired by ❀️ -- [Atlassian Design System](https://atlassian.design/) -- [chakra-ui](https://chakra-ui.com/) -- [zeit.co/design/](https://zeit.co/design/) -- [Github Primer](https://primer.style/components) -- [braid design system](https://seek-oss.github.io/braid-design-system) -- [react-ui.dev](https://react-ui.dev) -- [fannypack](https://v5.fannypack.style/) +- [Atlassian Design System](https://atlassian.design/) +- [chakra-ui](https://chakra-ui.com/) +- [zeit.co/design/](https://zeit.co/design/) +- [Github Primer](https://primer.style/components) +- [braid design system](https://seek-oss.github.io/braid-design-system) +- [react-ui.dev](https://react-ui.dev) +- [fannypack](https://v5.fannypack.style/) ## Built with... -- [trousers πŸ‘–](https://github.com/danieldelcore/trousers) -- [changesets πŸ¦‹](https://github.com/atlassian/changesets) -- [manypkg β˜”οΈ](https://github.com/Thinkmill/manypkg) +- [trousers πŸ‘–](https://github.com/danieldelcore/trousers) +- [changesets πŸ¦‹](https://github.com/atlassian/changesets) +- [manypkg β˜”οΈ](https://github.com/Thinkmill/manypkg) diff --git a/docs/theming-brief.md b/docs/theming-brief.md new file mode 100644 index 0000000..99791d1 --- /dev/null +++ b/docs/theming-brief.md @@ -0,0 +1,61 @@ +# Precursor theming and primitives + +Make Precursor a theming and primitives library. Refactor the existing theming +package in place. Adapt Grid, Stack, Inline, Text, and Heading, and add Divider +and Bleed. Migrate the current component catalog to the new tokens through its +existing packages and exports. Use logical axes for layout and let consumers +choose a heading's semantic level independently of its visual size. + +## Design tokens + +Use Style Dictionary as the token compiler. Keep the source definitions in the +tokens workspace and generate one CSS file per variant and a typed registry +with separate variant loaders. Run generation first in the ordinary package +build, before TypeScript and bundling. Storybook development, the static +Storybook build, and release packaging all use that build. Published packages +include the generated assets. ThemeProvider applies those assets at runtime. + +| Slot | Initial variants | Default | +| ----------- | ---------------------------------- | ------------- | +| Light color | Light palette | Light palette | +| Dark color | Dark palette | Dark palette | +| Spacing | Compact, comfortable, and spacious | Comfortable | +| Shape | Rounded and sharp | Rounded | +| Typography | Sans-serif, serif, and monospace | Sans-serif | + +Use a foundation-specific token path based on +`[foundation].[category].[variant].[state]`. Represent defaulted segments +with the literal `[default]` key and omit those segments from the CSS variable. +For example, `color.brand.bold.[default]` emits `--color-brand-bold` and +`color.brand.bold.hovered` emits `--color-brand-bold-hovered`. Fail generation +on normalized-name collisions or variants that disagree on their slot's +token contract. + +Use gap tokens such as `--spacing-gap-s` for margins and layout gaps. +Use `--spacing-inline` for spacing between inline elements and inset tokens such +as `--spacing-inset-s` for padding. +`--spacing-inset-squish` combines a smaller block inset with a larger inline inset. + +## ThemeProvider + +Scope provider selections to their descendants. Keep one active variant per +slot. Load new variants on demand and apply a whole selection once its styles +are ready. Deduplicate concurrent loads and retain successfully mounted +styles for reuse. The previous selection stays active on failure, and the +request can be retried. Stale requests cannot replace a newer selection. + +The separate `colorMode` setting selects the light or dark color slot. Each slot can have multiple palette variants. Mode and palette selections can change independently. + +Inline initial styles during SSR and reuse the styles in the document head +during hydration. For auto mode, include the selected palette for both color slots initially and +let `prefers-color-scheme` choose which applies before JavaScript runs. +Explicit light and dark selections stay fixed. + +## Acceptance + +Show all seven primitives together in Storybook with independent controls +for each slot. Verify first paint, hydration, system color changes, async +switching and retry, stylesheet reuse, and multiple provider scopes. Verify +that packaged consumers receive the generated assets and that the browser +loads other variants only when selected. Document the ThemeProvider migration +and include release notes. diff --git a/examples/0_Palette.tsx b/examples/Palette.stories.tsx similarity index 80% rename from examples/0_Palette.tsx rename to examples/Palette.stories.tsx index 5b847de..1a23e41 100644 --- a/examples/0_Palette.tsx +++ b/examples/Palette.stories.tsx @@ -1,8 +1,5 @@ -/* eslint-disable jsx-a11y/accessible-emoji */ -/** @jsx jsx */ -import { storiesOf } from '@storybook/react'; -import { useState } from 'react'; -import { jsx } from '@trousers/core'; +import type { Meta, StoryObj } from '@storybook/react-vite'; +import { Suspense, useId, useState } from 'react'; import Avatar from '@precursor/avatar'; import Blockquote from '@precursor/blockquote'; import Text from '@precursor/text'; @@ -10,6 +7,7 @@ import Button from '@precursor/button'; import Badge from '@precursor/badge'; import Lozenge from '@precursor/lozenge'; import Checkbox from '@precursor/checkbox'; +import Popup from '@precursor/popup'; import Code from '@precursor/code'; import Heading from '@precursor/heading'; import Input from '@precursor/input'; @@ -29,22 +27,186 @@ import Spinner from '@precursor/spinner'; import Skeleton from '@precursor/skeleton'; import Grid, { Column, Row } from '@precursor/grid'; import Inline from '@precursor/inline'; -import Toggle from '@precursor/Toggle'; +import Toggle from '@precursor/toggle'; import { Tabs, Tab, TabList, TabPanel } from '@precursor/tabs'; import List, { ListItem } from '@precursor/list'; -import { theme as baseTheme, Theme, ThemeProvider } from '@precursor/theme'; -import deepObject from 'object-deep-key'; -import { Box, Container, ThemeEditor, themeSchema } from '../fixtures'; +import { + defaultTheme, + themeVariants, + ThemeProvider, + useTheme, + type ThemeSelection, +} from '@precursor/theme'; +import { gapSizes } from '@precursor/tokens'; +import Bleed from '@precursor/bleed'; +import Divider from '@precursor/divider'; +import { Box, Container } from '../fixtures'; + +function ThemeSelect({ + name, + label, + options, + value, + onChange, +}: { + name: string; + label: string; + options: readonly Value[]; + value: Value; + onChange: (value: Value) => void; +}) { + const id = useId(); + + return ( + + + + + ); +} + +function ThemeControls({ + requested, + onChange, +}: { + requested: ThemeSelection; + onChange: (selection: ThemeSelection) => void; +}) { + const active = useTheme(); + return ( + + Theme + + + onChange({ ...requested, colorMode }) + } + /> + + onChange({ + ...requested, + color: { ...requested.color, light }, + }) + } + /> + + onChange({ + ...requested, + color: { ...requested.color, dark }, + }) + } + /> + {(['spacing', 'shape', 'typography'] as const).map((slot) => ( + + onChange({ ...requested, [slot]: value }) + } + /> + ))} + +
+ + Active selection: {active.colorMode}, {active.spacing},{' '} + {active.shape}, {active.typography} + +
+
+ ); +} + +function PrimitiveComposition() { + return ( + + + + Primitives + + + These layout and text primitives share the active theme. + + + + Layout + Grid, Stack, and Inline + + + First + + Second + + + + + + +
+ + This nested surface always uses light colors. + +
+
+
+
+ ); +} const BasicExample = () => { - const [theme, setTheme] = useState(baseTheme); + const [selection, setSelection] = useState({ + ...defaultTheme, + }); + const [retry, setRetry] = useState<(() => void) | null>(null); const [isModalOpen, setIsModalOpen] = useState(false); const closeModal = () => setIsModalOpen(false); const openModal = () => setIsModalOpen(true); return ( - + setRetry(() => retryLoad)} + >
Precursor β¬’ + Typography - - Heading One ({theme.fontSize.h1}/ - {theme.lineHeight.h1}) - - - Heading Two ({theme.fontSize.h2}/ - {theme.lineHeight.h2}) - - - Heading Three ({theme.fontSize.h3}/ - {theme.lineHeight.h3}) - - - Heading Four ({theme.fontSize.h4}/ - {theme.lineHeight.h4}) - - - Heading Five ({theme.fontSize.h5}/ - {theme.lineHeight.h5}) - - - Heading Six ({theme.fontSize.h6}/ - {theme.lineHeight.h6}) - + Heading One + Heading Two + Heading Three + Heading Four + Heading Five + Heading Six Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris volutpat, odio vitae @@ -178,16 +330,16 @@ const BasicExample = () => { Spacing - {Object.keys(theme.space).map(key => ( -
- + {gapSizes.map((size) => ( +
+
))} @@ -253,18 +405,29 @@ const BasicExample = () => { Page layouts - + - Navigation + + Navigation + - - - Side bar + + + Sidebar - - - Main content + + + Main content @@ -325,9 +488,9 @@ const BasicExample = () => { - - {`.some-class { background-color: red; }`} - + {`.some-class { background-color: red; }`} Lorem ipsum dolor sit amet, consectetur @@ -698,12 +861,18 @@ const BasicExample = () => { console.log('onChange')} - label="My checkbox" + name="updates" + label="Email me product updates" + /> + + @@ -954,6 +1123,42 @@ const BasicExample = () => { + + + + Overview + Settings + + + Project overview + + + Project settings + + + + Popups + + + + + Notifications are enabled. + + + + + + Modals { ); }; -storiesOf('Palette', module).add('Component Palette', () => ); +const meta = { + title: 'Palette', + component: BasicExample, + parameters: { layout: 'fullscreen' }, + decorators: [ + (Story) => ( + Loading theme…

}> + +
+ ), + ], +} satisfies Meta; + +export default meta; + +export const ComponentPalette: StoryObj = {}; diff --git a/fixtures/Box.tsx b/fixtures/Box.tsx index cb0ba3e..c73d62a 100644 --- a/fixtures/Box.tsx +++ b/fixtures/Box.tsx @@ -1,25 +1,30 @@ -/** @jsx jsx */ -import { jsx, css } from '@trousers/core'; -import { ReactNode, FC } from 'react'; +import type { FC, ReactNode } from 'react'; +import css, { classnames } from '@trousers/core'; -import { Theme } from '@precursor/theme'; +const boxStyles = css({ + display: 'block', + boxSizing: 'border-box', + minHeight: 20, +}).variant('inset', { + s: { padding: 'var(--spacing-inset-s)' }, + m: { padding: 'var(--spacing-inset-m)' }, + l: { padding: 'var(--spacing-inset-l)' }, +}); const Box: FC<{ width?: string; height?: string; + inset?: 's' | 'm' | 'l'; children?: ReactNode; backgroundColor?: string; -}> = ({ width = '100%', height = 0, children, backgroundColor }) => ( +}> = ({ width = '100%', height, inset, children, backgroundColor }) => (
` - display: block; - color: white; - min-height: 20px; - width: ${width}; - height: ${height}; - background-color: ${({ color }) => - backgroundColor || color.background.light}; - `} + className={classnames(boxStyles, { inset })} + style={{ + width, + height, + backgroundColor: backgroundColor ?? 'var(--color-surface-subtle)', + }} > {children}
diff --git a/fixtures/Container.tsx b/fixtures/Container.tsx index 43c3be4..459303f 100644 --- a/fixtures/Container.tsx +++ b/fixtures/Container.tsx @@ -1,14 +1,13 @@ -/** @jsx jsx */ -import { jsx } from '@trousers/core'; import { ReactNode, FC } from 'react'; const Container: FC<{ children?: ReactNode }> = ({ children }) => (
{children} diff --git a/fixtures/ThemeEditor.tsx b/fixtures/ThemeEditor.tsx deleted file mode 100644 index 5fd1bcb..0000000 --- a/fixtures/ThemeEditor.tsx +++ /dev/null @@ -1,232 +0,0 @@ -/** @jsx jsx */ -import { FC, Fragment, useState } from 'react'; -import { jsx } from '@trousers/core'; -import Label from '@precursor/label'; -import Select from '@precursor/select'; -import Input from '@precursor/input'; -import Message from '@precursor/message'; -import Heading from '@precursor/heading'; -import Stack from '@precursor/stack'; -import Toggle from '@precursor/toggle'; -import { Theme } from '@precursor/theme'; - -import { OptionType, ThemeSchema } from './themeSchema'; - -interface ThemeEditorProps { - schema: ThemeSchema; - theme: Theme; - onChange: (key: string, value: any) => void; -} - -const debounce = (func: Function, wait: number) => { - let timeout: ReturnType | null; - - return function executedFunction(...args: any[]) { - const later = () => { - timeout = null; - func(...args); - }; - if (timeout) { - clearTimeout(timeout); - } - - timeout = setTimeout(later, wait); - }; -}; - -interface ColorPickerProps { - name: string; - value: string; - options: { label: string; value: string }[]; - onChange: (key: string, value: string) => void; -} - -const ColorPicker: FC = ({ - name, - value, - options, - onChange, -}) => { - const [mode, setMode] = useState('tokens'); - const onChangeHandler = debounce(onChange, 50); - - return ( - - - {mode === 'tokens' ? ( - - ) : ( - onChangeHandler(name, e.target.value)} - /> - )} - - setMode(e.target.value === 'true' ? 'tokens' : 'manual') - } - label="manual picker" - size="s" - /> - - ); -}; - -const renderOption = ( - key: string, - themeValue: any, - schema: OptionType, - onChange: ThemeEditorProps['onChange'], -) => { - switch (schema.type) { - case 'text': - return ( - - - onChange(key, e.target.value)} - name={key} - defaultValue={themeValue} - type="text" - /> - - ); - case 'number': - return ( - - - onChange(key, e.target.value)} - name={key} - defaultValue={themeValue} - type="number" - /> - - ); - case 'option': - const options = schema.options.map(option => ({ - label: option, - value: option, - })); - const valueIndex = schema.options.findIndex( - val => val === themeValue, - ); - - return ( - - - - - ); - case 'color': - const colorOptions = schema.options.map(option => ({ - label: option, - value: option, - })); - const colorValueIndex = schema.options.findIndex( - val => val === themeValue, - ); - - return ( - onChange(name, value)} - /> - ); - default: - return null; - } -}; - -const renderOptionGroup = ( - key: string, - property: any, - schema: any, - onChange: ThemeEditorProps['onChange'], -) => ( - - - {key} - {Object.entries(property).map(([nestedKey, nestedValue]) => { - if (nestedValue.constructor === Object) { - return ( - - {renderOptionGroup( - key + '.' + nestedKey, - nestedValue, - schema.nested[nestedKey], - onChange, - )} - - ); - } - - if (!schema) { - return ( - - Error: schema not found for property: {nestedKey} - - ); - } - - return ( - - {renderOption( - key + '.' + nestedKey, - nestedValue, - schema, - onChange, - )} - - ); - })} - - -); - -const ThemeEditor: FC = ({ schema, theme, onChange }) => { - return ( - - {Object.entries(theme).map(([key, property]) => - renderOptionGroup(key, property, schema[key], onChange), - )} - - ); -}; - -export default ThemeEditor; diff --git a/fixtures/index.ts b/fixtures/index.ts index 8014513..6400d20 100644 --- a/fixtures/index.ts +++ b/fixtures/index.ts @@ -1,4 +1,2 @@ -export { default as ThemeEditor } from './ThemeEditor'; -export { default as themeSchema } from './themeSchema'; export { default as Box } from './Box'; export { default as Container } from './Container'; diff --git a/fixtures/themeSchema.ts b/fixtures/themeSchema.ts deleted file mode 100644 index 277c708..0000000 --- a/fixtures/themeSchema.ts +++ /dev/null @@ -1,135 +0,0 @@ -import { Theme } from '@precursor/theme'; -import { color, space, fontFamily, elevation } from '@precursor/tokens'; - -interface Text extends Nested { - type: 'text'; -} - -interface Option extends Nested { - type: 'option'; - options: any[]; -} - -interface Color extends Nested { - type: 'color'; - options: any[]; -} - -interface Numeral extends Nested { - type: 'number'; -} - -interface Range extends Nested { - type: 'range'; - min: number; - max: number; - step?: number; -} - -interface Nested { - nested?: Record; -} - -export type OptionType = Text | Color | Option | Numeral | Range; - -export type ThemeSchema = Record; - -const allColors = [ - ...Object.values(color.neutral), - ...Object.values(color.warning), - ...Object.values(color.error), - ...Object.values(color.success), -]; - -const themeSchema: Record = { - color: { - type: 'color', - options: allColors, - nested: { - primary: { - type: 'color', - options: Object.values(color.primary), - }, - typography: { - type: 'color', - options: Object.values(color.neutral), - }, - background: { - type: 'color', - options: Object.values(color.neutral), - }, - neutral: { - type: 'color', - options: Object.values(color.neutral), - }, - info: { - type: 'color', - options: Object.values(color.info), - }, - warning: { - type: 'color', - options: Object.values(color.warning), - }, - error: { - type: 'color', - options: Object.values(color.error), - }, - success: { - type: 'color', - options: Object.values(color.success), - }, - }, - }, - space: { - type: 'text', - }, - spacePreset: { - type: 'option', - options: Object.values(space), - }, - font: { - type: 'option', - options: [ - ...Object.values(fontFamily), - 'Arial', - 'Helvetica', - 'Comic Sans MS', - 'Verdana', - 'Courier New', - 'Monaco', - 'monospace', - ], - }, - fontSize: { - type: 'text', - }, - lineHeight: { - type: 'text', - }, - fontWeight: { - type: 'option', - options: [100, 200, 300, 400, 500, 600, 700], - }, - radius: { - type: 'text', - }, - border: { - type: 'text', - nested: { - color: { - type: 'color', - options: allColors, - }, - }, - }, - breakpoint: { type: 'text' }, - mediaQuery: { - type: 'text', - }, - elevation: { - type: 'option', - options: Object.values(elevation), - }, -}; - -export default themeSchema; diff --git a/jest.config.js b/jest.config.js deleted file mode 100644 index 0e82798..0000000 --- a/jest.config.js +++ /dev/null @@ -1,21 +0,0 @@ -module.exports = { - transform: { - '^.+\\.tsx?$': 'ts-jest', - }, - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - testRegex: '^.+\\.spec\\.(ts|tsx|js|jsx)$', - testPathIgnorePatterns: ['/node_modules/', 'lib'], - snapshotSerializers: ['jest-serializer-html-string'], - watchPlugins: [ - 'jest-watch-typeahead/filename', - 'jest-watch-typeahead/testname', - ], - globals: { - 'ts-jest': { - tsConfig: 'tsconfig.json', - }, - }, - moduleNameMapper: { - '@trousers/(.*)$': '/packages/$1/src', - }, -}; diff --git a/package.json b/package.json index 02eed93..5b8cd34 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "precursor", "version": "0.1.0", - "license": "MIT", "private": true, + "license": "MIT", "repository": "https://github.com/danieldelcore/precursor", "workspaces": [ "packages/components/*", @@ -12,68 +12,63 @@ "packages/common/*" ], "scripts": { - "prestart": "yarn build", - "start": "run-p start:*", - "start:watch": "tsc --build --watch", - "start:stories": "start-storybook -p 9000 -s assets", - "clean": "rm -rf node_modules/.cache && rimraf packages/**/**/{tsconfig.tsbuildinfo,lib,dist}", - "validate": "yarn build && yarn lint && yarn monorepo:check", - "postinstall": "yarn monorepo:check", + "start": "yarn start:stories", + "start:stories": "yarn build && storybook dev -p 9000", + "clean": "node scripts/build.mjs --clean && node scripts/build-tokens.mjs --clean", + "build": "yarn tokens:build && tsc --build && node scripts/build.mjs", + "types:check": "tsc -p tsconfig.examples.json", + "test": "yarn build && vitest run", + "test:watch": "yarn build && vitest", + "test:coverage": "yarn build && vitest run --coverage", + "lint": "oxlint --deny-warnings", + "lint:fix": "yarn lint --fix", + "format": "oxfmt", + "format:check": "oxfmt --check", "monorepo:check": "manypkg check", "monorepo:fix": "manypkg fix", - "predeploy-storybook": "build-storybook -s assets", - "deploy-storybook": "storybook-to-ghpages", - "build": "tsc --build", - "test": "jest", - "test:watch": "jest --watch", - "test:coverage": "jest --coverage", - "lint": "eslint --config .eslintrc.js --ext tsx,ts ./packages/**/**/ ./examples ./fixtures", - "lint:fix": "yarn lint -- --fix", + "validate": "yarn build && yarn types:check && yarn lint && yarn format:check && yarn monorepo:check && vitest run", + "stories:build": "yarn build && storybook build", + "predeploy-storybook": "yarn stories:build", + "deploy-storybook": "gh-pages -d storybook-static", "docs:update": "markdown-toc -i ./README.md --maxdepth 3", - "prerelease": "yarn lint && yarn monorepo:check && yarn test", - "release": "yarn build && yarn changeset publish" + "release": "yarn validate && changeset publish", + "version:packages": "changeset version \"$@\" && yarn install --mode=update-lockfile", + "tokens:build": "node scripts/build-tokens.mjs" }, - "dependencies": { - "@babel/core": "^7.7.5", - "@changesets/cli": "^2.6.2", - "@manypkg/cli": "^0.11.1", - "@storybook/addons": "^5.3.0", - "@storybook/react": "^5.3.0", - "@storybook/source-loader": "^5.3.0", - "@storybook/storybook-deployer": "^2.8.1", - "@testing-library/react": "^10.0.0", - "@trousers/collector": "^3.0.2", - "@trousers/core": "^3.0.2", - "@trousers/theme": "^3.0.0", - "@types/jest": "^25.2.0", - "@types/jsdom": "^12.2.3", - "@types/react": "^16.8.1", - "@types/react-dom": "^16.8.2", - "@typescript-eslint/eslint-plugin": "^1.4.2", - "@typescript-eslint/parser": "^1.4.2", - "babel-loader": "^8.0.6", - "eslint": "^7.5.0", - "eslint-config-prettier": "^4.1.0", - "eslint-plugin-import": "^2.22.0", - "eslint-plugin-jsx-a11y": "^6.3.1", - "eslint-plugin-prettier": "^3.0.1", - "eslint-plugin-react": "^7.12.4", - "eslint-plugin-react-hooks": "^1.5.0", - "jest": "^25.3.0", - "jest-serializer-html-string": "^1.0.1", - "jest-watch-typeahead": "^0.4.2", - "jsdom": "^14.0.0", + "devDependencies": { + "@changesets/cli": "^3.1.0", + "@manypkg/cli": "^0.25.1", + "@storybook/react-vite": "11.0.0", + "@testing-library/dom": "^10.4.2", + "@testing-library/react": "^16.3.3", + "@trousers/core": "4.1.0", + "@trousers/esbuild": "4.1.0", + "@types/node": "^24.0.0", + "@types/react": "19.3.3", + "@types/react-dom": "19.3.0", + "@vitest/coverage-v8": "5.1.2", + "esbuild": "^0.28.2", + "gh-pages": "^6.3.0", + "jsdom": "^31.0.1", "markdown-toc": "^1.2.0", - "npm-run-all": "^4.1.5", - "object-deep-key": "^1.1.3", - "prettier": "^1.16.4", - "react": "^16.8.1", - "react-dom": "^16.8.4", - "react-stable-ref": "^0.4.0", - "rimraf": "^2.6.3", - "storybook-addon-performance": "^0.10.0", - "ts-jest": "^25.3.1", - "ts-loader": "^6.2.1", - "typescript": "^3.8.1" + "oxfmt": "^0.81.0", + "oxlint": "^1.96.0", + "react": "19.3.1", + "react-dom": "19.3.1", + "storybook": "11.0.0", + "style-dictionary": "^5.8.0", + "typescript": "~5.9.3", + "vite": "^8.4.1", + "vitest": "5.1.2" + }, + "engines": { + "node": "^24.15.0 || >=26" + }, + "packageManager": "yarn@4.19.0", + "manypkg": { + "defaultBranch": "master", + "ignoredRules": [ + "INCORRECT_REPOSITORY_FIELD" + ] } } diff --git a/packages/common/copy-to-clipboard/package.json b/packages/common/copy-to-clipboard/package.json index b86387c..eea3110 100644 --- a/packages/common/copy-to-clipboard/package.json +++ b/packages/common/copy-to-clipboard/package.json @@ -2,11 +2,30 @@ "name": "@precursor/copy-to-clipboard", "version": "0.1.2", "description": "Copy to clipboard utility", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/danieldelcore/precursor.git", + "directory": "packages/common/copy-to-clipboard" + }, + "files": [ + "dist" + ], "main": "dist/index.js", - "module": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", - "license": "MIT", - "dependencies": {}, - "devDependencies": {}, - "repository": "https://github.com/danieldelcore/precursor/tree/master/packages/common/copy-to-clipboard" + "exports": { + ".": { + "import": { + "types": "./dist/index.d.mts", + "default": "./dist/index.mjs" + }, + "require": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "default": "./dist/index.js" + }, + "./package.json": "./package.json" + } } diff --git a/packages/common/copy-to-clipboard/tsconfig.json b/packages/common/copy-to-clipboard/tsconfig.json index 9bea8f3..9ce02f8 100644 --- a/packages/common/copy-to-clipboard/tsconfig.json +++ b/packages/common/copy-to-clipboard/tsconfig.json @@ -4,7 +4,8 @@ "compilerOptions": { "outDir": "dist", "rootDir": ".", - "baseUrl": "." + "tsBuildInfoFile": "./tsconfig.tsbuildinfo" }, - "references": [] + "references": [], + "exclude": ["dist", "**/*.spec.*"] } diff --git a/packages/common/types/package.json b/packages/common/types/package.json index f7d2625..236bd8e 100644 --- a/packages/common/types/package.json +++ b/packages/common/types/package.json @@ -1,11 +1,30 @@ { "name": "@precursor/types", "version": "0.1.2", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/danieldelcore/precursor.git", + "directory": "packages/common/types" + }, + "files": [ + "dist" + ], "main": "dist/index.js", - "module": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", - "license": "MIT", - "dependencies": {}, - "devDependencies": {}, - "repository": "https://github.com/danieldelcore/precursor/tree/master/packages/common/types" + "exports": { + ".": { + "import": { + "types": "./dist/index.d.mts", + "default": "./dist/index.mjs" + }, + "require": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "default": "./dist/index.js" + }, + "./package.json": "./package.json" + } } diff --git a/packages/common/types/tsconfig.json b/packages/common/types/tsconfig.json index 9bea8f3..9ce02f8 100644 --- a/packages/common/types/tsconfig.json +++ b/packages/common/types/tsconfig.json @@ -4,7 +4,8 @@ "compilerOptions": { "outDir": "dist", "rootDir": ".", - "baseUrl": "." + "tsBuildInfoFile": "./tsconfig.tsbuildinfo" }, - "references": [] + "references": [], + "exclude": ["dist", "**/*.spec.*"] } diff --git a/packages/components/avatar/Avatar.spec.tsx b/packages/components/avatar/Avatar.spec.tsx index 336c397..4b0de2f 100644 --- a/packages/components/avatar/Avatar.spec.tsx +++ b/packages/components/avatar/Avatar.spec.tsx @@ -1,5 +1,14 @@ +import { render } from '@testing-library/react'; +import { describe, expect, it } from 'vitest'; +import Avatar from '@precursor/avatar'; + describe('Avatar', () => { - it('this is a placeholder test', () => { - expect(true).toEqual(true); + it('renders the image using the compiled component styles', () => { + const { getByRole } = render(); + const image = getByRole('img', { name: 'Ada' }); + + expect(image.getAttribute('src')).toBe('/avatar.png'); + expect(image.className).not.toBe(''); + expect(image.parentElement?.className).not.toBe(''); }); }); diff --git a/packages/components/avatar/Avatar.tsx b/packages/components/avatar/Avatar.tsx index 51d54a0..e31cf38 100644 --- a/packages/components/avatar/Avatar.tsx +++ b/packages/components/avatar/Avatar.tsx @@ -1,24 +1,22 @@ -/** @jsx jsx */ +import { classnames, css } from 'trousers'; import { FC } from 'react'; -import { jsx, css } from '@trousers/core'; import Image, { ImageProps } from '@precursor/image'; -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface AvatarProps extends ImageProps {} +export type AvatarProps = ImageProps; + +const avatarStyles = css({ + display: 'inline-block', + position: 'relative', + outline: '0px', + height: '64px', + width: '64px', + overflow: 'hidden', + borderRadius: '50%', +}); const Avatar: FC = ({ src, alt }) => ( - + {alt} ); diff --git a/packages/components/avatar/package.json b/packages/components/avatar/package.json index 13d5802..7acb3bf 100644 --- a/packages/components/avatar/package.json +++ b/packages/components/avatar/package.json @@ -2,20 +2,49 @@ "name": "@precursor/avatar", "version": "0.1.5", "description": "Avatar component", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/danieldelcore/precursor.git", + "directory": "packages/components/avatar" + }, + "files": [ + "dist" + ], + "sideEffects": [ + "**/*.css", + "./dist/browser.mjs" + ], "main": "dist/index.js", - "module": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", - "license": "MIT", + "exports": { + ".": { + "browser": { + "types": "./dist/index.d.mts", + "default": "./dist/browser.mjs" + }, + "import": { + "types": "./dist/index.d.mts", + "default": "./dist/index.mjs" + }, + "require": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "default": "./dist/index.js" + }, + "./styles.css": "./dist/index.css", + "./package.json": "./package.json" + }, "dependencies": { "@precursor/image": "^0.1.3", - "@trousers/collector": "^3.0.2", - "@trousers/core": "^3.0.2" + "trousers": "^4.1.0" }, "devDependencies": { - "react": "^16.8.1" + "react": "19.3.1" }, "peerDependencies": { - "react": ">=16.8.0" - }, - "repository": "https://github.com/danieldelcore/precursor/tree/master/packages/components/avatar" + "react": "^19.0.0" + } } diff --git a/packages/components/avatar/tsconfig.json b/packages/components/avatar/tsconfig.json index 073580b..cfac9ed 100644 --- a/packages/components/avatar/tsconfig.json +++ b/packages/components/avatar/tsconfig.json @@ -4,7 +4,12 @@ "compilerOptions": { "outDir": "dist", "rootDir": ".", - "baseUrl": "." + "tsBuildInfoFile": "./tsconfig.tsbuildinfo" }, - "references": [{ "path": "../image" }] + "references": [ + { + "path": "../image" + } + ], + "exclude": ["dist", "**/*.spec.*"] } diff --git a/packages/components/badge/Badge.tsx b/packages/components/badge/Badge.tsx index c33a110..68ce95a 100644 --- a/packages/components/badge/Badge.tsx +++ b/packages/components/badge/Badge.tsx @@ -1,38 +1,44 @@ -/** @jsx jsx */ +import { classnames, css } from 'trousers'; import { FC, ReactNode } from 'react'; -import { jsx } from '@trousers/core'; -import collector from '@trousers/collector'; - -import { Theme } from '@precursor/theme'; export interface BadgeProps { status?: 'error' | 'success' | 'warning'; children: ReactNode; } -const styles = (status: BadgeProps['status']) => collector('Badge') - .element` - display: inline-block; - min-width: 30px; - border-radius: 1rem; - padding: 2px 6px; - text-align: center; - font-size: ${({ fontSize }) => fontSize.small}; - background-color: ${({ color }) => color.info.light}; - color: ${({ color }) => color.info.base}; -`.modifier('error', status === 'error')` - background-color: ${({ color }) => color.error.light}; - color: ${({ color }) => color.error.base}; -`.modifier('warning', status === 'warning')` - background-color: ${({ color }: Theme) => color.warning.light}; - color: ${({ color }: Theme) => color.warning.base}; -`.modifier('success', status === 'success')` - background-color: ${({ color }: Theme) => color.success.light}; - color: ${({ color }: Theme) => color.success.base}; -`; +const styles = css('Badge', { + display: 'inline-block', + minWidth: '30px', + borderRadius: '1rem', + padding: 'var(--spacing-inset-xxs) var(--spacing-inset-xs)', + textAlign: 'center', + fontSize: 'var(--typography-size-small)', + backgroundColor: 'var(--color-feedback-info-surface)', + color: 'var(--color-feedback-info)', +}) + .modifier('error', { + backgroundColor: 'var(--color-feedback-error-surface)', + color: 'var(--color-feedback-error)', + }) + .modifier('warning', { + backgroundColor: 'var(--color-feedback-warning-surface)', + color: 'var(--color-feedback-warning)', + }) + .modifier('success', { + backgroundColor: 'var(--color-feedback-success-surface)', + color: 'var(--color-feedback-success)', + }); const Badge: FC = ({ status, children }) => ( - {children} + + {children} + ); export default Badge; diff --git a/packages/components/badge/package.json b/packages/components/badge/package.json index ef200a6..2b0e742 100644 --- a/packages/components/badge/package.json +++ b/packages/components/badge/package.json @@ -2,19 +2,48 @@ "name": "@precursor/badge", "version": "0.1.6", "description": "Badge component", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/danieldelcore/precursor.git", + "directory": "packages/components/badge" + }, + "files": [ + "dist" + ], + "sideEffects": [ + "**/*.css", + "./dist/browser.mjs" + ], "main": "dist/index.js", - "module": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", - "license": "MIT", + "exports": { + ".": { + "browser": { + "types": "./dist/index.d.mts", + "default": "./dist/browser.mjs" + }, + "import": { + "types": "./dist/index.d.mts", + "default": "./dist/index.mjs" + }, + "require": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "default": "./dist/index.js" + }, + "./styles.css": "./dist/index.css", + "./package.json": "./package.json" + }, "dependencies": { - "@trousers/collector": "^3.0.2", - "@trousers/core": "^3.0.2" + "trousers": "^4.1.0" }, "devDependencies": { - "react": "^16.8.1" + "react": "19.3.1" }, "peerDependencies": { - "react": ">=16.8.0" - }, - "repository": "https://github.com/danieldelcore/precursor/tree/master/packages/components/badge" + "react": "^19.0.0" + } } diff --git a/packages/components/badge/tsconfig.json b/packages/components/badge/tsconfig.json index 9bea8f3..9ce02f8 100644 --- a/packages/components/badge/tsconfig.json +++ b/packages/components/badge/tsconfig.json @@ -4,7 +4,8 @@ "compilerOptions": { "outDir": "dist", "rootDir": ".", - "baseUrl": "." + "tsBuildInfoFile": "./tsconfig.tsbuildinfo" }, - "references": [] + "references": [], + "exclude": ["dist", "**/*.spec.*"] } diff --git a/packages/components/button/Button.tsx b/packages/components/button/Button.tsx index c0084e5..0c8579d 100644 --- a/packages/components/button/Button.tsx +++ b/packages/components/button/Button.tsx @@ -1,9 +1,6 @@ -/** @jsx jsx */ +import { classnames, css } from 'trousers'; import { FC, ReactNode, Fragment } from 'react'; -import { jsx } from '@trousers/core'; -import collector from '@trousers/collector'; -import { Theme } from '@precursor/theme'; import Spinner from '@precursor/spinner'; export interface ButtonProps { @@ -13,95 +10,99 @@ export interface ButtonProps { disabled?: boolean; loading?: boolean; onClick?: React.MouseEventHandler; + popoverTarget?: string; + popoverTargetAction?: 'hide' | 'show' | 'toggle'; } -const styles = (props: ButtonProps) => collector('Button').element` - display: inline-block; - position: relative; - min-height: 30px; - color: ${({ color }) => color.typography.base}; - text-align: center; - font-weight: ${({ fontWeight }) => fontWeight.base}; - line-height: ${({ lineHeight }) => lineHeight.base}; - letter-spacing: .1rem; - text-decoration: none; - white-space: nowrap; - background-color: ${({ color }) => color.neutral.lighter}; - border-radius: ${({ radius }) => radius.l}; - padding: ${({ spacePreset }) => `${spacePreset.insetSquish}`}; - cursor: pointer; - user-select: none; - border: none; - outline: none; - transition: background-color 200ms; +const styles = css('Button', { + display: 'inline-block', + position: 'relative', + minHeight: '30px', + color: 'var(--color-text)', + textAlign: 'center', + 'font-weight': 'var(--typography-weight)', + lineHeight: 'var(--typography-line-height)', + letterSpacing: '.1rem', + textDecoration: 'none', + whiteSpace: 'nowrap', + backgroundColor: 'var(--color-neutral-lighter)', + borderRadius: 'var(--shape-radius-l)', + padding: 'var(--spacing-inset-squish)', + cursor: 'pointer', + userSelect: 'none', + border: 'none', + outline: 'none', + transition: 'background-color 200ms', + '> *': { + pointerEvents: 'none', + }, + '&:focus': { + boxShadow: 'var(--color-neutral) 0px 0px 2px 1px', + outline: '0', + }, + '&:hover': { + backgroundColor: 'var(--color-neutral-light)', + }, + '&:active': { + backgroundColor: 'var(--color-neutral)', + }, +}) + .modifier('primary', { + color: 'var(--color-text-inverse)', + backgroundColor: 'var(--color-brand-bold)', + '&:focus': { + boxShadow: 'var(--color-brand-bold) 0px 0px 2px 1px', + outline: '0', + }, + '&:hover': { + backgroundColor: 'var(--color-brand-bold-hovered)', + }, + '&:active': { + backgroundColor: 'var(--color-brand-bold-pressed)', + }, + }) + .modifier('disabled', { + color: 'var(--color-text-disabled)', + backgroundColor: 'var(--color-neutral-lighter)', + cursor: 'not-allowed', + '&:hover': { + backgroundColor: 'var(--color-neutral-lighter)', + }, + }); - > * { - pointer-events: none; - } +const loadingStyles = css({ + position: 'absolute', + display: 'flex', + pointerEvents: 'none', + justifyContent: 'center', + alignItems: 'center', + inset: '0', +}); - &:focus { - box-shadow: ${({ color }) => color.neutral.base} 0px 0px 2px 1px; - outline: 0; - } +const hiddenTextStyles = css({ + opacity: '0', +}); - &:hover { - background-color: ${({ color }) => color.neutral.light}; - } - - &:active { - background-color: ${({ color }) => color.neutral.base}; - } - `.modifier('primary', props.primary)` - color: ${({ color }) => color.typography.baseInverse}; - background-color: ${({ color }) => color.primary.base}; - - &:focus { - box-shadow: ${({ color }) => color.primary.base} 0px 0px 2px 1px; - outline: 0; - } - - &:hover { - background-color: ${({ color }) => color.primary.dark}; - } - - &:active { - background-color: ${({ color }) => color.primary.darker}; - } - `.modifier('disabled', props.disabled || props.loading)` - color: #CFD8E3; - background-color: ${({ color }: Theme) => color.neutral.lighter}; - cursor: not-allowed; - - &:hover { - background-color: ${({ color }: Theme) => color.neutral.lighter}; - } - `; - -const Button: FC = props => ( +const Button: FC = (props) => ( ); -Button.defaultProps = { - type: 'button', -}; - export default Button; diff --git a/packages/components/button/package.json b/packages/components/button/package.json index 51288e5..89061f8 100644 --- a/packages/components/button/package.json +++ b/packages/components/button/package.json @@ -2,21 +2,50 @@ "name": "@precursor/button", "version": "0.1.8", "description": "button component", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/danieldelcore/precursor.git", + "directory": "packages/components/button" + }, + "files": [ + "dist" + ], + "sideEffects": [ + "**/*.css", + "./dist/browser.mjs" + ], "main": "dist/index.js", - "module": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", - "license": "MIT", + "exports": { + ".": { + "browser": { + "types": "./dist/index.d.mts", + "default": "./dist/browser.mjs" + }, + "import": { + "types": "./dist/index.d.mts", + "default": "./dist/index.mjs" + }, + "require": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "default": "./dist/index.js" + }, + "./styles.css": "./dist/index.css", + "./package.json": "./package.json" + }, "dependencies": { "@precursor/spinner": "^0.1.1", "@precursor/theme": "^0.1.7", - "@trousers/collector": "^3.0.2", - "@trousers/core": "^3.0.2" + "trousers": "^4.1.0" }, "devDependencies": { - "react": "^16.8.1" + "react": "19.3.1" }, "peerDependencies": { - "react": ">=16.8.0" - }, - "repository": "https://github.com/danieldelcore/precursor/tree/master/packages/components/button" + "react": "^19.0.0" + } } diff --git a/packages/components/button/tsconfig.json b/packages/components/button/tsconfig.json index 80ddcb8..919cf2d 100644 --- a/packages/components/button/tsconfig.json +++ b/packages/components/button/tsconfig.json @@ -4,7 +4,15 @@ "compilerOptions": { "outDir": "dist", "rootDir": ".", - "baseUrl": "." + "tsBuildInfoFile": "./tsconfig.tsbuildinfo" }, - "references": [{ "path": "../../theming/theme" }, { "path": "../spinner" }] + "references": [ + { + "path": "../../theming/theme" + }, + { + "path": "../spinner" + } + ], + "exclude": ["dist", "**/*.spec.*"] } diff --git a/packages/components/checkbox/Checkbox.tsx b/packages/components/checkbox/Checkbox.tsx index 7f3a3e2..79033c8 100644 --- a/packages/components/checkbox/Checkbox.tsx +++ b/packages/components/checkbox/Checkbox.tsx @@ -1,42 +1,93 @@ -/** @jsx jsx */ -import { FC } from 'react'; -import { jsx } from '@trousers/core'; -import collector from '@trousers/collector'; - -import Label from '@precursor/label'; -import Input, { InputProps } from '@precursor/input'; -import { Theme } from '@precursor/theme'; +import { classnames, css } from 'trousers'; +import type { InputProps } from '@precursor/input'; export interface CheckboxProps extends InputProps { label: string; + defaultChecked?: boolean; } -const styles = collector('Checkbox').element` - height: auto; - width: auto; - appearance: checkbox; - display: inline; - cursor: pointer; - margin-right: ${({ spacePreset }) => spacePreset.inline}; -`; +const labelStyles = css({ + display: 'inline-flex', + alignItems: 'center', + gap: 'var(--spacing-inline)', + minBlockSize: '24px', + cursor: 'pointer', + color: 'var(--color-text)', + fontSize: 'var(--typography-size-label)', + 'font-weight': 'var(--typography-weight-label)', + '&:has(:disabled)': { + color: 'var(--color-text-disabled)', + cursor: 'not-allowed', + }, +}); + +const inputStyles = css('Checkbox', { + '--checkbox-size': '18px', + appearance: 'none', + display: 'inline-grid', + placeContent: 'center', + boxSizing: 'border-box', + flexShrink: 0, + inlineSize: 'var(--checkbox-size)', + blockSize: 'var(--checkbox-size)', + margin: 0, + border: 'var(--shape-border-medium, 2px) solid var(--color-neutral)', + borderRadius: 'var(--shape-radius-s)', + backgroundColor: 'var(--color-surface)', + cursor: 'inherit', + '&:not(:disabled):hover': { borderColor: 'var(--color-border-focused)' }, + '&:focus-visible': { + outline: 'var(--shape-border-medium) solid var(--color-focus)', + outlineOffset: 'var(--shape-border-medium)', + }, + '&:checked': { + borderColor: 'var(--color-brand-bold)', + backgroundColor: 'var(--color-brand-bold)', + '&::before': { + content: '""', + inlineSize: 'calc(var(--checkbox-size) / 2.2)', + blockSize: 'calc(var(--checkbox-size) / 4)', + borderLeft: '2px solid var(--color-brand-ink)', + borderBottom: '2px solid var(--color-brand-ink)', + transform: 'translateY(-1px) rotate(-45deg)', + }, + }, + '&:disabled': { opacity: 0.65 }, + '@media (forced-colors: active)': { + appearance: 'checkbox', + '&:checked::before': { content: 'none' }, + }, +}) + .modifier('small', { '--checkbox-size': '16px' }) + .modifier('large', { '--checkbox-size': '22px' }) + .modifier('success', { + borderColor: 'var(--color-feedback-success-border)', + }) + .modifier('warning', { + borderColor: 'var(--color-feedback-warning-border)', + }) + .modifier('error', { borderColor: 'var(--color-feedback-error-border)' }); -const Checkbox: FC = props => { +export default function Checkbox({ + label, + size, + state, + ...props +}: CheckboxProps) { return ( - + {label} + ); -}; - -export default Checkbox; +} diff --git a/packages/components/checkbox/package.json b/packages/components/checkbox/package.json index 485f840..e8aa762 100644 --- a/packages/components/checkbox/package.json +++ b/packages/components/checkbox/package.json @@ -2,22 +2,49 @@ "name": "@precursor/checkbox", "version": "0.1.4", "description": "Checkbox component", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/danieldelcore/precursor.git", + "directory": "packages/components/checkbox" + }, + "files": [ + "dist" + ], + "sideEffects": [ + "**/*.css", + "./dist/browser.mjs" + ], "main": "dist/index.js", - "module": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", - "license": "MIT", + "exports": { + ".": { + "browser": { + "types": "./dist/index.d.mts", + "default": "./dist/browser.mjs" + }, + "import": { + "types": "./dist/index.d.mts", + "default": "./dist/index.mjs" + }, + "require": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "default": "./dist/index.js" + }, + "./styles.css": "./dist/index.css", + "./package.json": "./package.json" + }, "dependencies": { "@precursor/input": "^0.1.7", - "@precursor/label": "^0.1.7", - "@precursor/theme": "^0.1.7", - "@trousers/collector": "^3.0.2", - "@trousers/core": "^3.0.2" + "trousers": "^4.1.0" }, "devDependencies": { - "react": "^16.8.1" + "react": "19.3.1" }, "peerDependencies": { - "react": ">=16.8.0" - }, - "repository": "https://github.com/danieldelcore/precursor/tree/master/packages/components/checkbox" + "react": "^19.0.0" + } } diff --git a/packages/components/checkbox/tsconfig.json b/packages/components/checkbox/tsconfig.json index 2da1429..6de699e 100644 --- a/packages/components/checkbox/tsconfig.json +++ b/packages/components/checkbox/tsconfig.json @@ -4,11 +4,12 @@ "compilerOptions": { "outDir": "dist", "rootDir": ".", - "baseUrl": "." + "tsBuildInfoFile": "./tsconfig.tsbuildinfo" }, "references": [ - { "path": "../../theming/theme" }, - { "path": "../input" }, - { "path": "../label" } - ] + { + "path": "../input" + } + ], + "exclude": ["dist", "**/*.spec.*"] } diff --git a/packages/components/code/Code.tsx b/packages/components/code/Code.tsx index 21167b2..48e6f9c 100644 --- a/packages/components/code/Code.tsx +++ b/packages/components/code/Code.tsx @@ -1,40 +1,36 @@ -import React, { FC, ReactNode } from 'react'; -import { useStyles } from '@trousers/core'; -import collector from '@trousers/collector'; - -import { Theme } from '@precursor/theme'; +import { classnames, css } from 'trousers'; +import { FC, ReactNode } from 'react'; export interface CodeProps { children: ReactNode; inline?: boolean; } -const preStyles = collector('Pre').element` - margin: 0; - - & > code { - display: block; - padding: 1rem 1.5rem; - white-space: pre; - max-width: 100%; - overflow-y: auto; - color: ${({ color }) => color.typography.base}; - font-family: ${({ font }) => font.code}; - } -`; - -const codeStyles = collector('Code').element` - padding: .2rem .5rem; - font-size: 90%; - border-radius: ${({ radius }) => radius.s}; - background-color: ${({ color }) => color.background.light}; - color: ${({ color }) => color.typography.base}; - font-family: ${({ font }) => font.code}; -`; - -const Code: FC = props => { - const preClassNames = useStyles(preStyles); - const codeClassNames = useStyles(codeStyles); +const preStyles = css('Pre', { + margin: '0', + '& > code': { + display: 'block', + padding: 'var(--spacing-inset-s) var(--spacing-inset-m)', + whiteSpace: 'pre', + maxWidth: '100%', + overflowY: 'auto', + color: 'var(--color-text)', + fontFamily: 'var(--typography-family-code)', + }, +}); + +const codeStyles = css('Code', { + padding: 'var(--spacing-inset-xxs) var(--spacing-inset-xs)', + fontSize: '90%', + borderRadius: 'var(--shape-radius-s)', + backgroundColor: 'var(--color-surface-subtle)', + color: 'var(--color-text)', + fontFamily: 'var(--typography-family-code)', +}); + +const Code: FC = (props) => { + const preClassNames = classnames(preStyles); + const codeClassNames = classnames(codeStyles); const codeBlock = {props.children}; diff --git a/packages/components/code/package.json b/packages/components/code/package.json index 310578a..7c03081 100644 --- a/packages/components/code/package.json +++ b/packages/components/code/package.json @@ -2,20 +2,49 @@ "name": "@precursor/code", "version": "0.1.6", "description": "code component", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/danieldelcore/precursor.git", + "directory": "packages/components/code" + }, + "files": [ + "dist" + ], + "sideEffects": [ + "**/*.css", + "./dist/browser.mjs" + ], "main": "dist/index.js", - "module": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", - "license": "MIT", + "exports": { + ".": { + "browser": { + "types": "./dist/index.d.mts", + "default": "./dist/browser.mjs" + }, + "import": { + "types": "./dist/index.d.mts", + "default": "./dist/index.mjs" + }, + "require": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "default": "./dist/index.js" + }, + "./styles.css": "./dist/index.css", + "./package.json": "./package.json" + }, "dependencies": { "@precursor/theme": "^0.1.7", - "@trousers/collector": "^3.0.2", - "@trousers/core": "^3.0.2" + "trousers": "^4.1.0" }, "devDependencies": { - "react": "^16.8.1" + "react": "19.3.1" }, "peerDependencies": { - "react": ">=16.8.0" - }, - "repository": "https://github.com/danieldelcore/precursor/tree/master/packages/components/code" + "react": "^19.0.0" + } } diff --git a/packages/components/code/tsconfig.json b/packages/components/code/tsconfig.json index 88fa918..85f4812 100644 --- a/packages/components/code/tsconfig.json +++ b/packages/components/code/tsconfig.json @@ -4,7 +4,12 @@ "compilerOptions": { "outDir": "dist", "rootDir": ".", - "baseUrl": "." + "tsBuildInfoFile": "./tsconfig.tsbuildinfo" }, - "references": [{ "path": "../../theming/theme" }] + "references": [ + { + "path": "../../theming/theme" + } + ], + "exclude": ["dist", "**/*.spec.*"] } diff --git a/packages/components/image/Image.tsx b/packages/components/image/Image.tsx index adc9200..6c5da5f 100644 --- a/packages/components/image/Image.tsx +++ b/packages/components/image/Image.tsx @@ -1,20 +1,17 @@ -/** @jsx jsx */ +import { classnames, css } from 'trousers'; import { FC } from 'react'; -import { css, jsx } from '@trousers/core'; export interface ImageProps { src: string; alt?: string; } -const Image: FC = props => ( - {props.alt} +const imageStyles = css({ + width: '100%', +}); + +const Image: FC = (props) => ( + {props.alt} ); export default Image; diff --git a/packages/components/image/package.json b/packages/components/image/package.json index 610627a..650b0c2 100644 --- a/packages/components/image/package.json +++ b/packages/components/image/package.json @@ -2,18 +2,48 @@ "name": "@precursor/image", "version": "0.1.3", "description": "image component", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/danieldelcore/precursor.git", + "directory": "packages/components/image" + }, + "files": [ + "dist" + ], + "sideEffects": [ + "**/*.css", + "./dist/browser.mjs" + ], "main": "dist/index.js", - "module": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", - "license": "MIT", + "exports": { + ".": { + "browser": { + "types": "./dist/index.d.mts", + "default": "./dist/browser.mjs" + }, + "import": { + "types": "./dist/index.d.mts", + "default": "./dist/index.mjs" + }, + "require": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "default": "./dist/index.js" + }, + "./styles.css": "./dist/index.css", + "./package.json": "./package.json" + }, "dependencies": { - "@trousers/core": "^3.0.2" + "trousers": "^4.1.0" }, "devDependencies": { - "react": "^16.8.1" + "react": "19.3.1" }, "peerDependencies": { - "react": ">=16.8.0" - }, - "repository": "https://github.com/danieldelcore/precursor/tree/master/packages/components/image" + "react": "^19.0.0" + } } diff --git a/packages/components/image/tsconfig.json b/packages/components/image/tsconfig.json index 9bea8f3..9ce02f8 100644 --- a/packages/components/image/tsconfig.json +++ b/packages/components/image/tsconfig.json @@ -4,7 +4,8 @@ "compilerOptions": { "outDir": "dist", "rootDir": ".", - "baseUrl": "." + "tsBuildInfoFile": "./tsconfig.tsbuildinfo" }, - "references": [] + "references": [], + "exclude": ["dist", "**/*.spec.*"] } diff --git a/packages/components/input/Input.tsx b/packages/components/input/Input.tsx index 89525a4..4d39da3 100644 --- a/packages/components/input/Input.tsx +++ b/packages/components/input/Input.tsx @@ -1,8 +1,6 @@ -import React, { FC, ChangeEventHandler } from 'react'; -import { useStyles } from '@trousers/core'; -import collector from '@trousers/collector'; +import { classnames, css } from 'trousers'; +import { FC, ChangeEventHandler } from 'react'; -import { Theme } from '@precursor/theme'; import { InputTypes } from '@precursor/types'; export interface InputProps { @@ -20,50 +18,59 @@ export interface InputProps { onChange?: ChangeEventHandler; } -const styles = ({ size, state, disabled }: InputProps) => collector( - 'Input', -).element` - --input-height: 44px; - --input-border-color: #E2E8F0; - height: var(--input-height); - padding: 0 10px; - background-color: ${({ color }) => color.background.base}; - border-radius: ${({ radius }) => radius.m}; - border-color: var(--input-border-color); - border-style: solid; - border-width: 2px; - box-shadow: none; - appearance: none; - width: 100%; - margin: 0; - font-family: ${({ font }) => font.base}; - color: ${({ color }) => color.typography.base}; - - &::placeholder { - color: ${({ color }) => color.typography.placeholder}; - } - - &:focus { - box-shadow: var(--input-border-color) 0px 0px 2px 1px; - outline: 0; - } -`.modifier('success', state === 'success')` - --input-border-color: #31C48D; -`.modifier('warning', state === 'warning')` - --input-border-color: #FDBA8C; -`.modifier('error', state === 'error')` - --input-border-color: #F98080; -`.modifier('disabled', disabled)` - cursor: not-allowed; - background-color: ${({ color }: Theme) => color.background.light}; -`.modifier('small', size === 's')` - --input-height: 36px; -`.modifier('large', size === 'l')` - --input-height: 52px; -`; +const styles = css('Input', { + '--input-height': '44px', + '--input-border-color': 'var(--color-border-control)', + height: 'var(--input-height)', + padding: '0 var(--spacing-inset-xs)', + backgroundColor: 'var(--color-surface)', + borderRadius: 'var(--shape-radius-m)', + borderColor: 'var(--input-border-color)', + borderStyle: 'solid', + borderWidth: '2px', + boxShadow: 'none', + appearance: 'none', + width: '100%', + margin: '0', + fontFamily: 'var(--typography-family)', + color: 'var(--color-text)', + '&::placeholder': { + color: 'var(--color-text-placeholder)', + }, + '&:focus': { + boxShadow: 'var(--input-border-color) 0px 0px 2px 1px', + outline: '0', + }, +}) + .modifier('success', { + '--input-border-color': 'var(--color-feedback-success-border)', + }) + .modifier('warning', { + '--input-border-color': 'var(--color-feedback-warning-border)', + }) + .modifier('error', { + '--input-border-color': 'var(--color-feedback-error-border)', + }) + .modifier('disabled', { + cursor: 'not-allowed', + backgroundColor: 'var(--color-surface-subtle)', + }) + .modifier('small', { + '--input-height': '36px', + }) + .modifier('large', { + '--input-height': '52px', + }); const Input: FC = ({ type = 'text', ...props }) => { - const classNames = useStyles(styles(props)); + const classNames = classnames(styles, { + success: props.state === 'success', + warning: props.state === 'warning', + error: props.state === 'error', + disabled: props.disabled, + small: props.size === 's', + large: props.size === 'l', + }); return ( = ({ type = 'text', ...props }) => { onChange={props.onChange} placeholder={props.placeholder} type={type} - value={props.value || props.defaultValue} + value={props.value} + defaultValue={props.defaultValue} checked={props.checked} /> ); diff --git a/packages/components/input/package.json b/packages/components/input/package.json index 1c368af..19a9fd3 100644 --- a/packages/components/input/package.json +++ b/packages/components/input/package.json @@ -2,20 +2,50 @@ "name": "@precursor/input", "version": "0.1.7", "description": "input component", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/danieldelcore/precursor.git", + "directory": "packages/components/input" + }, + "files": [ + "dist" + ], + "sideEffects": [ + "**/*.css", + "./dist/browser.mjs" + ], "main": "dist/index.js", - "module": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", - "license": "MIT", + "exports": { + ".": { + "browser": { + "types": "./dist/index.d.mts", + "default": "./dist/browser.mjs" + }, + "import": { + "types": "./dist/index.d.mts", + "default": "./dist/index.mjs" + }, + "require": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "default": "./dist/index.js" + }, + "./styles.css": "./dist/index.css", + "./package.json": "./package.json" + }, "dependencies": { "@precursor/theme": "^0.1.7", - "@trousers/collector": "^3.0.2", - "@trousers/core": "^3.0.2" + "@precursor/types": "^0.1.2", + "trousers": "^4.1.0" }, "devDependencies": { - "react": "^16.8.1" + "react": "19.3.1" }, "peerDependencies": { - "react": ">=16.8.0" - }, - "repository": "https://github.com/danieldelcore/precursor/tree/master/packages/components/input" + "react": "^19.0.0" + } } diff --git a/packages/components/input/tsconfig.json b/packages/components/input/tsconfig.json index 1ac2033..3a3db07 100644 --- a/packages/components/input/tsconfig.json +++ b/packages/components/input/tsconfig.json @@ -4,7 +4,12 @@ "compilerOptions": { "outDir": "dist", "rootDir": ".", - "baseUrl": "." + "tsBuildInfoFile": "./tsconfig.tsbuildinfo" }, - "references": [{ "path": "../../common/types" }] + "references": [ + { + "path": "../../common/types" + } + ], + "exclude": ["dist", "**/*.spec.*"] } diff --git a/packages/components/keyboard/Keyboard.tsx b/packages/components/keyboard/Keyboard.tsx index e8c739b..a78b248 100644 --- a/packages/components/keyboard/Keyboard.tsx +++ b/packages/components/keyboard/Keyboard.tsx @@ -1,7 +1,5 @@ -/** @jsx jsx */ +import { classnames, css } from 'trousers'; import { FC, ReactNode } from 'react'; -import { jsx, css } from '@trousers/core'; -import { Theme } from '@precursor/theme'; export interface KeyboardProps { children?: ReactNode; @@ -11,12 +9,12 @@ export interface KeyboardProps { ctrl?: boolean; } -const styles = css` - padding: 0 10px; - background-color: ${({ color }) => color.background.light}; - border-radius: ${({ radius }) => radius.s}; - border: ${({ border }) => `${border.size[0]} solid ${border.color.base}`}; -`; +const styles = css({ + paddingInline: 'var(--spacing-inset-xs)', + backgroundColor: 'var(--color-surface-subtle)', + borderRadius: 'var(--shape-radius-s)', + border: 'var(--shape-border-thin) solid var(--color-border)', +}); const Keyboard: FC = ({ children, @@ -25,7 +23,7 @@ const Keyboard: FC = ({ option, ctrl, }) => ( - + {command && '⌘'} {shift && '⇧'} {option && 'βŒ₯'} diff --git a/packages/components/keyboard/package.json b/packages/components/keyboard/package.json index 2763fe1..efa7561 100644 --- a/packages/components/keyboard/package.json +++ b/packages/components/keyboard/package.json @@ -2,20 +2,49 @@ "name": "@precursor/keyboard", "version": "0.1.3", "description": "keyboard combo component", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/danieldelcore/precursor.git", + "directory": "packages/components/keyboard" + }, + "files": [ + "dist" + ], + "sideEffects": [ + "**/*.css", + "./dist/browser.mjs" + ], "main": "dist/index.js", - "module": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", - "license": "MIT", + "exports": { + ".": { + "browser": { + "types": "./dist/index.d.mts", + "default": "./dist/browser.mjs" + }, + "import": { + "types": "./dist/index.d.mts", + "default": "./dist/index.mjs" + }, + "require": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "default": "./dist/index.js" + }, + "./styles.css": "./dist/index.css", + "./package.json": "./package.json" + }, "dependencies": { "@precursor/theme": "^0.1.5", - "@trousers/collector": "^3.0.2", - "@trousers/core": "^3.0.2" + "trousers": "^4.1.0" }, "devDependencies": { - "react": "^16.8.1" + "react": "19.3.1" }, "peerDependencies": { - "react": ">=16.8.0" - }, - "repository": "https://github.com/danieldelcore/precursor/tree/master/packages/components/keyboard" + "react": "^19.0.0" + } } diff --git a/packages/components/keyboard/tsconfig.json b/packages/components/keyboard/tsconfig.json index 88fa918..85f4812 100644 --- a/packages/components/keyboard/tsconfig.json +++ b/packages/components/keyboard/tsconfig.json @@ -4,7 +4,12 @@ "compilerOptions": { "outDir": "dist", "rootDir": ".", - "baseUrl": "." + "tsBuildInfoFile": "./tsconfig.tsbuildinfo" }, - "references": [{ "path": "../../theming/theme" }] + "references": [ + { + "path": "../../theming/theme" + } + ], + "exclude": ["dist", "**/*.spec.*"] } diff --git a/packages/components/label/Label.tsx b/packages/components/label/Label.tsx index 2091377..c57e920 100644 --- a/packages/components/label/Label.tsx +++ b/packages/components/label/Label.tsx @@ -1,7 +1,5 @@ -/** @jsx jsx */ +import { classnames, css } from 'trousers'; import { FC, ReactNode } from 'react'; -import { jsx, css } from '@trousers/core'; -import { Theme } from '@precursor/theme'; export interface LabelProps { children: ReactNode; @@ -9,18 +7,17 @@ export interface LabelProps { className?: string; } +const labelStyles = css({ + display: 'inline-flex', + alignItems: 'center', + marginBottom: '0', + 'font-weight': 'var(--typography-weight-label)', + fontSize: 'var(--typography-size-label)', + cursor: 'pointer', +}); + const Label: FC = ({ htmlFor, children }) => ( -