Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

Commit 30839f1

Browse files
Merge pull request #447 from Kilo-Org/catrielmuller/kilo-ui-storybook
feat: add storybook for kilo-ui
2 parents e02debf + 04a6279 commit 30839f1

61 files changed

Lines changed: 5346 additions & 47 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ playground
1717
tmp
1818
dist
1919
ts-dist
20+
storybook-static
2021
.turbo
2122
**/.serena
2223
.serena/

bun.lock

Lines changed: 291 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
@font-face {
2+
font-family: "Inter";
3+
src: url("@opencode-ai/ui/fonts/inter.woff2") format("woff2-variations");
4+
font-display: swap;
5+
font-style: normal;
6+
font-weight: 100 900;
7+
}
8+
9+
@font-face {
10+
font-family: "Inter Fallback";
11+
src: local("Arial");
12+
size-adjust: 100%;
13+
ascent-override: 97%;
14+
descent-override: 25%;
15+
line-gap-override: 1%;
16+
}
17+
18+
@font-face {
19+
font-family: "IBM Plex Mono";
20+
src: url("@opencode-ai/ui/fonts/ibm-plex-mono.woff2") format("woff2");
21+
font-display: swap;
22+
font-style: normal;
23+
font-weight: 400;
24+
}
25+
26+
@font-face {
27+
font-family: "IBM Plex Mono";
28+
src: url("@opencode-ai/ui/fonts/ibm-plex-mono-medium.woff2") format("woff2");
29+
font-display: swap;
30+
font-style: normal;
31+
font-weight: 500;
32+
}
33+
34+
@font-face {
35+
font-family: "IBM Plex Mono";
36+
src: url("@opencode-ai/ui/fonts/ibm-plex-mono-bold.woff2") format("woff2");
37+
font-display: swap;
38+
font-style: normal;
39+
font-weight: 700;
40+
}
41+
42+
@font-face {
43+
font-family: "IBM Plex Mono Fallback";
44+
src: local("Courier New");
45+
size-adjust: 100%;
46+
ascent-override: 97%;
47+
descent-override: 25%;
48+
line-gap-override: 1%;
49+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type { StorybookConfig } from "storybook-solidjs-vite"
2+
import { mergeConfig } from "vite"
3+
import solidPlugin from "vite-plugin-solid"
4+
5+
const config: StorybookConfig = {
6+
framework: "storybook-solidjs-vite",
7+
stories: ["../src/**/*.stories.@(ts|tsx)"],
8+
addons: ["@storybook/addon-docs", "@storybook/addon-themes", "@storybook/addon-a11y"],
9+
refs: {},
10+
viteFinal: async (config) => {
11+
return mergeConfig(config, {
12+
plugins: [solidPlugin()],
13+
resolve: {
14+
conditions: ["browser", "solid", "module", "import"],
15+
},
16+
esbuild: {
17+
jsxImportSource: "solid-js",
18+
jsx: "automatic",
19+
},
20+
})
21+
},
22+
}
23+
24+
export default config
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<style>
2+
/* Hide Color Scheme toolbar when kilo-vscode theme is active */
3+
html[data-kilo-theme="kilo-vscode"] [aria-label^="Color Scheme"] {
4+
display: none !important;
5+
}
6+
7+
/* Hide VS Code Theme toolbar by default and when kilo theme is active */
8+
html:not([data-kilo-theme="kilo-vscode"]) [aria-label^="VSCode Theme"] {
9+
display: none !important;
10+
}
11+
</style>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { addons } from "storybook/manager-api"
2+
import { GLOBALS_UPDATED, SET_GLOBALS } from "storybook/internal/core-events"
3+
4+
addons.register("kilo-ui/toolbar-visibility", (api) => {
5+
const update = (globals: Record<string, unknown>) => {
6+
const isVscode = globals["theme"] === "kilo-vscode"
7+
document.documentElement.setAttribute("data-kilo-theme", isVscode ? "kilo-vscode" : "kilo")
8+
}
9+
10+
const channel = api.getChannel()
11+
if (!channel) return
12+
13+
channel.on(SET_GLOBALS, ({ globals }: { globals: Record<string, unknown> }) => {
14+
update(globals)
15+
})
16+
17+
channel.on(GLOBALS_UPDATED, ({ globals }: { globals: Record<string, unknown> }) => {
18+
update(globals)
19+
})
20+
})
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/** @jsxImportSource solid-js */
2+
import type { Preview, SolidRenderer } from "storybook-solidjs-vite"
3+
import type { DecoratorFunction } from "storybook/internal/types"
4+
import { applyKiloTheme, applyVscodeTheme, clearVscodeTheme } from "../src/stories/theme-decorator"
5+
import "./fonts.css"
6+
import "../src/styles/index.css"
7+
8+
const themeDecorator: DecoratorFunction<SolidRenderer> = (Story, context) => {
9+
const themeId = (context.globals["theme"] as string) ?? "kilo"
10+
const vscodeThemeId = (context.globals["vscodeTheme"] as string) ?? "dark-modern"
11+
12+
const colorScheme = (() => {
13+
if (themeId === "kilo-vscode") return applyVscodeTheme(vscodeThemeId)
14+
clearVscodeTheme()
15+
return (context.globals["colorScheme"] as "light" | "dark") ?? "dark"
16+
})()
17+
18+
applyKiloTheme(themeId, colorScheme)
19+
document.body.style.background = "var(--background-base)"
20+
document.body.style.color = "var(--text-base)"
21+
return Story()
22+
}
23+
24+
const preview: Preview = {
25+
parameters: {
26+
controls: {
27+
matchers: {
28+
color: /(background|color)$/i,
29+
date: /Date$/i,
30+
},
31+
},
32+
layout: "centered",
33+
},
34+
decorators: [themeDecorator],
35+
globalTypes: {
36+
theme: {
37+
description: "Theme",
38+
toolbar: {
39+
title: "Theme",
40+
icon: "paintbrush",
41+
items: [
42+
{ value: "kilo", title: "Kilo" },
43+
{ value: "kilo-vscode", title: "Kilo VSCode" },
44+
],
45+
dynamicTitle: true,
46+
},
47+
},
48+
colorScheme: {
49+
description: "Color Scheme",
50+
toolbar: {
51+
title: "Color Scheme",
52+
icon: "circlehollow",
53+
items: [
54+
{ value: "dark", title: "Dark", icon: "moon" },
55+
{ value: "light", title: "Light", icon: "sun" },
56+
],
57+
dynamicTitle: true,
58+
},
59+
},
60+
vscodeTheme: {
61+
description: "VSCode Theme",
62+
toolbar: {
63+
title: "VSCode Theme",
64+
icon: "browser",
65+
items: [
66+
{ value: "dark-modern", title: "Dark Modern (default)" },
67+
{ value: "dark-plus", title: "Dark+" },
68+
{ value: "dark-vs", title: "Dark (Visual Studio)" },
69+
{ value: "light-modern", title: "Light Modern" },
70+
{ value: "light-plus", title: "Light+" },
71+
{ value: "light-vs", title: "Light (Visual Studio)" },
72+
{ value: "hc-black", title: "High Contrast" },
73+
{ value: "hc-light", title: "High Contrast Light" },
74+
{ value: "monokai", title: "Monokai" },
75+
{ value: "solarized-dark", title: "Solarized Dark" },
76+
{ value: "solarized-light", title: "Solarized Light" },
77+
{ value: "red", title: "Red" },
78+
{ value: "quiet-light", title: "Quiet Light" },
79+
{ value: "tomorrow-night-blue", title: "Tomorrow Night Blue" },
80+
{ value: "kimbie-dark", title: "Kimbie Dark" },
81+
{ value: "abyss", title: "Abyss" },
82+
],
83+
dynamicTitle: true,
84+
},
85+
},
86+
},
87+
initialGlobals: {
88+
theme: "kilo",
89+
colorScheme: "dark",
90+
vscodeTheme: "dark-modern",
91+
},
92+
}
93+
94+
export default preview
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"jsx": "preserve",
5+
"jsxImportSource": "solid-js"
6+
},
7+
"include": ["./**/*", "../src/**/*"]
8+
}

