Skip to content

chore: 🤖 provide support for root theme attribute#814

Merged
punkbit merged 139 commits intomainfrom
chore/support-root-theme
Mar 3, 2026
Merged

chore: 🤖 provide support for root theme attribute#814
punkbit merged 139 commits intomainfrom
chore/support-root-theme

Conversation

@punkbit
Copy link
Collaborator

@punkbit punkbit commented Feb 9, 2026

Why?

The following PR fulfils the request made in #813 by providing support for root theme attributes.

The process will provide control for the consumer's main html, e.g. data-cui-theme. It'll get the preferred theme from localStorage (if available), to prevent theme flashing, e.g. due to SSR vs browser runtime. Note that there'll be further changes once the set of PRs are merged (see https://github.com/ClickHouse/click-ui/pulls/punkbit).

It also provides documentation explaining how to use it in the consumer application.

⚠️ WARNING: Dedends on #773, which should be merged first.
🤖 NOTE: switch base branch once #773 merged.

How?

  • Control the consumer main HTML data-cui-theme
  • Gets preferred theme from localStorage to prevent theme flashing
  • Provides documentation, e.g. how-to use it

Preview?

Persist theme (refresh page)

demo-cui-theme-persist-refresh.mov

Attribute data-cui-theme

demo-cui-theme.mov

Build dist version

Screenshot 2026-02-10 at 11 05 53

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ punkbit
❌ GitHub Actions


GitHub Actions seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Base automatically changed from chore/distribution-unbundled to main February 11, 2026 16:50
Copy link
Member

@elizabetdev elizabetdev left a comment

Choose a reason for hiding this comment

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

LGTM! 🎉

It looks like #773, which this PR depended on, has been merged.

What else do we need to move this forward? Should we have an engineer take a look?

Resolved conflicts by accepting main's changes while preserving the PR's
core root theme functionality:

- ClickUIProvider: Combined main's theme validation (isValidThemeName,
  getFallbackThemeName) with PR's root theme attribute management
  (setRootThemeAttribute, removeRootThemeAttribute) and localStorage
  persistence (CUI_THEME_STORAGE_KEY)

- Theme exports: Updated to use main's simplified ThemeName type while
  keeping InitCUIThemeScript export for preventing theme flash

- Components: Accepted main's refactored icon paths (@/components/Assets/*)

- README: Integrated PR's theme documentation into main's structure

- Config: Accepted main's vite.config.ts (build configuration not
  related to root theme feature)

- Deleted src/components/icons/Flags/index.tsx as per main

The PR's core functionality is preserved:
- InitCUIThemeScript for preventing theme flash on SSR
- Root theme attribute (data-cui-theme) management
- localStorage theme persistence
@punkbit punkbit marked this pull request as ready for review February 23, 2026 19:16
@workflow-authentication-public
Copy link
Contributor

workflow-authentication-public bot commented Feb 23, 2026

📚 Storybook Preview Deployed

✅ Preview URL: https://click-iyud1ef9b-clickhouse.vercel.app

Built from commit: 2f3c7b3bba78a8af4769db9cddfd297d7b4037d9

@punkbit punkbit merged commit f071983 into main Mar 3, 2026
7 checks passed
@punkbit punkbit deleted the chore/support-root-theme branch March 3, 2026 10:46
punkbit added a commit that referenced this pull request Mar 9, 2026
* chore: 🤖 update required packages

* chore: 🤖 provide styled components types

* fix: 🐛 linter should ignore d.ts files

* fix: 🐛 use double quotes

* fix: 🐛 vite > v2 separates vitest config

* chore: 🤖 reorder package

* chore: 🤖 remove side property (deprecated)

* fix: 🐛 dropdown amends

* fix: 🐛 theme prop

* fix: 🐛 type

* chore: 🤖 TIAS build version supported on next v16 RSC

* chore: 🤖 WIP ongoing styled-component v6.1.11 (non experimental) support

* chore: 🤖 strict react version for dev

* fix: 🐛 missing ref on forwardRef, might have plenty of these

* chore: 🤖 update lockfile

* chore: 🤖 remove optional flag from ref (typo)

* chore: 🤖 add comment for future ref

* refactor: 💡 banner

* chore: 🤖 lint amends (double quotes)

