npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@molecule/app-now-playing-bar-angular

v1.1.1

Published

Persistent now-playing bar — track artwork, title/artist, transport controls (prev/play-pause/next), scrubber, and volume slider

Readme

@molecule/app-now-playing-bar-angular

Angular persistent now-playing bar — track artwork, title/artist, transport controls (prev/play-pause/next), scrubber, and volume slider.

Angular counterpart of @molecule/app-now-playing-bar-react: the same exports, the same props (React names), the same DOM for the same input. Used by music-streaming, podcast, and audiobook apps as a sticky dock at the bottom of the page (or panel) showing what's currently playing.

Sticky positioning is intentionally NOT enforced inside the component — the caller wraps <div mol-now-playing-bar> in their own position: sticky / position: fixed container at whatever scope makes sense (page, layout shell, panel).

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

import { Component, signal } from '@angular/core'
import { NowPlayingBar } from '@molecule/app-now-playing-bar-angular'

@Component({
  selector: 'app-player',
  standalone: true,
  imports: [NowPlayingBar],
  template: `
    <div style="position: sticky; bottom: 0">
      <div
        mol-now-playing-bar
        [track]="track"
        [isPlaying]="playing()"
        (onPlay)="playing.set(true)"
        (onPause)="playing.set(false)"
        [currentTime]="time()"
        [duration]="240"
        [onSeek]="setTime"
      ></div>
    </div>
  `,
})
export class Player {
  readonly track = { id: 't1', title: 'Untitled', artist: 'Various' }
  readonly playing = signal(false)
  readonly time = signal(0)
  readonly setTime = (seconds: number): void => this.time.set(seconds)
}

Type

feature

Installation

npm install @molecule/app-now-playing-bar-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular

API

Interfaces

NowPlayingTrack

A track currently loaded in the now-playing bar. Only id, title, and artist are required; artwork is an optional image URL displayed on the left edge of the bar.

interface NowPlayingTrack {
  /** Stable identifier for the track (used as a key by parent lists). */
  id: string
  /** Track title shown as the primary label in the bar. */
  title: string
  /** Artist / podcast / source label shown below the title. */
  artist: string
  /** Optional artwork image URL (square). */
  artwork?: string
}

NowPlayingBarProps

Props accepted by {@link NowPlayingBar} — the same props @molecule/app-now-playing-bar-react accepts. The trailing node prop is projected content in Angular (an input cannot carry a node), so it is typed unknown: pass it in the host template, not as a value.

interface NowPlayingBarProps {
  /**
   * The currently loaded track, or `null`/`undefined` when nothing is playing.
   * When absent the bar renders a compact empty state ("Nothing playing")
   * instead of throwing — you can leave it mounted rather than conditionally
   * unmounting it.
   */
  track?: NowPlayingTrack | null
  /** True when the track is actively playing. Drives the play/pause toggle. */
  isPlaying: boolean
  /** Called when the user presses play. */
  onPlay: () => void
  /** Called when the user presses pause. */
  onPause: () => void
  /**
   * Optional next-track handler. When omitted the next button is hidden. It
   * receives the click event, as React's `onClick` handler does.
   */
  onNext?: (event?: MouseEvent) => void
  /**
   * Optional previous-track handler. When omitted the previous button is
   * hidden. It receives the click event, as React's `onClick` handler does.
   */
  onPrev?: (event?: MouseEvent) => void
  /** Current playback position in seconds. */
  currentTime: number
  /** Total track duration in seconds. */
  duration: number
  /** Called when the user scrubs to a new position (in seconds). */
  onSeek: (seconds: number) => void
  /** Volume level in `[0, 1]`. Optional — when omitted the volume control is hidden. */
  volume?: number
  /** Called when the volume slider changes (in `[0, 1]`). Required to render the volume control. */
  onVolumeChange?: (volume: number) => void
  /** Optional content rendered at the right edge, projected as `[slot=trailing]`. */
  trailing?: unknown
  /** Extra classes merged onto the root element. */
  className?: string
}

Classes

NowPlayingBar

NowPlayingBar component.

Persistent now-playing bar: track artwork, title/artist, transport controls (prev/play-pause/next), scrubber and volume slider. The host IS the root <div> (div[mol-now-playing-bar]), matching React's root exactly: role, aria-label, data-mol-id and (in the empty state) data-mol-empty live on it.

Sticky positioning is intentionally NOT enforced inside the component — the caller decides where it lives. All styling routes through getClassMap(); all user-visible text routes through t() so a locale switch re-renders it. The trailing node prop is projected content ([slot=trailing]) and its wrapper renders only while it carries nodes, matching React's {trailing && <div>…</div>}.

