ui

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2026 License: Apache-2.0, MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ui holds the Crest components admin views are made of, for custom admin pages. Use them inside a panel: they rely on its stylesheet, icon sprite, and Alpine components.

In a .crest file, import the package and use qualified tags:

<ui.Card Title="Revenue"><ui.Stat Label="Today" Value={v.Today} /></ui.Card>

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Badge

type Badge struct {
	Text string
	Tone string
}

Badge is a status pill. Tone is neutral, info, success, warning, or danger.

func (Badge) Render

func (b Badge) Render(ctx context.Context, crestW io.Writer) error

func (Badge) RenderSlots

func (b Badge) RenderSlots(crestTrack *slot.Track) slot.Rendered

type Button

type Button struct {
	Label    string
	Href     string
	Type     string
	Variant  string
	Icon     string
	Small    bool
	Disabled bool
}

Button is a button, or a link styled as one when Href is set. Variant is "", "primary", "danger", or "dashed"; Icon names a sprite symbol, such as "plus".

func (Button) Render

func (b Button) Render(ctx context.Context, crestW io.Writer) error

func (Button) RenderSlots

func (b Button) RenderSlots(crestTrack *slot.Track) slot.Rendered

type Card

type Card struct {
	Title    string
	Actions  crest.Component
	Children crest.Component
}

Card is a raised panel with an optional uppercase title and actions.

func (Card) Render

func (c Card) Render(ctx context.Context, crestW io.Writer) error

func (Card) RenderSlots

func (c Card) RenderSlots(crestTrack *slot.Track) slot.Rendered

type Chart

type Chart struct {
	Body crest.Component
}

Chart holds a rendered SVG chart.

func (Chart) Render

func (c Chart) Render(ctx context.Context, crestW io.Writer) error

func (Chart) RenderSlots

func (c Chart) RenderSlots(crestTrack *slot.Track) slot.Rendered

type Column

type Column struct {
	Label   string
	Numeric bool
}

Column is one header cell of a Table. Numeric right-aligns it.

type DataRow

type DataRow struct {
	Label, Value string
}

DataRow is one labeled value of a chart's data table, which screen readers and the "Show data" disclosure read.

type Dialog

type Dialog struct {
	Title    string
	Trigger  string
	Footer   crest.Component
	Children crest.Component
}

Dialog is a modal opened by its trigger button. Children are the body; Footer holds its buttons, and any button with x-on:click="hide" closes it.

func (Dialog) Render

func (d Dialog) Render(ctx context.Context, crestW io.Writer) error

func (Dialog) RenderSlots

func (d Dialog) RenderSlots(crestTrack *slot.Track) slot.Rendered

type EmptyState

type EmptyState struct {
	Icon     string
	Text     string
	Children crest.Component
}

EmptyState fills a card that has nothing to show.

func (EmptyState) Render

func (e EmptyState) Render(ctx context.Context, crestW io.Writer) error

func (EmptyState) RenderSlots

func (e EmptyState) RenderSlots(crestTrack *slot.Track) slot.Rendered

type Field

type Field struct {
	Label    string
	For      string
	Help     string
	Error    string
	Required bool
	Children crest.Component
}

Field is a labeled form control. Children are the control itself; Error and Help are shown under it.

func (Field) Render

func (f Field) Render(ctx context.Context, crestW io.Writer) error

func (Field) RenderSlots

func (f Field) RenderSlots(crestTrack *slot.Track) slot.Rendered

type LegendItem

type LegendItem struct {
	Label, Value, Share, Class string
}

LegendItem is one series of a partition chart. Class picks its color, such as "series-1" or "tone-warning".

type Pagination

type Pagination struct {
	Page     int
	Pages    int
	PrevHref string
	NextHref string
}

Pagination is a pager with previous and next links.

func (Pagination) Render

func (p Pagination) Render(ctx context.Context, crestW io.Writer) error

func (Pagination) RenderSlots

func (p Pagination) RenderSlots(crestTrack *slot.Track) slot.Rendered

type Progress

type Progress struct {
	Label string
	Value int
	Max   int
	Note  string
	Tone  string
}

Progress is a labeled progress bar. Max 0 shows a busy bar.

func (Progress) Render

func (p Progress) Render(ctx context.Context, crestW io.Writer) error

func (Progress) RenderSlots

func (p Progress) RenderSlots(crestTrack *slot.Track) slot.Rendered

type Sparkline

type Sparkline struct {
	Label  string
	Points []int64
	Tone   string
}

Sparkline is a small line chart of Points, oldest first.

func (Sparkline) Render

func (s Sparkline) Render(ctx context.Context, crestW io.Writer) error

func (Sparkline) RenderSlots

func (s Sparkline) RenderSlots(crestTrack *slot.Track) slot.Rendered

type Stat

type Stat struct {
	Label string
	Value string
	Delta string
	Tone  string
}

Stat is a labeled figure, such as a dashboard metric. Delta is shown with Tone, such as "+4.2%" in success.

func (Stat) Render

func (s Stat) Render(ctx context.Context, crestW io.Writer) error

func (Stat) RenderSlots

func (s Stat) RenderSlots(crestTrack *slot.Track) slot.Rendered

type Table

type Table struct {
	Columns   []Column
	Empty     string
	EmptyIcon string
	Rows      int
	Children  crest.Component
}

Table is a data table in a card. Children are the <tr> rows.

func (Table) Render

func (t Table) Render(ctx context.Context, crestW io.Writer) error

func (Table) RenderSlots

func (t Table) RenderSlots(crestTrack *slot.Track) slot.Rendered

type Toast

type Toast struct {
	Text string
	Tone string
}

Toast is a short status message. Tone is success, info, warning, or danger.

func (Toast) Render

func (t Toast) Render(ctx context.Context, crestW io.Writer) error

func (Toast) RenderSlots

func (t Toast) RenderSlots(crestTrack *slot.Track) slot.Rendered

type Widget

type Widget struct {
	Data WidgetData
}

Widget renders one dashboard widget: a figure, a chart, or a table, in a card. Fill Data with sight.WidgetOf on a custom page.

func (Widget) Render

func (w Widget) Render(ctx context.Context, crestW io.Writer) error

func (Widget) RenderSlots

func (w Widget) RenderSlots(crestTrack *slot.Track) slot.Rendered

type WidgetCell

type WidgetCell struct {
	Text    string
	Href    string
	Numeric bool
}

WidgetCell is one cell of a table widget, linked when Href is set.

type WidgetData

type WidgetData struct {
	Key       string
	Kind      string
	Title     string
	Note      string
	Badge     string
	Width     int
	Href      string
	LinkLabel string
	Value     string
	Delta     string
	DeltaTone string
	DeltaIcon string
	Compare   string
	Chart     crest.Component
	Legend    []LegendItem
	Columns   []Column
	Rows      []WidgetRow
	Data      []DataRow
	Empty     string
	Error     string
}

WidgetData is what a Widget shows. Kind is value, trend, partition, or table; Error replaces the body when the widget failed to load.

type WidgetRow

type WidgetRow struct {
	Cells []WidgetCell
}

WidgetRow is one row of a table widget.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL