A component library based on Shadcn and Tailwind for all things Lagoon related.
The ChangeFeed component supports dynamic content updates via a GitHub action workflow. This allows for updates via Pull Requests without needing a full release of the ui-library.
Use ChangeFeedContainer to fetch data at runtime:
import { ChangeFeedContainer } from '@uselagoon/ui-library';
export default function ChangeFeed() {
return (
<ChangeFeedContainer
sourceData="https://raw.githubusercontent.com/your-org/main-app/main/public/data/changefeed.json"
refetchInterval={600000}
/>
);
}Create or update .npmrc in your project root:
@uselagoon:registry=https://registry.npmjs.org
npm install @uselagoon/ui-library tailwindcss @tailwindcss/postcss postcssOr with yarn:
yarn add @uselagoon/ui-library tailwindcss @tailwindcss/postcss postcssAdd the UI library styles to your root layout:
import '@uselagoon/ui-library/dist/ui-library.css';Using a component from the library:
import '@uselagoon/ui-library/dist/ui-library.css';
import { Button, SwitchWithDescription } from '@uselagoon/ui-library';
export default () => (
<>
<Button variant="ghost" disabled>A spooky disabled button</Button>
<SwitchWithDescription
description="This is a switch description."
id="first"
label="Switch Text"
/>
</>
);View the component documentation on Chromatic (URL available after setup).
To include UI library stories in your project's Storybook, add to your .storybook/main.ts:
import type { StorybookConfig } from '@storybook/react-vite';
const config: StorybookConfig = {
// ... your existing config
refs: {
'ui-library': {
title: 'Lagoon UI Library',
url: 'https://<branch>--<app-id>.chromatic.com/', // Get URL from Chromatic dashboard
},
},
};
export default config;| Workflow | Trigger | Actions |
|---|---|---|
| CI | Push to main, PRs | Type check, lint, format check, build, build Storybook |
| Publish | GitHub Release published | All CI checks + publish to NPM |
| Chromatic | Push to main, PRs | Deploy Storybook to Chromatic (when token configured) |
- Update version in
package.json - Commit and push to main
- Create a GitHub Release with a new tag (e.g.,
v2.1.0) - The publish workflow automatically builds and publishes to NPM
Clone the repo locally:
git clone https://github.com/uselagoon/ui-library.git
cd ui-library
npm install
npm run storybookIt is recommended to build components in isolation with the help of storybook (currently V 9.0).
Open your browser and visit http://localhost:6006.
The project structure is as follows:
├── src
│ ├── components # React source code and demos (which then get bundled)
│ ├── hooks # Custom hooks
│ ├── providers # Custom theme and NextLink providers
│ ├── stories # Storybook stories
│ ├── index.css # Autogenerated tailwind css file
│ └── index.ts # Entrypoint for your exported components (that your project then imports)
├── eslint.config.js # Eslint config
├── vite.config.ts # Vite bundler config
└── package.json
Given that there's a storybook instance running, navigate to the src directory and modify/create new components with their respective stories.tsx files.
Modify and customize anything with Tailwind and/or custom css files if needed.
Then run the lint and format scripts, and you're ready to go!
npm run typecheck # TypeScript check
npm run lint # ESLint
npm run format # Prettier formattingTo add a new component from Shadcn, refer to the Shadcn CLI guide.
PRs and issues are welcome, we invite contributions from everyone.
This guide could come in handy: GitHub contribution guide