diff --git a/.dockerignore b/.dockerignore index 1f65925..5845c57 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,10 +1,6 @@ node_modules -npm-debug.log* -dist -storybook-static +**/node_modules +**/dist +apps/docs/storybook-static .git -.gitignore -.dockerignore -Dockerfile -README.md -*.log +scripts/deploy.env diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..468db42 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,25 @@ +# Runs on every push and pull request. Gitea Actions uses GitHub Actions syntax. +name: CI + +on: + push: + branches: [main] + pull_request: + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 24 + cache: npm + - run: npm ci + - run: npm run lint + - run: npm run typecheck + - run: npm test + # Package, landing page and Storybook. + - run: npm run build + # What `npm publish` would upload. + - run: npm pack -w @openkhalix/tansy-ui --dry-run diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..23dabb7 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,34 @@ +# Publishes @openkhalix/tansy-ui when a version tag (v0.4.0, v1.0.0 …) is pushed. +# +# Needs a repository secret NPM_TOKEN: an npm "Automation" (or granular +# publish) token for an account that belongs to the openkhalix npm org. +name: Release + +on: + push: + tags: ['v*'] + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 24 + cache: npm + registry-url: https://registry.npmjs.org + - run: npm ci + - name: Tag must match the package version + run: | + version=$(node -p "require('./packages/ui/package.json').version") + if [ "${GITHUB_REF_NAME}" != "v${version}" ]; then + echo "Tag ${GITHUB_REF_NAME} does not match package version v${version}" >&2 + exit 1 + fi + - run: npm run lint + - run: npm test + # prepublishOnly re-runs typecheck, tests and the library build. + - run: npm publish -w @openkhalix/tansy-ui --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.gitignore b/.gitignore index affcd43..4493f36 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ node_modules dist dist-ssr -dist-lib storybook-static *.local .DS_Store diff --git a/.oxlintrc.json b/.oxlintrc.json index efce4b0..7cea03f 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -17,13 +17,13 @@ "overrides": [ { "files": [ - "src/components/Card.tsx", - "src/components/Dialog.tsx", - "src/components/Drawer.tsx", - "src/components/DropdownMenu.tsx", - "src/components/Popover.tsx", - "src/components/Table.tsx", - "src/components/Tabs.tsx" + "packages/ui/src/components/Card.tsx", + "packages/ui/src/components/Dialog.tsx", + "packages/ui/src/components/Drawer.tsx", + "packages/ui/src/components/DropdownMenu.tsx", + "packages/ui/src/components/Popover.tsx", + "packages/ui/src/components/Table.tsx", + "packages/ui/src/components/Tabs.tsx" ], "rules": { "react/only-export-components": "off" diff --git a/Dockerfile b/Dockerfile index 30fedfd..6e48eee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,25 +4,30 @@ FROM node:26-alpine AS build WORKDIR /app +# Workspace manifests first, so dependency installs cache between builds. COPY package.json package-lock.json ./ +COPY packages/ui/package.json packages/ui/ +COPY packages/brand/package.json packages/brand/ +COPY apps/site/package.json apps/site/ +COPY apps/docs/package.json apps/docs/ RUN npm ci COPY . . RUN npm run lint \ - && npm run build \ - && npm run build-storybook + && npm test \ + && npm run build FROM nginx:1.29-alpine AS runtime LABEL org.opencontainers.image.title="Tansy UI" \ org.opencontainers.image.description="Landing page and Storybook for the Tansy UI React component kit" \ org.opencontainers.image.source="local:ui-showcase" \ - org.opencontainers.image.licenses="UNLICENSED" + org.opencontainers.image.licenses="MIT" COPY nginx.conf /etc/nginx/conf.d/default.conf -COPY --from=build /app/dist /usr/share/nginx/html -COPY --from=build /app/storybook-static /usr/share/nginx/html/docs +COPY --from=build /app/apps/site/dist /usr/share/nginx/html +COPY --from=build /app/apps/docs/storybook-static /usr/share/nginx/html/docs EXPOSE 80 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7f2d37d --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 OpenKhalix + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index fb483a7..631d4c6 100644 --- a/README.md +++ b/README.md @@ -1,186 +1,107 @@

- Tansy UI logo + Tansy UI logo

Tansy UI

- A themeable React component kit, with every state documented in Storybook.
- By OpenKhalix. + A themeable, accessible React component kit by OpenKhalix.
+ Website · + Storybook · + Package README · + Changelog

