Skip to content

Commit f51818a

Browse files
author
IA Jim
committed
CR suggestion fixes
- base tag name on file name - click listener cleanup - adds semantic 'expanded' class string - console warns on clipboard failures
1 parent 3ba002f commit f51818a

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

demo/app-root.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,22 @@ const storyEntries = Object.keys(storyModules)
1313
.map(path => {
1414
const labs = path.includes('/src/labs/');
1515
const parts = path.split('/');
16-
const tag = parts[parts.length - 2];
16+
const filename = parts[parts.length - 1]; // e.g. "ia-button-story.ts"
17+
const tag = filename.replace(/-story\.ts$/, '');
1718
return { tag, storyTag: `${tag}-story`, id: `elem-${tag}`, labs };
1819
})
1920
.sort((a, b) => a.tag.localeCompare(b.tag));
2021

2122
const productionEntries = storyEntries.filter(e => !e.labs);
22-
const labsEntries = storyEntries.filter(e => e.labs);
23-
const ALL_ENTRIES = [...productionEntries, ...labsEntries];
23+
const labsEntries = storyEntries.filter(e => e.labs);
24+
const ALL_ENTRIES = [...productionEntries, ...labsEntries];
2425

2526
@customElement('app-root')
2627
export class AppRoot extends LitElement {
2728
createRenderRoot() { return this; }
2829

2930
private _observer?: IntersectionObserver;
31+
private _abortController = new AbortController();
3032

3133
render() {
3234
return html`
@@ -90,12 +92,13 @@ export class AppRoot extends LitElement {
9092
const top = el.getBoundingClientRect().top + window.scrollY;
9193
window.scrollTo({ top: Math.max(0, top - 16), behavior: 'smooth' });
9294
}
93-
});
95+
}, { signal: this._abortController.signal });
9496
});
9597
}
9698

9799
disconnectedCallback() {
98100
super.disconnectedCallback();
99101
this._observer?.disconnect();
102+
this._abortController.abort();
100103
}
101104
}

demo/index.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ app-root {
8585
#ia-content {
8686
flex: 1;
8787
padding: 0.75rem 1rem;
88-
padding-bottom: 100vh;
88+
padding-bottom: 100vh; /* lets scroll-spy activate on the last element */
8989
min-width: 0;
9090
}
9191

demo/story-template.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ export class StoryTemplate extends LitElement {
7979
></slot>
8080
</div>
8181
<button
82-
class="details-toggle ${this.detailsVisible ? '' : 'collapsed'}"
82+
class="details-toggle ${this.detailsVisible ? 'expanded' : 'collapsed'}"
8383
@click=${() => (this.detailsVisible = !this.detailsVisible)}
8484
>
8585
Import, Usage &amp; Settings
8686
</button>
87-
<div id="details" class="${this.detailsVisible ? '' : 'collapsed'}">
87+
<div id="details" class="${this.detailsVisible ? 'expanded' : 'collapsed'}">
8888
<div class="details-inner">
8989
${this.detailsTemplate}
9090
</div>
@@ -194,8 +194,8 @@ export class StoryTemplate extends LitElement {
194194
this.copiedKey = which;
195195
clearTimeout(this._copyTimeout);
196196
this._copyTimeout = setTimeout(() => (this.copiedKey = null), 2000);
197-
} catch {
198-
// Clipboard API unavailable (non-HTTPS or permission denied) — silent fail
197+
} catch (e) {
198+
console.warn('Clipboard write failed:', e);
199199
}
200200
}
201201

0 commit comments

Comments
 (0)