colorsbymax 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +212 -37
- package/dist/{ThemeSwitcher-CnxUWdBP.js → ThemeSwitcher-L1GXY55E.js} +1139 -51
- package/dist/auto.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +113 -112
- package/types/index.d.ts +13 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
What changed in each colorsbymax release. Update with `npm install colorsbymax@latest`.
|
|
4
4
|
|
|
5
|
+
## 0.2.2 (2026-09-25)
|
|
6
|
+
|
|
7
|
+
- **MCP server for AI agents.** [colorsbymax-mcp](mcp/) lets Claude Code, Cursor, VS Code Copilot and other agents set colorsbymax up in a project (with the right edits for Vite, Next.js, Remix, Astro, Nuxt, SvelteKit, plain HTML and more), find themes, build one from brand colours, check contrast and finish. Add it with `claude mcp add colorsbymax -- npx -y colorsbymax-mcp`.
|
|
8
|
+
- **A new README** with colour-coded sections and navigation, and a full guide to using colorsbymax with Claude Code, Cursor, VS Code Copilot, Claude Desktop, Windsurf, Cline and Codex, with or without the MCP server.
|
|
9
|
+
- Fixed: on sites whose body text is a warm or tinted dark (such as dark brown), re-colouring could take the text colour for the brand colour, so brand areas came out far too light or garish. The text colour is no longer a brand candidate.
|
|
10
|
+
|
|
11
|
+
## 0.2.1 (2026-09-25)
|
|
12
|
+
|
|
13
|
+
- **Smarter colours when re-colouring a site.** After swapping, text and icons are only adjusted to undo harm the swap did: a pair that reads as well as the site's original design did is left alone (so deliberately soft icons stay soft), and a fix keeps the design's intent, so white icons on a coloured pill stay white, using the nearest theme colour that works. Icon-only buttons are judged as icons (3:1), not text (4.5:1). Across 59 themes on a test site, nothing reads worse than the original design.
|
|
14
|
+
- **Audit.** A new Audit button in the panel header checks the page in the chosen colours and pins numbered notes to what won't look right: a logo that's hard to see (offering "Colour the logo", or, for picture logos colorsbymax can't re-colour, advice and a "Preview inverted" look), pictures whose solid background shows as a box against the theme, and text or icons below readable contrast. A bar by the colour button shows the count and the theme's own contrast issues, with Re-check and Close; it re-checks by itself when the colours or settings change.
|
|
15
|
+
- **"I'm done": finish without the switcher popping up in production.** A new button at the bottom of the panel shows your chosen colours and three ways to finish, each with code to copy and a prompt for Claude, Cursor or Copilot: keep the colours as the site's default and hide the switcher in production (it still shows in development), hide it on this device only (Alt+Shift+C or `?colorsbymax` brings it back), or remove colorsbymax and keep the colours in your CSS. Cancel goes back.
|
|
16
|
+
- **`hidden` config option:** hides the colour button while the theme still applies, e.g. `hidden: import.meta.env.PROD`.
|
|
17
|
+
- A `defaultTheme` in the config is now applied on re-coloured sites too (it used to be treated as the page's original look), and the page's own colours stay available as "… original".
|
|
18
|
+
- **"Colour the logo too" setting**, off by default: the site's logo keeps its own colours whatever the theme. It works on re-coloured sites and on sites using the colour variables. colorsbymax finds logos by `data-colorsbymax-logo`, or "logo" in a class, id or label, or common brand classes.
|
|
19
|
+
- Fixed: content that appeared while a theme was showing could be re-coloured from the theme's colours instead of the site's, giving the wrong colour (for example buttons turning blue).
|
|
20
|
+
- Fixed: decorative gradient strips, like animated underlines, were treated as the background behind text and icons.
|
|
21
|
+
- When an element changes class (a nav item becoming active), its contents are re-checked too.
|
|
22
|
+
|
|
5
23
|
## 0.2.0 (2026-09-25)
|
|
6
24
|
|
|
7
25
|
**Upgrading from 0.1.x:** the colour button moves to the bottom-right corner; add `position: 'top-right'` to keep it where it was. If your site doesn't use colorsbymax's `--color-*` variables, themes now re-colour it automatically; to keep the old behaviour (themes set only the variables), pass `recolour: false` in the config.
|
package/README.md
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/MaxMuyalwa/colorsbymax/main/docs/readme/hero.svg" alt="colorsbymax by mrmaxdesigns: re-colour any website, live." width="880">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/colorsbymax"><img src="https://img.shields.io/npm/v/colorsbymax?style=flat-square&color=0d6b84&label=colorsbymax" alt="colorsbymax on npm"></a>
|
|
7
|
+
<a href="https://www.npmjs.com/package/colorsbymax-mcp"><img src="https://img.shields.io/npm/v/colorsbymax-mcp?style=flat-square&color=7c3aed&label=colorsbymax-mcp" alt="colorsbymax-mcp on npm"></a>
|
|
8
|
+
<img src="https://img.shields.io/badge/React-18%20%7C%2019-be185d?style=flat-square" alt="React 18 or 19">
|
|
9
|
+
<img src="https://img.shields.io/badge/types-included-15803d?style=flat-square" alt="TypeScript types included">
|
|
10
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/licence-MIT-c2410c?style=flat-square" alt="MIT licence"></a>
|
|
11
|
+
</p>
|
|
4
12
|
|
|
5
13
|
A floating theme switcher for websites. Visitors (or the site's owner) can re-colour the whole site instantly: pick one of the site's own themes, a hand-tuned pick, or one of 715 library themes in 14 categories; build and share custom palettes; or override single colours. Every theme is checked against the Web Content Accessibility Guidelines (WCAG) contrast rules, with one-click fixes.
|
|
6
14
|
|
|
7
|
-
|
|
15
|
+
<p align="center">
|
|
16
|
+
<a href="#at-a-glance"><img src="https://raw.githubusercontent.com/MaxMuyalwa/colorsbymax/main/docs/readme/nav-start.svg" alt="1. Get started" height="36"></a>
|
|
17
|
+
<a href="#coding-agents-mcp"><img src="https://raw.githubusercontent.com/MaxMuyalwa/colorsbymax/main/docs/readme/nav-agents.svg" alt="2. Coding agents" height="36"></a>
|
|
18
|
+
<a href="#features"><img src="https://raw.githubusercontent.com/MaxMuyalwa/colorsbymax/main/docs/readme/nav-inside.svg" alt="3. Features" height="36"></a>
|
|
19
|
+
<a href="#add-it-to-a-site"><img src="https://raw.githubusercontent.com/MaxMuyalwa/colorsbymax/main/docs/readme/nav-control.svg" alt="4. Full control" height="36"></a>
|
|
20
|
+
<a href="#finished-keep-your-colours-and-hide-the-switcher"><img src="https://raw.githubusercontent.com/MaxMuyalwa/colorsbymax/main/docs/readme/nav-ship.svg" alt="5. Ship it" height="36"></a>
|
|
21
|
+
<a href="#building-the-package"><img src="https://raw.githubusercontent.com/MaxMuyalwa/colorsbymax/main/docs/readme/nav-hood.svg" alt="6. Under the hood" height="36"></a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
<br>
|
|
25
|
+
|
|
26
|
+
<img src="https://raw.githubusercontent.com/MaxMuyalwa/colorsbymax/main/docs/readme/section-start.svg" alt="01 · Get started: two steps to a live colour switcher" width="100%">
|
|
27
|
+
|
|
28
|
+
## At a glance
|
|
8
29
|
|
|
9
30
|
- **Two steps.** `npm install colorsbymax`, then `import 'colorsbymax/auto'` once. The colour button appears and visitors can re-colour the site, even if its colours are hard-coded (see [Quick start](#quick-start)).
|
|
10
31
|
- **React 18 or 19.**
|
|
@@ -14,39 +35,6 @@ A floating theme switcher for websites. Visitors (or the site's owner) can re-co
|
|
|
14
35
|
- **ESM only.** Import it from a bundler or `import()`; `require('colorsbymax')` from CommonJS isn't supported.
|
|
15
36
|
- **The colour tools work on their own too.** `contrastRatio`, `checkTheme`, `suggestFix`, `fixAll`, `themeFromPalette`, `darkTokens` and the rest are plain functions with no UI.
|
|
16
37
|
|
|
17
|
-
## Features
|
|
18
|
-
|
|
19
|
-
- **Site themes first.** The panel opens on a group named after the site, holding its own colours. If those fail contrast, an accessible version is generated automatically.
|
|
20
|
-
- **Scan the site.** Press "Scan site" and colorsbymax reads the colours actually painted on the page (ignoring any theme it has applied, and including gradients). It works out the page background, surfaces, text and brand colours, then adds themes named after the site: Scanned (as found), Accessible, Soft, Bold, Complementary, and the closest library matches. Scans run only when asked, and the results are remembered.
|
|
21
|
-
- **Max’s picks and library.** 5 hand-tuned picks, plus 715 library themes (Bright, Fun, Pastel, Earth tones, Summer, Autumn, Winter, Spring, Ocean, Warm, Nature, Moody, Monochrome, Eclectic) with search and "Surprise me". The library loads only when the panel opens.
|
|
22
|
-
- **Custom palettes, single-colour overrides, JSON import/export.**
|
|
23
|
-
- **Palettes from images and PDFs.** In Import / export, upload or drop a mood board, screenshot or photo. colorsbymax picks out its main colours, lets you leave any out, previews the palette it builds around them and saves it as a custom palette. Nothing leaves the browser. PDFs, such as brand guides, work where the site [turns them on](#pdf-uploads); hex codes written in a PDF take priority.
|
|
24
|
-
- **Contrast checks.** Problems show as a badge on the theme; the breakdown offers per-item fixes or "Fix all automatically", which changes lightness only.
|
|
25
|
-
- **No flash on reload.** An inline pre-paint script applies the saved theme before the page draws.
|
|
26
|
-
- **Works on any site.** The panel carries its own stylesheet inside a shadow root, so it needs no Tailwind or other CSS from the site, and the site's CSS can't restyle it.
|
|
27
|
-
- **Movable colour button.** The floating button starts in the corner; visitors can drag it anywhere (mouse or touch; a tooltip says so on hover, and the panel closes while it moves) and it stays there, remembered across reloads. The panel then opens beside it, on whichever side has room. Its dot cycles through the current theme's colours.
|
|
28
|
-
- **Light and dark mode.** Every built-in theme is designed light; dark mode lists a generated dark twin of each (dark surfaces, light text, brand colours lifted to read on dark, then contrast-fixed) and switches the current theme to its twin. The panel turns dark with it. Custom palettes stay as they were made.
|
|
29
|
-
- **Visitor settings.** The gear in the panel header opens settings: theme mode (Light, Dark, Auto), panel size (Compact, Standard, Large), which groups and sections to show, whether the button can be dragged or its dot animates, and moving the button back to its corner. Saved per site.
|
|
30
|
-
- **Resizable panel.** Drag the panel's free edges or corner (the ones away from the colour button) to any size, or pick a size in settings; double-click an edge to reset it. The layout follows the panel's width, so a large panel shows three theme cards a row.
|
|
31
|
-
- **Clear groups and feedback.** The site's own group (globe), Max’s picks (paintbrush) and Yours (person) sit in their own row, apart from the library's categories. Toasts confirm what just happened; saving, importing or building a palette says it went to Yours and offers "Show" to jump straight to it. Tooltips are drawn in the panel's colours.
|
|
32
|
-
- **Themed scrollbars.** The page's scrollbars and the panel's slim one take the selected theme's primary colour. Turn the page's off with `scrollbars: false`.
|
|
33
|
-
- **Accessible panel.** A labelled dialog with focus trap, Escape, the colour button or an outside click to close, keyboard operable, and reduced-motion support.
|
|
34
|
-
|
|
35
|
-
## How it works
|
|
36
|
-
|
|
37
|
-
Every colour is one of 35 tokens (`primary`, `surface`, `ink`, `data-1`…), exposed as `--color-<token>` CSS variables. Applying a theme just sets those variables on `<html>`, so anything the site paints with `var(--color-primary)` (directly, or through Tailwind CSS v4 utilities like `bg-primary`) changes instantly. There's no rebuild and no re-render.
|
|
38
|
-
|
|
39
|
-
The switcher renders into a `<colorsbymax-root>` element on `<body>` with its own shadow root and stylesheet. Only the `--color-*` variables cross into it. With reduced motion, the colour button's dot holds still on the theme's primary colour.
|
|
40
|
-
|
|
41
|
-
## Try the demo
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
npm install
|
|
45
|
-
npm run dev
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
This serves `demo/`: colorsbymax's own landing page, built with Tailwind, where every colour is a token (it uses every token group, and a strip shows the live values); `/plain.html`, a plain-CSS bakery site with deliberately careless global styles to show they don't reach the panel; and `/unwired.html`, a coffee shop with only hard-coded colours whose whole setup is `import 'colorsbymax/auto'`.
|
|
49
|
-
|
|
50
38
|
## Quick start
|
|
51
39
|
|
|
52
40
|
```bash
|
|
@@ -69,10 +57,138 @@ That's all. The colour button appears in the bottom-right corner once the page h
|
|
|
69
57
|
autoMount({ siteName: 'My site', storageKey: 'my-site-theme' })
|
|
70
58
|
```
|
|
71
59
|
|
|
60
|
+
- **Logos keep their own colours** unless a visitor turns on "Colour the logo too" in settings. Mark your logo with `data-colorsbymax-logo` if colorsbymax doesn't find it (it looks for "logo" in a class, id or label).
|
|
72
61
|
- **Where automatic re-colouring falls short:** images keep their colours, hover and focus colours keep the site's own, and colours drawn by `::before`/`::after` aren't swapped. For full control, use the colour variables below; colorsbymax then applies themes to them directly, with no page reading at all.
|
|
73
62
|
|
|
74
63
|
Already installed it? Get the newest version with `npm install colorsbymax@latest` (see [Updating](#updating)).
|
|
75
64
|
|
|
65
|
+
## Try the demo
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npm install
|
|
69
|
+
npm run dev
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
This serves `demo/`: colorsbymax's own landing page, built with Tailwind, where every colour is a token (it uses every token group, and a strip shows the live values); `/plain.html`, a plain-CSS bakery site with deliberately careless global styles to show they don't reach the panel; and `/unwired.html`, a coffee shop with only hard-coded colours whose whole setup is `import 'colorsbymax/auto'`.
|
|
73
|
+
|
|
74
|
+
<br>
|
|
75
|
+
|
|
76
|
+
<img src="https://raw.githubusercontent.com/MaxMuyalwa/colorsbymax/main/docs/readme/section-agents.svg" alt="02 · Coding agents: let Claude, Cursor or Copilot do it" width="100%">
|
|
77
|
+
|
|
78
|
+
## Coding agents (MCP)
|
|
79
|
+
|
|
80
|
+
Your coding agent can set colorsbymax up and use it for you. [colorsbymax-mcp](mcp/) is an [MCP](https://modelcontextprotocol.io) server that gives Claude Code, Cursor, VS Code Copilot, Claude Desktop, Windsurf, Codex and other agents colorsbymax's own tools:
|
|
81
|
+
|
|
82
|
+
| The agent can… | Tool |
|
|
83
|
+
| --- | --- |
|
|
84
|
+
| Look at your project and add colorsbymax the right way for its framework: Vite, Next.js, Remix, Gatsby, Astro, Nuxt, SvelteKit, Vue, Svelte or plain HTML | `setup_plan` |
|
|
85
|
+
| Find themes by mood, category or closeness to your brand colour, in light or dark | `find_themes`, `get_theme` |
|
|
86
|
+
| Build a complete, accessible theme around your brand colours | `theme_from_colours` |
|
|
87
|
+
| Check contrast and suggest the smallest fixes | `check_contrast` |
|
|
88
|
+
| Make your chosen colours the default and hide the switcher in production, or remove colorsbymax and keep them | `finish` |
|
|
89
|
+
| Read these docs and the full TypeScript API | `docs` |
|
|
90
|
+
|
|
91
|
+
It reads your project but never changes it: the agent makes the edits, so you review them as usual. It runs with `npx`, so there's nothing to install first (Node 18 or later).
|
|
92
|
+
|
|
93
|
+
### Claude Code
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
claude mcp add colorsbymax -- npx -y colorsbymax-mcp
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
That adds it for you in this project. Add `--scope user` to have it in every project, or `--scope project` to share it with your team through a `.mcp.json` file. Check it with `/mcp` inside Claude Code.
|
|
100
|
+
|
|
101
|
+
### Cursor
|
|
102
|
+
|
|
103
|
+
Add this to `.cursor/mcp.json` in your project, or to `~/.cursor/mcp.json` for every project:
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"mcpServers": {
|
|
108
|
+
"colorsbymax": { "command": "npx", "args": ["-y", "colorsbymax-mcp"] }
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
It then shows under **Settings → MCP**, and Cursor's agent uses it when you ask about colours or themes.
|
|
114
|
+
|
|
115
|
+
### VS Code (GitHub Copilot)
|
|
116
|
+
|
|
117
|
+
Add this to `.vscode/mcp.json`, then use it from Copilot Chat in **Agent** mode:
|
|
118
|
+
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"servers": {
|
|
122
|
+
"colorsbymax": { "command": "npx", "args": ["-y", "colorsbymax-mcp"] }
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Claude Desktop
|
|
128
|
+
|
|
129
|
+
Open **Settings → Developer → Edit Config**, add the same `mcpServers` entry as Cursor to `claude_desktop_config.json`, and restart Claude Desktop.
|
|
130
|
+
|
|
131
|
+
### Windsurf, Cline, Codex and others
|
|
132
|
+
|
|
133
|
+
Most agents take the same `mcpServers` entry as Cursor: Windsurf in `~/.codeium/windsurf/mcp_config.json`, and Cline under **MCP Servers → Configure**. For the Codex CLI, add this to `~/.codex/config.toml`:
|
|
134
|
+
|
|
135
|
+
```toml
|
|
136
|
+
[mcp_servers.colorsbymax]
|
|
137
|
+
command = "npx"
|
|
138
|
+
args = ["-y", "colorsbymax-mcp"]
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
On Windows, if an editor can't start `npx`, use `"command": "cmd"` with `"args": ["/c", "npx", "-y", "colorsbymax-mcp"]`.
|
|
142
|
+
|
|
143
|
+
### What to ask
|
|
144
|
+
|
|
145
|
+
- *"Add colorsbymax to this project."*
|
|
146
|
+
- *"Find me a calm ocean theme that also works in dark mode."*
|
|
147
|
+
- *"Build a theme around our brand colours #e63946 and #1d3557, and check its contrast."*
|
|
148
|
+
- *"Does white text pass on #f59e0b?"*
|
|
149
|
+
- *"I've picked my colours in the panel. Make them the default and hide the switcher in production."* Paste the theme from the panel's **Import / export**, or name the theme.
|
|
150
|
+
|
|
151
|
+
### Without MCP
|
|
152
|
+
|
|
153
|
+
Any coding agent can still do it from a prompt. Paste this into Claude, Cursor, Copilot or another agent:
|
|
154
|
+
|
|
155
|
+
> Install the colorsbymax npm package in this project and add `import 'colorsbymax/auto'` to the app's entry file, so the colorsbymax colour button appears on every page. For Next.js, Remix or other server-rendered apps, load it in the browser only, with `import('colorsbymax/auto')` inside a `useEffect`. Follow https://github.com/MaxMuyalwa/colorsbymax#quick-start and don't change anything else.
|
|
156
|
+
|
|
157
|
+
When you're done choosing colours, the panel's **I'm done** button gives you ready-made prompts for keeping your colours, hiding the switcher or removing it (see [Finished?](#finished-keep-your-colours-and-hide-the-switcher)).
|
|
158
|
+
|
|
159
|
+
<br>
|
|
160
|
+
|
|
161
|
+
<img src="https://raw.githubusercontent.com/MaxMuyalwa/colorsbymax/main/docs/readme/section-inside.svg" alt="03 · What's inside: everything in the panel" width="100%">
|
|
162
|
+
|
|
163
|
+
## Features
|
|
164
|
+
|
|
165
|
+
- **Site themes first.** The panel opens on a group named after the site, holding its own colours. If those fail contrast, an accessible version is generated automatically.
|
|
166
|
+
- **Scan the site.** Press "Scan site" and colorsbymax reads the colours actually painted on the page (ignoring any theme it has applied, and including gradients). It works out the page background, surfaces, text and brand colours, then adds themes named after the site: Scanned (as found), Accessible, Soft, Bold, Complementary, and the closest library matches. Scans run only when asked, and the results are remembered.
|
|
167
|
+
- **Max’s picks and library.** 5 hand-tuned picks, plus 715 library themes (Bright, Fun, Pastel, Earth tones, Summer, Autumn, Winter, Spring, Ocean, Warm, Nature, Moody, Monochrome, Eclectic) with search and "Surprise me". The library loads only when the panel opens.
|
|
168
|
+
- **Custom palettes, single-colour overrides, JSON import/export.**
|
|
169
|
+
- **Palettes from images and PDFs.** In Import / export, upload or drop a mood board, screenshot or photo. colorsbymax picks out its main colours, lets you leave any out, previews the palette it builds around them and saves it as a custom palette. Nothing leaves the browser. PDFs, such as brand guides, work where the site [turns them on](#pdf-uploads); hex codes written in a PDF take priority.
|
|
170
|
+
- **Contrast checks.** Problems show as a badge on the theme; the breakdown offers per-item fixes or "Fix all automatically", which changes lightness only.
|
|
171
|
+
- **No flash on reload.** An inline pre-paint script applies the saved theme before the page draws.
|
|
172
|
+
- **Works on any site.** The panel carries its own stylesheet inside a shadow root, so it needs no Tailwind or other CSS from the site, and the site's CSS can't restyle it.
|
|
173
|
+
- **Movable colour button.** The floating button starts in the corner; visitors can drag it anywhere (mouse or touch; a tooltip says so on hover, and the panel closes while it moves) and it stays there, remembered across reloads. The panel then opens beside it, on whichever side has room. Its dot cycles through the current theme's colours.
|
|
174
|
+
- **Light and dark mode.** Every built-in theme is designed light; dark mode lists a generated dark twin of each (dark surfaces, light text, brand colours lifted to read on dark, then contrast-fixed) and switches the current theme to its twin. The panel turns dark with it. Custom palettes stay as they were made.
|
|
175
|
+
- **Visitor settings.** The gear in the panel header opens settings: theme mode (Light, Dark, Auto), panel size (Compact, Standard, Large), which groups and sections to show, whether the button can be dragged or its dot animates, and moving the button back to its corner. Saved per site.
|
|
176
|
+
- **Resizable panel.** Drag the panel's free edges or corner (the ones away from the colour button) to any size, or pick a size in settings; double-click an edge to reset it. The layout follows the panel's width, so a large panel shows three theme cards a row.
|
|
177
|
+
- **Audit the page.** The **Audit** button in the panel header looks at the page in the chosen colours and pins notes to what won't look right: a logo that disappears against its background (with a one-click "Colour the logo", or tips when it's a picture colorsbymax can't re-colour, plus "Preview inverted"), pictures whose solid background shows as a box, and text or icons too faint to read. The notes stay on the page as you scroll; **Re-check** after a fix (it also re-checks when the colours change) and close it from its bar.
|
|
178
|
+
- **Clear groups and feedback.** The site's own group (globe), Max’s picks (paintbrush) and Yours (person) sit in their own row, apart from the library's categories. Toasts confirm what just happened; saving, importing or building a palette says it went to Yours and offers "Show" to jump straight to it. Tooltips are drawn in the panel's colours.
|
|
179
|
+
- **Themed scrollbars.** The page's scrollbars and the panel's slim one take the selected theme's primary colour. Turn the page's off with `scrollbars: false`.
|
|
180
|
+
- **Accessible panel.** A labelled dialog with focus trap, Escape, the colour button or an outside click to close, keyboard operable, and reduced-motion support.
|
|
181
|
+
|
|
182
|
+
## How it works
|
|
183
|
+
|
|
184
|
+
Every colour is one of 35 tokens (`primary`, `surface`, `ink`, `data-1`…), exposed as `--color-<token>` CSS variables. Applying a theme just sets those variables on `<html>`, so anything the site paints with `var(--color-primary)` (directly, or through Tailwind CSS v4 utilities like `bg-primary`) changes instantly. There's no rebuild and no re-render.
|
|
185
|
+
|
|
186
|
+
The switcher renders into a `<colorsbymax-root>` element on `<body>` with its own shadow root and stylesheet. Only the `--color-*` variables cross into it. With reduced motion, the colour button's dot holds still on the theme's primary colour.
|
|
187
|
+
|
|
188
|
+
<br>
|
|
189
|
+
|
|
190
|
+
<img src="https://raw.githubusercontent.com/MaxMuyalwa/colorsbymax/main/docs/readme/section-control.svg" alt="04 · Full control: paint with colour tokens" width="100%">
|
|
191
|
+
|
|
76
192
|
## Add it to a site
|
|
77
193
|
|
|
78
194
|
This is the full setup, for sites that want exact control over which colour goes where. colorsbymax needs React 18 or 19, and ships as plain JavaScript with TypeScript types, so Vite, Next.js, webpack and other bundlers use it without extra setup:
|
|
@@ -133,6 +249,7 @@ Without a `siteName`, the site group is named from the page's `og:site_name`, it
|
|
|
133
249
|
// no --color-* variables, the default), true or false
|
|
134
250
|
position: 'bottom-right', // where the button starts: bottom-right (default), bottom-left,
|
|
135
251
|
// top-left, or top-right (just under a floating nav bar)
|
|
252
|
+
hidden: import.meta.env.PROD, // hide the button (the theme still applies), e.g. in production
|
|
136
253
|
}
|
|
137
254
|
```
|
|
138
255
|
|
|
@@ -154,6 +271,46 @@ PDF.js still downloads only when a visitor picks a PDF. Sites that don't opt in
|
|
|
154
271
|
|
|
155
272
|
`examples/tsungi.config.js` is a complete example for tsungi.online, the first site to use colorsbymax.
|
|
156
273
|
|
|
274
|
+
<br>
|
|
275
|
+
|
|
276
|
+
<img src="https://raw.githubusercontent.com/MaxMuyalwa/colorsbymax/main/docs/readme/section-ship.svg" alt="05 · Ship it: keep your colours and go live" width="100%">
|
|
277
|
+
|
|
278
|
+
## Finished? Keep your colours and hide the switcher
|
|
279
|
+
|
|
280
|
+
The colours you pick in the panel are saved only in your own browser. When you're happy with them, press **I'm done** at the bottom of the panel. It shows your colours and three ways to finish, each with code to copy and a prompt you can paste into Claude, Cursor, Copilot or any AI editor. **Cancel, keep using colorsbymax** takes you back without changing anything.
|
|
281
|
+
|
|
282
|
+
### Keep the colours and hide it in production (recommended)
|
|
283
|
+
|
|
284
|
+
Make your pick the site's default for everyone, and keep the button out of production while it still shows when you run the site locally, so you can keep iterating:
|
|
285
|
+
|
|
286
|
+
```js
|
|
287
|
+
// With the one-line setup, replace `import 'colorsbymax/auto'` with:
|
|
288
|
+
import { autoMount } from 'colorsbymax/auto'
|
|
289
|
+
|
|
290
|
+
autoMount({
|
|
291
|
+
defaultTheme: { name: 'Ocean', tokens: { primary: '#0d6b84', /* …every colour… */ } },
|
|
292
|
+
hidden: import.meta.env.PROD,
|
|
293
|
+
})
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
With `ThemeProvider`, add the same `defaultTheme` and `hidden` to its `config`. The panel fills in all your colours for you. Not using Vite? Use `process.env.NODE_ENV === 'production'` in place of `import.meta.env.PROD` (Next.js, webpack).
|
|
297
|
+
|
|
298
|
+
**Bring it back later:** it keeps showing in development. To show it in production again, set `hidden: false` or remove the line, or ask your AI editor: *"Show the colorsbymax colour switcher again in production: in its config, set hidden to false or remove the hidden line."*
|
|
299
|
+
|
|
300
|
+
### Hide it on this device only
|
|
301
|
+
|
|
302
|
+
Hides the button in your browser straight away, with no code change and nothing different for anyone else. **To bring it back**, press **Alt+Shift+C** on the page, or open it with `?colorsbymax` at the end of the address.
|
|
303
|
+
|
|
304
|
+
### Remove colorsbymax
|
|
305
|
+
|
|
306
|
+
1. `npm uninstall colorsbymax`
|
|
307
|
+
2. Delete its import (`import 'colorsbymax/auto'`, `autoMount`, or `ThemeProvider` and `ThemeSwitcher`) and any colorsbymax pre-paint script.
|
|
308
|
+
3. Keep your colours:
|
|
309
|
+
- If your site uses the `--color-*` variables, paste the CSS the panel gives you (`:root { --color-primary: …; … }`) into your global stylesheet.
|
|
310
|
+
- If colorsbymax was re-colouring hard-coded colours for you, the chosen colours only exist while it runs, so your CSS needs updating to them. The panel's prompt asks your AI editor to do that.
|
|
311
|
+
|
|
312
|
+
To bring it back later, install it again and follow the [Quick start](#quick-start).
|
|
313
|
+
|
|
157
314
|
## Updating
|
|
158
315
|
|
|
159
316
|
```bash
|
|
@@ -162,8 +319,18 @@ npm install colorsbymax@latest
|
|
|
162
319
|
|
|
163
320
|
This moves you to the newest release and records it in your `package.json`. `npm update` alone isn't enough while colorsbymax is below 1.0: with the usual `^0.1.0` range, npm treats 0.2.0 as a breaking change and stays on 0.1.x. Check which version you have with `npm ls colorsbymax`.
|
|
164
321
|
|
|
322
|
+
If it still installs the old version right after a release, npm is using its cached list of versions; add `--prefer-online` to check the registry:
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
npm install colorsbymax@latest --prefer-online
|
|
326
|
+
```
|
|
327
|
+
|
|
165
328
|
What changed in each release, and anything you need to do when upgrading, is in [CHANGELOG.md](CHANGELOG.md).
|
|
166
329
|
|
|
330
|
+
<br>
|
|
331
|
+
|
|
332
|
+
<img src="https://raw.githubusercontent.com/MaxMuyalwa/colorsbymax/main/docs/readme/section-hood.svg" alt="06 · Under the hood: build, regenerate, contribute" width="100%">
|
|
333
|
+
|
|
167
334
|
## Building the package
|
|
168
335
|
|
|
169
336
|
`src/` is the source; `dist/` is what sites install: plain JavaScript with the JSX compiled away. `types/` holds the hand-written TypeScript declarations; `npm run typecheck` compiles `types/check.tsx` against them and checks they match the built exports. The panel's icons are copied from Lucide into `src/icons.jsx` by `npm run icons`. `dist/` is committed so installs straight from GitHub work even when npm skips install scripts, so rebuild it before committing changes to `src/`. `npm publish` also rebuilds it first:
|
|
@@ -172,6 +339,14 @@ What changed in each release, and anything you need to do when upgrading, is in
|
|
|
172
339
|
npm run build
|
|
173
340
|
```
|
|
174
341
|
|
|
342
|
+
## README artwork
|
|
343
|
+
|
|
344
|
+
The hero, the section banners and the navigation chips are SVGs in `docs/readme/`, drawn by `scripts/make-readme-art.mjs` from colorsbymax's own themes:
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
node scripts/make-readme-art.mjs
|
|
348
|
+
```
|
|
349
|
+
|
|
175
350
|
## Panel styles
|
|
176
351
|
|
|
177
352
|
The panel is styled with Tailwind classes in `src/ThemePanel.jsx` and `src/ThemeSwitcher.jsx`. `scripts/build-css.mjs` compiles them, with `src/panel.css`, into `src/panel-css.generated.js`. The demo server does this automatically as you edit; otherwise run:
|