← Public packages
@kody/example-reading-list
A small reading list app built from the app starter: warm theme, mobile layout, sign-in, and saved books.
Files
import type { ButtonHTMLAttributes, InputHTMLAttributes, ReactNode } from 'react'
import { useId } from 'react'
export function Button({
variant = 'secondary',
...props
}: ButtonHTMLAttributes<HTMLButtonElement> & { variant?: 'primary' | 'secondary' }) {
return <button className="button" data-variant={variant} {...props} />
}
/** A text input that always has a visible label tied to it. */
export function TextField({
label,
...props
}: InputHTMLAttributes<HTMLInputElement> & { label: string }) {
const id = useId()
return (
<div className="field">
<label htmlFor={id}>{label}</label>
<input id={id} {...props} />
</div>
)
}
export function Alert(props: { title: string; children?: ReactNode }) {
return (
<div className="alert" role="alert">
<strong>{props.title}</strong>
{props.children ? <div>{props.children}</div> : null}
</div>
)
}
/** Placeholder rows shown while data loads, announced to screen readers. */
export function LoadingRows(props: { label: string; rows?: number }) {
return (
<div role="status" aria-live="polite" style={{ display: 'grid', gap: 8 }}>
<span className="visually-hidden">{props.label}</span>
{Array.from({ length: props.rows ?? 3 }, (_, index) => (
<div key={index} className="skeleton" aria-hidden="true" />
))}
</div>
)
}
export function EmptyState(props: { children: ReactNode }) {
return <p className="muted">{props.children}</p>
}