By the time ew-solid-ui reached 0.0.9 it had docs, examples, and a green test suite, which sounds reassuring until you remember what those things actually prove. A button on its own page. A modal on another page. A select on a third. Everything evenly spaced, everything well behaved. Of course nothing breaks.
Storybook is not where a component library gets tested. A real product is: a select inside a modal, a button hanging off the right edge of an input, streamed text arriving every few dozen milliseconds, the theme flipping, a phone keyboard eating half the viewport. That's the exam.
So I went looking for a real project to throw at it. Another admin dashboard was pointless — those pages are mostly tables, and tables don't stress anything. In the end I picked DeepSeek's chat demo.
The reasoning was practical. It's dense enough to hit nearly every weak spot a component library has, and it comes with a finished design, so spacing, radii, and colors are already decided. I wouldn't waste time second-guessing visuals; all of it could go into one question.
| What I wanted to test | Where the demo exercises it |
|---|---|
| Can CSS variables absorb an entire external theme? | The official --dsw-* token set, plus light/dark switching |
| Do nested overlays fight each other? | A select for language, voice, and region inside the settings modal |
| Can a composer be reshaped by the business layer? | Attachment strip, toggle row, recording spectrum, drag overlay |
| Does it survive high-frequency streaming updates? | Token-level Markdown with math and Mermaid inside |
| Does mobile fall apart? | visualViewport , keyboard insets, safe areas |
That's how this project started. The short version of how it ended: the library held up, but a few things only showed themselves in a page like this. What follows is the order I hit them, including how each one was found.
Two live URLs: ds-chat.eveningwater.com, or the GitHub Pages build. You paste a DeepSeek API key into settings first. The browser calls https://api.deepseek.com directly; there's no server of mine in the middle.
Feature-wise I copied the official demo: streaming replies, deep thinking, web search, continue, regenerate, edit prompt; message branches with version switching; Markdown, code blocks, math, Mermaid, citation chips; image and document attachments with drag, paste, and retry; voice input and read-aloud; session list with rename, delete, and ZIP import/export; light and dark themes, Chinese and English, mobile safe areas.
The stack is nothing to show off:
| Concern | Choice |
|---|---|
| Build / language | Vite 6 + TypeScript 5.7 |
| Framework | SolidJS 1.9 (fine-grained reactivity, no virtual DOM) |
| Component library | ew-solid-ui 0.0.10 |
| State | createMemoryStore fromew-solid-ui/headless |
| Storage | IndexedDB (sessions/attachments) + localStorage (settings) |
| Content rendering | ew-solid-ui Markdown + KaTeX + Mermaid + Prism |
idb, fflate, KaTeX, Mermaid, and Prism are just tools. They have nothing to do with whether I use the component library, so they went in where needed. No zustand for state, no second UI library. That's the whole dependency story.
src/
├── app/ page shell: App, theme, viewport, global styles
├── components/
│ ├── chatInput/ input, draft attachments, voice, spectrum, drag overlay
│ ├── files/ file icons, file cards, preview hook
│ ├── markdown/ Markdown adapter, code block, math, Mermaid, links
│ ├── messages/ message list, user/assistant messages, thinking and search steps
│ ├── search/ search results panel, source cards, citation chips
│ ├── session/ welcome page, session page, mobile top bar
│ ├── settings/ settings modal, API Key form
│ └── sider/ sidebar, session item, mobile drawer
├── i18n/ Chinese and English copy
├── services/ api / chat / markdown / speech, settings and attachments
└── utils/
Only one rule matters: anything generic comes from the library; anything that only exists because this is a chat app I write myself.
Generic: Button, Icon (the multi-color drag-and-drop illustration is upload-picture from the library), Tooltip, Dropdown, Modal, Select, the various fields, Popover, Welcome, Markdown, Toast, plus headless useCopy and createMemoryStore. Specific: the composer, message timeline, attachment cards, citation preprocessing, SSE, persistence, recording.
Keep that line and you never end up cramming chat logic into a generic component just to prove you used the dependency.
Rendering isn't the hard part of a chat page. State is. Streaming output, upload progress, the session list, and the settings panel all change independently, and one sloppy move re-renders the world.
createMemoryStore in ew-solid-ui/headless covered it, so zustand never got installed:
import { createMemoryStore } from 'ew-solid-ui/headless'
export const useChatStore = createMemoryStore<ChatState>({
ready: false,
sessions: [],
activeId: null,
streaming: {},
})
It keeps zustand's getState / setState and adds replaceState. Three things mattered in practice.
Reading state.xxx subscribes you automatically, and only top-level fields are tracked. Importing history flips importingHistory, and the sidebar — which only reads sessions — doesn't flinch. That's nice. setState is a shallow merge and an empty patch notifies nobody, so nested objects have to be replaced wholesale. I didn't believe that at first and mutated streaming[id].status in place. The page didn't move. I stared at it for a while before remembering how shallow merge works. And getState() gives you a plain snapshot, so it can go straight into IndexedDB or JSON.stringify without proxy-clone surprises.
useChatStore, useSettings, useUploads, useReadAloud, useSearchPanel, useMobileSider, and useSettingsDialog are all built on it.
| Component | Where |
|---|---|
Button |
Sidebar, settings, message actions, modal footers |
Icon |
Everywhere |
Tooltip |
Composer toggles, voice, retry, sidebar collapse |
Dropdown |
The "more" menu on a session |
Modal |
Settings, delete confirmation, import confirmation |
Select |
Language, voice, region, province, city |
InputField |
Session rename |
PasswordField |
API Key input |
TextareaField |
Editing a prompt, and the composer body |
Welcome |
New-conversation screen |
Markdown |
Message body |
Popover |
Source card behind a citation chip |
Toasts +toast |
Global notifications |
useCopy |
Copy buttons, code blocks |
createMemoryStore |
All shared state |
Everything comes from the package root except the headless pieces, which live under /headless:
import {
Button, Icon, Tooltip, Dropdown, Modal, Select,
InputField, PasswordField, TextareaField,
Welcome, Popover, Toasts, toast,
} from 'ew-solid-ui'
import { createMemoryStore, useCopy } from 'ew-solid-ui/headless'
Toasts is mounted once in main.tsx. Business code only ever calls toast.error(...); the container and animations are none of its business.
Symptom: the send button was brown. The demo's is blue. Nothing I did turned it blue. Time to look.
First suspicion, obviously, was that --ew-accent wasn't taking effect. DevTools said the value was exactly what I wrote. The button stayed brown. So I went digging through the stylesheet and found a second layer, --ewcp-*, already declared on :root:
:root {
--ewcp-color-primary: var(--ew-accent);
}
That's when it clicked. A custom property is resolved on the element where it is declared, not where you override it. :root is evaluated before body, so it picked up the library's default brown and inherited it down to everything. My blue --ew-accent on body was invisible to it.
The fix is unglamorous — re-point that layer on body too:
body {
--ewcp-color-primary: var(--ew-accent);
--ewcp-color-primary-hover: var(--ew-accent-strong);
--ewcp-color-text: var(--ew-ink);
--ewcp-color-border: var(--ew-line-strong);
--ewcp-color-bg: var(--ew-card);
--ewcp-radius-sm: var(--ew-radius-sm);
}
Save. Blue. That's it? Yes, that's it — and I spent a good half hour doubting my CSS skills first.
The theme mapping itself lives at the end of src/app/theme.css, --dsw-* onto --ew-*:
body {
--ew-accent: var(--dsw-alias-brand-primary);
--ew-card: var(--dsw-alias-bg-base);
--ew-ink: var(--dsw-alias-label-primary);
--ew-ink-soft: var(--dsw-alias-label-secondary);
--ew-muted: var(--dsw-alias-label-tertiary);
--ew-line: var(--dsw-alias-border-l2);
--ew-line-strong: var(--dsw-alias-border-l3);
--ew-fill: var(--dsw-alias-interactive-bg-hover);
}
Flip body.light / body.dark and buttons, inputs, modals, and dropdowns follow. No duplicate styles per component.
In main.tsx, styles have to be imported before the business components:
import { render } from 'solid-js/web'
import { Toasts } from 'ew-solid-ui'
import 'ew-solid-ui/styles.css'
import './app/theme.css'
import './app/global.css'
import { App } from './app/App'
render(() => (<><App /><Toasts /></>), document.getElementById('root') as HTMLElement)
Vite injects CSS in module evaluation order. Put import { App } first and the CSS Modules load first; the library's stylesheet arrives afterwards and quietly overwrites them.
What makes this one nasty: your rule is in the file, DevTools shows it, and it does nothing. Send button height, settings dialog width, theme card radius — each broke this way at some point. I now check main.tsx import order before touching styles, which saves me from doubting my own sanity.
The overrides themselves aren't clever. Layout lives under my own class names; component internals get precise :global(.ew-*) edits; nothing gets copied wholesale.
.apiKeyInput :global(.ew-field__control),
.apiKeyInput :global(.ew-field__control:focus-within) {
height: 100%;
border: none;
background: transparent;
box-shadow: none;
}
Sometimes specificity has to be doubled. .sendButton alone loses to .ewcp-button--small, so the send button uses .sendButton.sendButton. It's ugly. It works.
The welcome screen uses Welcome as a container, title from props, composer in extra, with the library's icon and description hidden:
<WelcomeArea
class={styles.welcome}
title={t('welcomeMessageChat250808')}
extra={<ChatInput sessionId={null} />}
/>
The settings dialog lets Modal own the portal, backdrop, Esc, and focus, while navigation and content stay mine. The library defaults to max-width: 520px and the demo is 760×500, so the business class overrides it — no forking the component:
.dialog {
width: 760px;
height: 500px;
max-width: calc(100vw - 32px);
padding: 19px 24px 22px;
}
The API key input puts the confirm button in PasswordField's suffix slot:
<PasswordField
value={form.value()}
suffix={
<Show when={value.trim()}>
<span class={styles.divider} />
<Button variant="link" onClick={submit}>OK</Button>
</Show>
}
/>
Cheaper than wrapping an input and a button in a div, and the focus ring, disabled state, and password visibility are already handled.
Copying uses useCopy instead of a hand-rolled clipboard fallback:
const { copied, copy } = useCopy({ duration: 1000 })
if (!(await copy(text))) {
showToast({ key: 'copyFailed' })
}
The icon flips between copy and check on copied(), and failures go through a toast.
Sender
There's a ready-made Sender that covers an entire chat input and should, in theory, drop right in. The demo's composer is too weird for it: attachment strip, toggle row, recording spectrum, drag overlay, per-file upload state, all inside one rounded box. Sender's slots can't hold that, and fighting it would have cost more than building it.
So only TextareaField got used, for the body. It fits: autoResize with minRows / maxRows replaces the mirror-div height measurement, and value / onInput / onKeyDown are properly controlled.
The one annoyance is that it doesn't expose the textarea ref. Voice transcription inserts at the caret, desktop needs autofocus, and paste needs to read files — all three need the native element. So I ended up with querySelector('textarea') on the container, used in exactly those three places and nowhere else. It works. It isn't clean, and I'll come back to it.
The call chain isn't long:
ChatInput.send()
→ chat/store.sendMessage()
→ services/api/client (POST /anthropic/v1/messages)
→ services/api/sse (byte stream → text → SSE events)
→ services/api/parseEvent (thinking / text / tool_use / usage)
→ chat/store updates sessionCache
→ MessageList / ReplyArea / Markdown update automatically
The SSE parser is written by hand against the WHATWG spec: incremental UTF-8 decoding, CRLF/LF/CR line splitting, accumulating event / data / id, dispatching on a blank line, ignoring keep-alive comments. I couldn't just grab a library, because fetch hands you a ReadableStream and a lot of SSE packages only speak EventSource.
The store holds little: sessions (summaries), sessionCache (the active conversation's full messages), streaming (which sessions are mid-stream), two error fields for persistence failures, and importingHistory to lock the composer during import.
Assistant messages aren't rendered raw. They go through buildReplyView first: thinking blocks, tool calls, and search results become timeline steps; text blocks get merged; citation sources (Source[]) and search panel data are computed; error, stopped, and safety-refusal states are normalized.
useReplyView reuses the previous sources array when the content hasn't changed. Otherwise every streamed token creates a new array reference and forces Markdown to re-parse. Pure waste.
The chain:
streamed text
→ useThrottleMarkdownRender (throttle derived from the last render's cost)
→ preprocessMarkdown (only [citation:N] and <br>)
→ ew-solid-ui Markdown (marked lexer + Solid renderer)
→ components (CodeBlock / MathBlock / InlineMath / CitationLink)
Preprocessing does two things, and it skips fenced and inline code so sample snippets don't get mangled.
Math was a detour. I wrote my own $...$ extraction first, then discovered the library's Markdown already handles $...$, $$...$$, \(...\), and \[...\], calling back through mathInline / mathBlock. The business side only has to run KaTeX. So my preprocessing was pointless. Deleted. Time spent for nothing.
Citations work the same way: [citation:N] becomes [N], the citation hook receives the index and looks up the source, and nothing renders when there isn't one. The library's citation detection skips [N](url), so ordinary links survive.
Tables, lists, headings, paragraphs, code blocks, inline code, and images are all handled by the library's lexer and renderer. I only replace nodes that need customizing, through components.
Streaming states get their own handling: an unclosed formula keeps the last successful render, Mermaid draws only complete lines and defers errors until the stream ends, Prism language packs load on demand with a plain-text fallback. Copy and the Mermaid/code toggle use Button + Icon + useCopy.
Attachments sit in two layers. Draft files live in draftMap so the composer can show upload progress inline; after sending they're written to IndexedDB and the message keeps only a file ID.
The upload state machine is in services/attachments.ts: queued → up → done, with error splitting into retryable and terminal. Previews come from useFileView, which reads a Blob from the File or IndexedDB and builds a blob: URL; SVG goes through a data URL to stay isolated. Cards, thumbnails, retry, delete — all business components, with library buttons and icons inside.
Voice records with MediaRecorder next to an AudioContext and AnalyserNode. The spectrum reads frequency data every frame, maps it onto logarithmic bands, and writes transform directly instead of going through reactivity. Why? Sixty re-renders per second would hurt even Solid. The clip then goes to the server for transcription and the text lands at the caret. Read-aloud is centralized in services/speech/readAloud.ts and stops when the message changes.
Persistence is ordinary: settings in localStorage, sessions and attachments in IndexedDB, export as session JSON plus attachments in a ZIP. Import understands DeepSeek's export format and overwrites local sessions, hence the confirmation and progress. Import also locks the composer and cancels speech; otherwise the two flows race for state and strange things happen.
One note on mobile: the sidebar is a drawer, fixed on desktop; the settings dialog becomes a bottom sheet on phones. useIsMobile is just matchMedia('not all and (min-width: 768px)'), useMobileViewport follows visualViewport so the top bar and composer stay visible when the keyboard opens, and usePreventPageScroll kills whole-page scrolling while preserving inner scroll areas and pinch zoom. Without that the page feels bolted shut.
Streaming Markdown is throttled against the previous render's cost rather than a fixed interval. A fixed interval is either laggy or wasteful; the adaptive version made long answers visibly smoother.
The message list follows the bottom only within 40px, and stops as soon as you scroll up on purpose. After switching branches, scroll position is restored relative to the version selector, so answers of different lengths don't make the page jump. That one was annoying enough to fix properly.
Prism, Mermaid, and KaTeX all load lazily. On the library side I import only what's used and let Vite tree-shake the rest.
Finding problems was the point, so this section is more useful than everything above it.
TextareaField doesn't expose a ref
So I querySelector('textarea'). That's my implementation flaw and the library's design flaw. A component should hand out its native element or a ref; business code shouldn't reverse-engineer DOM structure. Easy to fix, and it's on the next version's list.
--ewcp-* resolves on :root
That's a variable-layering limitation. If the internal layer inherited, or were declared with :where(), one override on the business side would be enough, and "why is the button brown" would never become an incident.
:global(.ew-*) works, but it's dirty. It asks the consumer to remember things like .ew-field__control, and a rename inside the library breaks it. More semantic slots and more CSS variables would beat making people guess at internals.
It went unused here, which says enough. Real chat inputs grow an attachment strip and a status row, and two slots named header and footer genuinely can't absorb that.
All four are on my todo list, and I'll pick them off in the next release.
While I was writing this up, the library published 0.0.10 and fixed one of the items on my list: in standalone mode, Spin dropped the class prop, applying it only on the wrapper branch. The casualty was the streaming waiting state, which was three spans and twenty lines of hand-written CSS.
After the fix, one line does it:
<Show when={waiting()}>
<Spin variant="dots" class={styles.waiting} />
</Show>
What's left in CSS is two layers: the outer class restores the demo's size, gap, and color, and the inner rule replaces the library's bounce with the demo's opacity fade. Three spans and .waitingDot are gone, the animation is unchanged, and there's less code.
The same release made the CodeBlock highlighter pluggable, so createPrismHighlighter(Prism) can wire Prism straight in. I didn't switch, because highlighting is synchronous and can't wait for a lazily imported language pack, and there's still no header slot for the Mermaid diagram/code toggle. Neither is a styling problem, so the custom code block stays.
One observation worth keeping: a verification project that pushes fixes back into the library is worth more than ten Storybook stories.
pnpm install
pnpm dev # http://localhost:8090
pnpm typecheck
pnpm build
You need a DeepSeek API key in settings on first launch. The endpoint comes from __API_ORIGIN__ in vite.config.ts, defaulting to https://api.deepseek.com; change that one line if you want a proxy.
The value of this project isn't how faithfully it copies DeepSeek. It's that it proves something concrete: a Solid app with no React, no zustand, and every piece of UI coming from a self-maintained component library can carry a page with this much interaction density.
It also put the library's weak spots under a lamp — variable layering, ref passthrough, slot design. None of that shows up in Storybook. It only surfaces after a week of being dragged through real work.
One-line summary: a component library isn't good because it looks good in a demo; it's good if it's still standing after the business is done with it.
That's it from me. Go poke at the demo if you feel like it, and open an issue if something's off.