feat: add CodeEditor component#780
Conversation
|
/barista review |
|
Concerns — solid component; two things to look at before merge. The editor itself is well done — reuses
Nits:
|
Replace the tests/ subfolder with a colocated CodeEditor.cy.ts covering the editor's real behaviour (blur-commit change vs live update, Esc tab-trap exit, prop diff-sync, readonly/variant/size swaps, labeling ARIA, overflow emit) and move the CodePreview sanitization cases to a sibling CodePreview.test.ts.
- Reuse the shared InputVariant union (via Exclude<…, 'ghost'>) instead of
redeclaring it, so the code field can't drift from the inputs beside it.
- Drop the ghost variant: a borderless code surface reads as plain text and
loses the affordance that it's an editable field. Removed from the type, the
theme fragment, the variants story, the playground knob, and the docs.
- Type language as CodeLanguage | (string & {}) to keep autocomplete while
still allowing arbitrary keys.
- Extract the ~200 lines of theme + highlightStyle literals into a sibling
theme.ts (taking the lazy-imported CodeMirror modules as params so the
static graph stays editor-free).
Drop the maxHeight style-injection prop (no precedent in the library and at odds with P10's styling-via-CSS rule). The cap is now set by the consumer through the --cm-max-height custom property on the root, which cascades into CodeMirror and the base theme already reads. Add the data-slot="control" styling hook the component was missing. The overflow emit stays: the cap crossing needs the ResizeObserver to measure, so a consumer can't derive it from CSS.
|
/barista review |
|
Re-reviewing per @shariquerik — checked whether the prior concerns were addressed. Looks good — all three points from the last pass are resolved.
Nice direction: the old One thing worth a glance, not blocking: |
Use the canonical `disabled` state prop (P4) to match TextInput/Textarea instead of the non-standard `readonly`. Disabled now also greys the surface (flat gray box, no hover/focus chrome, dimmed content) so the field reads as inert like the other inputs, not just blocks editing.
|
/barista review |
|
Re-reviewing per @shariquerik — third pass, no new concerns. Looks good — stable since the last pass; everything still holds and the surface got tighter.
CI all green (Cypress 1-3, build, coverage, test). Nothing blocking. |
Coverage: 56.68% (+0.15% vs
main)