@molecule/app-slide-thumbnail-angular
Feature · slide-thumbnail · App (browser) · v1.1.2 · Apache-2.0
Slide thumbnail tile for presentation editors / slideshow navigators
npm install @molecule/app-slide-thumbnail-angularHow it works
@molecule/app-slide-thumbnail-angular is a ready-made slide-thumbnail feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.
import { Component } from '@angular/core'
import { SlideThumbnail } from '@molecule/app-slide-thumbnail-angular'
interface Slide {
id: string
title: string
}
@Component({
selector: 'app-slide-strip',
standalone: true,
imports: [SlideThumbnail],
template: `
<div style="display: flex; flex-direction: column; gap: 8px">
@for (slide of slides; track slide.id; let i = $index) {
<button
mol-slide-thumbnail
[index]="i + 1"
[active]="i === activeIndex"
[width]="160"
(onClick)="onSelect(i)"
>
<span>{{ slide.title }}</span>
</button>
}
</div>
`,
})
export class SlideStrip {
slides: Slide[] = []
activeIndex = 0
onSelect(index: number): void {
this.activeIndex = index
}
}Works with: @molecule/app-angular, @molecule/app-i18n, @molecule/app-ui, @molecule/app-ui-angular
Reference
Angular slide thumbnail tile for presentation editors / slideshow
navigators — the counterpart of @molecule/app-slide-thumbnail-react: the
same props and the same DOM for the same input.
Renders a fixed-width clickable tile with an index badge and an "active" outline; the app supplies the scaled-down slide preview as the button's default content.
Props: index (1-based, required), active, onClick,
aspect ('16/9' | '4/3' | '1/1', default '16/9'), width (px,
default 160), className, and the projected preview content.
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Quick Start
import { Component } from '@angular/core'
import { SlideThumbnail } from '@molecule/app-slide-thumbnail-angular'
interface Slide {
id: string
title: string
}
@Component({
selector: 'app-slide-strip',
standalone: true,
imports: [SlideThumbnail],
template: `
<div style="display: flex; flex-direction: column; gap: 8px">
@for (slide of slides; track slide.id; let i = $index) {
<button
mol-slide-thumbnail
[index]="i + 1"
[active]="i === activeIndex"
[width]="160"
(onClick)="onSelect(i)"
>
<span>{{ slide.title }}</span>
</button>
}
</div>
`,
})
export class SlideStrip {
slides: Slide[] = []
activeIndex = 0
onSelect(index: number): void {
this.activeIndex = index
}
}
Type
feature
Installation
npm install @molecule/app-slide-thumbnail-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-i18n @molecule/app-ui @molecule/app-ui-angular
API
Interfaces
SlideThumbnailProps
Props accepted by SlideThumbnail — the same props
@molecule/app-slide-thumbnail-react accepts. Node props (children) are
projected content in Angular (an input cannot carry a node), so they are
typed unknown: pass them in the host template, not as values.
interface SlideThumbnailProps {
/** Slide index (1-based). */
index: number
/** Live preview content, projected as the element's default content. */
children?: unknown
/** Whether the thumbnail represents the active slide. */
active?: boolean
/** Click handler; receives the DOM click event (React's `onClick`). */
onClick?: (event: MouseEvent) => void
/** Optional aspect ratio (defaults to 16/9). */
aspect?: '16/9' | '4/3' | '1/1'
/** Width in pixels. Defaults to 160. */
width?: number
/** Extra classes. */
className?: string
}
Classes
SlideThumbnail
SlideThumbnail component.
Slide thumbnail tile for presentation editors / slideshow navigators. The
host IS the <button> (button[mol-slide-thumbnail]), matching React's
root exactly: the live scaled-down preview is projected as the element's
default content, and the index badge follows it. Styling routes through
ClassMap tokens (cm.position('relative') + cm.cursorPointer, the tile
canvas through cm.surface), with the same inline style React sets for the
tile canvas and the badge; the badge's colours come from the theme scrim
(cm.bgScrim) with the theme's inverse text (cm.textOnTone).
The translated aria-label is read through the binding's reactive
useTranslation(), so a locale switch refreshes it (React's components
re-render through useTranslation()).
@Component({
selector: 'button[mol-slide-thumbnail]',
standalone: true,
inputs: ['index', 'active', 'onClick', 'aspect', 'width', 'className'],
host: {
'[attr.type]': "'button'",
'[attr.aria-current]': 'active ? "true" : null',
'[attr.data-mol-id]': "'slide-thumbnail'",
'[attr.data-slide-index]': 'index',
'[attr.aria-label]': 'label()',
'[class]': 'classes()',
'[style.width]': 'widthText()',
'[style.aspect-ratio]': 'aspectText()',
'[style.outline]': 'outlineText()',
'[style.outline-offset]': "'2px'",
'[style.overflow]': "'hidden'",
'[style.border]': "'none'",
'[style.padding]': "'0'",
'(click)': 'handleClick($event)',
},
template: `<ng-content></ng-content>
<span [class]="badgeClasses()" [style]="badgeStyle()">{{ index }}</span>`,
})
export class SlideThumbnail {
/** Slide index (1-based). */
index?: number
/** Whether the thumbnail represents the active slide. */
active?: boolean
/** Click handler; receives the DOM click event (React's `onClick`). */
onClick?: (event: MouseEvent) => void
/** Optional aspect ratio (defaults to `'16/9'` at read time). */
aspect?: '16/9' | '4/3' | '1/1'
/** Width in pixels (defaults to 160 at read time). */
width?: number
/** Extra classes. */
className?: string
/**
* Reactive translation, read in the injection context. Its `t` reads the
* locale notifications, so the label re-renders on a locale switch (the
* static `t` does not).
*/
private readonly i18n = useTranslation()
/**
* The current class map.
* @returns The UIClassMap.
*/
cm(): UIClassMap {
return getClassMap()
}
/**
* Computes the wrapper class list (React's
* `cm.cn(cm.position('relative'), cm.cursorPointer, cm.surface, className)`).
* @returns The class string.
*/
classes(): string {
return this.cm().cn(
this.cm().position('relative'),
this.cm().cursorPointer,
this.cm().surface,
this.className,
)
}
/**
* The index badge's class list (React's
* `cm.cn(cm.bgScrim, cm.textOnTone)` — the theme scrim under the theme's
* inverse text).
* @returns The class string.
*/
badgeClasses(): string {
return this.cm().cn(this.cm().bgScrim, this.cm().textOnTone)
}
/**
* The translated accessible label (React's `t('slideThumbnail.label', { index })`).
* @returns The label text.
*/
label(): string {
return this.i18n.t(
'slideThumbnail.label',
{ index: this.index ?? '' },
{ defaultValue: 'Slide {{index}}' },
)
}
/**
* The tile width (React's `width`, default 160).
* @returns The CSS width.
*/
widthText(): string {
return `${this.width ?? 160}px`
}
/**
* The tile aspect ratio (React's `aspect`, default 16/9, slash spaced out).
* @returns The CSS aspect-ratio.
*/
aspectText(): string {
return (this.aspect ?? '16/9').replace('/', ' / ')
}
/**
* The active outline (React's `active ? '2px solid currentColor' : 'none'`).
* @returns The CSS outline.
*/
outlineText(): string {
return this.active ? '2px solid currentColor' : 'none'
}
/**
* The index badge's inline style (React's absolute top-left badge, applied
* as a style map so each declaration lands through the CSSOM as React's do;
* the colours live on `SlideThumbnail.badgeClasses`).
* @returns The style map.
*/
badgeStyle(): Record<string, string> {
return {
position: 'absolute',
left: '4px',
top: '4px',
padding: '0 4px',
'font-size': '10px',
'font-weight': '700',
'border-radius': '3px',
}
}
/**
* Forwards the click to the React-named handler with the native event.
*
* @param event - The native click event.
*/
handleClick(event: MouseEvent): void {
this.onClick?.(event)
}
}
Injection Notes
Requirements
Peer dependencies:
@angular/common^22.0.0@angular/core^22.0.0@angular/platform-browser^22.0.0@molecule/app-angular^3.5.0 || ^4.0.0@molecule/app-i18n^1.0.1@molecule/app-ui^1.4.0@molecule/app-ui-angular^1.1.0
Runtime Dependencies
-
@angular/common -
@angular/core -
@angular/platform-browser -
@molecule/app-angular -
@molecule/app-i18n -
@molecule/app-ui -
@molecule/app-ui-angular -
Requires a bonded ClassMap (frame uses
cm.position('relative')+cm.cursorPointer) — rendering throws otherwise. -
The tile canvas is the theme's surface token (
cm.surface) and the index badge sits on a theme scrim (cm.bgScrim+cm.textOnTone), so both follow the app's theme — render your own themed preview inside the button. -
The active outline uses
currentColor; set a text color on a parent to control it. -
The index label's aria-label comes from
t('slideThumbnail.label')with an English fallback, read through the binding's reactiveuseTranslation(), so a locale switch updates it at once. -
Companion locale bond:
@molecule/app-locales-slide-thumbnail.
Translations
Translation strings are provided by @molecule/app-locales-slide-thumbnail.