packages/kilo-ui/package.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"./accordion": "./src/components/accordion.tsx",
3939
"./sticky-accordion-header": "./src/components/sticky-accordion-header.tsx",
4040
"./resize-handle": "./src/components/resize-handle.tsx",
41+
"./progress": "./src/components/progress.tsx",
4142
"./progress-circle": "./src/components/progress-circle.tsx",
4243
"./tag": "./src/components/tag.tsx",
4344
"./typewriter": "./src/components/typewriter.tsx",
@@ -80,8 +81,22 @@
8081
"solid-js": "catalog:"
8182
},
8283
"devDependencies": {
84+
"@storybook/addon-a11y": "10.2.10",
85+
"@storybook/addon-docs": "10.2.10",
86+
"@storybook/addon-themes": "10.2.10",
8387
"@tsconfig/node22": "catalog:",
8488
"@types/bun": "catalog:",
85-
"typescript": "catalog:"
89+
"storybook": "10.2.10",
90+
"storybook-solidjs-vite": "10.0.9",
91+
"typescript": "catalog:",
92+
"vite": "7.3.1",
93+
"vite-plugin-solid": "2.11.10"
94+
},
95+
"scripts": {
96+
"storybook": "storybook dev -p 6006",
97+
"build-storybook": "storybook build"
98+
},
99+
"dependencies": {
100+
"@kobalte/core": "0.13.11"
86101
}
87102
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "@opencode-ai/ui/progress"

0 commit comments

Comments
 (0)