@nick_tag_tech/themes
v0.1.2
Published
Shared theme catalog and adapters for Nick's apps (web, CLI, Electron). Strongly-typed semantic color tokens, CSS variable + xterm adapters, and first-paint bootstrap.
Maintainers
Readme
@nick_tag_tech/themes
Published on npm: https://www.npmjs.com/package/@nick_tag_tech/themes
One source of truth for Nick's color themes across every project — SPAs, web apps, Electron apps, and terminal/CLI experiences. Strongly-typed semantic color tokens, a framework-agnostic core, and optional Vue/Pinia/terminal adapters.
Ported verbatim from nicktagportal (packages/types/src/themes). 17 themes,
16 semantic color keys each, solarized-light as the default.
Install
bun add @nick_tag_tech/themes
# or consume by Git URL during early integration:
bun add github:notTag/DesignSystemvue and pinia are optional peer dependencies (only needed for those adapters).
Core usage (framework-agnostic)
import {
themes,
themeList,
DEFAULT_THEME_ID,
applyThemeToElement,
toCssVariables,
type Theme,
type ThemeColors,
type ThemeId,
} from '@nick_tag_tech/themes'
// Apply to <html> (writes --color-* vars + data-theme-type)
applyThemeToElement(themes['solarized-dark'])
// Or get a plain record for your own rendering
const vars = toCssVariables(themes['gruvbox'].colors)
// { '--color-surface': '#...', ... }First-paint bootstrap (no flash)
Inline this in <head> before your bundle to apply the saved theme
synchronously:
import { createBootstrapScript } from '@nick_tag_tech/themes/bootstrap'
const inline = createBootstrapScript('nicksite-theme')
// <script>${inline}</script>themeCssVariableMap and resolveThemeId are also exported for custom bootstrap
logic.
Terminal / xterm
import { toTerminalTheme } from '@nick_tag_tech/themes/terminal'
terminal.options.theme = toTerminalTheme(themes['hermes'].colors)The returned shape is structurally compatible with @xterm/xterm's ITheme
(the core package carries no xterm dependency).
Vue + Pinia adapters
// Pinia store factory — preserves preview/confirm + localStorage persistence
import { createThemeStore } from '@nick_tag_tech/themes/pinia'
export const useThemeStore = createThemeStore({ storageKey: 'nicksite-theme' })
// Vue effect — applies the reactive theme to the DOM on change
import { useThemeEffect } from '@nick_tag_tech/themes/vue'
import { storeToRefs } from 'pinia'
const { currentTheme } = storeToRefs(useThemeStore())
useThemeEffect(currentTheme)Persistence conventions
Storage keys are documented, not forced. Override via the adapter options.
| Consumer | Storage key |
| ------------------- | -------------------- |
| Shell / site theme | nicksite-theme |
| CLI terminal theme | nicksite-cli-theme |
CSS variables
| Theme color key | CSS variable |
| ---------------- | ------------------------ |
| surface | --color-surface |
| surfaceRaised | --color-surface-raised |
| surfaceOverlay | --color-surface-overlay|
| text | --color-text |
| textMuted | --color-text-muted |
| textOnAccent | --color-text-on-accent |
| accent | --color-accent |
| accentCyan | --color-accent-cyan |
| accentYellow | --color-accent-yellow |
| destructive | --color-destructive |
| link | --color-link |
| linkHover | --color-link-hover |
| border | --color-border |
| headerBg | --color-header-bg |
| selection | --color-selection |
| hover | --color-hover |
Scripts
bun install
bun test # registry, css vars, terminal, bootstrap
bun run typecheck # tsc --noEmit (strict)
bun run build # emit ESM + .d.ts to dist/Migrating nicktagportal
- Add
@nick_tag_tech/themesas a dependency. - Replace imports from
@/themes/@ntypes/themeswith@nick_tag_tech/themes. - Swap the local
useThemeCSS-var application forapplyThemeToElement/useThemeEffect, and the local stores forcreateThemeStore. - Replace the CLI's
toXtermThemewithtoTerminalThemefrom@nick_tag_tech/themes/terminal. - Move first-paint bootstrap to
createBootstrapScript. - Keep temporary re-exports in
packages/types/src/themesif needed, then delete the duplicated theme files once consumers are migrated.
Adding a theme
- Add
src/themes/<id>.tsexporting aThemewith all 16 color keys. - Register it in
src/themes/index.ts(themes,themeList) and add the id to theThemeIdunion insrc/themes/types.ts. bun test— the registry test fails if a color key is missing or ordering drifts.