@Component({
  selector: 'div[mol-now-playing-bar]',
  standalone: true,
  hostDirectives: [MolPlacement],
  inputs: [
    'track',
    'isPlaying',
    'onPlay',
    'onPause',
    'onNext',
    'onPrev',
    'currentTime',
    'duration',
    'onSeek',
    'volume',
    'onVolumeChange',
    'className',
  ],
  host: {
    role: 'region',
    '[attr.aria-label]': 'ariaLabel()',
    '[attr.data-mol-id]': "'now-playing-bar'",
    '[attr.data-mol-empty]': 'isEmpty() ? "true" : null',
    '[class]': 'rootClasses()',
  },
  template: `@if (isEmpty()) {
      <span [class]="emptySpanClasses()" data-mol-id="now-playing-bar-empty">{{
        emptyLabel()
      }}</span>
    } @else {
      <div
        [class]="shrink0Classes()"
        data-mol-id="now-playing-bar-artwork"
        style="width: 56px; height: 56px"
      >
        @if (track?.artwork; as artwork) {
          <img
            [attr.src]="artwork"
            [attr.alt]="artworkAlt()"
            style="width: 100%; height: 100%; object-fit: cover; border-radius: 6px"
          />
        } @else {
          <div
            aria-hidden="true"
            [class]="artworkPlaceholderClasses()"
            style="width: 100%; height: 100%; border-radius: 6px"
          ></div>
        }
      </div>

      <div
        [class]="metaClasses()"
        data-mol-id="now-playing-bar-meta"
        style="min-width: 0px; flex: 1 1 0%"
      >
        <span
          [class]="titleClasses()"
          data-mol-id="now-playing-bar-title"
          style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block"
          >{{ track?.title }}</span
        >
        <span
          [class]="mediumTextClasses()"
          data-mol-id="now-playing-bar-artist"
          style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block"
          >{{ track?.artist }}</span
        >
      </div>

      <div [class]="transportClasses()" data-mol-id="now-playing-bar-transport">
        @if (onPrev) {
          <button
            type="button"
            (click)="runPrev($event)"
            [attr.aria-label]="prevLabel()"
            data-mol-id="now-playing-bar-prev"
            [class]="cursorClasses()"
          >
            ⏮
          </button>
        }
        <button
          type="button"
          (click)="toggle()"
          [attr.aria-label]="playLabel()"
          [attr.aria-pressed]="isPlaying ? 'true' : 'false'"
          data-mol-id="now-playing-bar-play"
          [class]="cursorClasses()"
        >
          {{ isPlaying ? '⏸' : '▶' }}
        </button>
        @if (onNext) {
          <button
            type="button"
            (click)="runNext($event)"
            [attr.aria-label]="nextLabel()"
            data-mol-id="now-playing-bar-next"
            [class]="cursorClasses()"
          >
            ⏭
          </button>
        }
      </div>

      <div
        [class]="rowClasses()"
        data-mol-id="now-playing-bar-scrubber"
        style="flex: 2 1 0%; min-width: 0px"
      >
        <span [class]="mediumTextClasses()" data-mol-id="now-playing-bar-current-time">{{
          formatTime(currentTime)
        }}</span>
        <input
          #seekInput
          type="range"
          [attr.min]="0"
          [attr.max]="seekMax()"
          [attr.step]="0.1"
          [attr.value]="seekValue()"
          (input)="onSeekInput($event)"
          [attr.aria-label]="seekLabel()"
          data-mol-id="now-playing-bar-seek"
          style="flex: 1 1 0%; min-width: 0px"
        />
        <span [class]="mediumTextClasses()" data-mol-id="now-playing-bar-duration">{{
          formatTime(duration)
        }}</span>
      </div>

      @if (onVolumeChange && typeof volume === 'number') {
        <div [class]="volumeClasses()" data-mol-id="now-playing-bar-volume" style="width: 120px">
          <span aria-hidden="true">{{ volume === 0 ? '🔇' : '🔊' }}</span>
          <input
            #volumeInput
            type="range"
            [attr.min]="0"
            [attr.max]="1"
            [attr.step]="0.01"
            [attr.value]="volume"
            (input)="onVolumeInput($event)"
            [attr.aria-label]="volumeLabel()"
            data-mol-id="now-playing-bar-volume-slider"
            style="flex: 1 1 0%; min-width: 0px"
          />
        </div>
      }

      <div #trailingWrapper [class]="shrink0Classes()" data-mol-id="now-playing-bar-trailing">
        <ng-content select="[slot=trailing]"></ng-content>
      </div>
    }`,
})
export class NowPlayingBar implements AfterViewChecked {
  track?: NowPlayingTrack | null
  isPlaying = false
  onPlay?: () => void
  onPause?: () => void
  onNext?: (event?: MouseEvent) => void
  onPrev?: (event?: MouseEvent) => void
  currentTime = 0
  duration = 0
  onSeek?: (seconds: number) => void
  volume?: number
  onVolumeChange?: (volume: number) => void
  className?: string

  private readonly i18n = useTranslation()
  @ViewChild('trailingWrapper') trailingWrapperRef?: ElementRef<HTMLElement>
  @ViewChild('seekInput') seekInputRef?: ElementRef<HTMLInputElement>
  @ViewChild('volumeInput') volumeInputRef?: ElementRef<HTMLInputElement>

