Hub

Description

Hub is the frame of a top-level page. Its header is a breadcrumb trail that starts at the hub's own name, followed by the page's commands on the right. The page's content goes below it as sections. Hub is a SectionStack, so content is added with .Section(...) and .FlatSection(...), and a section added with grow: true takes the height that is left. A Hub fills the area it is placed in.

The trail takes the width the commands leave and clips what does not fit. Commands keep their own width. When the trail is too narrow, the crumbs between the first and the last are shortened with an ellipsis first; the first crumb keeps its full name.

Each crumb after the first draws its own separator, so calling .Collapse() on a component used as a crumb hides the crumb and its separator together. A crumb with a link is an <a href>: a plain click goes through Router.Navigate, and a middle-click or Ctrl+click opens it in a new tab. The trail is announced to screen readers as a breadcrumb, and the last crumb is marked as the current page.

HubHeader is the same header row without the page around it. Use it to put a header on a SectionStack you manage yourself, or above several groups on one page.

Usage

Create a hub with Hub(title, href), add crumbs with .Crumb(...) and commands with .Commands(...), then add the content as sections.

A header on its own, over a SectionStack with two headed groups:

var groups = SectionStack().S()
   .Title(HubHeader("Organizations", "#/organizations").Commands(Button().SetIcon(UIcons.Search)))
   .Section(organizationCards)
   .Title(HubHeader("People", "#/people").Commands(Button().SetIcon(UIcons.Search)))
   .Section(peopleCards, grow: true);
Method What it does
Hub(title, href) / Hub(title, onClick) / Hub(IObservable<string>, href) / Hub(HubHeader) Creates the page. The title is the first crumb; it links to href or runs onClick when one is given.
.Crumb(text, href) / .Crumb(text, onClick) / .Crumb(IObservable<string>, href) Adds a text crumb. A crumb with neither a link nor an action is the page you are on.
.Crumb(IComponent) / .Crumbs(params IComponent[]) Adds any component as a crumb. Give a text in it the class tss-hub-crumb-label to draw it like the text crumbs.
.Commands(params IComponent[]) Adds commands to the right. The header spaces them, so don't add margins of your own.
Hub.Header The HubHeader.
Hub.Clear() Removes the sections and keeps the header.
HubHeader(...) The header row on its own, with the same Crumb, Crumbs, Commands and ClearCommands methods.

Styling hooks

.tss-hub, .tss-hub-header, .tss-hub-trail, .tss-hub-crumb (.tss-hub-crumb-root on the first crumb), .tss-hub-crumb-text and .tss-hub-crumb-link, .tss-hub-crumb-label, .tss-hub-commands. A collapsed first crumb hides the next crumb's separator by itself. If you hide the first crumb with your own CSS instead, for example on a phone where a page bar already shows the name, also hide .tss-hub-crumb-root + .tss-hub-crumb::before.

See also

API reference

class

Hub

public class Hub : SectionStack

A top-level page: a HubHeader (where you are, as a breadcrumb trail, and what you can do here) above the page's sections. It fills the area it is put in and is a SectionStack, so its content is added with .Section(...) / .FlatSection(...); a section added with grow: true takes the height that is left.

Namespace
Tesserae
Inheritance
SectionStack → Hub

Constructors

NameDescription
HubCreates a hub named title, whose name links to href when one is given.
Constructor
Hub
Overload
Hub(string, string)Creates a hub named title, whose name links to href when one is given.
Hub(IObservable<string>, string)Creates a hub whose name follows title, linking to href when one is given.
Hub(HubHeader)Creates a hub with a header you built.
Hub(string, string)
public Hub(string title, string href = null) : this(new HubHeader(title, href))

Creates a hub named title, whose name links to href when one is given.

Parameters

title string
href string
Hub(IObservable<string>, string)
public Hub(IObservable<string> title, string href = null) : this(new HubHeader(title, href))

Creates a hub whose name follows title, linking to href when one is given.

Parameters

title IObservable<string>
href string
Hub(HubHeader)
public Hub(HubHeader header)

Creates a hub with a header you built.

Parameters

header HubHeader

Properties

NameDescription
HeaderThe header row: the breadcrumb trail and the commands.
Property
Hub.Header
public HubHeader Header { get; }

The header row: the breadcrumb trail and the commands.

Methods

NameDescription
CrumbAdds a text crumb after the ones already in the trail. See Crumb.
CrumbsAdds several component crumbs, in order.
CommandsAdds commands to the right of the header. See Commands.
ClearRemoves every section; the header stays.
Method
Hub.Crumb
Overload
Crumb(string, string)Adds a text crumb after the ones already in the trail. See Crumb.
Crumb(string, Action)Adds a text crumb that runs onClick. See Crumb.
Crumb(IObservable<string>, string)Adds a text crumb that follows text. See Crumb.
Crumb(IComponent)Adds a component as a crumb. See Crumb.
Crumb(string, string)
public Hub Crumb(string text, string href = null)

Adds a text crumb after the ones already in the trail. See Crumb.

Parameters