* refactor: 💡 removes style prop as typed prop

* chore: 🤖 remove ajv

* chore: 🤖 format

* test: 💍 add aria pressed to ButtonGroup

* chore: 🤖 format

* test: 💍 use local getByText

* chore: 🤖 update lockfile

* chore: 🤖 add changeset

* chore: 🤖 small text amend to trigger vercel deploy

* chore: 🤖 prevent running on CI

* chore: 🤖 add HUSKY to preven husky runnig pre-commit hook

* fix: 🐛 conflict resolution

* chore: 🤖 bump rc number

* docs: 📝 build esm, how to use

* chore: 🤖 ESM vite builder (wip)

* fix: 🐛 remove .tsx extension from import statements

* fix: 🐛 remove .tsx extension from import statements

* fix: 🐛 remove .tsx extension from import statements

* fix: 🐛 remove .ts extension from import statements

* fix: 🐛 remove .ts extension from import statements

* chore: 🤖 add eslint to assess import extensions not required

* chore: 🤖 format

* chore: 🤖 temporary custom resolve tsconfig path

* refactor: 💡 export from correct theme boundary

* chore: 🤖 node externals in vite, remove alias

* chore: 🤖 use relative paths

* chore: 🤖 use externalize deps

* chore: 🤖 for ESM compatibility, tweak/handle CJS components

* chore: revert ts alias rewrite to relative

* chore: lint do not allow barrel imports

* chore: remove excludes from tsconfig

* chore: set vite settings to preserve file struct in output

* fix: solve import cycles

* fix: solve import cycles in stories

* fix: build amends

* fix: add .js extension

* chore: analyze and visualise bundle

* chore: split ESM, CJS distribution

* chore: format

* fix: 🐛 lint code block

* fix: 🐛 import Separator

* chore: format

* fix: 🐛 import Separator

* chore: 🤖 add changeset

* chore: 🤖 use 0.0.251-rc.62

* chore: 🤖 resolve conflict resolution, deleted files which were removed in main branch

* chore: 🤖 resolve conflict resolution, middle truncator

* chore: 🤖 resolve conflict resolution, missing container changes

* refactor: 💡 FileMultiUpload to follow FileUpload due to middle truncator

* fix: 🐛 prevent icon success pushed right

* fix: 🐛 remove file size from multiple file upload

* chore: 🤖 merge conflict amend for ButtonGroup

* chore: 🤖 remove comment

* chore: 🤖 missing typecheck call on build

* chore: 🤖 missing import

* chore: 🤖 checkout datedetails from main

* chore: 🤖 remove comment

* docs: 📝 prefer american english

* chore: 🤖 add dom utils, e.g. setRootThemeAttr and remove

* chore: 🤖 on mount, set root html theme attribute

* chore: 🤖 add support for SSR initial color scheme to prevent flash

* docs: 📝 introduce SSR flash theme prevention

* chore: 🤖 tweak package.json

* feat: 🎸 add theme persistence via localStorage

* docs: 📝 add theme persistence instructions

* chore: 🤖 remove attempt for prefers-color-scheme should be handled separate

* chore: 🤖 code format

* chore: 🤖 add changeset

* fix: 🐛 typo amend

* fix: 🐛 icon name type

* fix: 🐛 image name as icon type

* chore: 🤖 export hooks

* chore: 🤖 create useInitialTheme hook

* chore: 🤖 add get root util

* chore: 🤖 bump pkg

* docs: 📝 add themes instructions

* chore: 🤖 add note

* chore: 🤖 update package.json

* fix: 🐛 merge latest conflicts amends

* refactor: 💡 rename InitColorSchemeScript

* chore: 🤖 update lockfile

* fix: 🐛 lockfile

* fix: 🐛 dirname

* fix: 🐛 filename

* chore: 🤖 bump pkg

* chore: 🤖 bump pkg

* docs: 📝 conflict amends

* chore: 🤖 merge amend

* docs: 📝 missing assets management

* chore: 🤖 bump version

* bump version to 0.0.251-test.73

* fix: 🐛 prevent circular dependency

* refactor: 💡 use THEMES values

* docs: 📝 custom styles

* chore: 🤖 format

* refactor: 💡 avoid hard typed  themes

---------

Co-authored-by: GitHub Actions <actions@clickhouse.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants