Page Title

A document's big title, icon, cover and properties.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/page-title

Usage

import { PageTitle } from "./ui/uicontext/components/kit/PageTitle.ts"
const Message = UiSchema.TaggedEnum({	RenamedPage: { title: Schema.String },	ChoseIcon: { icon: Schema.NullOr(Schema.String) },	ChoseCover: { cover: Schema.NullOr(Schema.String) },})export const Title = (h: Html.H<typeof Message.Type>, page: { title: string; icon: string | null; cover: string | null }) =>	PageTitle(h, {		props: { id: "page-title", title: page.title, icon: page.icon, cover: page.cover },		onEmit: {			RequestedTitle: ({ title }) => Message.RenamedPage({ title }),			RequestedIcon: ({ icon }) => Message.ChoseIcon({ icon }),			RequestedCover: ({ cover }) => Message.ChoseCover({ cover }),		},	})

Examples

With properties

A page that is a database record passes record, and its fields show under the title.

Status
In review
Owner
Noor Haddad
Due
Mar 31

An image cover

Reposition an image cover by dragging it or with the arrow keys; RequestedCover brings back its position.

Read-only

With can: [] the title is a heading and the icon and cover can't change, for a guest or a locked page.

🧾

Travel and expenses policy

API reference

Props

PageTitle props
NameTypeDefaultDescription
idrequiredstring—Unique on the page
titlerequiredstring—The page's title; edits come back as RequestedTitle
iconstring | null—An emoji, or null for none
coverstring | null—An image address, or "gradient:<name>" for a built-in gradient; null for none
coverPositionnumber50Where an image cover sits vertically, from 0 (its top) to 100 (its bottom); 50 by default
placeholderstring"Untitled"What an empty title shows; "Untitled" by default
bodystring—The page's body: the id of the Editor that Enter at the end of the title goes on to
record{ fields, item }—A page that is a record: its fields and values, shown read-only under the title
iconsstring[]—The icons to offer
coversstring[]—The covers to offer: image addresses or gradients; the built-in gradients by default
canCan(["edit"])"edit""edit" by default: without it the title, icon and cover can't change
widthnumber—The column's width in pixels (720)
localestring—The locale numbers and dates are formatted in; the browser's by default

Events

PageTitle events
EventPayloadDescription
RequestedTitle{ id: string; title: string }The person changed the title
RequestedIcon{ id: string; icon: string | null }The person picked an icon, or removed it (null)
RequestedCover{ id: string; cover: string | null; position?: number }The person picked a cover, or removed it (null); after a reposition, position is where it sits (0–100)

Accessibility

  • The title is a labelled text field; Enter or Down at its end moves into the page's body.
  • Add icon and Add cover show on hover and on keyboard focus. The icon and cover pickers are popovers that close with Escape.
  • A database page's properties are a description list of names and values.

Source