text string
href string
Crumb(string, Action)
public Hub Crumb(string text, Action onClick)

Adds a text crumb that runs onClick. See Crumb.

Parameters

text string
onClick Action
Crumb(IObservable<string>, string)
public Hub Crumb(IObservable<string> text, string href = null)

Adds a text crumb that follows text. See Crumb.

Parameters

text IObservable<string>
href string
Crumb(IComponent)
public Hub Crumb(IComponent component)

Adds a component as a crumb. See Crumb.

Parameters

component IComponent
Method
Hub.Crumbs
public Hub Crumbs(params IComponent[] components)

Adds several component crumbs, in order.

Method
Hub.Commands
public Hub Commands(params IComponent[] commands)

Adds commands to the right of the header. See Commands.

Method
Hub.Clear
public override void Clear()

Removes every section; the header stays.

class

HubHeader

public sealed class HubHeader : IComponent, IHasMarginPadding

The header row of a Hub: a breadcrumb trail that starts at the hub's own name, followed by the page's commands on the right. The trail takes whatever room the commands leave and clips what does not fit; the commands keep their own width and are never squeezed. Every crumb after the first carries its own separator, so collapsing a crumb (.Collapse() on the component handed to Crumb) takes its separator with it. A Hub builds one of these as its first title. Use it on its own to put the same header on a SectionStack you manage yourself, or above several groups on one page.

Namespace
Tesserae
Implements
IComponent, IHasMarginPadding

Constructors

NameDescription
HubHeaderCreates a header whose first crumb is title, linking to href when one is given.
Constructor
HubHeader
Overload
HubHeader(string, string)Creates a header whose first crumb is title, linking to href when one is given.
HubHeader(string, Action)Creates a header whose first crumb is title, running onClick when it is clicked.
HubHeader(IObservable<string>, string)Creates a header whose first crumb follows title, linking to href when one is given.
HubHeader(IComponent)Creates a header whose first crumb is a component of your own.
HubHeader(string, string)
public HubHeader(string title, string href = null) : this()

Creates a header whose first crumb is title, linking to href when one is given.

Parameters

title string
href string
HubHeader(string, Action)
public HubHeader(string title, Action onClick) : this()

Creates a header whose first crumb is title, running onClick when it is clicked.

Parameters

title string
onClick Action
HubHeader(IObservable<string>, string)
public HubHeader(IObservable<string> title, string href = null) : this()

Creates a header whose first crumb follows title, linking to href when one is given.

Parameters

title IObservable<string>
href string
HubHeader(IComponent)
public HubHeader(IComponent title) : this()

Creates a header whose first crumb is a component of your own.

Parameters

title IComponent

Properties

NameDescription
MarginGets or sets the CSS margin of the header.
PaddingGets or sets the CSS padding of the header.
Property
HubHeader.Margin
public string Margin { get ; set ; }

Gets or sets the CSS margin of the header.

Property
HubHeader.Padding
public string Padding { get ; set ; }

Gets or sets the CSS padding of the header.

Methods

NameDescription
CrumbAdds a text crumb, linking to href when one is given. A crumb without a link is the page you are on.
CrumbsAdds several crumbs, in order.
CommandsAdds commands to the right of the trail. They keep their own width; use the gap the header puts between them rather than a margin of your own.
ClearCommandsRemoves every command.
RenderRenders the header.
Method
HubHeader.Crumb
Overload
Crumb(string, string)Adds a text crumb, linking to href when one is given. A crumb without a link is the page you are on.
Crumb(string, Action)Adds a text crumb that runs onClick when clicked.
Crumb(IObservable<string>, string)Adds a text crumb that follows text, linking to href when one is given.
Crumb(IComponent)Adds a component as a crumb - a picker, a title with an avatar, a name that changes. Collapsing the component hides the crumb and its separator together.
Crumb(string, string)
public HubHeader Crumb(string text, string href = null)

Adds a text crumb, linking to href when one is given. A crumb without a link is the page you are on.

Parameters

text string
href string
Crumb(string, Action)
public HubHeader Crumb(string text, Action onClick)

Adds a text crumb that runs onClick when clicked.

Parameters

text string
onClick Action
Crumb(IObservable<string>, string)
public HubHeader Crumb(IObservable<string> text, string href = null)

Adds a text crumb that follows text, linking to href when one is given.

Parameters

text IObservable<string>
href string
Crumb(IComponent)
public HubHeader Crumb(IComponent component)

Adds a component as a crumb - a picker, a title with an avatar, a name that changes. Collapsing the component hides the crumb and its separator together.

Parameters

component IComponent
Method
HubHeader.Crumbs
public HubHeader Crumbs(params IComponent[] components)

Adds several crumbs, in order.

Method
HubHeader.Commands
public HubHeader Commands(params IComponent[] commands)

Adds commands to the right of the trail. They keep their own width; use the gap the header puts between them rather than a margin of your own.

Method
HubHeader.ClearCommands
public HubHeader ClearCommands()

Removes every command.

Method
HubHeader.Render
public HTMLElement Render()

Renders the header.