@molecule/app-ticker-row-angular
Feature · ticker-row · App (browser) · v1.1.4 · Apache-2.0
Financial ticker row — symbol, price, change%, sparkline for crypto/stocks/markets
npm install @molecule/app-ticker-row-angularHow it works
@molecule/app-ticker-row-angular is a ready-made ticker-row 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 { TickerRow } from '@molecule/app-ticker-row-angular'
@Component({
selector: 'app-watchlist',
standalone: true,
imports: [TickerRow],
template: `
<div
mol-ticker-row
symbol="BTC"
name="Bitcoin"
price="$67,420"
[changePct]="2.34"
meta="$1.3T"
[onClick]="() => openAsset('btc')"
></div>
`,
})
export class Watchlist {
readonly openAsset = (symbol: string): void => {
console.log('open asset', symbol)
}
}Works with: @molecule/app-angular, @molecule/app-ui, @molecule/app-ui-angular
Reference
Angular financial ticker row — symbol + price + change% + optional sparkline.
Exports <TickerRow> (use the mol-ticker-row attribute on a div). Use
for crypto trackers, stock watchlists, market dashboards. It is the Angular
counterpart of @molecule/app-ticker-row-react: the same props (React
names) and the same DOM for the same input. Pair the sparkline projection
with the sparkline component from @molecule/app-sparkline-angular.
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 { TickerRow } from '@molecule/app-ticker-row-angular'
@Component({
selector: 'app-watchlist',
standalone: true,
imports: [TickerRow],
template: `
<div
mol-ticker-row
symbol="BTC"
name="Bitcoin"
price="$67,420"
[changePct]="2.34"
meta="$1.3T"
[onClick]="() => openAsset('btc')"
></div>
`,
})
export class Watchlist {
readonly openAsset = (symbol: string): void => {
console.log('open asset', symbol)
}
}
Type
feature
Installation
npm install @molecule/app-ticker-row-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular
API
Interfaces
TickerRowProps
Props accepted by TickerRow — the same props
@molecule/app-ticker-row-react accepts. Node props are projected content in
Angular (an input cannot carry a node): symbol, name, icon, price,
sparkline and meta are the element's [slot=<name>] content, with a
string/number input rendering as text instead. changeDisplay is text-only
(React's condition and fallback are both input-value shaped, so there is no
slot for it).
interface TickerRowProps {
/** Symbol / ticker display ("BTC", "AAPL"): text, or `[slot=symbol]` content. */
symbol?: unknown
/** Full name display ("Bitcoin", "Apple Inc."): text, or `[slot=name]` content. */
name?: unknown
/** Optional leading icon / logo: text, or `[slot=icon]` content. */
icon?: unknown
/** Current price (formatted): text, or `[slot=price]` content. */
price?: unknown
/** Period change percentage. Used for direction + color. */
changePct?: number
/** Period change formatted display (defaults to `changePct` formatted). Text. */
changeDisplay?: string
/** Optional sparkline node: text, or `[slot=sparkline]` content. */
sparkline?: unknown
/** Optional volume / market-cap display: text, or `[slot=meta]` content. May hold a control; it keeps its own clicks. */
meta?: unknown
/**
* Click handler (React's `onClick`). While it is set the whole row is
* clickable through a transparent native button laid over it, named by the
* symbol; the inner controls (the `meta` slot) sit above that button and
* keep their own clicks. The handler runs with no arguments.
*/
onClick?: () => void
/** Extra classes. */
className?: string
}
Classes
TickerRow
TickerRow component.
Financial ticker row — symbol + price + change% + optional icon, sparkline
and meta. The host IS the root <div> (div[mol-ticker-row]), matching
React's root exactly. While onClick is set the whole row is clickable
through a transparent native button laid over it — the row's open action,
named by the symbol — and the row's inner control (the meta slot, which
may hold a control) is raised into a positioned wrapper so it paints above
the open button and keeps its own clicks. A native button turns Enter and
Space into the same click itself. The direction color comes from the theme
success/error text tokens (cm.textSuccess / cm.textError); the default
percentage text comes from Intl.NumberFormat in the app's active locale.
The layout and type classes come from the ClassMap bond. Same props, same
DOM as @molecule/app-ticker-row-react's TickerRow. Node-valued
symbol, name, icon, price, sparkline and meta content is
projected ([slot=<name>]); a string or number input renders as text.
@Component({
selector: 'div[mol-ticker-row]',
standalone: true,
hostDirectives: [MolPlacement],
inputs: [
'symbol',
'name',
'icon',
'price',
'changePct',
'changeDisplay',
'sparkline',
'meta',
'className',
'onClick',
],
host: {
'[class]': 'classes()',
},
// prettier-ignore
template: `@if (onClick) {<button type="button" [attr.aria-labelledby]="instanceNameId" data-mol-id="ticker-row-open" (click)="handleClick()" [class]="openButtonClasses()" [style.background]="'transparent'" [style.border]="'none'" [style.padding]="'0px'"></button>}<div #iconDiv [class]="iconClasses()">@if (hasIcon) {<ng-container>{{ icon }}</ng-container>}<ng-content select="[slot=icon]" /></div><div [class]="symbolClasses()"><span [attr.id]="symbolId()" [class]="symbolTextClasses()">@if (hasSymbol) {<ng-container>{{ symbol }}</ng-container>}<ng-content select="[slot=symbol]" /></span><span #nameSpan [class]="nameClasses()">@if (hasName) {<ng-container>{{ name }}</ng-container>}<ng-content select="[slot=name]" /></span></div><div #sparkDiv [class]="sparkClasses()">@if (hasSparkline) {<ng-container>{{ sparkline }}</ng-container>}<ng-content select="[slot=sparkline]" /></div><div [class]="priceClasses()"><span [class]="priceTextClasses()">@if (hasPrice) {<ng-container>{{ price }}</ng-container>}<ng-content select="[slot=price]" /></span>@if (showChange) {<span [class]="changeTextClasses()"><span aria-hidden="true">{{ arrow() }}</span><span [class]="srOnlyClasses()">{{ directionLabel() }}</span>{{ ' ' }}@if (hasChangeDisplay) {<ng-container>{{ changeDisplay }}</ng-container>}@else {<ng-container>{{ formattedChange() }}</ng-container>}</span>}</div><div #metaDiv [class]="metaClasses()">@if (hasMeta) {<ng-container>{{ meta }}</ng-container>}<ng-content select="[slot=meta]" /></div>`,
})
export class TickerRow {
symbol?: unknown
/** Full name display: text, or `[slot=name]` content. */
name?: unknown
/** Optional leading icon / logo: text, or `[slot=icon]` content. */
icon?: unknown
/** Current price (formatted): text, or `[slot=price]` content. */
price?: unknown
/** Period change percentage — drives direction + color when present. */
changePct?: number
/** Period change formatted display (defaults to `changePct` formatted). */
changeDisplay?: string
/** Optional sparkline node: text, or `[slot=sparkline]` content. */
sparkline?: unknown
/** Optional volume / market-cap display: text, or `[slot=meta]` content. */
meta?: unknown
/** Extra classes. */
className?: string
/** Click handler (React's `onClick`). */
onClick?: () => void
/** This instance's name id (the open button's `aria-labelledby`). */
private readonly instanceNameId = nameId()
@ViewChild('iconDiv', { static: true }) private iconDiv?: ElementRef<HTMLDivElement>
@ViewChild('nameSpan', { static: true }) private nameSpan?: ElementRef<HTMLSpanElement>
@ViewChild('sparkDiv', { static: true }) private sparkDiv?: ElementRef<HTMLDivElement>
@ViewChild('metaDiv', { static: true }) private metaDiv?: ElementRef<HTMLDivElement>
constructor() {
usePlacement((hasContent) => {
const icon = this.iconDiv?.nativeElement
setElementPresent(icon, this.hasIcon || (icon ? hasContent(icon) : false))
const name = this.nameSpan?.nativeElement
setElementPresent(name, this.hasName || (name ? hasContent(name) : false))
const spark = this.sparkDiv?.nativeElement
setElementPresent(spark, this.hasSparkline || (spark ? hasContent(spark) : false))
const meta = this.metaDiv?.nativeElement
setElementPresent(meta, this.hasMeta || (meta ? hasContent(meta) : false))
})
}
/** The current class map. */
cm(): UIClassMap {
return getClassMap()
}
private readonly i18n = useTranslation()
private readonly locale = useLocale()
classes(): string {
return this.cm().cn(
this.cm().flex({ align: 'center', gap: 'sm' }),
this.cm().sp('py', 2),
this.onClick != null ? this.cm().position('relative') : undefined,
this.onClick != null ? this.cm().cursorPointer : undefined,
this.className,
)
}
openButtonClasses(): string {
return this.cm().cn(this.cm().position('absolute'), this.cm().inset0, this.cm().cursorPointer)
}
/** The screen-reader-only direction span's class (`cm.cn(cm.srOnly)`). */
srOnlyClasses(): string {
return this.cm().cn(this.cm().srOnly)
}
symbolId(): string | null {
return this.onClick ? this.instanceNameId : null
}
handleClick(): void {
this.onClick?.()
}
symbolTextClasses(): string {
return this.cm().cn(this.cm().textSize('sm'), this.cm().fontWeight('bold'))
}
symbolClasses(): string {
return this.cm().cn(this.cm().flex1, this.cm().stack(0))
}
/** The icon wrapper's class. */
iconClasses(): string {
return this.cm().cn(this.cm().shrink0)
}
/** The name span's class. */
nameClasses(): string {
return this.cm().cn(this.cm().textSize('xs'))
}
/** The sparkline wrapper's class. */
sparkClasses(): string {
return this.cm().cn(this.cm().shrink0)
}
priceClasses(): string {
return this.cm().cn(this.cm().textCenter, this.cm().stack(0))
}
priceTextClasses(): string {
return this.cm().cn(this.cm().textSize('sm'), this.cm().fontWeight('semibold'))
}
changeTextClasses(): string {
return this.cm().cn(
this.cm().textSize('xs'),
this.cm().fontWeight('semibold'),
this.colorClass(),
)
}
colorClass(): string | undefined {
return this.positive ? this.cm().textSuccess : this.negative ? this.cm().textError : undefined
}
metaClasses(): string {
return this.cm().cn(
this.cm().textSize('xs'),
this.cm().shrink0,
this.onClick ? this.cm().position('relative') : undefined,
)
}
/** Whether a changePct input is present. */
get hasChangePct(): boolean {
return this.changePct !== undefined
}
get hasChangeDisplay(): boolean {
return this.changeDisplay !== undefined && this.changeDisplay !== null
}
get showChange(): boolean {
return this.hasChangeDisplay || this.hasChangePct
}
/** Whether the direction is positive (React's `changePct > 0`). */
get positive(): boolean {
return this.changePct !== undefined && this.changePct > 0
}
/** Whether the direction is negative (React's `changePct < 0`). */
get negative(): boolean {
return this.changePct !== undefined && this.changePct < 0
}
/** The direction arrow. */
arrow(): string {
return this.positive ? '▲' : this.negative ? '▼' : '–'
}
directionLabel(): string {
return this.positive
? this.i18n.t('tickerRow.change.up', {}, { defaultValue: 'Up' })
: this.negative
? this.i18n.t('tickerRow.change.down', {}, { defaultValue: 'Down' })
: this.i18n.t('tickerRow.change.flat', {}, { defaultValue: 'Unchanged' })
}
formattedChange(): string {
return new Intl.NumberFormat(this.locale(), {
style: 'percent',
minimumFractionDigits: 2,
maximumFractionDigits: 2,
}).format(this.changePct! / 100)
}
/** Whether a text symbol input is present. */
get hasSymbol(): boolean {
return this.symbol !== undefined && this.symbol !== null
}
/** Whether a text price input is present. */
get hasPrice(): boolean {
return this.price !== undefined && this.price !== null
}
get hasName(): boolean {
return this.name !== undefined && this.name !== null && this.name !== ''
}
get hasIcon(): boolean {
return this.icon !== undefined && this.icon !== null && this.icon !== ''
}
/** Whether a text sparkline input is present (React's truthiness). */
get hasSparkline(): boolean {
return this.sparkline !== undefined && this.sparkline !== null && this.sparkline !== ''
}
get hasMeta(): boolean {
return this.meta !== undefined && this.meta !== null && this.meta !== ''
}
}
(Member comments are shortened to their first sentence, and the 26 longest are left out to fit; the full declaration is in node_modules/@molecule/app-ticker-row-angular/dist/ticker-row.component.d.ts.)
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 || ^4.0.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 -
Requires a wired ClassMap bond (
getClassMap()throws before bonding).price/metaare opaque display nodes — the app owns number/currency formatting. -
changePctdrives direction (▲/▼/–) and the theme's success/error text tokens (cm.textSuccess/cm.textError). PasschangeDisplayto control the change text; the default formatschangePctas a percent in the app's active locale. -
With
onClickthe whole row is clickable through a transparent native button laid over it, named by the symbol; the inner controls (themetaslot) sit above that button and keep their own clicks. A native button turns Enter and Space into the same click itself. -
Node-valued props (
symbol,name,icon,price,sparkline,meta) are projected content:[slot=<name>], with a string or number input rendering as text instead.changeDisplayis text-only.
Translations
Translation strings are provided by @molecule/app-locales-ticker-row.