Skip to content

Commit 5d4aff9

Browse files
refactor: address comments.
1 parent 2b4605f commit 5d4aff9

6 files changed

Lines changed: 49 additions & 34 deletions

File tree

docs/next-steps.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,8 @@ Focused follow-up work for `@knighted/develop`.
2626
6. **Panel sizing without JS height sync**
2727
- Revisit the current side-layout preview height calculation and investigate a pure CSS replacement.
2828
- Keep existing behavior constraints: preview should not exceed the combined editor stack height in side layouts, and preview content should scroll internally when it overflows.
29+
30+
7. **CDN failure recovery UX**
31+
- Detect transient CDN/module loading failures and surface a clear recovery action in-app.
32+
- Add a user-triggered retry path (for example, Reload page / Force reload) when runtime bootstrap imports fail.
33+
- Consider an optional automatic one-time retry before showing recovery controls, while avoiding infinite reload loops.

eslint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ export default [
2020
sourceType: 'module',
2121
ecmaVersion: 'latest',
2222
},
23+
rules: {
24+
'no-unused-vars': 'error',
25+
},
2326
},
2427
{
2528
...playwrightConfig,

playwright/app.spec.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,6 @@ const setStylesEditorSource = async (page: Page, source: string) => {
2929
await editorContent.fill(source)
3030
}
3131

32-
const getLongListComponentSource = (count = 1200) =>
33-
[
34-
'const App = () => {',
35-
` const items = Array.from({ length: ${count} }, (_, index) => ({`,
36-
' id: index + 1,',
37-
' title: `List item ${index + 1}`',
38-
' }))',
39-
'',
40-
' return (',
41-
" <section style={{ padding: '12px', fontFamily: 'system-ui, sans-serif' }}>",
42-
" <h2 style={{ margin: '0 0 12px', fontSize: '1rem' }}>Long Preview List</h2>",
43-
" <ul style={{ margin: 0, paddingLeft: '1.25rem' }}>",
44-
' {items.map(item => (',
45-
" <li key={item.id} style={{ marginBottom: '8px' }}>",
46-
' <strong>{item.title}</strong>',
47-
' </li>',
48-
' ))}',
49-
' </ul>',
50-
' </section>',
51-
' )',
52-
'}',
53-
].join('\n')
54-
5532
const getCollapseButton = (page: Page, panelName: 'component' | 'styles' | 'preview') =>
5633
page.locator(`#collapse-${panelName}`)
5734

src/app.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ const panelMap = {
8282
preview: previewPanel,
8383
}
8484

85+
const compactViewportMediaQuery = window.matchMedia('(max-width: 900px)')
86+
8587
const getCurrentLayout = () => {
8688
if (appGrid.classList.contains('app-grid--preview-right')) {
8789
return 'preview-right'
@@ -94,7 +96,7 @@ const getCurrentLayout = () => {
9496
return 'default'
9597
}
9698

97-
const isCompactViewport = () => window.matchMedia('(max-width: 900px)').matches
99+
const isCompactViewport = () => compactViewportMediaQuery.matches
98100

99101
const getPanelCollapseAxis = panelName => {
100102
if (isCompactViewport()) {
@@ -680,9 +682,15 @@ for (const button of panelCollapseButtons) {
680682
})
681683
}
682684

683-
window.addEventListener('resize', () => {
685+
const handleCompactViewportChange = () => {
684686
applyPanelCollapseState()
685-
})
687+
}
688+
689+
if (typeof compactViewportMediaQuery.addEventListener === 'function') {
690+
compactViewportMediaQuery.addEventListener('change', handleCompactViewportChange)
691+
} else {
692+
compactViewportMediaQuery.onchange = handleCompactViewportChange
693+
}
686694

687695
if (typeof ResizeObserver !== 'undefined' && editorsStack) {
688696
const sidePreviewHeightObserver = new ResizeObserver(() => {

src/index.html

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ <h2>Component</h2>
142142
data-collapse-axis="vertical"
143143
data-collapsed="false"
144144
aria-expanded="true"
145-
aria-controls="component-panel"
145+
aria-controls="component-panel-content"
146+
aria-label="Collapse component panel"
146147
title="Collapse component panel"
147148
>
148149
<svg viewBox="0 0 24 24" aria-hidden="true">
@@ -202,7 +203,9 @@ <h2>Component</h2>
202203
</div>
203204
</div>
204205
</div>
205-
<textarea id="jsx-editor" spellcheck="false"></textarea>
206+
<div class="panel-content" id="component-panel-content">
207+
<textarea id="jsx-editor" spellcheck="false"></textarea>
208+
</div>
206209
</section>
207210

208211
<section class="panel styles-panel" id="styles-panel">
@@ -217,7 +220,8 @@ <h2>Styles</h2>
217220
data-collapse-axis="vertical"
218221
data-collapsed="false"
219222
aria-expanded="true"
220-
aria-controls="styles-panel"
223+
aria-controls="styles-panel-content"
224+
aria-label="Collapse styles panel"
221225
title="Collapse styles panel"
222226
>
223227
<svg viewBox="0 0 24 24" aria-hidden="true">
@@ -269,8 +273,10 @@ <h2>Styles</h2>
269273
</div>
270274
</div>
271275
</div>
272-
<textarea id="css-editor" spellcheck="false"></textarea>
273-
<div class="panel-footer" id="style-warning"></div>
276+
<div class="panel-content" id="styles-panel-content">
277+
<textarea id="css-editor" spellcheck="false"></textarea>
278+
<div class="panel-footer" id="style-warning"></div>
279+
</div>
274280
</section>
275281
</div>
276282

@@ -302,7 +308,8 @@ <h2>Preview</h2>
302308
data-collapse-axis="vertical"
303309
data-collapsed="false"
304310
aria-expanded="true"
305-
aria-controls="preview-panel"
311+
aria-controls="preview-panel-content"
312+
aria-label="Collapse preview panel"
306313
title="Collapse preview panel"
307314
>
308315
<svg viewBox="0 0 24 24" aria-hidden="true">
@@ -312,7 +319,9 @@ <h2>Preview</h2>
312319
</button>
313320
</div>
314321
</div>
315-
<div class="preview-host" id="preview-host"></div>
322+
<div class="panel-content" id="preview-panel-content">
323+
<div class="preview-host" id="preview-host"></div>
324+
</div>
316325
</section>
317326

318327
<aside class="diagnostics-drawer" id="diagnostics-drawer" hidden>

src/styles/panels-editor.css

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,13 @@ textarea:focus {
214214
overflow: auto;
215215
}
216216

217+
.panel-content {
218+
flex: 1;
219+
min-height: 0;
220+
display: flex;
221+
flex-direction: column;
222+
}
223+
217224
.panel.panel--collapsed-vertical {
218225
min-height: auto;
219226
}
@@ -232,7 +239,10 @@ textarea:focus {
232239
.styles-panel.panel--collapsed-vertical .editor-host,
233240
.styles-panel.panel--collapsed-vertical textarea,
234241
.styles-panel.panel--collapsed-vertical .panel-footer,
235-
.preview-panel.panel--collapsed-vertical .preview-host {
242+
.preview-panel.panel--collapsed-vertical .preview-host,
243+
.component-panel.panel--collapsed-vertical .panel-content,
244+
.styles-panel.panel--collapsed-vertical .panel-content,
245+
.preview-panel.panel--collapsed-vertical .panel-content {
236246
display: none;
237247
}
238248

@@ -262,6 +272,7 @@ textarea:focus {
262272
}
263273

264274
.preview-panel.panel--collapsed-horizontal .preview-host,
275+
.preview-panel.panel--collapsed-horizontal .panel-content,
265276
.preview-panel.panel--collapsed-horizontal .controls label,
266277
.preview-panel.panel--collapsed-horizontal .controls .hint-icon {
267278
display: none;
@@ -303,10 +314,12 @@ textarea:focus {
303314

304315
.component-panel.panel--collapsed-horizontal .editor-host,
305316
.component-panel.panel--collapsed-horizontal textarea,
317+
.component-panel.panel--collapsed-horizontal .panel-content,
306318
.component-panel.panel--collapsed-horizontal .panel-header-main-actions,
307319
.component-panel.panel--collapsed-horizontal .panel-header .icon-button,
308320
.styles-panel.panel--collapsed-horizontal .editor-host,
309321
.styles-panel.panel--collapsed-horizontal textarea,
322+
.styles-panel.panel--collapsed-horizontal .panel-content,
310323
.styles-panel.panel--collapsed-horizontal .panel-header-main-actions,
311324
.styles-panel.panel--collapsed-horizontal .panel-header .icon-button,
312325
.styles-panel.panel--collapsed-horizontal .panel-footer {

0 commit comments

Comments
 (0)