  constructor() {
    usePlacement((hasContent) => {
      const wrapper = this.trailingWrapperRef?.nativeElement
      setElementPresent(wrapper, wrapper ? hasContent(wrapper) : false)
    })
  }

  cm(): UIClassMap {
    return getClassMap()
  }

  isEmpty(): boolean {
    return this.track == null
  }

  rootClasses(): string {
    return this.cm().cn(
      this.cm().flex({ align: 'center', gap: 'md' }),
      this.cm().sp('p', 3),
      this.className,
    )
  }

  ariaLabel(): string {
    return this.isEmpty() ? this.emptyLabel() : this.regionLabel()
  }

  emptyLabel(): string {
    return this.i18n.t('nowPlaying.empty', {}, { defaultValue: 'Nothing playing' })
  }

  regionLabel(): string {
    return this.i18n.t(
      'nowPlaying.aria.region',
      { title: this.track?.title ?? '' },
      { defaultValue: 'Now playing: {{title}}' },
    )
  }

  artworkAlt(): string {
    return this.i18n.t(
      'nowPlaying.aria.artwork',
      { title: this.track?.title ?? '' },
      { defaultValue: 'Artwork for {{title}}' },
    )
  }

  playLabel(): string {
    return this.isPlaying
      ? this.i18n.t('nowPlaying.aria.pause', {}, { defaultValue: 'Pause' })
      : this.i18n.t('nowPlaying.aria.play', {}, { defaultValue: 'Play' })
  }

  prevLabel(): string {
    return this.i18n.t('nowPlaying.aria.prev', {}, { defaultValue: 'Previous track' })
  }

  nextLabel(): string {
    return this.i18n.t('nowPlaying.aria.next', {}, { defaultValue: 'Next track' })
  }

  seekLabel(): string {
    return this.i18n.t('nowPlaying.aria.seek', {}, { defaultValue: 'Seek' })
  }

  volumeLabel(): string {
    return this.i18n.t('nowPlaying.aria.volume', {}, { defaultValue: 'Volume' })
  }

  seekMax(): number {
    return this.duration > 0 ? this.duration : 0
  }

  seekValue(): number {
    return Math.min(this.currentTime, this.seekMax())
  }

  shrink0Classes(): string {
    return this.cm().cn(this.cm().shrink0)
  }

  cursorClasses(): string {
    return this.cm().cn(this.cm().cursorPointer)
  }

  emptySpanClasses(): string {
    return this.cm().cn(this.cm().textSize('sm'), this.cm().textMuted)
  }

  artworkPlaceholderClasses(): string {
    return this.cm().cn(this.cm().flex({ align: 'center', justify: 'center' }))
  }

  metaClasses(): string {
    return this.cm().cn(this.cm().stack(0))
  }

  titleClasses(): string {
    return this.cm().cn(this.cm().textSize('sm'), this.cm().fontWeight('semibold'))
  }

  mediumTextClasses(): string {
    return this.cm().textSize('xs')
  }

  transportClasses(): string {
    return this.cm().cn(this.cm().flex({ align: 'center', gap: 'sm' }), this.cm().shrink0)
  }

  rowClasses(): string {
    return this.cm().cn(this.cm().flex({ align: 'center', gap: 'sm' }))
  }
// … truncated — 9 more members: volumeClasses, toggle, runPrev, runNext, onSeekInput, onVolumeInput, formatTime, ngAfterViewChecked, syncControlledInputs; the full declaration is in node_modules/@molecule/app-now-playing-bar-angular/dist/now-playing-bar.component.d.ts

(Member comments are left out to fit; the full declaration is in node_modules/@molecule/app-now-playing-bar-angular/dist/now-playing-bar.component.d.ts.)

Functions

formatTime(seconds)

Format a number of seconds as m:ss (or 0:00 for non-finite input).

function formatTime(seconds: number): string
  • seconds — Seconds to format.

Returns: The formatted m:ss string.

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.13.0
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-angular ^1.1.0

Runtime Dependencies

  • @angular/common
  • @angular/core
  • @angular/platform-browser
  • @molecule/app-angular
  • @molecule/app-ui
  • @molecule/app-ui-angular

Pair with @molecule/app-locales-now-playing-bar for translations in 79 languages. All styling routes through getClassMap(); all user-facing text routes through t().

track is optional: leave it null/undefined when nothing is playing and the bar renders a compact empty state ("Nothing playing") instead of throwing, so you can leave it mounted rather than conditionally unmounting it. Requires a wired ClassMap bond and the Angular binding's i18n provider — getClassMap() and useTranslation() both throw before wiring. Transport buttons render text glyphs (not an icon set), so their size tracks the app font. The trailing node prop is projected content ([slot=trailing]).

Translations

Translation strings are provided by @molecule/app-locales-now-playing-bar.