@molecule/app-leaderboard-list-angular
Feature · leaderboard-list · App (browser) · v1.1.2 · Apache-2.0
Wrapper list above leaderboard rows with podium / top-N highlighting
npm install @molecule/app-leaderboard-list-angularHow it works
@molecule/app-leaderboard-list-angular is a ready-made leaderboard-list 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 { LeaderboardList } from '@molecule/app-leaderboard-list-angular'
@Component({
selector: 'app-top-contributors',
standalone: true,
imports: [LeaderboardList],
template: `
<div mol-leaderboard-list>
<h3 slot="title">Top Contributors</h3>
@for (e of entries; track e.id) {
<div class="flex justify-between">
<span>{{ e.rank }}. {{ e.name }}</span>
<strong>{{ e.score }}</strong>
</div>
}
</div>
`,
})
export class TopContributors {
entries = [
{ id: 'u1', rank: 1, name: 'Alice Chen', score: 4820 },
{ id: 'u2', rank: 2, name: 'Bo Diaz', score: 4515 },
]
}Works with: @molecule/app-angular, @molecule/app-ui, @molecule/app-ui-angular
Reference
Angular leaderboard list container — the counterpart of
@molecule/app-leaderboard-list-react: the same props and the same DOM for
the same input.
Exports <LeaderboardList> — header row (title + actions) above a vertical
stack of rows. Pair with a row component
(@molecule/app-leaderboard-row-react in React apps; your own Angular
rows otherwise) — this container adds no rank/podium logic of its own.
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 { LeaderboardList } from '@molecule/app-leaderboard-list-angular'
@Component({
selector: 'app-top-contributors',
standalone: true,
imports: [LeaderboardList],
template: `
<div mol-leaderboard-list>
<h3 slot="title">Top Contributors</h3>
@for (e of entries; track e.id) {
<div class="flex justify-between">
<span>{{ e.rank }}. {{ e.name }}</span>
<strong>{{ e.score }}</strong>
</div>
}
</div>
`,
})
export class TopContributors {
entries = [
{ id: 'u1', rank: 1, name: 'Alice Chen', score: 4820 },
{ id: 'u2', rank: 2, name: 'Bo Diaz', score: 4515 },
]
}
Type
feature
Installation
npm install @molecule/app-leaderboard-list-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular
API
Interfaces
LeaderboardListProps
Props accepted by LeaderboardList — the same props
@molecule/app-leaderboard-list-react accepts. Node props (children,
title, actions, emptyState) 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 LeaderboardListProps {
/** Pre-rendered leaderboard rows, projected as the element's default content. */
children?: unknown
/** Optional title above the list, projected as `[slot=title]` content. */
title?: unknown
/** Optional period selector / actions row, projected as `[slot=actions]` content. */
actions?: unknown
/** Optional empty state, projected as `[slot=emptyState]` content. Rendered only when the list is empty. */
emptyState?: unknown
/** Extra classes. */
className?: string
}
Classes
LeaderboardList
LeaderboardList component.
Container above a stack of rows — header + actions + the list. The host IS
the outer <div> (div[mol-leaderboard-list]), matching React's root
exactly. Doesn't itself render rank logic; pair with a row component
(@molecule/app-leaderboard-row-react in React apps; your own rows
otherwise).
The node props are projected slots: title renders inside the <h3>,
actions bare beside it, children inside the list container, and
emptyState bare in place of the list (React's
childCount === 0 ? emptyState : <div>…). The optional wrappers are taken
out of the DOM when React renders nothing (setElementPresent) and the
bare slots' content is moved to where React renders it (placeContent),
in LeaderboardList.reconcile.
@Component({
selector: 'div[mol-leaderboard-list]',
standalone: true,
hostDirectives: [MolPlacement],
inputs: ['className'],
host: {
'[class]': 'classes()',
},
template: `<header #header [class]="headerClasses()">
<h3 #title [class]="titleClasses()"><ng-content select="[slot=title]"></ng-content></h3>
<span #actions><ng-content select="[slot=actions]"></ng-content></span>
</header>
<div #list [class]="listClasses()"><ng-content></ng-content></div>
<span #empty><ng-content select="[slot=emptyState]"></ng-content></span>`,
})
export class LeaderboardList {
/** Extra classes on the outer wrapper. */
className?: string
/** The header capture wrapper (absent when neither title nor actions exist). */
@ViewChild('header') header?: ElementRef<HTMLElement>
/** The title's `<h3>` (absent when the title slot is empty). */
@ViewChild('title') title?: ElementRef<HTMLElement>
/** The actions capture wrapper (always absent; React renders the slot bare). */
@ViewChild('actions') actions?: ElementRef<HTMLElement>
/** The list container (absent when the default slot is empty). */
@ViewChild('list') list?: ElementRef<HTMLElement>
/** The emptyState capture wrapper (rendered bare, or absent with the list rendered). */
@ViewChild('empty') empty?: ElementRef<HTMLElement>
/** The component host, the parent the bare `emptyState` renders in. */
private readonly host = inject(ElementRef<HTMLElement>)
constructor() {
usePlacement((hasContent) => this.reconcile(hasContent))
}
/**
* The current class map.
* @returns The UIClassMap.
*/
cm(): UIClassMap {
return getClassMap()
}
/**
* Computes the wrapper class list (`cm.stack(2)` + `className`).
* @returns The class string.
*/
classes(): string {
return this.cm().cn(this.cm().stack(2), this.className)
}
/**
* Computes the header class (`cm.flex({ align: 'center', justify: 'between', gap: 'sm' })`).
* @returns The class string.
*/
headerClasses(): string {
return this.cm().flex({ align: 'center', justify: 'between', gap: 'sm' })
}
/**
* Computes the title class (`cm.textSize('sm')` + `cm.fontWeight('semibold')`).
* @returns The class string.
*/
titleClasses(): string {
return this.cm().cn(this.cm().textSize('sm'), this.cm().fontWeight('semibold'))
}
/**
* Computes the list container class (`cm.stack(1)`).
* @returns The class string.
*/
listClasses(): string {
return this.cm().stack(1)
}
/**
* Applies React's conditions: the `<header>` renders when the title or the
* actions exist (the `<h3>` only for a title, the actions bare); the list
* container renders when the default slot has rows, otherwise the empty
* state renders bare in its place.
*
* @param hasContent - Reads whether a slot has content.
*/
private reconcile(hasContent: SlotReader): void {
const header = this.header?.nativeElement
const title = this.title?.nativeElement
const actions = this.actions?.nativeElement
const list = this.list?.nativeElement
const empty = this.empty?.nativeElement
const hasTitle = hasContent(title)
const hasActions = hasContent(actions)
const hasChildren = hasContent(list)
setElementPresent(header, hasTitle || hasActions)
setElementPresent(title, hasTitle)
// React renders `actions` bare inside the header: the projected content
// sits where the capture wrapper is, and the wrapper itself renders nothing.
if (actions && header) {
placeContent(actions, header, actions)
setElementPresent(actions, false)
}
setElementPresent(list, hasChildren)
// React renders `emptyState` bare in place of the list.
if (empty) {
if (hasChildren) {
placeContent(empty, null)
setElementPresent(empty, false)
} else {
placeContent(empty, this.host.nativeElement, empty)
setElementPresent(empty, false)
}
}
}
}
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 -
Node props are projected content:
titleis selected by[slot=title],actionsby[slot=actions],emptyStateby[slot=emptyState], and the rows are the element's default content. -
emptyStaterenders only when the default content is empty; map your entries directly (as in the example) so the empty case is detectable. -
No
data-mol-idprop; styling resolves throughgetClassMap().