Skip to content

Commit ed9e9ad

Browse files
fix: inheritable properties leaking in. (#6)
1 parent b7152c6 commit ed9e9ad

3 files changed

Lines changed: 43 additions & 22 deletions

File tree

docs/next-steps.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,15 @@ Focused follow-up work for `@knighted/develop`.
99
2. **Preview UX polish**
1010
- Keep tooltip affordances for mode-specific behavior.
1111
- Continue tightening panel control alignment and spacing without introducing extra markup.
12+
13+
3. **In-browser component/style linting**
14+
- Explore running lint checks for component and style sources directly in the playground.
15+
- Prefer CDN-delivered tooling where possible and preserve graceful fallback behavior when unavailable.
16+
17+
4. **In-browser component type checking**
18+
- Explore TypeScript/JSX type checking for component source in-browser using CDN-delivered tooling.
19+
- Keep diagnostics responsive and surface clear inline/editor feedback without blocking the preview loop.
20+
21+
5. **In-browser component testing**
22+
- Explore authoring and running component-focused tests in-browser (for example, a Vitest-compatible flow) using CDN-delivered tooling.
23+
- Define a lightweight test UX that supports writing tests, running them on demand, and displaying results in-app.

src/app.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,13 +455,29 @@ const updateStyleWarning = () => {
455455
styleWarning.textContent = `${styleLabels[mode]} is compiled in-browser via @knighted/css/browser.`
456456
}
457457

458+
const shadowPreviewBaseStyles = `
459+
:host {
460+
all: initial;
461+
display: var(--preview-host-display, block);
462+
flex: var(--preview-host-flex, 1 1 auto);
463+
min-height: var(--preview-host-min-height, 180px);
464+
padding: var(--preview-host-padding, 18px);
465+
overflow: var(--preview-host-overflow, auto);
466+
position: var(--preview-host-position, relative);
467+
background: var(--surface-preview);
468+
color-scheme: var(--control-color-scheme, dark);
469+
z-index: var(--preview-host-z-index, 1);
470+
box-sizing: border-box;
471+
}
472+
`
473+
458474
const applyStyles = (target, cssText) => {
459475
if (!target) return
460476

461477
const styleTag = document.createElement('style')
462478
const isShadowTarget = target instanceof ShadowRoot
463479
styleTag.textContent = isShadowTarget
464-
? cssText
480+
? `${shadowPreviewBaseStyles}\n${cssText}`
465481
: `@scope (#preview-host) {\n${cssText}\n}`
466482
target.append(styleTag)
467483
}

src/styles.css

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -510,13 +510,21 @@ textarea:focus {
510510
}
511511

512512
.preview-host {
513-
flex: 1 1 auto;
514-
min-height: 180px;
515-
padding: 18px;
516-
overflow: auto;
517-
position: relative;
513+
--preview-host-display: block;
514+
--preview-host-flex: 1 1 auto;
515+
--preview-host-min-height: 180px;
516+
--preview-host-padding: 18px;
517+
--preview-host-overflow: auto;
518+
--preview-host-position: relative;
519+
--preview-host-z-index: 1;
520+
display: var(--preview-host-display);
521+
flex: var(--preview-host-flex);
522+
min-height: var(--preview-host-min-height);
523+
padding: var(--preview-host-padding);
524+
overflow: var(--preview-host-overflow);
525+
position: var(--preview-host-position);
518526
background: var(--surface-preview);
519-
z-index: 1;
527+
z-index: var(--preview-host-z-index);
520528
}
521529

522530
.preview-host[data-style-compiling='true']::before {
@@ -613,7 +621,6 @@ textarea:focus {
613621
padding: 0;
614622
}
615623

616-
.shadow-hint::before,
617624
.shadow-hint::after {
618625
opacity: 0;
619626
visibility: hidden;
@@ -624,18 +631,6 @@ textarea:focus {
624631
visibility 120ms ease;
625632
}
626633

627-
.shadow-hint::before {
628-
content: '';
629-
position: absolute;
630-
top: calc(100% + 4px);
631-
right: 4px;
632-
border-left: 6px solid transparent;
633-
border-right: 6px solid transparent;
634-
border-bottom: 6px solid var(--surface-tooltip);
635-
transform: translateY(-4px);
636-
z-index: 31;
637-
}
638-
639634
.shadow-hint::after {
640635
content: attr(data-tooltip);
641636
position: absolute;
@@ -656,9 +651,7 @@ textarea:focus {
656651
z-index: 30;
657652
}
658653

659-
.shadow-hint:hover::before,
660654
.shadow-hint:hover::after,
661-
.shadow-hint:focus-visible::before,
662655
.shadow-hint:focus-visible::after {
663656
opacity: 1;
664657
visibility: visible;

0 commit comments

Comments
 (0)