--- -Tansy UI is named after the tansy flower, also called *golden buttons*: many small, round heads that together read as one bloom. The kit works the same way. It is a set of small, owned parts (buttons, fields, selects, feedback and overlays) that combine into a consistent interface. +Tansy UI is named after the tansy flower, also called *golden buttons*: many small, round heads that read +as one bloom. It is published to npm as **`@openkhalix/tansy-ui`**: -Every part ships with: - -- **Named variants.** A short list of deliberate choices, such as `variant="outline"`, instead of one-off styling. -- **Its states.** Error, disabled, loading and required are part of the component, and each has its own story. -- **Tokens, not hex codes.** Colours come from a 50–900 palette ramp, so switching the palette re-themes every part without a code change. - -> **Status:** pre-release (v0.3.0). Tansy UI builds as a library (`npm run build:lib`) but is not published to npm yet. It is developed in this repository, with a landing page and a Storybook workshop as its showcase. - -## Components - -Built on [Base UI](https://base-ui.com) for accessible behaviour, styled with Tailwind CSS v4. - -| Group | Components | -|---|---| -| Actions | `Button`, `IconButton`, `LinkButton`, `ToggleGroup`, `Toggle` | -| Forms | `Field`, `Input`, `FeaturedInput`, `TextArea`, `FeaturedTextArea`, `NumberInput`, `Select`, `FeaturedSelect`, `Combobox`, `NativeSelect`, `Checkbox`, `CheckboxGroup`, `Radio`, `Switch`, `Slider` | -| Overlays | `Dialog` (`Modal`), `AlertDialog`, `Drawer` (`Sheet`), `Popover`, `Tooltip`, `InfoTip`, `DropdownMenu` | -| Navigation | `Tabs`, `Accordion`, `Breadcrumb`, `Pagination` | -| Feedback | `Alert`, `Toast` (`Toaster`, `useToast`), `Spinner`, `Progress`, `Meter`, `Skeleton` | -| Display | `Badge`, `CountBadge`, `Avatar`, `AvatarGroup`, `Kbd`, `Table` | -| Layout | `Card`, `Separator` | - -Every component follows one API (see [`docs/CONVENTIONS.md`](docs/CONVENTIONS.md)): - -- `color` for meaning and `variant` for style; -- `size` of `sm`, `md` or `lg`; -- `startIcon` and `endIcon` as React nodes; -- `label`, `description` and `error` on every field; -- `value`, `defaultValue` and `onValueChange` for anything with a value. - -## Usage - -```css -/* app.css */ -@import "tailwindcss"; -@import "tansy-ui/tokens.css"; -@source "../node_modules/tansy-ui/dist-lib"; +```bash +npm install @openkhalix/tansy-ui ``` -```tsx -import { Mail } from 'lucide-react' -import { Button, FeaturedInput, Select, Switch } from 'tansy-ui' +See the [package README](packages/ui/README.md) for setup and usage. -export function InviteForm() { - return ( -
- } required /> - + + + + ) +} +``` + +### Next.js + +Components are marked `"use client"`, so you can import them straight into Server Components. Helpers such +as `cn` and `applyPalette` stay server-safe. + +## Dark mode and palettes + +```ts +import { applyPalette } from '@openkhalix/tansy-ui' + +document.documentElement.classList.toggle('dark', true) // dark mode +applyPalette(document.documentElement, 'emerald') // classicBlue, emerald, violet, amber, crimson, slate, teal +``` + +Apply a palette to `` so popups, which render in a portal, pick it up too. + +## Components + +| Group | Components | +|---|---| +| Actions | `Button`, `IconButton`, `LinkButton`, `ToggleGroup`, `Toggle` | +| Forms | `Field`, `Input`, `FeaturedInput`, `TextArea`, `FeaturedTextArea`, `NumberInput`, `Select`, `FeaturedSelect`, `Combobox`, `NativeSelect`, `Checkbox`, `CheckboxGroup`, `Radio`, `Switch`, `Slider` | +| Overlays | `Dialog` (`Modal`), `AlertDialog`, `Drawer` (`Sheet`), `Popover`, `Tooltip`, `InfoTip`, `DropdownMenu` | +| Navigation | `Tabs`, `Accordion`, `Breadcrumb`, `Pagination` | +| Feedback | `Alert`, `Toast` (`Toaster`, `useToast`), `Spinner`, `Progress`, `Meter`, `Skeleton` | +| Display | `Badge`, `CountBadge`, `Avatar`, `AvatarGroup`, `Kbd`, `Table` | +| Layout | `Card`, `Separator` | + +Every component has a Storybook page with its props, controls and a story for each state: +https://ui.openkhalix.com/docs/ + +## Licence and credit + +MIT © OpenKhalix. Use it, fork it, and ship it in commercial products, free. The licence's only condition +is that you keep the copyright notice in copies of the code. + +If Tansy UI helps you, a visible credit such as "UI by [Tansy UI](https://ui.openkhalix.com)" in your +README or site footer is much appreciated. It isn't required. diff --git a/packages/ui/package.json b/packages/ui/package.json new file mode 100644 index 0000000..8ac9a0d --- /dev/null +++ b/packages/ui/package.json @@ -0,0 +1,78 @@ +{ + "name": "@openkhalix/tansy-ui", + "version": "0.4.0", + "description": "A themeable, accessible React component kit built on Base UI and Tailwind CSS v4.", + "license": "MIT", + "author": "OpenKhalix", + "homepage": "https://ui.openkhalix.com", + "keywords": [ + "react", + "components", + "ui", + "design-system", + "tailwindcss", + "base-ui", + "accessible", + "dark-mode" + ], + "type": "module", + "sideEffects": [ + "*.css" + ], + "module": "./dist/index.js", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "source": "./src/index.ts", + "types": "./dist/index.d.ts", + "import": "./dist/index.js" + }, + "./tokens.css": "./dist/tokens.css", + "./styles.css": "./dist/styles.css", + "./package.json": "./package.json" + }, + "files": [ + "dist", + "README.md", + "CHANGELOG.md", + "LICENSE" + ], + "publishConfig": { + "access": "public" + }, + "scripts": { + "build": "vite build --config vite.lib.config.ts && tsc -p tsconfig.lib.json && cp src/styles/tokens.css dist/tokens.css && tailwindcss -i src/styles/styles.css -o dist/styles.css --minify", + "typecheck": "tsc -p tsconfig.json --noEmit", + "test": "vitest run", + "test:watch": "vitest", + "prepublishOnly": "npm run typecheck && npm test && npm run build" + }, + "peerDependencies": { + "react": "^19.0.0", + "react-dom": "^19.0.0" + }, + "dependencies": { + "@base-ui/react": "^1.8.0", + "clsx": "^2.1.1", + "lucide-react": "^1.48.0", + "tailwind-merge": "^3.7.0" + }, + "devDependencies": { + "@testing-library/jest-dom": "^7.0.1", + "@testing-library/react": "^16.3.3", + "@testing-library/user-event": "^14.6.7", + "@types/node": "^24.13.3", + "@types/react": "^19.2.18", + "@types/react-dom": "^19.2.7", + "@vitejs/plugin-react": "^6.1.1", + "axe-core": "^4.13.0", + "jsdom": "^30.1.1", + "react": "^19.2.8", + "react-dom": "^19.2.8", + "tailwindcss": "^4.3.3", + "typescript": "~6.0.2", + "vite": "^8.3.0", + "vitest": "^5.0.2", + "@tailwindcss/cli": "^4.3.3" + } +} diff --git a/src/components/Accordion.stories.tsx b/packages/ui/src/components/Accordion.stories.tsx similarity index 100% rename from src/components/Accordion.stories.tsx rename to packages/ui/src/components/Accordion.stories.tsx diff --git a/src/components/Accordion.test.tsx b/packages/ui/src/components/Accordion.test.tsx similarity index 100% rename from src/components/Accordion.test.tsx rename to packages/ui/src/components/Accordion.test.tsx diff --git a/src/components/Accordion.tsx b/packages/ui/src/components/Accordion.tsx similarity index 100% rename from src/components/Accordion.tsx rename to packages/ui/src/components/Accordion.tsx diff --git a/src/components/Alert.stories.tsx b/packages/ui/src/components/Alert.stories.tsx similarity index 100% rename from src/components/Alert.stories.tsx rename to packages/ui/src/components/Alert.stories.tsx diff --git a/src/components/Alert.test.tsx b/packages/ui/src/components/Alert.test.tsx similarity index 100% rename from src/components/Alert.test.tsx rename to packages/ui/src/components/Alert.test.tsx diff --git a/src/components/Alert.tsx b/packages/ui/src/components/Alert.tsx similarity index 100% rename from src/components/Alert.tsx rename to packages/ui/src/components/Alert.tsx diff --git a/src/components/AlertDialog.stories.tsx b/packages/ui/src/components/AlertDialog.stories.tsx similarity index 100% rename from src/components/AlertDialog.stories.tsx rename to packages/ui/src/components/AlertDialog.stories.tsx diff --git a/src/components/AlertDialog.test.tsx b/packages/ui/src/components/AlertDialog.test.tsx similarity index 100% rename from src/components/AlertDialog.test.tsx rename to packages/ui/src/components/AlertDialog.test.tsx diff --git a/src/components/AlertDialog.tsx b/packages/ui/src/components/AlertDialog.tsx similarity index 100% rename from src/components/AlertDialog.tsx rename to packages/ui/src/components/AlertDialog.tsx diff --git a/src/components/Avatar.stories.tsx b/packages/ui/src/components/Avatar.stories.tsx similarity index 100% rename from src/components/Avatar.stories.tsx rename to packages/ui/src/components/Avatar.stories.tsx diff --git a/src/components/Avatar.test.tsx b/packages/ui/src/components/Avatar.test.tsx similarity index 100% rename from src/components/Avatar.test.tsx rename to packages/ui/src/components/Avatar.test.tsx diff --git a/src/components/Avatar.tsx b/packages/ui/src/components/Avatar.tsx similarity index 100% rename from src/components/Avatar.tsx rename to packages/ui/src/components/Avatar.tsx diff --git a/src/components/Badge.stories.tsx b/packages/ui/src/components/Badge.stories.tsx similarity index 100% rename from src/components/Badge.stories.tsx rename to packages/ui/src/components/Badge.stories.tsx diff --git a/src/components/Badge.test.tsx b/packages/ui/src/components/Badge.test.tsx similarity index 100% rename from src/components/Badge.test.tsx rename to packages/ui/src/components/Badge.test.tsx diff --git a/src/components/Badge.tsx b/packages/ui/src/components/Badge.tsx similarity index 100% rename from src/components/Badge.tsx rename to packages/ui/src/components/Badge.tsx diff --git a/src/components/Breadcrumb.stories.tsx b/packages/ui/src/components/Breadcrumb.stories.tsx similarity index 100% rename from src/components/Breadcrumb.stories.tsx rename to packages/ui/src/components/Breadcrumb.stories.tsx diff --git a/src/components/Breadcrumb.test.tsx b/packages/ui/src/components/Breadcrumb.test.tsx similarity index 100% rename from src/components/Breadcrumb.test.tsx rename to packages/ui/src/components/Breadcrumb.test.tsx diff --git a/src/components/Breadcrumb.tsx b/packages/ui/src/components/Breadcrumb.tsx similarity index 100% rename from src/components/Breadcrumb.tsx rename to packages/ui/src/components/Breadcrumb.tsx diff --git a/src/components/Button.stories.tsx b/packages/ui/src/components/Button.stories.tsx similarity index 100% rename from src/components/Button.stories.tsx rename to packages/ui/src/components/Button.stories.tsx diff --git a/src/components/Button.test.tsx b/packages/ui/src/components/Button.test.tsx similarity index 100% rename from src/components/Button.test.tsx rename to packages/ui/src/components/Button.test.tsx diff --git a/src/components/Button.tsx b/packages/ui/src/components/Button.tsx similarity index 100% rename from src/components/Button.tsx rename to packages/ui/src/components/Button.tsx diff --git a/src/components/Card.stories.tsx b/packages/ui/src/components/Card.stories.tsx similarity index 100% rename from src/components/Card.stories.tsx rename to packages/ui/src/components/Card.stories.tsx diff --git a/src/components/Card.test.tsx b/packages/ui/src/components/Card.test.tsx similarity index 100% rename from src/components/Card.test.tsx rename to packages/ui/src/components/Card.test.tsx diff --git a/src/components/Card.tsx b/packages/ui/src/components/Card.tsx similarity index 100% rename from src/components/Card.tsx rename to packages/ui/src/components/Card.tsx diff --git a/src/components/Checkbox.stories.tsx b/packages/ui/src/components/Checkbox.stories.tsx similarity index 100% rename from src/components/Checkbox.stories.tsx rename to packages/ui/src/components/Checkbox.stories.tsx diff --git a/src/components/Checkbox.test.tsx b/packages/ui/src/components/Checkbox.test.tsx similarity index 100% rename from src/components/Checkbox.test.tsx rename to packages/ui/src/components/Checkbox.test.tsx diff --git a/src/components/Checkbox.tsx b/packages/ui/src/components/Checkbox.tsx similarity index 100% rename from src/components/Checkbox.tsx rename to packages/ui/src/components/Checkbox.tsx diff --git a/src/components/CheckboxGroup.stories.tsx b/packages/ui/src/components/CheckboxGroup.stories.tsx similarity index 100% rename from src/components/CheckboxGroup.stories.tsx rename to packages/ui/src/components/CheckboxGroup.stories.tsx diff --git a/src/components/CheckboxGroup.test.tsx b/packages/ui/src/components/CheckboxGroup.test.tsx similarity index 100% rename from src/components/CheckboxGroup.test.tsx rename to packages/ui/src/components/CheckboxGroup.test.tsx diff --git a/src/components/CheckboxGroup.tsx b/packages/ui/src/components/CheckboxGroup.tsx similarity index 100% rename from src/components/CheckboxGroup.tsx rename to packages/ui/src/components/CheckboxGroup.tsx diff --git a/src/components/Combobox.stories.tsx b/packages/ui/src/components/Combobox.stories.tsx similarity index 100% rename from src/components/Combobox.stories.tsx rename to packages/ui/src/components/Combobox.stories.tsx diff --git a/src/components/Combobox.test.tsx b/packages/ui/src/components/Combobox.test.tsx similarity index 100% rename from src/components/Combobox.test.tsx rename to packages/ui/src/components/Combobox.test.tsx diff --git a/src/components/Combobox.tsx b/packages/ui/src/components/Combobox.tsx similarity index 100% rename from src/components/Combobox.tsx rename to packages/ui/src/components/Combobox.tsx diff --git a/src/components/Dialog.stories.tsx b/packages/ui/src/components/Dialog.stories.tsx similarity index 100% rename from src/components/Dialog.stories.tsx rename to packages/ui/src/components/Dialog.stories.tsx diff --git a/src/components/Dialog.test.tsx b/packages/ui/src/components/Dialog.test.tsx similarity index 100% rename from src/components/Dialog.test.tsx rename to packages/ui/src/components/Dialog.test.tsx diff --git a/src/components/Dialog.tsx b/packages/ui/src/components/Dialog.tsx similarity index 100% rename from src/components/Dialog.tsx rename to packages/ui/src/components/Dialog.tsx diff --git a/src/components/Drawer.stories.tsx b/packages/ui/src/components/Drawer.stories.tsx similarity index 100% rename from src/components/Drawer.stories.tsx rename to packages/ui/src/components/Drawer.stories.tsx diff --git a/src/components/Drawer.test.tsx b/packages/ui/src/components/Drawer.test.tsx similarity index 100% rename from src/components/Drawer.test.tsx rename to packages/ui/src/components/Drawer.test.tsx diff --git a/src/components/Drawer.tsx b/packages/ui/src/components/Drawer.tsx similarity index 100% rename from src/components/Drawer.tsx rename to packages/ui/src/components/Drawer.tsx diff --git a/src/components/DropdownMenu.stories.tsx b/packages/ui/src/components/DropdownMenu.stories.tsx similarity index 100% rename from src/components/DropdownMenu.stories.tsx rename to packages/ui/src/components/DropdownMenu.stories.tsx diff --git a/src/components/DropdownMenu.test.tsx b/packages/ui/src/components/DropdownMenu.test.tsx similarity index 100% rename from src/components/DropdownMenu.test.tsx rename to packages/ui/src/components/DropdownMenu.test.tsx diff --git a/src/components/DropdownMenu.tsx b/packages/ui/src/components/DropdownMenu.tsx similarity index 100% rename from src/components/DropdownMenu.tsx rename to packages/ui/src/components/DropdownMenu.tsx diff --git a/src/components/FeaturedInput.stories.tsx b/packages/ui/src/components/FeaturedInput.stories.tsx similarity index 100% rename from src/components/FeaturedInput.stories.tsx rename to packages/ui/src/components/FeaturedInput.stories.tsx diff --git a/src/components/FeaturedInput.test.tsx b/packages/ui/src/components/FeaturedInput.test.tsx similarity index 100% rename from src/components/FeaturedInput.test.tsx rename to packages/ui/src/components/FeaturedInput.test.tsx diff --git a/src/components/FeaturedInput.tsx b/packages/ui/src/components/FeaturedInput.tsx similarity index 100% rename from src/components/FeaturedInput.tsx rename to packages/ui/src/components/FeaturedInput.tsx diff --git a/src/components/FeaturedSelect.stories.tsx b/packages/ui/src/components/FeaturedSelect.stories.tsx similarity index 100% rename from src/components/FeaturedSelect.stories.tsx rename to packages/ui/src/components/FeaturedSelect.stories.tsx diff --git a/src/components/FeaturedSelect.test.tsx b/packages/ui/src/components/FeaturedSelect.test.tsx similarity index 100% rename from src/components/FeaturedSelect.test.tsx rename to packages/ui/src/components/FeaturedSelect.test.tsx diff --git a/src/components/FeaturedSelect.tsx b/packages/ui/src/components/FeaturedSelect.tsx similarity index 100% rename from src/components/FeaturedSelect.tsx rename to packages/ui/src/components/FeaturedSelect.tsx diff --git a/src/components/FeaturedTextArea.stories.tsx b/packages/ui/src/components/FeaturedTextArea.stories.tsx similarity index 100% rename from src/components/FeaturedTextArea.stories.tsx rename to packages/ui/src/components/FeaturedTextArea.stories.tsx diff --git a/src/components/FeaturedTextArea.test.tsx b/packages/ui/src/components/FeaturedTextArea.test.tsx similarity index 100% rename from src/components/FeaturedTextArea.test.tsx rename to packages/ui/src/components/FeaturedTextArea.test.tsx diff --git a/src/components/FeaturedTextArea.tsx b/packages/ui/src/components/FeaturedTextArea.tsx similarity index 100% rename from src/components/FeaturedTextArea.tsx rename to packages/ui/src/components/FeaturedTextArea.tsx diff --git a/src/components/Field.stories.tsx b/packages/ui/src/components/Field.stories.tsx similarity index 100% rename from src/components/Field.stories.tsx rename to packages/ui/src/components/Field.stories.tsx diff --git a/src/components/Field.tsx b/packages/ui/src/components/Field.tsx similarity index 100% rename from src/components/Field.tsx rename to packages/ui/src/components/Field.tsx diff --git a/src/components/Input.stories.tsx b/packages/ui/src/components/Input.stories.tsx similarity index 100% rename from src/components/Input.stories.tsx rename to packages/ui/src/components/Input.stories.tsx diff --git a/src/components/Input.test.tsx b/packages/ui/src/components/Input.test.tsx similarity index 100% rename from src/components/Input.test.tsx rename to packages/ui/src/components/Input.test.tsx diff --git a/src/components/Input.tsx b/packages/ui/src/components/Input.tsx similarity index 100% rename from src/components/Input.tsx rename to packages/ui/src/components/Input.tsx diff --git a/src/components/Kbd.stories.tsx b/packages/ui/src/components/Kbd.stories.tsx similarity index 100% rename from src/components/Kbd.stories.tsx rename to packages/ui/src/components/Kbd.stories.tsx diff --git a/src/components/Kbd.test.tsx b/packages/ui/src/components/Kbd.test.tsx similarity index 100% rename from src/components/Kbd.test.tsx rename to packages/ui/src/components/Kbd.test.tsx diff --git a/src/components/Kbd.tsx b/packages/ui/src/components/Kbd.tsx similarity index 100% rename from src/components/Kbd.tsx rename to packages/ui/src/components/Kbd.tsx diff --git a/src/components/NativeSelect.stories.tsx b/packages/ui/src/components/NativeSelect.stories.tsx similarity index 100% rename from src/components/NativeSelect.stories.tsx rename to packages/ui/src/components/NativeSelect.stories.tsx diff --git a/src/components/NativeSelect.test.tsx b/packages/ui/src/components/NativeSelect.test.tsx similarity index 100% rename from src/components/NativeSelect.test.tsx rename to packages/ui/src/components/NativeSelect.test.tsx diff --git a/src/components/NativeSelect.tsx b/packages/ui/src/components/NativeSelect.tsx similarity index 100% rename from src/components/NativeSelect.tsx rename to packages/ui/src/components/NativeSelect.tsx diff --git a/src/components/NumberInput.stories.tsx b/packages/ui/src/components/NumberInput.stories.tsx similarity index 100% rename from src/components/NumberInput.stories.tsx rename to packages/ui/src/components/NumberInput.stories.tsx diff --git a/src/components/NumberInput.test.tsx b/packages/ui/src/components/NumberInput.test.tsx similarity index 100% rename from src/components/NumberInput.test.tsx rename to packages/ui/src/components/NumberInput.test.tsx diff --git a/src/components/NumberInput.tsx b/packages/ui/src/components/NumberInput.tsx similarity index 100% rename from src/components/NumberInput.tsx rename to packages/ui/src/components/NumberInput.tsx diff --git a/src/components/Pagination.stories.tsx b/packages/ui/src/components/Pagination.stories.tsx similarity index 100% rename from src/components/Pagination.stories.tsx rename to packages/ui/src/components/Pagination.stories.tsx diff --git a/src/components/Pagination.test.tsx b/packages/ui/src/components/Pagination.test.tsx similarity index 100% rename from src/components/Pagination.test.tsx rename to packages/ui/src/components/Pagination.test.tsx diff --git a/src/components/Pagination.tsx b/packages/ui/src/components/Pagination.tsx similarity index 100% rename from src/components/Pagination.tsx rename to packages/ui/src/components/Pagination.tsx diff --git a/src/components/Popover.stories.tsx b/packages/ui/src/components/Popover.stories.tsx similarity index 100% rename from src/components/Popover.stories.tsx rename to packages/ui/src/components/Popover.stories.tsx diff --git a/src/components/Popover.test.tsx b/packages/ui/src/components/Popover.test.tsx similarity index 100% rename from src/components/Popover.test.tsx rename to packages/ui/src/components/Popover.test.tsx diff --git a/src/components/Popover.tsx b/packages/ui/src/components/Popover.tsx similarity index 100% rename from src/components/Popover.tsx rename to packages/ui/src/components/Popover.tsx diff --git a/src/components/Progress.stories.tsx b/packages/ui/src/components/Progress.stories.tsx similarity index 100% rename from src/components/Progress.stories.tsx rename to packages/ui/src/components/Progress.stories.tsx diff --git a/src/components/Progress.test.tsx b/packages/ui/src/components/Progress.test.tsx similarity index 100% rename from src/components/Progress.test.tsx rename to packages/ui/src/components/Progress.test.tsx diff --git a/src/components/Progress.tsx b/packages/ui/src/components/Progress.tsx similarity index 100% rename from src/components/Progress.tsx rename to packages/ui/src/components/Progress.tsx diff --git a/src/components/Radio.stories.tsx b/packages/ui/src/components/Radio.stories.tsx similarity index 100% rename from src/components/Radio.stories.tsx rename to packages/ui/src/components/Radio.stories.tsx diff --git a/src/components/Radio.test.tsx b/packages/ui/src/components/Radio.test.tsx similarity index 100% rename from src/components/Radio.test.tsx rename to packages/ui/src/components/Radio.test.tsx diff --git a/src/components/Radio.tsx b/packages/ui/src/components/Radio.tsx similarity index 100% rename from src/components/Radio.tsx rename to packages/ui/src/components/Radio.tsx diff --git a/src/components/Select.stories.tsx b/packages/ui/src/components/Select.stories.tsx similarity index 100% rename from src/components/Select.stories.tsx rename to packages/ui/src/components/Select.stories.tsx diff --git a/src/components/Select.test.tsx b/packages/ui/src/components/Select.test.tsx similarity index 100% rename from src/components/Select.test.tsx rename to packages/ui/src/components/Select.test.tsx diff --git a/src/components/Select.tsx b/packages/ui/src/components/Select.tsx similarity index 100% rename from src/components/Select.tsx rename to packages/ui/src/components/Select.tsx diff --git a/src/components/SelectParts.tsx b/packages/ui/src/components/SelectParts.tsx similarity index 100% rename from src/components/SelectParts.tsx rename to packages/ui/src/components/SelectParts.tsx diff --git a/src/components/Separator.stories.tsx b/packages/ui/src/components/Separator.stories.tsx similarity index 100% rename from src/components/Separator.stories.tsx rename to packages/ui/src/components/Separator.stories.tsx diff --git a/src/components/Separator.test.tsx b/packages/ui/src/components/Separator.test.tsx similarity index 100% rename from src/components/Separator.test.tsx rename to packages/ui/src/components/Separator.test.tsx diff --git a/src/components/Separator.tsx b/packages/ui/src/components/Separator.tsx similarity index 100% rename from src/components/Separator.tsx rename to packages/ui/src/components/Separator.tsx diff --git a/src/components/Skeleton.stories.tsx b/packages/ui/src/components/Skeleton.stories.tsx similarity index 100% rename from src/components/Skeleton.stories.tsx rename to packages/ui/src/components/Skeleton.stories.tsx diff --git a/src/components/Skeleton.test.tsx b/packages/ui/src/components/Skeleton.test.tsx similarity index 100% rename from src/components/Skeleton.test.tsx rename to packages/ui/src/components/Skeleton.test.tsx diff --git a/src/components/Skeleton.tsx b/packages/ui/src/components/Skeleton.tsx similarity index 100% rename from src/components/Skeleton.tsx rename to packages/ui/src/components/Skeleton.tsx diff --git a/src/components/Slider.stories.tsx b/packages/ui/src/components/Slider.stories.tsx similarity index 100% rename from src/components/Slider.stories.tsx rename to packages/ui/src/components/Slider.stories.tsx diff --git a/src/components/Slider.test.tsx b/packages/ui/src/components/Slider.test.tsx similarity index 100% rename from src/components/Slider.test.tsx rename to packages/ui/src/components/Slider.test.tsx diff --git a/src/components/Slider.tsx b/packages/ui/src/components/Slider.tsx similarity index 100% rename from src/components/Slider.tsx rename to packages/ui/src/components/Slider.tsx diff --git a/src/components/Spinner.stories.tsx b/packages/ui/src/components/Spinner.stories.tsx similarity index 100% rename from src/components/Spinner.stories.tsx rename to packages/ui/src/components/Spinner.stories.tsx diff --git a/src/components/Spinner.test.tsx b/packages/ui/src/components/Spinner.test.tsx similarity index 100% rename from src/components/Spinner.test.tsx rename to packages/ui/src/components/Spinner.test.tsx diff --git a/src/components/Spinner.tsx b/packages/ui/src/components/Spinner.tsx similarity index 100% rename from src/components/Spinner.tsx rename to packages/ui/src/components/Spinner.tsx diff --git a/src/components/Switch.stories.tsx b/packages/ui/src/components/Switch.stories.tsx similarity index 100% rename from src/components/Switch.stories.tsx rename to packages/ui/src/components/Switch.stories.tsx diff --git a/src/components/Switch.test.tsx b/packages/ui/src/components/Switch.test.tsx similarity index 100% rename from src/components/Switch.test.tsx rename to packages/ui/src/components/Switch.test.tsx diff --git a/src/components/Switch.tsx b/packages/ui/src/components/Switch.tsx similarity index 100% rename from src/components/Switch.tsx rename to packages/ui/src/components/Switch.tsx diff --git a/src/components/Table.stories.tsx b/packages/ui/src/components/Table.stories.tsx similarity index 100% rename from src/components/Table.stories.tsx rename to packages/ui/src/components/Table.stories.tsx diff --git a/src/components/Table.test.tsx b/packages/ui/src/components/Table.test.tsx similarity index 100% rename from src/components/Table.test.tsx rename to packages/ui/src/components/Table.test.tsx diff --git a/src/components/Table.tsx b/packages/ui/src/components/Table.tsx similarity index 100% rename from src/components/Table.tsx rename to packages/ui/src/components/Table.tsx diff --git a/src/components/Tabs.stories.tsx b/packages/ui/src/components/Tabs.stories.tsx similarity index 100% rename from src/components/Tabs.stories.tsx rename to packages/ui/src/components/Tabs.stories.tsx diff --git a/src/components/Tabs.test.tsx b/packages/ui/src/components/Tabs.test.tsx similarity index 100% rename from src/components/Tabs.test.tsx rename to packages/ui/src/components/Tabs.test.tsx diff --git a/src/components/Tabs.tsx b/packages/ui/src/components/Tabs.tsx similarity index 100% rename from src/components/Tabs.tsx rename to packages/ui/src/components/Tabs.tsx diff --git a/src/components/TextArea.stories.tsx b/packages/ui/src/components/TextArea.stories.tsx similarity index 100% rename from src/components/TextArea.stories.tsx rename to packages/ui/src/components/TextArea.stories.tsx diff --git a/src/components/TextArea.test.tsx b/packages/ui/src/components/TextArea.test.tsx similarity index 100% rename from src/components/TextArea.test.tsx rename to packages/ui/src/components/TextArea.test.tsx diff --git a/src/components/TextArea.tsx b/packages/ui/src/components/TextArea.tsx similarity index 100% rename from src/components/TextArea.tsx rename to packages/ui/src/components/TextArea.tsx diff --git a/src/components/Toast.stories.tsx b/packages/ui/src/components/Toast.stories.tsx similarity index 100% rename from src/components/Toast.stories.tsx rename to packages/ui/src/components/Toast.stories.tsx diff --git a/src/components/Toast.test.tsx b/packages/ui/src/components/Toast.test.tsx similarity index 100% rename from src/components/Toast.test.tsx rename to packages/ui/src/components/Toast.test.tsx diff --git a/src/components/Toast.tsx b/packages/ui/src/components/Toast.tsx similarity index 100% rename from src/components/Toast.tsx rename to packages/ui/src/components/Toast.tsx diff --git a/src/components/ToggleGroup.stories.tsx b/packages/ui/src/components/ToggleGroup.stories.tsx similarity index 100% rename from src/components/ToggleGroup.stories.tsx rename to packages/ui/src/components/ToggleGroup.stories.tsx diff --git a/src/components/ToggleGroup.test.tsx b/packages/ui/src/components/ToggleGroup.test.tsx similarity index 100% rename from src/components/ToggleGroup.test.tsx rename to packages/ui/src/components/ToggleGroup.test.tsx diff --git a/src/components/ToggleGroup.tsx b/packages/ui/src/components/ToggleGroup.tsx similarity index 100% rename from src/components/ToggleGroup.tsx rename to packages/ui/src/components/ToggleGroup.tsx diff --git a/src/components/Tooltip.stories.tsx b/packages/ui/src/components/Tooltip.stories.tsx similarity index 100% rename from src/components/Tooltip.stories.tsx rename to packages/ui/src/components/Tooltip.stories.tsx diff --git a/src/components/Tooltip.test.tsx b/packages/ui/src/components/Tooltip.test.tsx similarity index 100% rename from src/components/Tooltip.test.tsx rename to packages/ui/src/components/Tooltip.test.tsx diff --git a/src/components/Tooltip.tsx b/packages/ui/src/components/Tooltip.tsx similarity index 100% rename from src/components/Tooltip.tsx rename to packages/ui/src/components/Tooltip.tsx diff --git a/src/components/accordion.tokens.ts b/packages/ui/src/components/accordion.tokens.ts similarity index 100% rename from src/components/accordion.tokens.ts rename to packages/ui/src/components/accordion.tokens.ts diff --git a/src/components/alert.tokens.ts b/packages/ui/src/components/alert.tokens.ts similarity index 100% rename from src/components/alert.tokens.ts rename to packages/ui/src/components/alert.tokens.ts diff --git a/src/components/avatar.tokens.ts b/packages/ui/src/components/avatar.tokens.ts similarity index 100% rename from src/components/avatar.tokens.ts rename to packages/ui/src/components/avatar.tokens.ts diff --git a/src/components/badge.tokens.ts b/packages/ui/src/components/badge.tokens.ts similarity index 100% rename from src/components/badge.tokens.ts rename to packages/ui/src/components/badge.tokens.ts diff --git a/src/components/button.tokens.ts b/packages/ui/src/components/button.tokens.ts similarity index 100% rename from src/components/button.tokens.ts rename to packages/ui/src/components/button.tokens.ts diff --git a/src/components/card.tokens.ts b/packages/ui/src/components/card.tokens.ts similarity index 100% rename from src/components/card.tokens.ts rename to packages/ui/src/components/card.tokens.ts diff --git a/src/components/checkbox.tokens.ts b/packages/ui/src/components/checkbox.tokens.ts similarity index 100% rename from src/components/checkbox.tokens.ts rename to packages/ui/src/components/checkbox.tokens.ts diff --git a/src/components/dialog.tokens.ts b/packages/ui/src/components/dialog.tokens.ts similarity index 100% rename from src/components/dialog.tokens.ts rename to packages/ui/src/components/dialog.tokens.ts diff --git a/src/components/display.fixtures.ts b/packages/ui/src/components/display.fixtures.ts similarity index 100% rename from src/components/display.fixtures.ts rename to packages/ui/src/components/display.fixtures.ts diff --git a/src/components/dropdown-menu.tokens.ts b/packages/ui/src/components/dropdown-menu.tokens.ts similarity index 100% rename from src/components/dropdown-menu.tokens.ts rename to packages/ui/src/components/dropdown-menu.tokens.ts diff --git a/src/components/featuredinput.tokens.ts b/packages/ui/src/components/featuredinput.tokens.ts similarity index 100% rename from src/components/featuredinput.tokens.ts rename to packages/ui/src/components/featuredinput.tokens.ts diff --git a/src/components/kbd.tokens.ts b/packages/ui/src/components/kbd.tokens.ts similarity index 100% rename from src/components/kbd.tokens.ts rename to packages/ui/src/components/kbd.tokens.ts diff --git a/src/components/numberinput.tokens.ts b/packages/ui/src/components/numberinput.tokens.ts similarity index 100% rename from src/components/numberinput.tokens.ts rename to packages/ui/src/components/numberinput.tokens.ts diff --git a/src/components/pagination.tokens.ts b/packages/ui/src/components/pagination.tokens.ts similarity index 100% rename from src/components/pagination.tokens.ts rename to packages/ui/src/components/pagination.tokens.ts diff --git a/src/components/popover.tokens.ts b/packages/ui/src/components/popover.tokens.ts similarity index 100% rename from src/components/popover.tokens.ts rename to packages/ui/src/components/popover.tokens.ts diff --git a/src/components/progress.tokens.ts b/packages/ui/src/components/progress.tokens.ts similarity index 100% rename from src/components/progress.tokens.ts rename to packages/ui/src/components/progress.tokens.ts diff --git a/src/components/radio.tokens.ts b/packages/ui/src/components/radio.tokens.ts similarity index 100% rename from src/components/radio.tokens.ts rename to packages/ui/src/components/radio.tokens.ts diff --git a/src/components/select.fixtures.ts b/packages/ui/src/components/select.fixtures.ts similarity index 100% rename from src/components/select.fixtures.ts rename to packages/ui/src/components/select.fixtures.ts diff --git a/src/components/select.tokens.ts b/packages/ui/src/components/select.tokens.ts similarity index 100% rename from src/components/select.tokens.ts rename to packages/ui/src/components/select.tokens.ts diff --git a/src/components/skeleton.tokens.ts b/packages/ui/src/components/skeleton.tokens.ts similarity index 100% rename from src/components/skeleton.tokens.ts rename to packages/ui/src/components/skeleton.tokens.ts diff --git a/src/components/slider.tokens.ts b/packages/ui/src/components/slider.tokens.ts similarity index 100% rename from src/components/slider.tokens.ts rename to packages/ui/src/components/slider.tokens.ts diff --git a/src/components/spinner.tokens.ts b/packages/ui/src/components/spinner.tokens.ts similarity index 100% rename from src/components/spinner.tokens.ts rename to packages/ui/src/components/spinner.tokens.ts diff --git a/src/components/switch.tokens.ts b/packages/ui/src/components/switch.tokens.ts similarity index 100% rename from src/components/switch.tokens.ts rename to packages/ui/src/components/switch.tokens.ts diff --git a/src/components/table.tokens.ts b/packages/ui/src/components/table.tokens.ts similarity index 100% rename from src/components/table.tokens.ts rename to packages/ui/src/components/table.tokens.ts diff --git a/src/components/tabs.tokens.ts b/packages/ui/src/components/tabs.tokens.ts similarity index 100% rename from src/components/tabs.tokens.ts rename to packages/ui/src/components/tabs.tokens.ts diff --git a/src/components/textarea.tokens.ts b/packages/ui/src/components/textarea.tokens.ts similarity index 100% rename from src/components/textarea.tokens.ts rename to packages/ui/src/components/textarea.tokens.ts diff --git a/src/components/toast.tokens.ts b/packages/ui/src/components/toast.tokens.ts similarity index 100% rename from src/components/toast.tokens.ts rename to packages/ui/src/components/toast.tokens.ts diff --git a/src/components/toggle.tokens.ts b/packages/ui/src/components/toggle.tokens.ts similarity index 100% rename from src/components/toggle.tokens.ts rename to packages/ui/src/components/toggle.tokens.ts diff --git a/src/components/tooltip.tokens.ts b/packages/ui/src/components/tooltip.tokens.ts similarity index 100% rename from src/components/tooltip.tokens.ts rename to packages/ui/src/components/tooltip.tokens.ts diff --git a/src/components/useToast.ts b/packages/ui/src/components/useToast.ts similarity index 100% rename from src/components/useToast.ts rename to packages/ui/src/components/useToast.ts diff --git a/src/index.ts b/packages/ui/src/index.ts similarity index 100% rename from src/index.ts rename to packages/ui/src/index.ts diff --git a/src/lib/cn.ts b/packages/ui/src/lib/cn.ts similarity index 100% rename from src/lib/cn.ts rename to packages/ui/src/lib/cn.ts diff --git a/src/lib/styles.ts b/packages/ui/src/lib/styles.ts similarity index 100% rename from src/lib/styles.ts rename to packages/ui/src/lib/styles.ts diff --git a/src/lib/useControllableState.ts b/packages/ui/src/lib/useControllableState.ts similarity index 100% rename from src/lib/useControllableState.ts rename to packages/ui/src/lib/useControllableState.ts diff --git a/packages/ui/src/styles/styles.css b/packages/ui/src/styles/styles.css new file mode 100644 index 0000000..1ccae4f --- /dev/null +++ b/packages/ui/src/styles/styles.css @@ -0,0 +1,19 @@ +/* + * Prebuilt Tansy UI stylesheet, for apps that don't use Tailwind: + * + * import '@openkhalix/tansy-ui/styles.css' + * + * Compiled at build time into dist/styles.css: the design tokens, only the + * utilities the components use, and Tailwind's preflight, a modern CSS reset. + * The components rely on that reset (as MUI relies on CssBaseline), so it's + * included rather than optional. Apps that use Tailwind v4 already have it: + * they should import tokens.css instead. + */ +@import "tailwindcss"; +@import "./tokens.css"; + +@source "../"; +@source not "../**/*.stories.tsx"; +@source not "../**/*.test.tsx"; +@source not "../**/*.fixtures.ts"; +@source not "../test"; diff --git a/src/styles/tokens.css b/packages/ui/src/styles/tokens.css similarity index 100% rename from src/styles/tokens.css rename to packages/ui/src/styles/tokens.css diff --git a/src/test/a11y.ts b/packages/ui/src/test/a11y.ts similarity index 100% rename from src/test/a11y.ts rename to packages/ui/src/test/a11y.ts diff --git a/src/test/setup.ts b/packages/ui/src/test/setup.ts similarity index 100% rename from src/test/setup.ts rename to packages/ui/src/test/setup.ts diff --git a/src/theme/applyPalette.ts b/packages/ui/src/theme/applyPalette.ts similarity index 100% rename from src/theme/applyPalette.ts rename to packages/ui/src/theme/applyPalette.ts diff --git a/src/theme/palettes.ts b/packages/ui/src/theme/palettes.ts similarity index 100% rename from src/theme/palettes.ts rename to packages/ui/src/theme/palettes.ts diff --git a/packages/ui/src/version.ts b/packages/ui/src/version.ts new file mode 100644 index 0000000..11e78ea --- /dev/null +++ b/packages/ui/src/version.ts @@ -0,0 +1,7 @@ +declare const __TANSY_VERSION__: string | undefined + +/** + * The package version. The library build injects it from package.json; apps + * in this repo that compile the source define it in their Vite config too. + */ +export const VERSION: string = typeof __TANSY_VERSION__ === 'string' ? __TANSY_VERSION__ : '0.0.0-dev' diff --git a/tsconfig.app.json b/packages/ui/tsconfig.json similarity index 83% rename from tsconfig.app.json rename to packages/ui/tsconfig.json index 154719a..847c58d 100644 --- a/tsconfig.app.json +++ b/packages/ui/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo", "target": "es2023", "lib": ["ES2023", "DOM"], "module": "esnext", @@ -10,9 +10,6 @@ /* Bundler mode */ "moduleResolution": "bundler", - "paths": { - "@/*": ["./src/*"] - }, "allowImportingTsExtensions": true, "verbatimModuleSyntax": true, "moduleDetection": "force", diff --git a/tsconfig.lib.json b/packages/ui/tsconfig.lib.json similarity index 67% rename from tsconfig.lib.json rename to packages/ui/tsconfig.lib.json index 9cb8439..9d16a14 100644 --- a/tsconfig.lib.json +++ b/packages/ui/tsconfig.lib.json @@ -1,15 +1,15 @@ { - "extends": "./tsconfig.app.json", + "extends": "./tsconfig.json", "compilerOptions": { "noEmit": false, "declaration": true, "emitDeclarationOnly": true, "declarationMap": true, "allowImportingTsExtensions": false, - "outDir": "dist-lib", + "outDir": "dist", "rootDir": "src", "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.lib.tsbuildinfo" }, - "include": ["src/index.ts", "src/vite-env.d.ts"], - "exclude": ["src/**/*.stories.tsx", "src/**/*.test.tsx", "src/test", "src/docs", "src/App.tsx", "src/main.tsx"] + "include": ["src/index.ts"], + "exclude": ["src/**/*.stories.tsx", "src/**/*.test.tsx", "src/test"] } diff --git a/vite.config.ts b/packages/ui/vite.config.ts similarity index 62% rename from vite.config.ts rename to packages/ui/vite.config.ts index 5cb4297..319b067 100644 --- a/vite.config.ts +++ b/packages/ui/vite.config.ts @@ -1,27 +1,20 @@ /// import { readFileSync } from 'node:fs' -import { fileURLToPath, URL } from 'node:url' import react from '@vitejs/plugin-react' -import tailwindcss from '@tailwindcss/vite' import { defineConfig } from 'vite' +/** Test config. The library build lives in vite.lib.config.ts. */ const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')) as { version: string } export default defineConfig({ - // package.json is the single source of the version; see src/version.ts. define: { __TANSY_VERSION__: JSON.stringify(pkg.version), }, - plugins: [react(), tailwindcss()], + plugins: [react()], test: { environment: 'jsdom', setupFiles: ['src/test/setup.ts'], include: ['src/**/*.test.{ts,tsx}'], css: false, }, - resolve: { - alias: { - '@': fileURLToPath(new URL('./src', import.meta.url)), - }, - }, }) diff --git a/vite.lib.config.ts b/packages/ui/vite.lib.config.ts similarity index 61% rename from vite.lib.config.ts rename to packages/ui/vite.lib.config.ts index 216e21a..ec59b41 100644 --- a/vite.lib.config.ts +++ b/packages/ui/vite.lib.config.ts @@ -4,11 +4,12 @@ import react from '@vitejs/plugin-react' import { defineConfig } from 'vite' /** - * Library build: `npm run build:lib` → dist-lib/. + * Library build: `npm run build` → dist/. * - * One ES module per source file (preserveModules) so apps only bundle the + * One ES module per source file (preserveModules), so apps only bundle the * components they import. Dependencies stay external. Types come from - * `tsc -p tsconfig.lib.json`, and tokens.css is copied alongside. + * `tsc -p tsconfig.lib.json`; tokens.css and styles.css are added by the + * build script. */ const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')) as { version: string @@ -17,13 +18,26 @@ const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), } const external = [...Object.keys(pkg.dependencies), ...Object.keys(pkg.peerDependencies ?? {})] +/** + * Component modules use hooks, so React Server Components must treat them as + * client code. Pure helpers (cn, applyPalette, style maps) stay unmarked so a + * server component can still call them. + */ +function isClientModule(fileName: string) { + return ( + fileName.startsWith('components/') && + !fileName.endsWith('.tokens.js') && + !fileName.endsWith('.fixtures.js') + ) +} + export default defineConfig({ define: { __TANSY_VERSION__: JSON.stringify(pkg.version), }, plugins: [react()], build: { - outDir: 'dist-lib', + outDir: 'dist', emptyOutDir: true, sourcemap: true, copyPublicDir: false, @@ -37,6 +51,7 @@ export default defineConfig({ preserveModules: true, preserveModulesRoot: 'src', entryFileNames: '[name].js', + banner: (chunk) => (isClientModule(chunk.fileName) ? "'use client';" : ''), }, }, }, diff --git a/scripts/README.md b/scripts/README.md index 0331aef..803ecb2 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -30,8 +30,10 @@ environment instead, which is what CI should do. ## How it works -1. `npm ci`, `npm run lint`, `npm run build`, `npm run build-storybook` -2. Stage `dist/` at the root and `storybook-static/` under `docs/`, zip with +1. `npm ci`, `npm run lint`, `npm test`, `npm run build` (package, landing + page, Storybook) +2. Stage `apps/site/dist/` at the root and `apps/docs/storybook-static/` under + `docs/`, zip with Python's `zipfile` (there is no `zip` binary on the build host), base64 it 3. Upload `scripts/cpanel-deploy.php` to the docroot over the cPanel UAPI 4. POST the base64 payload to it with a `Host` header for the subdomain, diff --git a/scripts/check-stories.mjs b/scripts/check-stories.mjs index 1915f51..2940414 100644 --- a/scripts/check-stories.mjs +++ b/scripts/check-stories.mjs @@ -2,13 +2,13 @@ /** * Render every story in a real browser and report what's broken. * - * For each story in storybook-static/index.json it: + * For each story in apps/docs/storybook-static/index.json it: * - loads the story in Chrome (light or dark mode), * - records page errors and console errors, * - runs axe, including colour contrast (jsdom tests can't check that), * - saves a screenshot. * - * npm run build-storybook + * npm run build:docs * node scripts/check-stories.mjs [--filter forms-] [--mode dark] [--palette emerald] [--width 375] [--out dir] [--no-shots] * * Exits non-zero when any story has an error or an axe violation. @@ -25,7 +25,7 @@ const opt = (name, fallback) => { const i = args.indexOf(`--${name}`) return i === -1 ? fallback : args[i + 1] } -const DIR = resolve(opt('dir', 'storybook-static')) +const DIR = resolve(opt('dir', 'apps/docs/storybook-static')) const FILTER = opt('filter', '') const MODE = opt('mode', 'light') const PALETTE = opt('palette', '') diff --git a/scripts/deploy.py b/scripts/deploy.py index 174ee50..91a5b6b 100644 --- a/scripts/deploy.py +++ b/scripts/deploy.py @@ -37,6 +37,8 @@ REPO = Path(__file__).resolve().parent.parent STAGE = Path("/tmp/tansy-stage") ZIP = Path("/tmp/tansy-deploy.zip") ENV_FILE = REPO / "scripts" / "deploy.env" +SITE_DIST = REPO / "apps" / "site" / "dist" +STORYBOOK = REPO / "apps" / "docs" / "storybook-static" # The docroot must keep these regardless of what a build contains: cPanel # writes them, and removing .htaccess would take the site offline. @@ -157,10 +159,11 @@ def run(cmd: list[str], cwd: Path = REPO, timeout: int = 900) -> None: def build() -> None: run(["npm", "ci"]) run(["npm", "run", "lint"]) + run(["npm", "test"]) + # Builds the package, then the landing page and Storybook. run(["npm", "run", "build"]) - run(["npm", "run", "build-storybook"]) - if not (REPO / "storybook-static" / "index.json").exists(): - die("storybook-static/index.json missing after build-storybook") + if not (STORYBOOK / "index.json").exists(): + die(f"{STORYBOOK}/index.json missing after the Storybook build") def git(*args: str) -> str: @@ -177,7 +180,7 @@ def require_clean_tree() -> None: def build_stamp() -> dict: - version = json.loads((REPO / "package.json").read_text())["version"] + version = json.loads((REPO / "packages" / "ui" / "package.json").read_text())["version"] return { "version": version, "commit": git("rev-parse", "--short", "HEAD"), @@ -187,11 +190,11 @@ def build_stamp() -> dict: def package() -> dict: - dist = REPO / "dist" - sb = REPO / "storybook-static" + dist = SITE_DIST + sb = STORYBOOK for d in (dist, sb): if not d.is_dir(): - die(f"{d} does not exist - run: npm run build && npm run build-storybook") + die(f"{d} does not exist - run: npm run build") if STAGE.exists(): shutil.rmtree(STAGE) @@ -366,14 +369,14 @@ def verify(panel: Panel) -> None: idx = panel.get_from_origin("/index.html") live_sha = _h.sha256(idx.encode()).hexdigest() - local_sha = _h.sha256((REPO / "dist" / "index.html").read_bytes()).hexdigest() + local_sha = _h.sha256((SITE_DIST / "index.html").read_bytes()).hexdigest() if live_sha != local_sha: die(f"index.html mismatch\n live {live_sha[:32]}\n local {local_sha[:32]}") log("index.html matches the local build") sb = panel.get_from_origin("/docs/index.json") sb_sha = _h.sha256(sb.encode()).hexdigest() - sb_local = _h.sha256((REPO / "storybook-static" / "index.json").read_bytes()).hexdigest() + sb_local = _h.sha256((STORYBOOK / "index.json").read_bytes()).hexdigest() if sb_sha != sb_local: die("docs/index.json mismatch") log("docs/index.json matches") diff --git a/scripts/gen_catalogue.py b/scripts/gen_catalogue.py index 884a30f..3a7f4ff 100644 --- a/scripts/gen_catalogue.py +++ b/scripts/gen_catalogue.py @@ -3,12 +3,12 @@ Generate the landing page's component catalogue from the built Storybook index, so it cannot drift from the stories again. -Run it after `npm run build-storybook` and before `npm run build` when you +Run it after `npm run build:docs` and before `npm run build:site` when you add or remove a component. It prints the entries to paste into -src/data/catalogue.ts and writes /tmp/component_catalogue.json. +packages/brand/src/catalogue.ts and writes /tmp/component_catalogue.json. python3 scripts/gen_catalogue.py # print entries - python3 scripts/gen_catalogue.py --patch # also rewrite src/data/catalogue.ts + python3 scripts/gen_catalogue.py --patch # also rewrite packages/brand/src/catalogue.ts Components are read from story titles (`Group/Name`), so a new component appears here without editing this script; only DETAIL is hand-written. @@ -22,8 +22,8 @@ import sys from pathlib import Path REPO = Path(__file__).resolve().parent.parent -IDX = REPO / "storybook-static" / "index.json" -CATALOGUE = REPO / "src" / "data" / "catalogue.ts" +IDX = REPO / "apps" / "docs" / "storybook-static" / "index.json" +CATALOGUE = REPO / "packages" / "brand" / "src" / "catalogue.ts" OUT = Path("/tmp/component_catalogue.json") # Group order on the landing page; matches the Storybook sidebar. @@ -75,7 +75,7 @@ DETAIL = { def collect(): if not IDX.is_file(): - sys.exit(f"{IDX} not found - run: npm run build-storybook") + sys.exit(f"{IDX} not found - run: npm run build:docs") entries = json.loads(IDX.read_text())["entries"].values() comps: dict[str, dict] = {} @@ -150,7 +150,7 @@ def patch_catalogue(entries) -> None: def main() -> None: ap = argparse.ArgumentParser() ap.add_argument("--patch", action="store_true", - help="rewrite the catalogue and story counts in src/data/catalogue.ts") + help="rewrite the catalogue and story counts in packages/brand/src/catalogue.ts") args = ap.parse_args() entries = collect() @@ -167,7 +167,7 @@ def main() -> None: if args.patch: patch_catalogue(entries) - print("now run: npm run build") + print("now run: npm run build:site") if __name__ == "__main__": diff --git a/scripts/test-package.mjs b/scripts/test-package.mjs new file mode 100644 index 0000000..4b2badc --- /dev/null +++ b/scripts/test-package.mjs @@ -0,0 +1,195 @@ +#!/usr/bin/env node +/** + * Install the packed package into fresh apps, the way a user would, and prove + * it works. Run before publishing: + * + * npm run test:package # all scenarios + * npm run test:package -- vite # one scenario: vite | plain | next + * + * 1. vite Vite + Tailwind v4 + strict TypeScript (library types checked too). + * Must type-check, build and render without errors. + * 2. plain React without Tailwind, using only the prebuilt styles.css. The + * primary button must get its brand colour. + * 3. next Next.js App Router. A Server Component imports the components; + * `next build` must prerender it, which fails unless the component + * modules are marked "use client". + * + * Apps are created under $TMPDIR/tansy-package-test and installed from npm. + */ +import { execSync } from 'node:child_process' +import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs' +import { createServer } from 'node:http' +import { createRequire } from 'node:module' +import { tmpdir } from 'node:os' +import { dirname, extname, join, resolve } from 'node:path' +import { fileURLToPath } from 'node:url' + +const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..') +const PKG_DIR = join(ROOT, 'packages/ui') +const WORK = join(tmpdir(), 'tansy-package-test') +const only = process.argv[2] +const require = createRequire(import.meta.url) + +const sh = (cmd, cwd) => execSync(cmd, { cwd, stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf8' }) +const write = (dir, files) => { + for (const [path, content] of Object.entries(files)) { + mkdirSync(dirname(join(dir, path)), { recursive: true }) + writeFileSync(join(dir, path), content.trimStart()) + } +} +const log = (msg) => console.log(`[test:package] ${msg}`) + +// --- pack --------------------------------------------------------------------- +rmSync(WORK, { recursive: true, force: true }) +mkdirSync(WORK, { recursive: true }) +log('building and packing @openkhalix/tansy-ui') +sh('npm run build', PKG_DIR) +const tarball = join(WORK, sh(`npm pack --pack-destination ${WORK}`, PKG_DIR).trim().split('\n').pop()) +const { version } = JSON.parse(readFileSync(join(PKG_DIR, 'package.json'), 'utf8')) +log(`packed ${tarball}`) + +const APP = ` +import { Mail } from 'lucide-react' +import { Badge, Button, Dialog, FeaturedInput, Select, Tabs, VERSION } from '@openkhalix/tansy-ui' + +export function Demo() { + return ( +
+ tansy {VERSION} + } /> +