@molecule/app-slide-thumbnail-svelte

Feature · slide-thumbnail · App (browser) · v1.1.4 · Apache-2.0

Slide thumbnail tile for presentation editors / slideshow navigators

npm install @molecule/app-slide-thumbnail-svelte

npm · Source on GitHub

How it works

@molecule/app-slide-thumbnail-svelte 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.

<script lang="ts">
  import { SlideThumbnail } from '@molecule/app-slide-thumbnail-svelte'

  interface Slide {
    id: string
    title: string
  }

  let {
    slides,
    activeIndex,
    onSelect,
  }: {
    slides: Slide[]
    activeIndex: number
    onSelect: (index: number) => void
  } = $props()
</script>

<div style="display: flex; flex-direction: column; gap: 8px">
  {#each slides as slide, i (slide.id)}
    <SlideThumbnail
      index={i + 1}
      active={i === activeIndex}
      onClick={() => onSelect(i)}
      width={160}
    >
      <span>{slide.title}</span>
    </SlideThumbnail>
  {/each}
</div>

Works with: @molecule/app-i18n, @molecule/app-svelte, @molecule/app-ui, @molecule/app-ui-svelte

Reference

Svelte slide thumbnail tile for presentation editors / slideshow navigators. Renders a fixed-width clickable tile with an index badge and an "active" outline; the app supplies the scaled-down slide preview as the default snippet.

Svelte counterpart of @molecule/app-slide-thumbnail-react: the same props (React names), the same DOM for the same input, and the same ClassMap tokens. Apps switch framework by changing only the package name in their imports.

Props: index (1-based, required), active, onClick, aspect ('16/9' | '4/3' | '1/1', default '16/9'), width (px, default 160), className, and the default snippet as children.

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.ts JSDoc, not this file.

Quick Start

<script lang="ts">
  import { SlideThumbnail } from '@molecule/app-slide-thumbnail-svelte'

  interface Slide {
    id: string
    title: string
  }

  let {
    slides,
    activeIndex,
    onSelect,
  }: {
    slides: Slide[]
    activeIndex: number
    onSelect: (index: number) => void
  } = $props()
</script>

<div style="display: flex; flex-direction: column; gap: 8px">
  {#each slides as slide, i (slide.id)}
    <SlideThumbnail
      index={i + 1}
      active={i === activeIndex}
      onClick={() => onSelect(i)}
      width={160}
    >
      <span>{slide.title}</span>
    </SlideThumbnail>
  {/each}
</div>

Type

feature

Installation

npm install @molecule/app-slide-thumbnail-svelte @molecule/app-i18n @molecule/app-svelte @molecule/app-ui @molecule/app-ui-svelte svelte

API

Interfaces

SlideThumbnailProps

Props for the SlideThumbnail component.

interface SlideThumbnailProps {
  /** Slide index (1-based). */
  index: number
  /** Live preview content (rendered scaled-down) — the default snippet. */
  children?: Snippet
  /** 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
}

Constants

SlideThumbnail

const SlideThumbnail: LegacyComponentType

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-i18n ^1.0.1
  • @molecule/app-svelte ^3.5.0 || ^4.0.0
  • @molecule/app-ui ^1.4.0
  • @molecule/app-ui-svelte ^1.6.0
  • svelte ^5.0.0

Runtime Dependencies

  • @molecule/app-i18n

  • @molecule/app-svelte

  • @molecule/app-ui

  • @molecule/app-ui-svelte

  • svelte

  • Requires a wired ClassMap bond (e.g. @molecule/app-ui-tailwind) — getClassMap() throws before bonding.

  • 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 children.

  • 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 useTranslation(), 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.