@brightspot/ui
v5.0.3
Published
A UI library for building Brightspot CMS components.
Readme
Brightspot UI
About
Brightspot UI is a package of custom web components and styles to provide a basis for building new CMS components. It uses TailwindCSS for styling and LitElement for web components.
If you're developing a Brightspot CMS plugin or creating custom CMS UI for your project, then you've come to the right place!
Getting Started
Note: To get the best developer experience we recommend using VSCode editor. The marketplace of extensions that are available provide code formatting and intellisense for all the TailwindCSS classnames and our plugins, etc. The VSCode setup is documented here.
Prerequisites
Your codebase needs to be compatible with
- TailwindCSS v3
Installation
- Install the Brightspot ui node module as a devDependency
yarn add -D @brightspot/ui - Create a
tailwind.configfile and add Brightspot ui as a preset. More on TWCSS presets here.// (Typescript example) contents of tailwind.config.ts export default { ... presets: [require('@brightspot/ui')], ... }// (Javascript example) contents of tailwind.config.js export default { ... presets: [require('@brightspot/ui/dist/tailwind.config.js')], ... } - Build your frontend
Using Plugins
Brightspot UI comes with a variety of TailwindCSS plugins to make styling simpler and declarative. Visit the Storybook to see the available plugins.
To use our plugins, include them in your TailwindCSS config as usual. Plugin files are provided in both Typescript and Javascript variants and are available under the dist path in the platform-ui module.
An example of including a plugin:
// your tailwind.config.ts
...
plugins: [
require('@brightspot/ui/dist/tailwind-plugin-theme.ts'),
...Web Components
Brightspot UI includes custom web components built with LitElement. FOUC (Flash of Unstyled Content) prevention is handled automatically when you import the components.
Import components in your JavaScript/TypeScript:
import '@brightspot/ui/dist/components/widget/Widget'See the Storybook documentation for detailed usage examples and API references.
Examples
We use Storybook for interactive previewing of our ui components. Launch that in the browser by running:
yarn storybookDevelopment
Prerequisites
- Node.js v22+
- Yarn 1 (classic)
Layout
This repo ships two surfaces inside one published @brightspot/ui npm package:
src/— the modern design system (web components, Tailwind plugins, presets). Built byyarn buildintodist/.src/legacy/tool-ui/— the brightspot CMS frontend (JS, CSS, webpack, tests). Has its ownpackage.json. Built by(cd src/legacy/tool-ui && yarn build)intosrc/legacy/tool-ui/src/main/webapp/dist/.
The publish flow (yarn prepack) builds both.
Component-only work (no CMS needed)
yarn storybookOpens Storybook at http://localhost:6006. Iterate on src/ components and Tailwind plugins without booting the CMS.
CMS integration work
The brightspot CMS consumes @brightspot/ui from npm. Two workflows for local iteration:
Fast loop: webpack-dev-server (recommended for JS/CSS edits)
Start the CMS in docker as usual (from
brightspot/):./gradlew dockerStart the dev server (from
platform-ui/src/legacy/tool-ui/):yarn server:localProxies to
localhost(or~/.brightspot/local-urlif set), serves freshly compiled assets at/cms/dist/, and injectsx-brightspot-dev: 1on proxied requests so the CMS returns unhashed asset paths.Open the CMS at the dev-server URL (https://localhost:8080/cms/) instead of the docker URL. Edit files in
src/legacy/tool-ui/src/; changes hot-reload in the browser.
Full WAR rebuild (for the modern src/ surface, or final smoke)
yarn server:local only serves src/legacy/tool-ui/. For edits to the modern surface in src/, or to validate against the actual WAR build:
Link the package (once per machine, from
platform-ui/):yarn linkConsume the link (in
brightspot/cms/tool-ui/):yarn link @brightspot/uiEdit, then rebuild whichever surface changed:
yarn build # for src/ edits (cd src/legacy/tool-ui && yarn build) # for src/legacy/tool-ui/ editsRebuild the CMS WAR and roll it into tomcat (from
brightspot/):./gradlew :cms-tool-ui:yarnBuild ./gradlew dockerSmoke at https://localhost/cms/ (apache, port 443).
Unlink when done
# in brightspot/cms/tool-ui:
yarn unlink @brightspot/ui && yarn install --force
# in platform-ui:
yarn unlinkReleases
@brightspot/ui ships via release-please. For migration-track prereleases (-cms-ui-migration.N), bump the version, publish to npm, then update the consumer pin in brightspot/cms/tool-ui/package.json and rerun yarn install there.
