kodeui 0.0.0-stage → 0.1.0

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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +30 -2
  3. package/bin/kodeui.mjs +89 -0
  4. package/package.json +37 -4
  5. package/skill/kodeui/SKILL.md +105 -0
  6. package/skill/kodeui/assets/tokens.css +40 -0
  7. package/skill/kodeui/components/aurora-input/AuroraInput.tsx +153 -0
  8. package/skill/kodeui/components/aurora-input/aurora-input.css +218 -0
  9. package/skill/kodeui/components/aurora-input/index.ts +2 -0
  10. package/skill/kodeui/components/bloom-wall/BloomWall.tsx +90 -0
  11. package/skill/kodeui/components/bloom-wall/bloom-wall.css +10 -0
  12. package/skill/kodeui/components/bloom-wall/engine.ts +1022 -0
  13. package/skill/kodeui/components/bloom-wall/icons/icons-a.ts +818 -0
  14. package/skill/kodeui/components/bloom-wall/icons/icons-b.ts +827 -0
  15. package/skill/kodeui/components/bloom-wall/icons/index.ts +25 -0
  16. package/skill/kodeui/components/bloom-wall/icons/types.ts +8 -0
  17. package/skill/kodeui/components/bloom-wall/index.ts +12 -0
  18. package/skill/kodeui/components/bloom-wall/paint.ts +113 -0
  19. package/skill/kodeui/components/bloom-wall/palettes.ts +32 -0
  20. package/skill/kodeui/components/blur-in-text/BlurInText.tsx +53 -0
  21. package/skill/kodeui/components/blur-in-text/blur-in-text.css +14 -0
  22. package/skill/kodeui/components/blur-in-text/index.ts +2 -0
  23. package/skill/kodeui/components/glass-reveal/GlassReveal.tsx +108 -0
  24. package/skill/kodeui/components/glass-reveal/glass-reveal.css +126 -0
  25. package/skill/kodeui/components/glass-reveal/index.ts +2 -0
  26. package/skill/kodeui/components/glow-card/GlowCard.tsx +67 -0
  27. package/skill/kodeui/components/glow-card/glow-card.css +134 -0
  28. package/skill/kodeui/components/glow-card/index.ts +2 -0
  29. package/skill/kodeui/components/launch-chip/LaunchChip.tsx +180 -0
  30. package/skill/kodeui/components/launch-chip/icons.tsx +119 -0
  31. package/skill/kodeui/components/launch-chip/index.ts +3 -0
  32. package/skill/kodeui/components/launch-chip/launch-chip.css +345 -0
  33. package/skill/kodeui/components/ring-reveal/RingReveal.tsx +84 -0
  34. package/skill/kodeui/components/ring-reveal/index.ts +4 -0
  35. package/skill/kodeui/components/ring-reveal/ring-reveal.css +10 -0
  36. package/skill/kodeui/components/ring-reveal/ring.ts +298 -0
  37. package/skill/kodeui/components/rolling-text/RollingText.tsx +121 -0
  38. package/skill/kodeui/components/rolling-text/index.ts +4 -0
  39. package/skill/kodeui/components/rolling-text/roll.ts +94 -0
  40. package/skill/kodeui/components/rolling-text/rolling-text.css +43 -0
  41. package/skill/kodeui/components/use-live-transcript/index.ts +2 -0
  42. package/skill/kodeui/components/use-live-transcript/useLiveTranscript.ts +215 -0
  43. package/skill/kodeui/components/voice-input/VoiceInput.tsx +273 -0
  44. package/skill/kodeui/components/voice-input/icons.tsx +27 -0
  45. package/skill/kodeui/components/voice-input/index.ts +4 -0
  46. package/skill/kodeui/components/voice-input/useVoiceRecorder.ts +289 -0
  47. package/skill/kodeui/components/voice-input/voice-input.css +34 -0
  48. package/skill/kodeui/components/voice-note/VoiceNote.tsx +170 -0
  49. package/skill/kodeui/components/voice-note/index.ts +3 -0
  50. package/skill/kodeui/components/voice-note/noteFile.ts +25 -0
  51. package/skill/kodeui/components/voice-note/voice-note.css +45 -0
  52. package/skill/kodeui/references/aurora-input.md +44 -0
  53. package/skill/kodeui/references/bloom-wall.md +59 -0
  54. package/skill/kodeui/references/blur-in-text.md +17 -0
  55. package/skill/kodeui/references/frameworks.md +46 -0
  56. package/skill/kodeui/references/glass-reveal.md +40 -0
  57. package/skill/kodeui/references/glow-card.md +48 -0
  58. package/skill/kodeui/references/launch-chip.md +37 -0
  59. package/skill/kodeui/references/recipes.md +77 -0
  60. package/skill/kodeui/references/ring-reveal.md +35 -0
  61. package/skill/kodeui/references/rolling-text.md +19 -0
  62. package/skill/kodeui/references/theming.md +45 -0
  63. package/skill/kodeui/references/use-live-transcript.md +28 -0
  64. package/skill/kodeui/references/voice-input.md +60 -0
  65. package/skill/kodeui/references/voice-note.md +22 -0
  66. package/skill/kodeui/scripts/add.mjs +192 -0
  67. package/skill/kodeui/scripts/manifest.json +92 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ali Furqan (kodeui.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,31 @@
1
- # Temporary Holding Version
1
+ # KodeUI
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Design components Claude can install. **One command gives Claude Code all 11 KodeUI components:**
4
+
5
+ ```bash
6
+ npx kodeui@latest
7
+ ```
8
+
9
+ Then open Claude Code in your React or Next.js project and ask for what you want:
10
+
11
+ - "Add the KodeUI glow card to my sidebar, linking to /pricing"
12
+ - "Swap my chat box for the KodeUI voice input"
13
+ - "Put the KodeUI bloom wall behind my hero, triggered by the New pill"
14
+
15
+ Claude picks the component, copies its source into your project (you own the code), installs what
16
+ it needs, wires it in and matches your colours.
17
+
18
+ | Command | What it does |
19
+ |---|---|
20
+ | `npx kodeui@latest` | Installs the KodeUI skill for Claude Code in `~/.claude/skills/kodeui` (all your projects) |
21
+ | `npx kodeui@latest --project` | Installs it in `.claude/skills/kodeui` of this project, to commit for your team |
22
+ | `npx kodeui@latest add glow-card` | Copies a component into your project yourself, without Claude |
23
+ | `npx kodeui@latest list` | Lists the components |
24
+ | `npx kodeui@latest uninstall` | Removes the skill |
25
+
26
+ **Claude.ai or the Claude app chat:** download [kodeui.skill](https://kodeui.com/kodeui.skill) and upload it in
27
+ Settings → Capabilities → Skills.
28
+
29
+ Components: Bloom Wall, Ring Reveal, Glass Reveal, Glow Card, Aurora Input, Launch Chip, Rolling Text,
30
+ Blur-in Text, Voice Input, Voice Note, useLiveTranscript. See them at [kodeui.com](https://kodeui.com).
31
+ Needs React 18 or newer.
package/bin/kodeui.mjs ADDED
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env node
2
+ /*
3
+ * kodeui: give Claude the KodeUI design components.
4
+ *
5
+ * npx kodeui@latest install the KodeUI skill for Claude Code (all your projects)
6
+ * npx kodeui@latest --project install it in this project only (.claude/skills, commit it for your team)
7
+ * npx kodeui@latest add <names...> copy components into this project yourself, without Claude
8
+ * npx kodeui@latest list list the components
9
+ * npx kodeui@latest uninstall remove the skill (add --project for this project's copy)
10
+ */
11
+ import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
12
+ import { homedir } from 'node:os';
13
+ import { basename, dirname, join, resolve } from 'node:path';
14
+ import { spawnSync } from 'node:child_process';
15
+ import { fileURLToPath } from 'node:url';
16
+
17
+ const here = dirname(fileURLToPath(import.meta.url));
18
+ const SKILL = resolve(here, '..', 'skill', 'kodeui');
19
+ const VERSION = JSON.parse(readFileSync(resolve(here, '..', 'package.json'), 'utf8')).version;
20
+ const tty = process.stdout.isTTY && !process.env.NO_COLOR;
21
+ const c = (code) => (s) => (tty ? `\x1b[${code}m${s}\x1b[0m` : String(s));
22
+ const green = c('32'), dim = c('2'), bold = c('1'), cyan = c('36');
23
+
24
+ const args = process.argv.slice(2);
25
+ const flag = (f) => args.includes(f);
26
+ const cmd = args.find((a) => !a.startsWith('-')) ?? 'install';
27
+
28
+ function skillsDir() {
29
+ const i = args.indexOf('--dir');
30
+ if (i >= 0 && args[i + 1]) return resolve(args[i + 1]);
31
+ return flag('--project') ? resolve(process.cwd(), '.claude', 'skills') : join(homedir(), '.claude', 'skills');
32
+ }
33
+ const pretty = (p) => p.replace(homedir(), '~');
34
+
35
+ function install() {
36
+ if (!existsSync(join(SKILL, 'SKILL.md'))) { console.error('kodeui: the skill files are missing from this package.'); process.exit(1); }
37
+ const dir = skillsDir();
38
+ const target = join(dir, 'kodeui');
39
+ const had = existsSync(join(target, 'SKILL.md'));
40
+ // replace an older copy completely (only ever the kodeui folder inside a skills folder)
41
+ if (basename(target) === 'kodeui' && basename(dir) === 'skills' && existsSync(target)) rmSync(target, { recursive: true, force: true });
42
+ mkdirSync(dir, { recursive: true });
43
+ cpSync(SKILL, target, { recursive: true });
44
+ writeFileSync(join(target, '.kodeui-version'), VERSION + '\n');
45
+ const components = readdirSync(join(target, 'components')).filter((f) => !f.startsWith('.')).length;
46
+
47
+ console.log(`\n${green('✓')} ${bold(`KodeUI skill ${had ? 'updated' : 'installed'}`)} ${dim(`v${VERSION}`)}`);
48
+ console.log(` ${pretty(target)} ${dim(`(${components} components)`)}\n`);
49
+ console.log(`${bold('Now ask Claude.')} Open Claude Code in your React project and say what you want, e.g.`);
50
+ console.log(cyan(' "Add the KodeUI glow card to my sidebar, linking to /pricing"'));
51
+ console.log(cyan(' "Swap my chat box for the KodeUI voice input"'));
52
+ console.log(cyan(' "Put the KodeUI bloom wall behind my hero, triggered by the New pill"'));
53
+ console.log(dim(' Claude Code already open? Start a new session so it sees the skill.\n'));
54
+ if (flag('--project')) console.log(dim(' Installed for this project only: commit .claude/skills/kodeui so your team gets it too.\n'));
55
+ console.log(dim('Claude.ai or the Claude app chat: download https://kodeui.com/kodeui.skill and upload it in'));
56
+ console.log(dim('Settings → Capabilities → Skills.'));
57
+ console.log(dim('Without Claude: npx kodeui@latest add glow-card\n'));
58
+ }
59
+
60
+ function uninstall() {
61
+ const target = join(skillsDir(), 'kodeui');
62
+ if (!existsSync(target)) { console.log(`Nothing to remove at ${pretty(target)}.`); return; }
63
+ rmSync(target, { recursive: true, force: true });
64
+ console.log(`${green('✓')} Removed ${pretty(target)}.`);
65
+ }
66
+
67
+ function runAdd(rest) {
68
+ const r = spawnSync(process.execPath, [join(SKILL, 'scripts', 'add.mjs'), ...rest], { stdio: 'inherit', cwd: process.cwd() });
69
+ process.exit(r.status ?? 1);
70
+ }
71
+
72
+ function help() {
73
+ console.log(`${bold('kodeui')} ${dim(`v${VERSION}`)}: design components Claude can install (kodeui.com)
74
+
75
+ npx kodeui@latest Install the KodeUI skill for Claude Code (all projects)
76
+ npx kodeui@latest --project Install it in this project only (.claude/skills/kodeui)
77
+ npx kodeui@latest add <names...> Copy components into this project yourself
78
+ npx kodeui@latest list List the 11 components
79
+ npx kodeui@latest uninstall Remove the skill (--project for this project's copy)
80
+ `);
81
+ }
82
+
83
+ if (flag('-v') || flag('--version')) console.log(VERSION);
84
+ else if (flag('-h') || flag('--help') || cmd === 'help') help();
85
+ else if (cmd === 'install' || cmd === 'init') install();
86
+ else if (cmd === 'uninstall' || cmd === 'remove') uninstall();
87
+ else if (cmd === 'add') runAdd(args.slice(args.indexOf('add') + 1));
88
+ else if (cmd === 'list') runAdd(['list']);
89
+ else { console.error(`Unknown command "${cmd}".\n`); help(); process.exit(1); }
package/package.json CHANGED
@@ -1,6 +1,39 @@
1
1
  {
2
2
  "name": "kodeui",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "KodeUI: design components Claude can install. One command gives Claude Code all 11 components.",
5
+ "license": "MIT",
6
+ "author": "Ali Furqan (https://kodeui.com)",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/furqan4545/kodeui.git"
10
+ },
11
+ "type": "module",
12
+ "bin": {
13
+ "kodeui": "bin/kodeui.mjs"
14
+ },
15
+ "files": [
16
+ "bin",
17
+ "skill",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "engines": {
22
+ "node": ">=18"
23
+ },
24
+ "homepage": "https://kodeui.com",
25
+ "keywords": [
26
+ "claude",
27
+ "claude-code",
28
+ "skill",
29
+ "react",
30
+ "components",
31
+ "ui",
32
+ "animation",
33
+ "glow",
34
+ "nextjs"
35
+ ],
36
+ "scripts": {
37
+ "prepublishOnly": "node ../scripts/build-skill.mjs"
38
+ }
39
+ }
@@ -0,0 +1,105 @@
1
+ ---
2
+ name: kodeui
3
+ description: Install KodeUI (kodeui.com) design components into a React or Next.js app. 11 polished motion components with a dark "forest at night" look - Bloom Wall (a wall of glowing tiles that grows out of a button on hover), Ring Reveal, Glass Reveal (UI turns to frosted glass), Glow Card (spinning glowing border), Aurora Input (prompt box with a moving aurora border light), Launch Chip (animated "new feature" pill), Rolling Text, Blur-in Text, Voice Input (mic with a voice-reactive glow and voice notes), Voice Note and useLiveTranscript. Use this skill whenever the user mentions KodeUI or kodeui.com, or asks for a glowing or animated input / prompt box / chat composer, a card with a glowing or rotating gradient border, a voice or mic input that glows while you speak, an announcement or "what's new" pill, a blur-in hero headline, a frosted glass hover effect, an animated hover background, or wants their app to look like a premium AI product - even if they never say "KodeUI".
4
+ ---
5
+
6
+ # KodeUI
7
+
8
+ KodeUI is a free kit of 11 React design components. They are not an npm package: the source is
9
+ copied into the user's project (like shadcn/ui), so they own it and can change it. Every
10
+ component is one self-contained folder with its own CSS, works in React 18 and 19, is safe for
11
+ server rendering, follows `prefers-reduced-motion`, and needs no CSS framework.
12
+
13
+ The motion in these components is tuned to the millisecond (durations, easings, staggers, the
14
+ canvas maths). That tuning is the product, so copy the folders as they are and configure them
15
+ through props and CSS variables. Rewriting their internals almost always makes them feel worse.
16
+
17
+ ## The components
18
+
19
+ | Folder | Component | Use it for | Reference |
20
+ |---|---|---|---|
21
+ | `bloom-wall` | `BloomWall` | A hover effect behind a hero: glowing nature tiles grow out of a button, breathe, fold back | `references/bloom-wall.md` |
22
+ | `ring-reveal` | `RingReveal` | A dark backdrop that opens out of an element on hover (the wall without tiles) | `references/ring-reveal.md` |
23
+ | `glass-reveal` | `GlassReveal`, `Glass` | Buttons, pills and panels turn to frosted glass in 4 staggered steps | `references/glass-reveal.md` |
24
+ | `glow-card` | `GlowCard` | A card (upgrade, promo, pricing, feature) with a slow spinning four-colour border glow | `references/glow-card.md` |
25
+ | `aurora-input` | `AuroraInput` | A chat / prompt / search box whose border light moves every 3 s | `references/aurora-input.md` |
26
+ | `launch-chip` | `LaunchChip` | A "new feature" pill with a splash intro and a label that rolls to a second line | `references/launch-chip.md` |
27
+ | `rolling-text` | `RollingText` | Text that rolls up to the next line and back, width following | `references/rolling-text.md` |
28
+ | `blur-in-text` | `BlurInText` | A headline whose words arrive one by one out of a blur | `references/blur-in-text.md` |
29
+ | `voice-input` | `VoiceInput` | The Aurora Input with a mic: glow while recording, sweep while finishing, then a voice note | `references/voice-input.md` |
30
+ | `voice-note` | `VoiceNote` | A playable voice note pill (play, bars, length, Save, remove) | `references/voice-note.md` |
31
+ | `use-live-transcript` | `useLiveTranscript` | A hook: speech to text while the user talks | `references/use-live-transcript.md` |
32
+
33
+ `voice-input` needs `aurora-input`, `voice-note` and `use-live-transcript`, plus the npm package
34
+ `voice-glow`. Every other folder stands alone. Ready-made combinations (an AI hero, a chat
35
+ composer, a sidebar promo) are in `references/recipes.md`.
36
+
37
+ ## How to add components
38
+
39
+ 1. **Look at the project first.** Read `package.json` and the folder layout: the framework
40
+ (Next.js app or pages router, Vite, Remix / React Router, Astro, CRA), TypeScript or not, where
41
+ components live, the package manager (lockfile), and where the component will be used. KodeUI
42
+ needs React 18 or newer.
43
+
44
+ 2. **Pick the components.** Map the request to the table. When the user describes an effect
45
+ rather than a name ("a glowing chat box", "a pill that says what's new"), pick the closest
46
+ component and say which one you chose. If nothing fits, say so instead of stretching one.
47
+
48
+ 3. **Copy them with the script**, run from the project folder:
49
+
50
+ ```bash
51
+ node <this skill's folder>/scripts/add.mjs <names...>
52
+ ```
53
+
54
+ Names can be folders (`glow-card`), exports (`GlowCard`) or plain words (`card`, `voice`);
55
+ `node add.mjs list` prints them all. The script copies each folder and the folders it needs into
56
+ `src/components/kodeui/` (or `components/kodeui/` when there is no `src`; change it with
57
+ `--dir`), never overwrites an existing file unless you pass `--force`, adds `'use client'` to
58
+ the files that use hooks when the project is Next.js, and prints the npm packages to install,
59
+ the import lines and any framework notes. `--tokens` also copies the colour tokens file,
60
+ `--dry-run` shows what would happen. It also prints the exact import lines, through the
61
+ project's `paths` alias when `tsconfig.json` / `jsconfig.json` has one. Use the script rather
62
+ than copying by hand: it gets the dependency folders and the Next.js marks right every time.
63
+
64
+ 4. **Install what it printed** (for voice: `voice-glow`) with the project's own package manager.
65
+
66
+ 5. **Wire the component in.** Read the component's reference file before writing the code: it
67
+ has the props, a working example and the traps (for example, Bloom Wall needs a positioned
68
+ parent and a ref to its trigger). Match the project's conventions: its import alias (`@/`),
69
+ file naming, how it writes components. For framework specifics (Next.js server components,
70
+ pages-router CSS, JavaScript-only projects, Remix, Astro, Tailwind) read
71
+ `references/frameworks.md`.
72
+
73
+ 6. **Make it theirs.** Change words, sizes and colours through props and CSS variables, not by
74
+ editing the motion. Colour props exist on the card, the input, the voice glow and the wall;
75
+ the `--ku-*` variables tune the rest. `references/theming.md` shows both, including how to
76
+ match the user's brand colours.
77
+
78
+ 7. **Check it works.** Run the project's typecheck and build (or at least the typecheck), and fix
79
+ anything you introduced. If you can open the page, look at the effect; otherwise tell the user
80
+ exactly where to look and what to hover or click.
81
+
82
+ 8. **Tell the user what changed:** the folders added, the packages installed, the file where you
83
+ used each component, how to trigger the effect, and the one or two props they are most likely
84
+ to want to change.
85
+
86
+ ## Things that matter
87
+
88
+ - **Client components.** Every component with motion or state runs in the browser. In Next.js the
89
+ script marks those files with `'use client'`; a server component can still render them.
90
+ - **Positioned parents.** Bloom Wall and Ring Reveal draw a canvas that fills their nearest
91
+ positioned parent (`position: relative`), behind the content. Put them first inside that parent
92
+ and lift the content above with `position: relative; z-index: 1`.
93
+ - **Microphone and privacy.** Voice recording needs https or localhost and a click to start. The
94
+ live transcript uses the browser's speech service, which sends the audio away (Chrome to Google,
95
+ Edge to Microsoft); `transcribe={false}` keeps everything on the device. Mention this when you
96
+ add voice.
97
+ - **The host's CSS can reach inside.** A host rule made of a class plus an element, like
98
+ `.sidebar a` or `nav button`, outranks the components' one-class rules and restyles their inner
99
+ link or button (padding, radius, colour). When a component sits inside such a container, scope
100
+ the host rule (`.sidebar > a`, or `.sidebar a:not([class*="ku-"])`) and check the result.
101
+ - **No extra styling system.** Components ship plain CSS with `ku-` class names, so they sit
102
+ next to Tailwind, CSS modules or styled-components without clashes. Don't convert them to
103
+ Tailwind.
104
+ - **Dark surfaces.** The look is designed for dark backgrounds (`--ku-panel #0e1712`). On a light
105
+ page, put the component on a dark section or card, or tell the user it was made for dark UI.
@@ -0,0 +1,40 @@
1
+ /*
2
+ * KodeUI (kodeui.com) brand tokens: a forest at night.
3
+ * Dark moss surfaces, and the lights you find in nature after dark:
4
+ * fern, firefly, amber, sea glass, lagoon, coral, bloom and aurora.
5
+ * Every component reads these with a fallback, so it also works without this file.
6
+ */
7
+ :root {
8
+ /* surfaces, darkest first */
9
+ --ku-night: #060c09;
10
+ --ku-bg: #0a120e;
11
+ --ku-panel: #0e1712;
12
+ --ku-surface: #131e18;
13
+ --ku-surface-high: #192620;
14
+ --ku-surface-highest: #213029;
15
+ --ku-outline: #24342c;
16
+ --ku-outline-strong: #33463c;
17
+
18
+ /* text */
19
+ --ku-text: #e8f1eb;
20
+ --ku-text-2: #a2b6aa;
21
+ --ku-text-3: #6e8579;
22
+ --ku-link: #7fe3b0;
23
+
24
+ /* nature lights */
25
+ --ku-fern: #5ee08a;
26
+ --ku-firefly: #e6f36a;
27
+ --ku-amber: #ffc14d;
28
+ --ku-seaglass: #3cd6c4;
29
+ --ku-lagoon: #4da8ff;
30
+ --ku-coral: #ff6b6b;
31
+ --ku-bloom: #ff8fc8;
32
+ --ku-aurora: #9d8bf7;
33
+
34
+ /* type */
35
+ --ku-font: 'Inter Variable', Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
36
+ --ku-font-display: 'Fraunces Variable', Fraunces, ui-serif, Georgia, serif;
37
+
38
+ /* motion */
39
+ --ku-ease-out: cubic-bezier(.22, 1, .36, 1);
40
+ }
@@ -0,0 +1,153 @@
1
+ import {
2
+ forwardRef,
3
+ useState,
4
+ type ButtonHTMLAttributes,
5
+ type CSSProperties,
6
+ type ChangeEvent,
7
+ type KeyboardEvent,
8
+ type ReactNode,
9
+ type Ref,
10
+ type TextareaHTMLAttributes,
11
+ } from 'react';
12
+ import './aurora-input.css';
13
+
14
+ export interface AuroraInputProps {
15
+ value?: string;
16
+ defaultValue?: string;
17
+ onChange?: (value: string) => void;
18
+ placeholder?: string;
19
+ /** Enter submits, Shift+Enter is a new line. Without onSubmit, Enter is a plain new line. */
20
+ onSubmit?: (value: string) => void;
21
+ /** Buttons at the start of the action row. */
22
+ leftActions?: ReactNode;
23
+ /** Buttons at the end of the action row. */
24
+ rightActions?: ReactNode;
25
+ /** Above the textarea (a voice note goes here). */
26
+ top?: ReactNode;
27
+ /** Behind the text, over the box background (a voice glow goes here); clipped to the box. */
28
+ overlay?: ReactNode;
29
+ /** Seconds between light moves. Default 3: hold 2.2 s, move 0.8 s (the same split at any length). */
30
+ stepEvery?: number;
31
+ /** The border lights. Default sea glass, fern, aurora, bloom. Drawn at half strength like the default. */
32
+ colors?: string[];
33
+ textareaRef?: Ref<HTMLTextAreaElement>;
34
+ className?: string;
35
+ style?: CSSProperties;
36
+ disabled?: boolean;
37
+ 'aria-label'?: string;
38
+ /** Text rows before the box scrolls. Default 2. */
39
+ rows?: number;
40
+ /** Anything else for the textarea (name, id, autoFocus, onFocus...). */
41
+ textareaProps?: Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | 'defaultValue' | 'onChange' | 'placeholder' | 'disabled' | 'rows'>;
42
+ }
43
+
44
+ const REST = 'var(--ku-ai-rest)';
45
+
46
+ /**
47
+ * Conic stops for the aurora ring: the lights sit in two arcs, like the default
48
+ * (the first half between 115 and 193 degrees, the rest between 291 and 322 degrees),
49
+ * with the box colour everywhere else. The first light is drawn at 55 %, the others at 50 %.
50
+ */
51
+ export function auroraStops(colors: readonly string[]): string {
52
+ const parts = [`${REST} 0deg`, `${REST} 69deg`];
53
+ const half = Math.ceil(colors.length / 2);
54
+ const arcs: [readonly string[], number, number][] = [
55
+ [colors.slice(0, half), 115, 193],
56
+ [colors.slice(half), 291, 322],
57
+ ];
58
+ let n = 0;
59
+ arcs.forEach(([list, from, to], arc) => {
60
+ if (arc === 1) parts.push(`${REST} 270deg`);
61
+ list.forEach((c, i) => {
62
+ const deg = list.length === 1 ? (from + to) / 2 : from + ((to - from) * i) / (list.length - 1);
63
+ parts.push(`color-mix(in srgb, ${c} ${n === 0 ? 55 : 50}%, transparent) ${+deg.toFixed(3)}deg`);
64
+ n += 1;
65
+ });
66
+ });
67
+ parts.push(`${REST} 1turn`);
68
+ return parts.join(', ');
69
+ }
70
+
71
+ /**
72
+ * A prompt box with an aurora light on its 1 px border and a soft glow of it behind.
73
+ * Every few seconds the light glides a quarter turn to a new spot.
74
+ * Inside a GlassReveal it turns to frosted glass and the aurora fades away.
75
+ *
76
+ * The ref points at the outer frame; use `textareaRef` for the textarea.
77
+ */
78
+ export const AuroraInput = forwardRef<HTMLDivElement, AuroraInputProps>(function AuroraInput(props, ref) {
79
+ const {
80
+ value, defaultValue, onChange, placeholder, onSubmit, leftActions, rightActions, top, overlay,
81
+ stepEvery, colors, textareaRef, className, style, disabled, rows = 2, textareaProps,
82
+ } = props;
83
+ const label = props['aria-label'];
84
+
85
+ const [own, setOwn] = useState(defaultValue ?? '');
86
+ const controlled = value !== undefined;
87
+ const text = controlled ? value : own;
88
+
89
+ const change = (e: ChangeEvent<HTMLTextAreaElement>) => {
90
+ if (!controlled) setOwn(e.target.value);
91
+ onChange?.(e.target.value);
92
+ };
93
+ const keyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {
94
+ textareaProps?.onKeyDown?.(e);
95
+ if (e.defaultPrevented || !onSubmit) return;
96
+ if (e.key === 'Enter' && !e.shiftKey && !e.nativeEvent.isComposing) {
97
+ e.preventDefault();
98
+ onSubmit(text);
99
+ }
100
+ };
101
+
102
+ const vars: Record<string, string> = {};
103
+ if (stepEvery != null && stepEvery > 0) vars['--ku-aurora-step'] = `${stepEvery}s`;
104
+ if (colors && colors.length) vars['--ku-aurora-stops'] = auroraStops(colors);
105
+
106
+ const hasActions = leftActions != null || rightActions != null;
107
+
108
+ return (
109
+ <div
110
+ ref={ref}
111
+ className={className ? `ku-aurora-input ${className}` : 'ku-aurora-input'}
112
+ style={{ ...(vars as CSSProperties), ...style }}
113
+ >
114
+ <div className="ku-aurora-input__box">
115
+ {overlay != null && <div className="ku-aurora-input__overlay" aria-hidden="true">{overlay}</div>}
116
+ {top}
117
+ <textarea
118
+ {...textareaProps}
119
+ ref={textareaRef}
120
+ className="ku-aurora-input__field"
121
+ rows={rows}
122
+ value={text}
123
+ onChange={change}
124
+ onKeyDown={keyDown}
125
+ placeholder={placeholder}
126
+ disabled={disabled}
127
+ aria-label={label ?? textareaProps?.['aria-label'] ?? placeholder}
128
+ />
129
+ {hasActions && (
130
+ <div className="ku-aurora-input__actions">
131
+ {leftActions}
132
+ <span className="ku-aurora-input__grow" />
133
+ {rightActions}
134
+ </div>
135
+ )}
136
+ </div>
137
+ </div>
138
+ );
139
+ });
140
+
141
+ export interface AuroraInputActionProps extends ButtonHTMLAttributes<HTMLButtonElement> {
142
+ /** A 36 px round icon button with no fill, instead of a pill. */
143
+ round?: boolean;
144
+ }
145
+
146
+ /** A pill (or round icon) button styled for the action row. It turns to glass with the box. */
147
+ export const AuroraInputAction = forwardRef<HTMLButtonElement, AuroraInputActionProps>(function AuroraInputAction(
148
+ { round, className, type = 'button', ...rest },
149
+ ref,
150
+ ) {
151
+ const cls = ['ku-aurora-input__action', round && 'ku-aurora-input__action--round', className].filter(Boolean).join(' ');
152
+ return <button ref={ref} type={type} className={cls} {...rest} />;
153
+ });