Description

A sidebar navigation component

A fully featured Sidebar with Search, Navigation, Buttons, and Separators.

A sidebar can also shift into a second sidebar instead of being torn down and rebuilt, which is what navigating into an interface that has navigation of its own (a chat view, a project workspace) usually needs. ShiftTo(child) slides the track sideways by one full width to the child's panel, ShiftBack() returns, IsShifted / ShiftedSidebar read the state and OnShiftChanged reports it. The child renders inside the host and follows its open/closed state; the panel that ends up out of view is taken out of the tab and reading order once the transition finishes. It is one level deep, and ignored while the sidebar renders as a navbar.

A collapsed SidebarNav expands itself when a child, or a nested descendant, becomes selected, and scrolls the item into view, so the row marking the current page cannot sit invisible inside a closed group. Only selection changes trigger it: the user can still collapse the group by hand while the same item stays selected. Observe selection yourself through SidebarButton.SelectedStatus / SidebarNav.SelectedStatus (both IObservable<bool>), and opt a group out of the automatic expansion with KeepCollapsedOnSelection().

SidebarSearchBox can be driven by its host: Text / SetText(...) write into the box without raising OnSearch, and Focus() puts the caret in it.

Sample

API reference

class

SidebarButton

public class SidebarButton : ISearchableSidebarItem

A Button component for use within a Sidebar, supporting both open and closed states.

Namespace
Tesserae
Implements
ISearchableSidebarItem

Properties

NameDescription
IsSelectedGets or sets whether the button is currently selected.
SelectedStatusGets an observable for the selected status.
CurrentRenderedGets the component that is currently rendered.
IdentifierGets the full identifier of the button.
OwnIdentifierGets the own identifier of the button.
Property
SidebarButton.IsSelected
public bool IsSelected { get ; set ; }

Gets or sets whether the button is currently selected.

Property
SidebarButton.SelectedStatus
public IObservable<bool> SelectedStatus

Gets an observable for the selected status.

Property
SidebarButton.CurrentRendered
public IComponent CurrentRendered

Gets the component that is currently rendered.

Property
SidebarButton.Identifier
public string Identifier { get; private set; }

Gets the full identifier of the button.

Property
SidebarButton.OwnIdentifier
public string OwnIdentifier

Gets the own identifier of the button.

Methods

NameDescription
AddGroupIdentifierAdds a group identifier prefix to the button's identifier.
ReserveRoomForCommandsMarks the row as one that has commands, and says how wide its strip of them is - each is a 22px button with a 4px gap between them. Only the row knows how many it has, so it writes both here and the stylesheet reads them back to lay the label out beside the strip wherever the strip is permanent - always-visible, or selected. On hover the label keeps the full width of the rail and fades out into the row where the commands begin instead (see tss-sidebar-has-commands and the scrim on it in tss.sidebar.css).
TrackBadgeWidthMarks the row as one that carries a badge, and keeps how wide the badge is up to date. A badge is drawn over the row's right edge the way the commands are, so the name has to give way to it or a long one runs underneath the glyph - which is what a shared-space icon sitting on the last letters of the space's name was. The stylesheet keeps room for it at rest and fades the name out into it under the pointer, and both are sized from how wide the badge is. Unlike the commands there is no count to compute that from - a badge is an icon, or "+3", or "+1,204" - so it is measured, and re-measured whenever its text changes, and written where the stylesheet reads it back (see tss-sidebar-has-badge in tss.sidebar.css). The badge is hidden with visibility rather than display where the commands take its place, so the measurement stays true.
ShowShows the button.
CollapseCollapses the button.
NotSortableMarks the button as not sortable.
ClearProgressClears the progress indication background.
ProgressSets a progress indication background.
SetTextSets the text of the button.
CommandsAlwaysVisibleEnsures that commands associated with the button are always visible when the sidebar is open.
LightSets the button to use a light style.
RoundedRenders the button with rounded corners (defaults to a fully rounded "pill" shape), matching the rounded SidebarSearchBox style.
OutlinedDraws the button with a field's chrome - a border and the secondary surface behind it - instead of as a bare row. What a rail's own action wants when it stands next to a search box: the same outline, so the two read as a pair of controls rather than as a button beside a form field. Only the open button takes it; around a single glyph on the closed rail an outline is just a box.
AsSearchBoxDresses the button as a search field: a rounded outline, the label set as a placeholder rather than as a label, and - when keys are given - the shortcut that reaches it shown at the far end. For a search that answers somewhere else, which is most of them now: what the box would be for happens in a palette or on a page, so the thing on the rail only has to look like where a search starts and be pressable. A real input would take a caret it has nothing to do with.
SetKeyboardShortcutShows the shortcut that presses this button at its far end, and answers that shortcut for as long as the button is on screen - which is what makes the chip a promise rather than a note. The keys are the ones KeyboardShortcut displays, so ("Ctrl", "Shift", "O") reads Ctrl+Shift+O and triggers on ⌘⇧O on a Mac. Only the open button carries the chip - the closed rail has room for the glyph and nothing else - but the key works on either, because a collapsed rail is a smaller rail and not a different one. A button that is nowhere on screen holds no shortcut: there is nothing for the key to press.
ShortcutOnlyOnHoverKeeps the shortcut chip out of sight until the pointer is on the row - or something inside it has focus, so a row reached by tabbing shows its key too. The binding is untouched: the key works the same whether or not the chip is on screen. For a rail where most rows carry a key: all the chips at once read as a column of noise beside the labels, while one chip on the row being pointed at is still how the key gets discovered. The room at the end stays reserved either way, so a label does not re-flow as the chip appears.
ButtonOnScreenWhichever of the two renderings the user can actually see, or null when neither is. Mounted is not enough on its own: both are mounted at once while the sidebar hides the one it is not showing, and a collapsed button is mounted too.
DangerSets the button to use a danger style.
WarningSets the button to use a warning style.
DefaultSets the button to use the default style.
SuccessSets the button to use a success style.
PrimarySets the button to use the primary style.
SelectedSets whether the button is selected.
TooltipSets a tooltip for the closed state button.
OpenedTooltipSets a tooltip for the open state button.
OnClickAdds a click event handler to the button.
OnOpenIconClickAdds a click event handler to the icon when the button is open.
IdSets the ID of the button.
OnContextMenuAdds a context menu event handler to the button.
SetIconSets the icon for the button.
OnRenderedAdds a rendered event handler.
RenderClosedRenders the button for the closed state of the sidebar.
RenderOpenRenders the button for the open state of the sidebar.
Method
SidebarButton.AddGroupIdentifier
public void AddGroupIdentifier(string groupIdentifier)

Adds a group identifier prefix to the button's identifier.

Method
SidebarButton.ReserveRoomForCommands
private static void ReserveRoomForCommands(HTMLElement wrapper, int commandCount)

Marks the row as one that has commands, and says how wide its strip of them is - each is a 22px button with a 4px gap between them. Only the row knows how many it has, so it writes both here and the stylesheet reads them back to lay the label out beside the strip wherever the strip is permanent - always-visible, or selected. On hover the label keeps the full width of the rail and fades out into the row where the commands begin instead (see tss-sidebar-has-commands and the scrim on it in tss.sidebar.css).

Method
SidebarButton.TrackBadgeWidth
private void TrackBadgeWidth(HTMLElement wrapper, HTMLElement badges)

Marks the row as one that carries a badge, and keeps how wide the badge is up to date. A badge is drawn over the row's right edge the way the commands are, so the name has to give way to it or a long one runs underneath the glyph - which is what a shared-space icon sitting on the last letters of the space's name was. The stylesheet keeps room for it at rest and fades the name out into it under the pointer, and both are sized from how wide the badge is. Unlike the commands there is no count to compute that from - a badge is an icon, or "+3", or "+1,204" - so it is measured, and re-measured whenever its text changes, and written where the stylesheet reads it back (see tss-sidebar-has-badge in tss.sidebar.css). The badge is hidden with visibility rather than display where the commands take its place, so the measurement stays true.

Method
SidebarButton.Show
public void Show()

Shows the button.

Method
SidebarButton.Collapse
public void Collapse()

Collapses the button.

Method
SidebarButton.NotSortable
public SidebarButton NotSortable()

Marks the button as not sortable.

Returns

The current instance of the type.

Method
SidebarButton.ClearProgress
public SidebarButton ClearProgress()

Clears the progress indication background.

Returns

The current instance of the type.

Method
SidebarButton.Progress
public SidebarButton Progress(float progress)

Sets a progress indication background.

Parameters

progress
The progress value (0 to 1).

Returns

The current instance of the type.

Method
SidebarButton.SetText
public SidebarButton SetText(string text)

Sets the text of the button.

Parameters

text
The text.

Returns

The current instance of the type.

Method
SidebarButton.CommandsAlwaysVisible
public SidebarButton CommandsAlwaysVisible(bool alwaysVisible = true)

Ensures that commands associated with the button are always visible when the sidebar is open.

Returns

The current instance of the type.

Method
SidebarButton.Light
public SidebarButton Light()

Sets the button to use a light style.

Returns

The current instance of the type.

Method
SidebarButton.Rounded
public SidebarButton Rounded(BorderRadius radius = BorderRadius.Full)

Renders the button with rounded corners (defaults to a fully rounded "pill" shape), matching the rounded SidebarSearchBox style.

Parameters

radius
The border radius to apply. Defaults to Full.

Returns

The current instance of the type.

Method
SidebarButton.Outlined
public SidebarButton Outlined()

Draws the button with a field's chrome - a border and the secondary surface behind it - instead of as a bare row. What a rail's own action wants when it stands next to a search box: the same outline, so the two read as a pair of controls rather than as a button beside a form field. Only the open button takes it; around a single glyph on the closed rail an outline is just a box.

Returns

The current instance of the type.

Method
SidebarButton.AsSearchBox
public SidebarButton AsSearchBox(params string[] shortcutKeys)

Dresses the button as a search field: a rounded outline, the label set as a placeholder rather than as a label, and - when keys are given - the shortcut that reaches it shown at the far end. For a search that answers somewhere else, which is most of them now: what the box would be for happens in a palette or on a page, so the thing on the rail only has to look like where a search starts and be pressable. A real input would take a caret it has nothing to do with.

Parameters

shortcutKeys
The keys to show at the end, e.g. ("Ctrl", "K"). None hides it. The chip is a label only - use SetKeyboardShortcut for the key to press the button as well, which a search that answers somewhere else usually does not want: the palette or page it opens owns that key, and answers it from inside a text field too, where a button's shortcut steps aside.
Method
SidebarButton.SetKeyboardShortcut
public SidebarButton SetKeyboardShortcut(params string[] keys)

Shows the shortcut that presses this button at its far end, and answers that shortcut for as long as the button is on screen - which is what makes the chip a promise rather than a note. The keys are the ones KeyboardShortcut displays, so ("Ctrl", "Shift", "O") reads Ctrl+Shift+O and triggers on ⌘⇧O on a Mac. Only the open button carries the chip - the closed rail has room for the glyph and nothing else - but the key works on either, because a collapsed rail is a smaller rail and not a different one. A button that is nowhere on screen holds no shortcut: there is nothing for the key to press.

Parameters

keys
The keys, e.g. ("Ctrl", "Shift", "O"). None removes chip and binding.
Method
SidebarButton.ShortcutOnlyOnHover
public SidebarButton ShortcutOnlyOnHover(bool onlyOnHover = true)

Keeps the shortcut chip out of sight until the pointer is on the row - or something inside it has focus, so a row reached by tabbing shows its key too. The binding is untouched: the key works the same whether or not the chip is on screen. For a rail where most rows carry a key: all the chips at once read as a column of noise beside the labels, while one chip on the row being pointed at is still how the key gets discovered. The room at the end stays reserved either way, so a label does not re-flow as the chip appears.

Parameters

onlyOnHover
Whether the chip waits for a hover. False shows it at all times, the default.
Method
SidebarButton.ButtonOnScreen
private Button ButtonOnScreen()

Whichever of the two renderings the user can actually see, or null when neither is. Mounted is not enough on its own: both are mounted at once while the sidebar hides the one it is not showing, and a collapsed button is mounted too.

Method
SidebarButton.Danger
public SidebarButton Danger()

Sets the button to use a danger style.

Returns

The current instance of the type.

Method
SidebarButton.Warning
public SidebarButton Warning()

Sets the button to use a warning style.

Returns

The current instance of the type.

Method
SidebarButton.Default
public SidebarButton Default()

Sets the button to use the default style.

Returns

The current instance of the type.

Method
SidebarButton.Success
public SidebarButton Success()

Sets the button to use a success style.

Returns

The current instance of the type.

Method
SidebarButton.Primary
public SidebarButton Primary()

Sets the button to use the primary style.

Returns

The current instance of the type.

Method
SidebarButton.Selected
public SidebarButton Selected(bool isSelected = true)

Sets whether the button is selected.

Parameters

isSelected
Whether the button is selected.

Returns

The current instance of the type.

Method
SidebarButton.Tooltip
Overload
Tooltip(string)Sets a tooltip for the closed state button.
Tooltip(IComponent)Sets a tooltip component for the closed state button.
Tooltip(Func<IComponent>)Sets a tooltip generator function for the closed state button.
Tooltip(string)
public SidebarButton Tooltip(string text)

Sets a tooltip for the closed state button.

Parameters

text string
The tooltip text.

Returns

The current instance of the type.

Tooltip(IComponent)
public SidebarButton Tooltip(IComponent tooltip)

Sets a tooltip component for the closed state button.

Parameters

tooltip IComponent
The tooltip component.

Returns

The current instance of the type.

Tooltip(Func<IComponent>)
public SidebarButton Tooltip(Func<IComponent> tooltip)

Sets a tooltip generator function for the closed state button.

Parameters

tooltip Func<IComponent>
The tooltip generator function.

Returns

The current instance of the type.

Method
SidebarButton.OpenedTooltip
Overload
OpenedTooltip(string)Sets a tooltip for the open state button.
OpenedTooltip(IComponent)Sets a tooltip component for the open state button.
OpenedTooltip(Func<IComponent>)Sets a tooltip generator function for the open state button.
OpenedTooltip(string)
public SidebarButton OpenedTooltip(string text)

Sets a tooltip for the open state button.

Parameters

text string
The tooltip text.

Returns

The current instance of the type.

OpenedTooltip(IComponent)
public SidebarButton OpenedTooltip(IComponent tooltip)

Sets a tooltip component for the open state button.

Parameters

tooltip IComponent
The tooltip component.

Returns

The current instance of the type.

OpenedTooltip(Func<IComponent>)
public SidebarButton OpenedTooltip(Func<IComponent> tooltip)

Sets a tooltip generator function for the open state button.

Parameters

tooltip Func<IComponent>
The tooltip generator function.

Returns

The current instance of the type.

Method
SidebarButton.OnClick
Overload
OnClick(Action)Adds a click event handler to the button.
OnClick(Action<Button, MouseEvent>)Adds a click event handler with button and mouse event arguments.
OnClick(Action)
public SidebarButton OnClick(Action action)

Adds a click event handler to the button.

Parameters

action Action
The event handler action.

Returns

The current instance of the type.

OnClick(Action<Button, MouseEvent>)
public SidebarButton OnClick(Action<Button, MouseEvent> action)

Adds a click event handler with button and mouse event arguments.

Parameters

action Action<Button, MouseEvent>
The event handler action.

Returns

The current instance of the type.

Method
SidebarButton.OnOpenIconClick
Overload
OnOpenIconClick(Action<HTMLElement, MouseEvent>)Adds a click event handler to the icon when the button is open.
OnOpenIconClick(Action)Adds a click event handler to the icon when the button is open.
OnOpenIconClick(Action<HTMLElement, MouseEvent>)
public SidebarButton OnOpenIconClick(Action<HTMLElement, MouseEvent> action)

Adds a click event handler to the icon when the button is open.

Parameters

action Action<HTMLElement, MouseEvent>
The event handler action.

Returns

The current instance of the type.

OnOpenIconClick(Action)
public SidebarButton OnOpenIconClick(Action action)

Adds a click event handler to the icon when the button is open.

Parameters

action Action
The event handler action.

Returns

The current instance of the type.

Method
SidebarButton.Id
public SidebarButton Id(string id)

Sets the ID of the button.

Parameters

id
The ID.

Returns

The current instance of the type.

Method
SidebarButton.OnContextMenu
Overload
OnContextMenu(Action)Adds a context menu event handler to the button.
OnContextMenu(Action<Button, MouseEvent>)Adds a context menu event handler with button and mouse event arguments.
OnContextMenu(Action)
public SidebarButton OnContextMenu(Action action)

Adds a context menu event handler to the button.

Parameters

action Action
The event handler action.

Returns

The current instance of the type.

OnContextMenu(Action<Button, MouseEvent>)
public SidebarButton OnContextMenu(Action<Button, MouseEvent> action)

Adds a context menu event handler with button and mouse event arguments.

Parameters

action Action<Button, MouseEvent>
The event handler action.

Returns

The current instance of the type.

Method
SidebarButton.SetIcon
Overload
SetIcon(UIcons, string, UIconsWeight)Sets the icon for the button.
SetIcon(Emoji)Sets an emoji icon for the button.
SetIcon(UIcons, string, UIconsWeight)
public SidebarButton SetIcon(UIcons icon, string color = "", UIconsWeight weight = UIconsWeight.Regular)

Sets the icon for the button.

Parameters

icon UIcons
The icon.
color string
The color of the icon.
weight UIconsWeight
The weight of the icon.

Returns

The current instance of the type.

SetIcon(Emoji)
public SidebarButton SetIcon(Emoji icon)

Sets an emoji icon for the button.

Parameters

icon Emoji
The emoji icon.

Returns

The current instance of the type.

Method
SidebarButton.OnRendered
public ISidebarItem OnRendered(Action<HTMLElement> onRendered)

Adds a rendered event handler.

Parameters

onRendered
The rendered event handler.

Returns

The current instance of the type.

Method
SidebarButton.RenderClosed
public IComponent RenderClosed()

Renders the button for the closed state of the sidebar.

Method
SidebarButton.RenderOpen
public IComponent RenderOpen()

Renders the button for the open state of the sidebar.

class

SidebarPivot

public sealed class SidebarPivot : ISearchableSidebarItem
Namespace
Tesserae
Implements
ISearchableSidebarItem
class

SidebarNav

public class SidebarNav : ISearchableSidebarItem

A hierarchical navigation component for use within a Sidebar, allowing for nested ISidebarItem elements.

Namespace
Tesserae
Implements
ISearchableSidebarItem

Properties

NameDescription
IsCollapsedGets or sets whether the navigation is collapsed.
IsSelectedGets or sets whether the navigation is currently selected.
CollapsedStatusGets an observable for the collapsed status.
SelectedStatusGets an observable for the selected status.
CurrentRenderedGets the component that is currently rendered.
HasClickActionWhether the header does something when pressed, beyond expanding the group.
TextThe group's name, for a surface that shows the group apart from its header.
IdentifierGets the full identifier of the navigation component.
OwnIdentifierGets the own identifier of the navigation component.
Property
SidebarNav.IsCollapsed
public bool IsCollapsed { get ; set ; }

Gets or sets whether the navigation is collapsed.

Property
SidebarNav.IsSelected
public bool IsSelected { get ; set ; }

Gets or sets whether the navigation is currently selected.

Property
SidebarNav.CollapsedStatus
public IObservable<bool> CollapsedStatus

Gets an observable for the collapsed status.

Property
SidebarNav.SelectedStatus
public IObservable<bool> SelectedStatus

Gets an observable for the selected status.

Property
SidebarNav.CurrentRendered
public IComponent CurrentRendered

Gets the component that is currently rendered.

Property
SidebarNav.HasClickAction
internal bool HasClickAction { get; private set; }

Whether the header does something when pressed, beyond expanding the group.

Property
SidebarNav.Text
internal string Text

The group's name, for a surface that shows the group apart from its header.

Property
SidebarNav.Identifier
public string Identifier { get; private set; }

Gets the full identifier of the navigation component.

Property
SidebarNav.OwnIdentifier
public string OwnIdentifier

Gets the own identifier of the navigation component.

Methods

NameDescription
ShowShows the navigation component.
CollapseCollapses the navigation component.
NotSortableMarks the navigation component as not sortable.
SetTextSets the header text of the navigation.
CollapsedSets whether the navigation is collapsed.
SelectedSets whether the navigation is selected.
ToggleToggles the collapsed state.
KeepCollapsedOnSelectionKeeps the navigation collapsed when one of its items becomes selected. By default a collapsed navigation expands itself when a child (or a nested descendant) becomes selected, so the current selection is never hidden from the user.
OnOpenIconClickAdds a click event handler to the open header icon.
PressHeaderPresses the header, as a click on it would - what the group's own row does.
OnClickAdds a click event handler to the navigation header.
OnContextMenuAdds a context menu event handler.
ClearClears all items from the navigation.
AddAdds an item to the navigation.
RemoveRemoves an item from the navigation.
AddRangeAdds a range of items to the navigation.
RenderClosedRenders the navigation for the closed state of the sidebar.
RenderOpenRenders the navigation for the open state of the sidebar.
OnRenderedAdds a rendered event handler.
AddGroupIdentifierAdds a group identifier prefix to the navigation component's identifier.
LoadSortingLoads the sorting order for navigation items.
GetCurrentSortingGets the current sorting order of all items within this navigation.
SortableSets whether items within this navigation are sortable.
OnSortingChangedAdds a sorting change event handler.
OnParentChangedAdds a parent changed event handler, for cross-nav sorting.
Method
SidebarNav.Show
public void Show()

Shows the navigation component.

Method
SidebarNav.Collapse
public void Collapse()

Collapses the navigation component.

Method
SidebarNav.NotSortable
public SidebarNav NotSortable()

Marks the navigation component as not sortable.

Returns

The current instance of the type.

Method
SidebarNav.SetText
public SidebarNav SetText(string text)

Sets the header text of the navigation.

Parameters

text
The text.

Returns

The current instance of the type.

Method
SidebarNav.Collapsed
public SidebarNav Collapsed(bool isCollapsed = true)

Sets whether the navigation is collapsed.

Parameters

isCollapsed
Whether it is collapsed.

Returns

The current instance of the type.

Method
SidebarNav.Selected
public SidebarNav Selected(bool isSelected = true)

Sets whether the navigation is selected.

Parameters

isSelected
Whether it is selected.

Returns

The current instance of the type.

Method
SidebarNav.Toggle
public SidebarNav Toggle()

Toggles the collapsed state.

Returns

The current instance of the type.

Method
SidebarNav.KeepCollapsedOnSelection
public SidebarNav KeepCollapsedOnSelection(bool keepCollapsed = true)

Keeps the navigation collapsed when one of its items becomes selected. By default a collapsed navigation expands itself when a child (or a nested descendant) becomes selected, so the current selection is never hidden from the user.

Parameters

keepCollapsed
Whether to suppress the automatic expansion on selection.

Returns

The current instance of the type.

Method
SidebarNav.OnOpenIconClick
Overload
OnOpenIconClick(Action<HTMLElement, MouseEvent>)Adds a click event handler to the open header icon.
OnOpenIconClick(Action)Adds a click event handler to the open header icon.
OnOpenIconClick(Action<HTMLElement, MouseEvent>)
public SidebarNav OnOpenIconClick(Action<HTMLElement, MouseEvent> action)

Adds a click event handler to the open header icon.

Parameters

action Action<HTMLElement, MouseEvent>
The event handler action.

Returns

The current instance of the type.

OnOpenIconClick(Action)
public SidebarNav OnOpenIconClick(Action action)

Adds a click event handler to the open header icon.

Parameters

action Action
The event handler action.

Returns

The current instance of the type.

Method
SidebarNav.PressHeader
internal void PressHeader()

Presses the header, as a click on it would - what the group's own row does.

Method
SidebarNav.OnClick
Overload
OnClick(Action)Adds a click event handler to the navigation header.
OnClick(Action<SidebarNav>)Adds a click event handler with SidebarNav argument.
OnClick(Action<Button, MouseEvent>)Adds a click event handler with button and mouse event arguments.
OnClick(Action)
public SidebarNav OnClick(Action action)

Adds a click event handler to the navigation header.

Parameters

action Action
The event handler action.

Returns

The current instance of the type.

OnClick(Action<SidebarNav>)
public SidebarNav OnClick(Action<SidebarNav> action)

Adds a click event handler with SidebarNav argument.

Parameters

action Action<SidebarNav>
The event handler action.

Returns

The current instance of the type.

OnClick(Action<Button, MouseEvent>)
public SidebarNav OnClick(Action<Button, MouseEvent> action)

Adds a click event handler with button and mouse event arguments.

Parameters

action Action<Button, MouseEvent>
The event handler action.

Returns

The current instance of the type.

Method
SidebarNav.OnContextMenu
Overload
OnContextMenu(Action)Adds a context menu event handler.
OnContextMenu(Action<Button, MouseEvent>)Adds a context menu event handler with button and mouse event arguments.
OnContextMenu(Action)
public SidebarNav OnContextMenu(Action action)

Adds a context menu event handler.

Parameters

action Action
The event handler action.

Returns

The current instance of the type.

OnContextMenu(Action<Button, MouseEvent>)
public SidebarNav OnContextMenu(Action<Button, MouseEvent> action)

Adds a context menu event handler with button and mouse event arguments.

Parameters

action Action<Button, MouseEvent>
The event handler action.

Returns

The current instance of the type.

Method
SidebarNav.Clear
public void Clear()

Clears all items from the navigation.

Method
SidebarNav.Add
public void Add(ISidebarItem item)

Adds an item to the navigation.

Parameters

item
The item to add.
Method
SidebarNav.Remove
public void Remove(ISidebarItem item)

Removes an item from the navigation.

Parameters

item
The item to remove.
Method
SidebarNav.AddRange
public SidebarNav AddRange(IEnumerable<ISidebarItem> items)

Adds a range of items to the navigation.

Parameters

items
The items to add.

Returns

The current instance of the type.

Method
SidebarNav.RenderClosed
public IComponent RenderClosed()

Renders the navigation for the closed state of the sidebar.

Method
SidebarNav.RenderOpen
public IComponent RenderOpen()

Renders the navigation for the open state of the sidebar.

Method
SidebarNav.OnRendered
public ISidebarItem OnRendered(Action<HTMLElement> onRendered)

Adds a rendered event handler.

Parameters

onRendered
The rendered event handler.

Returns

The current instance of the type.

Method
SidebarNav.AddGroupIdentifier
public void AddGroupIdentifier(string groupIdentifier)

Adds a group identifier prefix to the navigation component's identifier.

Method
SidebarNav.LoadSorting
public void LoadSorting(Dictionary<string, string[]> itemOrder)

Loads the sorting order for navigation items.

Parameters

itemOrder
A dictionary mapping group identifiers to ordered item identifiers.
Method
SidebarNav.GetCurrentSorting
public Dictionary<string, string[]> GetCurrentSorting()

Gets the current sorting order of all items within this navigation.

Returns

A dictionary mapping group identifiers to ordered item identifiers.

Method
SidebarNav.Sortable
public SidebarNav Sortable(bool sortable = true, string sortableGroup = null)

Sets whether items within this navigation are sortable.

Parameters

sortable
Whether items are sortable.
sortableGroup
An optional group name for cross-nav sorting.

Returns

The current instance of the type.

Method
SidebarNav.OnSortingChanged
public SidebarNav OnSortingChanged(Action<Dictionary<string, string[]>> onSortingChanged)

Adds a sorting change event handler.

Parameters

onSortingChanged
The event handler action.

Returns

The current instance of the type.

Method
SidebarNav.OnParentChanged
public SidebarNav OnParentChanged(Action<ParentChangedEvent> onParentChanged)

Adds a parent changed event handler, for cross-nav sorting.

Parameters

onParentChanged
The event handler action.

Returns

The current instance of the type.

Events

NameDescription
_onSortingChangedEvent fired when sorting changes within the navigation.
Event
SidebarNav._onSortingChanged
public event Action<Dictionary<string, string[]>> _onSortingChanged

Event fired when sorting changes within the navigation.

Fields

NameDescription
KeepCollapsedClassA group that keeps its selection hidden says the selection is not the page the user is on (a theme picker, a mode switch), so a stylesheet that marks the group holding the current page can leave it out.
Field
SidebarNav.KeepCollapsedClass
private const string KeepCollapsedClass = "tss-sidebar-nav-keep-collapsed"

A group that keeps its selection hidden says the selection is not the page the user is on (a theme picker, a mode switch), so a stylesheet that marks the group holding the current page can leave it out.

class

SidebarSearchBox

public class SidebarSearchBox : ISidebarItem
Namespace
Tesserae
Implements
ISidebarItem

Properties

NameDescription
TextThe text in the box. Setting it does not raise OnSearch - a caller that clears the box usually has its own idea of what to do about the results.
Property
SidebarSearchBox.Text
public string Text { get ; set ; }

The text in the box. Setting it does not raise OnSearch - a caller that clears the box usually has its own idea of what to do about the results.

Methods

NameDescription
RoundedRenders the search box with rounded corners (defaults to a fully rounded "pill" shape, like the rounded SidebarButton). Removes the underlined style so the box shows a full rounded border.
SetTextSets the text in the box, without raising OnSearch.
FocusPuts the caret in the box.
OnClickMakes the box a way in rather than a place to type: clicking it - open, or as the icon on the closed rail - runs the handler, and so does focusing it, which is what SetKeyboardShortcut does. Nothing can be typed into it, because what is typed belongs to whatever the handler opened. This is the shape a search that answers somewhere else takes: the box says where to start and which key gets there, and a palette or a page does the searching.
ShortcutOnlyOnHoverKeeps the shortcut chip out of sight until the pointer is on the box - or the caret is in it, so a box reached by tabbing shows its key too. The binding is untouched: the key works the same whether or not the chip is on screen. The room the chip takes at the end is reserved either way, so what is typed does not re-flow as the chip appears.
Method
SidebarSearchBox.Rounded
public SidebarSearchBox Rounded(BorderRadius radius = BorderRadius.Full)

Renders the search box with rounded corners (defaults to a fully rounded "pill" shape, like the rounded SidebarButton). Removes the underlined style so the box shows a full rounded border.

Parameters

radius
The border radius to apply. Defaults to Full.

Returns

The current instance of the type.

Method
SidebarSearchBox.SetText
public SidebarSearchBox SetText(string text)

Sets the text in the box, without raising OnSearch.

Method
SidebarSearchBox.Focus
public SidebarSearchBox Focus()

Puts the caret in the box.

Method
SidebarSearchBox.OnClick
public SidebarSearchBox OnClick(Action onClick)

Makes the box a way in rather than a place to type: clicking it - open, or as the icon on the closed rail - runs the handler, and so does focusing it, which is what SetKeyboardShortcut does. Nothing can be typed into it, because what is typed belongs to whatever the handler opened. This is the shape a search that answers somewhere else takes: the box says where to start and which key gets there, and a palette or a page does the searching.

Method
SidebarSearchBox.ShortcutOnlyOnHover
public SidebarSearchBox ShortcutOnlyOnHover(bool onlyOnHover = true)

Keeps the shortcut chip out of sight until the pointer is on the box - or the caret is in it, so a box reached by tabbing shows its key too. The binding is untouched: the key works the same whether or not the chip is on screen. The room the chip takes at the end is reserved either way, so what is typed does not re-flow as the chip appears.

Parameters

onlyOnHover
Whether the chip waits for a hover. False shows it at all times, the default.
class

SidebarCommand

public class SidebarCommand : IComponent

A Command component for use within a Sidebar, typically appearing as a small action button.

Namespace
Tesserae
Implements
IComponent

Methods

NameDescription
ForegroundSets the foreground color of the command button.
HookToParentContextMenuConfigures the command to hook into the parent's context menu event.
BackgroundSets the background color of the command button.
DefaultSets the command to use the default style.
PrimarySets the command to use the primary style.
SuccessSets the command to use the success style.
DangerSets the command to use the danger style.
WarningSets the command to use the warning style.
TooltipSets a tooltip for the command.
OnClickMenuConfigures the command to show a menu when clicked.
ShowMenuShows the associated menu for the command.
RaiseOnClickProgrammatically raises the click event.
RaiseOnContextMenuProgrammatically raises the context menu event.
OnClickAdds a click event handler.
OnContextMenuAdds a context menu event handler.
SetIconSets the icon for the command.
RenderRenders the sidebar command.
Method
SidebarCommand.Foreground
public SidebarCommand Foreground(string color)

Sets the foreground color of the command button.

Parameters

color
The color.

Returns

The current instance of the type.

Method
SidebarCommand.HookToParentContextMenu
public SidebarCommand HookToParentContextMenu()

Configures the command to hook into the parent's context menu event.

Returns

The current instance of the type.

Method
SidebarCommand.Background
public SidebarCommand Background(string color)

Sets the background color of the command button.

Parameters

color
The color.

Returns

The current instance of the type.

Method
SidebarCommand.Default
public SidebarCommand Default()

Sets the command to use the default style.

Returns

The current instance of the type.

Method
SidebarCommand.Primary
public SidebarCommand Primary()

Sets the command to use the primary style.

Returns

The current instance of the type.

Method
SidebarCommand.Success
public SidebarCommand Success()

Sets the command to use the success style.

Returns

The current instance of the type.

Method
SidebarCommand.Danger
public SidebarCommand Danger()

Sets the command to use the danger style.

Returns

The current instance of the type.

Method
SidebarCommand.Warning
public SidebarCommand Warning()

Sets the command to use the warning style.

Returns

The current instance of the type.

Method
SidebarCommand.Tooltip
Overload
Tooltip(string)Sets a tooltip for the command.
Tooltip(IComponent)Sets a tooltip component for the command.
Tooltip(Func<IComponent>)Sets a tooltip generator function for the command.
Tooltip(string)
public SidebarCommand Tooltip(string text)

Sets a tooltip for the command.

Parameters

text string
The tooltip text.

Returns

The current instance of the type.

Tooltip(IComponent)
public SidebarCommand Tooltip(IComponent tooltip)

Sets a tooltip component for the command.

Parameters

tooltip IComponent
The tooltip component.

Returns

The current instance of the type.

Tooltip(Func<IComponent>)
public SidebarCommand Tooltip(Func<IComponent> tooltip)

Sets a tooltip generator function for the command.

Parameters

tooltip Func<IComponent>
The tooltip generator function.

Returns

The current instance of the type.

Method
SidebarCommand.OnClickMenu
public SidebarCommand OnClickMenu(Func<ISidebarItem[]> generator)

Configures the command to show a menu when clicked.

Parameters

generator
A function that generates the sidebar items for the menu.

Returns

The current instance of the type.

Method
SidebarCommand.ShowMenu
public void ShowMenu()

Shows the associated menu for the command.

Method
SidebarCommand.RaiseOnClick
public SidebarCommand RaiseOnClick(MouseEvent mouseEvent)

Programmatically raises the click event.

Parameters

mouseEvent
The mouse event arguments.

Returns

The current instance of the type.

Method
SidebarCommand.RaiseOnContextMenu
public SidebarCommand RaiseOnContextMenu(MouseEvent mouseEvent)

Programmatically raises the context menu event.

Parameters

mouseEvent
The mouse event arguments.

Returns

The current instance of the type.

Method
SidebarCommand.OnClick
Overload
OnClick(Action)Adds a click event handler.
OnClick(Action<Button, MouseEvent>)Adds a click event handler with button and mouse event arguments.
OnClick(Action)
public SidebarCommand OnClick(Action action)

Adds a click event handler.

Parameters

action Action
The event handler action.

Returns

The current instance of the type.

OnClick(Action<Button, MouseEvent>)
public SidebarCommand OnClick(Action<Button, MouseEvent> action)

Adds a click event handler with button and mouse event arguments.

Parameters

action Action<Button, MouseEvent>
The event handler action.

Returns

The current instance of the type.

Method
SidebarCommand.OnContextMenu
Overload
OnContextMenu(Action)Adds a context menu event handler.
OnContextMenu(Action<Button, MouseEvent>)Adds a context menu event handler with button and mouse event arguments.
OnContextMenu(Action)
public SidebarCommand OnContextMenu(Action action)

Adds a context menu event handler.

Parameters

action Action
The event handler action.

Returns

The current instance of the type.

OnContextMenu(Action<Button, MouseEvent>)
public SidebarCommand OnContextMenu(Action<Button, MouseEvent> action)

Adds a context menu event handler with button and mouse event arguments.

Parameters

action Action<Button, MouseEvent>
The event handler action.

Returns

The current instance of the type.

Method
SidebarCommand.SetIcon
Overload
SetIcon(UIcons, string, UIconsWeight)Sets the icon for the command.
SetIcon(Emoji)Sets an emoji icon for the command.
SetIcon(UIcons, string, UIconsWeight)
public SidebarCommand SetIcon(UIcons icon, string color = "", UIconsWeight weight = UIconsWeight.Regular)

Sets the icon for the command.

Parameters

icon UIcons
The icon.
color string
The color of the icon.
weight UIconsWeight
The weight of the icon.

Returns

The current instance of the type.

SetIcon(Emoji)
public SidebarCommand SetIcon(Emoji icon)

Sets an emoji icon for the command.

Parameters

icon Emoji
The emoji icon.

Returns

The current instance of the type.

Method
SidebarCommand.Render
public HTMLElement Render()

Renders the sidebar command.

Returns

The rendered HTMLElement.

class

SidebarCommands

public class SidebarCommands : ISidebarItem

A component for grouping multiple SidebarCommand items into a single line within a Sidebar.

Namespace
Tesserae
Implements
ISidebarItem

Properties

NameDescription
IsSelectedGets or sets whether the group is currently selected.
CurrentRenderedGets the component that is currently rendered.
IdentifierGets the full identifier of the command group.
OwnIdentifierGets the own identifier of the command group.
Property
SidebarCommands.IsSelected
public bool IsSelected { get; set; }

Gets or sets whether the group is currently selected.

Property
SidebarCommands.CurrentRendered
public IComponent CurrentRendered { get; private set; }

Gets the component that is currently rendered.

Property
SidebarCommands.Identifier
public string Identifier { get; private set; }

Gets the full identifier of the command group.

Property
SidebarCommands.OwnIdentifier
public string OwnIdentifier

Gets the own identifier of the command group.

Methods

NameDescription
RenderOpenRenders the commands for the open state of the sidebar.
ShowShows the commands.
CollapseCollapses the commands.
RenderOpenFullRenders all commands for the open state without truncation.
RenderClosedRenders the commands for the closed state of the sidebar.
AlignEndAligns the commands to the end of the line.
NotSortableMarks the commands as not sortable.
AddGroupIdentifierAdds a group identifier prefix to the command group's identifier.
Method
SidebarCommands.RenderOpen
public IComponent RenderOpen()

Renders the commands for the open state of the sidebar.

Method
SidebarCommands.Show
public void Show()

Shows the commands.

Method
SidebarCommands.Collapse
public void Collapse()

Collapses the commands.

Method
SidebarCommands.RenderOpenFull
public IComponent RenderOpenFull()

Renders all commands for the open state without truncation.

Method
SidebarCommands.RenderClosed
public IComponent RenderClosed()

Renders the commands for the closed state of the sidebar.

Method
SidebarCommands.AlignEnd
public SidebarCommands AlignEnd()

Aligns the commands to the end of the line.

Returns

The current instance of the type.

Method
SidebarCommands.NotSortable
public SidebarCommands NotSortable()

Marks the commands as not sortable.

Returns

The current instance of the type.

Method
SidebarCommands.AddGroupIdentifier
public void AddGroupIdentifier(string groupIdentifier)

Adds a group identifier prefix to the command group's identifier.

class

SidebarText

public class SidebarText : ISidebarItem

A Text component for use within a Sidebar, supporting both open and closed states.

Namespace
Tesserae
Implements
ISidebarItem

Constructors

NameDescription
SidebarTextInitializes a new instance of the SidebarText class.
Constructor
SidebarText
public SidebarText(string identifier, string text, string closedText = null, TextSize textSize = TextSize.Small, TextWeight textWeight = TextWeight.Regular)

Initializes a new instance of the SidebarText class.

Parameters

identifier
The identifier for the text item.
text
The text to display when the sidebar is open.
closedText
The optional text to display when the sidebar is closed.
textSize
The size of the text.
textWeight
The weight of the text.

Properties

NameDescription
CurrentRenderedGets the component that is currently rendered.
IsSelectedGets or sets whether the item is currently selected.
IdentifierGets the full identifier of the text component.
OwnIdentifierGets the own identifier of the text component.
Property
SidebarText.CurrentRendered
public IComponent CurrentRendered

Gets the component that is currently rendered.

Property
SidebarText.IsSelected
public bool IsSelected { get; set; }

Gets or sets whether the item is currently selected.

Property
SidebarText.Identifier
public string Identifier { get; private set; }

Gets the full identifier of the text component.

Property
SidebarText.OwnIdentifier
public string OwnIdentifier

Gets the own identifier of the text component.

Methods

NameDescription
ShowShows the text component.
CollapseCollapses the text component.
NotSortableMarks the text component as not sortable.
AddGroupIdentifierAdds a group identifier prefix to the text component's identifier.
SetTextSets the text content for the open state.
ForegroundSets the foreground color of the text.
PTSets the top padding of the text.
PBSets the bottom padding of the text.
PLSets the left padding of the text.
RenderClosedRenders the text for the closed state of the sidebar.
RenderOpenRenders the text for the open state of the sidebar.
Method
SidebarText.Show
public void Show()

Shows the text component.

Method
SidebarText.Collapse
public void Collapse()

Collapses the text component.

Method
SidebarText.NotSortable
public SidebarText NotSortable()

Marks the text component as not sortable.

Returns

The current instance of the type.

Method
SidebarText.AddGroupIdentifier
public void AddGroupIdentifier(string groupIdentifier)

Adds a group identifier prefix to the text component's identifier.

Method
SidebarText.SetText
public SidebarText SetText(string text)

Sets the text content for the open state.

Parameters

text
The text.

Returns

The current instance of the type.

Method
SidebarText.Foreground
public SidebarText Foreground(string color)

Sets the foreground color of the text.

Parameters

color
The color.

Returns

The current instance of the type.

Method
SidebarText.PT
public SidebarText PT(int pixels)

Sets the top padding of the text.

Parameters

pixels
The padding in pixels.

Returns

The current instance of the type.

Method
SidebarText.PB
public SidebarText PB(int pixels)

Sets the bottom padding of the text.

Parameters

pixels
The padding in pixels.

Returns

The current instance of the type.

Method
SidebarText.PL
public SidebarText PL(int pixels)

Sets the left padding of the text.

Parameters

pixels
The padding in pixels.

Returns

The current instance of the type.

Method
SidebarText.RenderClosed
public IComponent RenderClosed()

Renders the text for the closed state of the sidebar.

Method
SidebarText.RenderOpen
public IComponent RenderOpen()

Renders the text for the open state of the sidebar.

class

SidebarBadge

public class SidebarBadge : IComponent

A Badge component for sidebar items, often used to display counts or status indicators.

Namespace
Tesserae
Implements
IComponent

Constructors

NameDescription
SidebarBadgeInitializes a new instance of the SidebarBadge class.
Constructor
SidebarBadge
Overload
SidebarBadge(string, UIcons, TextSize)Initializes a new instance of the SidebarBadge class.
SidebarBadge(string, UIcons)Initializes a new instance of the SidebarBadge class.
SidebarBadge(string)Initializes a new instance of the SidebarBadge class.
SidebarBadge(ISidebarIcon)Initializes a new instance of the SidebarBadge class with an image.
SidebarBadge(string, UIcons, TextSize)
public SidebarBadge(string badge, UIcons badgeIcon, TextSize iconSize = TextSize.Tiny)

Initializes a new instance of the SidebarBadge class.

Parameters

badge string
The text content of the badge.
badgeIcon UIcons
An optional icon for the badge.
iconSize TextSize
The size of the icon.
SidebarBadge(string, UIcons)
public SidebarBadge(string badge, UIcons badgeIcon)

Initializes a new instance of the SidebarBadge class.

Parameters

badge string
The text content of the badge.
badgeIcon UIcons
An optional icon for the badge.
SidebarBadge(string)
public SidebarBadge(string badge)

Initializes a new instance of the SidebarBadge class.

Parameters

badge string
The text content of the badge.
SidebarBadge(ISidebarIcon)
public SidebarBadge(ISidebarIcon image)

Initializes a new instance of the SidebarBadge class with an image.

Parameters

image ISidebarIcon
The image icon.

Methods

NameDescription
SemiTransparentSets the badge icon to be semi-transparent.
ForegroundSets the foreground color of the badge.
BackgroundSets the background color of the badge.
DefaultSets the badge to use the default style.
PrimarySets the badge to use the primary style.
SuccessSets the badge to use the success style.
DangerSets the badge to use the danger style.
WarningSets the badge to use the warning style.
TooltipSets a tooltip for the badge.
SetIconSets the icon for the badge.
SetBadgeSets the text content of the badge.
RenderRenders the sidebar badge.
Method
SidebarBadge.SemiTransparent
public SidebarBadge SemiTransparent()

Sets the badge icon to be semi-transparent.

Returns

The current instance of the type.

Method
SidebarBadge.Foreground
public SidebarBadge Foreground(string color)

Sets the foreground color of the badge.

Parameters

color
The color.

Returns

The current instance of the type.

Method
SidebarBadge.Background
public SidebarBadge Background(string color)

Sets the background color of the badge.

Parameters

color
The color.

Returns

The current instance of the type.

Method
SidebarBadge.Default
public SidebarBadge Default()

Sets the badge to use the default style.

Returns

The current instance of the type.

Method
SidebarBadge.Primary
public SidebarBadge Primary()

Sets the badge to use the primary style.

Returns

The current instance of the type.

Method
SidebarBadge.Success
public SidebarBadge Success()

Sets the badge to use the success style.

Returns

The current instance of the type.

Method
SidebarBadge.Danger
public SidebarBadge Danger()

Sets the badge to use the danger style.

Returns

The current instance of the type.

Method
SidebarBadge.Warning
public SidebarBadge Warning()

Sets the badge to use the warning style.

Returns

The current instance of the type.

Method
SidebarBadge.Tooltip
Overload
Tooltip(string)Sets a tooltip for the badge.
Tooltip(IComponent)Sets a tooltip component for the badge.
Tooltip(Func<IComponent>)Sets a tooltip generator function for the badge.
Tooltip(string)
public SidebarBadge Tooltip(string text)

Sets a tooltip for the badge.

Parameters

text string
The tooltip text.

Returns

The current instance of the type.

Tooltip(IComponent)
public SidebarBadge Tooltip(IComponent tooltip)

Sets a tooltip component for the badge.

Parameters

tooltip IComponent
The tooltip component.

Returns

The current instance of the type.

Tooltip(Func<IComponent>)
public SidebarBadge Tooltip(Func<IComponent> tooltip)

Sets a tooltip generator function for the badge.

Parameters

tooltip Func<IComponent>
The tooltip generator function.

Returns

The current instance of the type.

Method
SidebarBadge.SetIcon
Overload
SetIcon(UIcons, string, UIconsWeight)Sets the icon for the badge.
SetIcon(Emoji)Sets an emoji icon for the badge.
SetIcon(UIcons, string, UIconsWeight)
public SidebarBadge SetIcon(UIcons icon, string color = "", UIconsWeight weight = UIconsWeight.Regular)

Sets the icon for the badge.

Parameters

icon UIcons
The icon.
color string
The color of the icon.
weight UIconsWeight
The weight of the icon.

Returns

The current instance of the type.

SetIcon(Emoji)
public SidebarBadge SetIcon(Emoji icon)

Sets an emoji icon for the badge.

Parameters

icon Emoji
The emoji icon.

Returns

The current instance of the type.

Method
SidebarBadge.SetBadge
public SidebarBadge SetBadge(string badge)

Sets the text content of the badge.

Parameters

badge
The badge text.

Returns

The current instance of the type.

Method
SidebarBadge.Render
public HTMLElement Render()

Renders the sidebar badge.

Returns

The rendered HTMLElement.

SidebarBrand

The row at the top of a rail that names the application: a logo, its name and an optional second line (workspace, tenant, environment). It has the same shape and height as SidebarProfile, and can also be the control that collapses and expands the rail.

class

SidebarBrand

public class SidebarBrand : SidebarIdentityRow<SidebarBrand>

The row at the top of a rail that says what the application is: a logo, its name, and an optional second line for whatever qualifies that name - the workspace, the tenant, the environment. It is the same shape and height as SidebarProfile, so a rail bracketed by the two reads as one piece of chrome. It can also be the one control that collapses and expands the rail - see WithSidebarControl. On the collapsed rail the row is the logo alone, with the name (and the second line) in its tooltip. The open rail is never narrower than the name and the second line need, so neither is ellipsized: the row measures its text and raises the sidebar's min-width to fit it.

Namespace
Tesserae
Inheritance
SidebarIdentityRow<SidebarBrand> → SidebarBrand

Constructors

NameDescription
SidebarBrandInitializes a new instance of the SidebarBrand class, with a logo loaded from a URL.
Constructor
SidebarBrand
Overload
SidebarBrand(string, string, string, string)Initializes a new instance of the SidebarBrand class, with a logo loaded from a URL.
SidebarBrand(string, UIcons, string, string, UIconsWeight)Initializes a new instance of the SidebarBrand class, with a glyph in place of a logo.
SidebarBrand(string, Emoji, string, string)Initializes a new instance of the SidebarBrand class, with an emoji in place of a logo.
SidebarBrand(string, ISidebarIcon, string, string)Initializes a new instance of the SidebarBrand class, with a logo of the caller's own.
SidebarBrand(string, string, string, string)
public SidebarBrand(string identifier, string title, string subtitle = null, string logoUrl = null) : this(identifier, LogosFor(logoUrl), title, subtitle)

Initializes a new instance of the SidebarBrand class, with a logo loaded from a URL.

Parameters

identifier string
The identifier for the item.
title string
The application's name.
subtitle string
What qualifies the name - the workspace, the tenant, the environment. None leaves the row a single line.
logoUrl string
The logo's URL. None leaves the row without one.
SidebarBrand(string, UIcons, string, string, UIconsWeight)
public SidebarBrand(string identifier, UIcons icon, string title, string subtitle = null, UIconsWeight weight = UIconsWeight.Regular) : this(identifier, new IComponent[] { Icon(icon, weight, TextSize.Medium), Icon(icon, weight, TextSize.Medium) }, title, subtitle)

Initializes a new instance of the SidebarBrand class, with a glyph in place of a logo.

Parameters

identifier string
The identifier for the item.
icon UIcons
The glyph.
title string
The application's name.
subtitle string
What qualifies the name. None leaves the row a single line.
weight UIconsWeight
The glyph's weight.
SidebarBrand(string, Emoji, string, string)
public SidebarBrand(string identifier, Emoji icon, string title, string subtitle = null) : this(identifier, new IComponent[] { Icon(icon, TextSize.Medium), Icon(icon, TextSize.Medium) }, title, subtitle)

Initializes a new instance of the SidebarBrand class, with an emoji in place of a logo.

Parameters

identifier string
The identifier for the item.
icon Emoji
The emoji.
title string
The application's name.
subtitle string
What qualifies the name. None leaves the row a single line.
SidebarBrand(string, ISidebarIcon, string, string)
public SidebarBrand(string identifier, ISidebarIcon logo, string title, string subtitle = null) : this(identifier, new IComponent[] { logo, logo.Clone() }, title, subtitle)

Initializes a new instance of the SidebarBrand class, with a logo of the caller's own.

Parameters

identifier string
The identifier for the item.
logo ISidebarIcon
The logo. It is cloned for the collapsed rail, since one element cannot be in two places.
title string
The application's name.
subtitle string
What qualifies the name. None leaves the row a single line.

Properties

NameDescription
Self
Property
SidebarBrand.Self
protected override SidebarBrand Self

Methods

NameDescription
WrapLogoA box of its own around whatever the logo is, so that an image, a glyph and an emoji all take the same square beside the name - the stylesheet sizes the box rather than each of the three.
SetTitleSets the application's name.
SetBadgePuts a badge after the application's name - the environment it runs in ("DEV", "VAL"), an edition, a pre-release marker - in the colours of a Badge of the same tone. The badge stays whole and the name ellipsizes before it, and the open rail grows to fit both. On the collapsed rail its text joins the name in the logo's default tooltip. Null or empty text removes it.
ConfigureAdds the command that opens the application's configuration.
WithSidebarControlMakes the brand the rail's own open/close control, which is where an application that has one usually wants it: at the top, on the row that is there in both states. While the sidebar is open it is the last command on the row, so closing the rail is the rightmost thing on it. While the sidebar is closed there is no room for a command beside the logo, so the logo is the control: it stands as the brand at rest and turns into the open button under the pointer. The row reports the two intentions rather than driving a sidebar itself, because the rail a brand sits on is not always the one it opens - an application shifts between rails, and rebuilds them - so the caller is the one that knows which Sidebar to toggle and what else follows from it.
Method
SidebarBrand.SetTitle
public SidebarBrand SetTitle(string title)

Sets the application's name.

Parameters

title
The name.

Returns

The current instance of the type.

Method
SidebarBrand.SetBadge
Overload
SetBadge(string, BadgeTone)Puts a badge after the application's name - the environment it runs in ("DEV", "VAL"), an edition, a pre-release marker - in the colours of a Badge of the same tone. The badge stays whole and the name ellipsizes before it, and the open rail grows to fit both. On the collapsed rail its text joins the name in the logo's default tooltip. Null or empty text removes it.
SetBadge(Badge)Puts a badge of the caller's own after the application's name - for one with an icon, an outline or colours outside the tones (Background, Foreground). Passing null removes it.
SetBadge(string, BadgeTone)
public SidebarBrand SetBadge(string text, BadgeTone tone = BadgeTone.Neutral)

Puts a badge after the application's name - the environment it runs in ("DEV", "VAL"), an edition, a pre-release marker - in the colours of a Badge of the same tone. The badge stays whole and the name ellipsizes before it, and the open rail grows to fit both. On the collapsed rail its text joins the name in the logo's default tooltip. Null or empty text removes it.

Parameters

text string
What the badge says.
tone BadgeTone
Its colour, as Tone takes it. Neutral by default.

Returns

The current instance of the type.

SetBadge(Badge)
public SidebarBrand SetBadge(Badge badge)

Puts a badge of the caller's own after the application's name - for one with an icon, an outline or colours outside the tones (Background, Foreground). Passing null removes it.

Parameters

badge Badge
The badge.

Returns

The current instance of the type.

Method
SidebarBrand.Configure
Overload
Configure(Action, string, UIcons)Adds the command that opens the application's configuration.
Configure(SidebarCommand)Sets the configuration command, built by the caller - for one that opens a menu (OnClickMenu) rather than a page. Passing null removes it.
Configure(Action, string, UIcons)
public SidebarBrand Configure(Action onClick, string tooltip = null, UIcons icon = UIcons.Settings)

Adds the command that opens the application's configuration.

Parameters

onClick Action
What pressing it does.
tooltip string
The tooltip. None uses "Settings".
icon UIcons
The icon. Defaults to a gear.

Returns

The current instance of the type.

Configure(SidebarCommand)
public SidebarBrand Configure(SidebarCommand command)

Sets the configuration command, built by the caller - for one that opens a menu (OnClickMenu) rather than a page. Passing null removes it.

Parameters

command SidebarCommand
The command.

Returns

The current instance of the type.

Method
SidebarBrand.WithSidebarControl
public SidebarBrand WithSidebarControl( Action onOpen, Action onClose, string openTooltip = null, string closeTooltip = null, UIcons openIcon = UIcons.SidebarFlip, UIcons closeIcon = UIcons.Sidebar)

Makes the brand the rail's own open/close control, which is where an application that has one usually wants it: at the top, on the row that is there in both states. While the sidebar is open it is the last command on the row, so closing the rail is the rightmost thing on it. While the sidebar is closed there is no room for a command beside the logo, so the logo is the control: it stands as the brand at rest and turns into the open button under the pointer. The row reports the two intentions rather than driving a sidebar itself, because the rail a brand sits on is not always the one it opens - an application shifts between rails, and rebuilds them - so the caller is the one that knows which Sidebar to toggle and what else follows from it.

Parameters

onOpen
What opening the rail does. Called from the control the collapsed rail shows.
onClose
What closing it does. Called from the last command on the open row.
openTooltip
The tooltip on the open control. None uses "Open Sidebar".
closeTooltip
The tooltip on the close command. None uses "Close Sidebar".
openIcon
The icon of the open control. The rail's own glyph, mirrored.
closeIcon
The icon of the close command. The rail's own glyph.

Returns

The current instance of the type.

SidebarProfile

The row that says who is signed in: a picture (falling back to the account's initials), a name, an optional second line, and the account's commands such as settings and signing out. On the collapsed rail it shows the picture alone.

class

SidebarProfile

public class SidebarProfile : SidebarIdentityRow<SidebarProfile>

The row that says who is signed in: a picture, a name, an optional second line for whatever identifies the account beside the name - an e-mail address, a company, a tenant - and the commands that belong to it, settings and signing out. The picture falls back to the account's initials, so a photo URL that only answers for accounts that have uploaded one can be passed unconditionally. On the collapsed rail the row is that picture alone, with the name and the second line in its tooltip.

Namespace
Tesserae
Inheritance
SidebarIdentityRow<SidebarProfile> → SidebarProfile

Constructors

NameDescription
SidebarProfileInitializes a new instance of the SidebarProfile class.
Constructor
SidebarProfile
public SidebarProfile(string identifier, string name, string subtitle = null, string pictureUrl = null, string initials = null) : this(identifier, name, subtitle, InitialAvatars(pictureUrl, string.IsNullOrWhiteSpace(initials) ? InitialsFor(name) : initials))

Initializes a new instance of the SidebarProfile class.

Parameters

identifier
The identifier for the item.
name
The name to show on the first line.
subtitle
What identifies the account beside the name - an e-mail address, a company, a tenant. None leaves the row a single line.
pictureUrl
The picture to show. None - or one that fails to load - falls back to the initials.
initials
The initials to fall back to. None takes them from the name.

Properties

NameDescription
Self
Property
SidebarProfile.Self
protected override SidebarProfile Self

Methods

NameDescription
InitialAvatarsThe two avatars a row needs - one for the open row, one for the collapsed rail, since a single element cannot be in two places. Built before the base constructor runs, which is what the array is for. They are the same size: the collapsed rail shows the row's picture in a box of the row's own height, not a smaller row.
SetNameSets the name shown on the first line, and the initials taken from it where none were given.
SetPictureSets the picture. One that fails to load falls back to the initials, so a URL that answers only for accounts that have uploaded a photo can be passed unconditionally.
SetInitialsSets the initials the picture falls back to. None - the default - takes them from the name.
PresenceShows a presence dot on the picture - online, away, busy, offline.
SettingsAdds the command that opens the account's settings.
LogoutAdds the command that signs the account out. Optional: an application whose only way out is a menu item, or that has no way out at all, leaves it off.
InitialsForThe initials a name falls back to when there is no picture: the first letter of the first word and of the last, so "M. Okafor" reads MO and "Okafor" reads O. Anything that is not a letter or a digit is skipped, which is what keeps an initial out of "M." and out of an emoji.
Method
SidebarProfile.InitialAvatars
private static Avatar[] InitialAvatars(string pictureUrl, string initials)

The two avatars a row needs - one for the open row, one for the collapsed rail, since a single element cannot be in two places. Built before the base constructor runs, which is what the array is for. They are the same size: the collapsed rail shows the row's picture in a box of the row's own height, not a smaller row.

Method
SidebarProfile.SetName
public SidebarProfile SetName(string name)

Sets the name shown on the first line, and the initials taken from it where none were given.

Parameters

name
The name.

Returns

The current instance of the type.

Method
SidebarProfile.SetPicture
public SidebarProfile SetPicture(string pictureUrl)

Sets the picture. One that fails to load falls back to the initials, so a URL that answers only for accounts that have uploaded a photo can be passed unconditionally.

Parameters

pictureUrl
The picture URL.

Returns

The current instance of the type.

Method
SidebarProfile.SetInitials
public SidebarProfile SetInitials(string initials)

Sets the initials the picture falls back to. None - the default - takes them from the name.

Parameters

initials
The initials.

Returns

The current instance of the type.

Method
SidebarProfile.Presence
public SidebarProfile Presence(AvatarPresence presence)

Shows a presence dot on the picture - online, away, busy, offline.

Parameters

presence
The presence state.

Returns

The current instance of the type.

Method
SidebarProfile.Settings
Overload
Settings(Action, string, UIcons)Adds the command that opens the account's settings.
Settings(SidebarCommand)Sets the settings command, built by the caller - for one that opens a menu (OnClickMenu) rather than going straight to a settings page, or one that is an href. Passing null removes it.
Settings(Action, string, UIcons)
public SidebarProfile Settings(Action onClick, string tooltip = null, UIcons icon = UIcons.Settings)

Adds the command that opens the account's settings.

Parameters

onClick Action
What pressing it does.
tooltip string
The tooltip. None uses "Settings".
icon UIcons
The icon. Defaults to a gear.

Returns

The current instance of the type.

Settings(SidebarCommand)
public SidebarProfile Settings(SidebarCommand command)

Sets the settings command, built by the caller - for one that opens a menu (OnClickMenu) rather than going straight to a settings page, or one that is an href. Passing null removes it.

Parameters

command SidebarCommand
The command.

Returns

The current instance of the type.

Method
SidebarProfile.Logout
Overload
Logout(Action, string, UIcons)Adds the command that signs the account out. Optional: an application whose only way out is a menu item, or that has no way out at all, leaves it off.
Logout(SidebarCommand)Sets the logout command, built by the caller. Passing null removes it.
Logout(Action, string, UIcons)
public SidebarProfile Logout(Action onClick, string tooltip = null, UIcons icon = UIcons.SignOutAlt)

Adds the command that signs the account out. Optional: an application whose only way out is a menu item, or that has no way out at all, leaves it off.

Parameters

onClick Action
What pressing it does.
tooltip string
The tooltip. None uses "Log out".
icon UIcons
The icon. Defaults to the sign-out arrow.

Returns

The current instance of the type.

Logout(SidebarCommand)
public SidebarProfile Logout(SidebarCommand command)

Sets the logout command, built by the caller. Passing null removes it.

Parameters

command SidebarCommand
The command.

Returns

The current instance of the type.

Method
SidebarProfile.InitialsFor
public static string InitialsFor(string name)

The initials a name falls back to when there is no picture: the first letter of the first word and of the last, so "M. Okafor" reads MO and "Okafor" reads O. Anything that is not a letter or a digit is skipped, which is what keeps an initial out of "M." and out of an emoji.

SidebarIdentityRow

The base shared by SidebarBrand and SidebarProfile: a row twice the height of an ordinary one, with a picture, a name, an optional second line and the commands that belong to what the row names.

class

SidebarIdentityRow<T>

public abstract class SidebarIdentityRow<T> : ISidebarItem where T : SidebarIdentityRow<T>

What a SidebarBrand and a SidebarProfile have in common: a row twice the height of an ordinary one, carrying a picture, a name, an optional second line under it, and the commands that belong to whatever the row names. The two exist as components rather than as a SidebarButton dressed up because the shape is different - two lines of text against a picture, taller than the rows around it, with the commands drawn at rest rather than under the pointer. Composing that out of a button and a stack got every application as far as a stylesheet of its own overriding the rail's heights, paddings and icon sizes, which is what this replaces. On the collapsed rail both are the picture alone, with the name (and the second line) in the tooltip.

Type Parameters

T
The concrete row type, so the fluent methods return it.
Namespace
Tesserae
Implements
ISidebarItem

Constructors

NameDescription
SidebarIdentityRow
Constructor
SidebarIdentityRow
protected SidebarIdentityRow(string identifier, string rowClass, IComponent openLeading, IComponent closedLeading, string title, string subtitle)

Parameters

identifier
The identifier for the item.
rowClass
The class naming the concrete row, e.g. tss-sidebar-profile.
openLeading
The picture shown while the sidebar is open.
closedLeading
The picture shown on the collapsed rail. A second instance, since one element cannot be in two places.
title
The name on the first line.
subtitle
The second line, or null for a single-line row.

Properties

NameDescription
SelfThe concrete row, so that a fluent method defined here returns the type it was called on.
OpenButtonThe button the open row draws, for a subclass that has to reach it.
ClosedButtonThe button the collapsed rail draws.
ClosedRootThe element the collapsed rail draws, for a row that puts something else beside the picture there - see WithSidebarControl, which lays a control over it for the hover.
TitleTextThe name on the first line.
SubtitleTextThe second line, or an empty string when there is none.
IsSelectedGets or sets whether the item is currently selected.
SelectedStatusGets an observable for the selected status.
CurrentRenderedGets the component that is currently rendered.
IdentifierGets the full identifier of the item, including group identifiers.
OwnIdentifierGets the own identifier of the item, without group identifiers.
Property
SidebarIdentityRow.Self
protected abstract T Self { get; }

The concrete row, so that a fluent method defined here returns the type it was called on.

Property
SidebarIdentityRow.OpenButton
protected Button OpenButton

The button the open row draws, for a subclass that has to reach it.

Property
SidebarIdentityRow.ClosedButton
protected Button ClosedButton

The button the collapsed rail draws.

Property
SidebarIdentityRow.ClosedRoot
protected HTMLElement ClosedRoot

The element the collapsed rail draws, for a row that puts something else beside the picture there - see WithSidebarControl, which lays a control over it for the hover.

Property
SidebarIdentityRow.TitleText
protected string TitleText

The name on the first line.

Property
SidebarIdentityRow.SubtitleText
protected string SubtitleText

The second line, or an empty string when there is none.

Property
SidebarIdentityRow.IsSelected
public bool IsSelected { get ; set ; }

Gets or sets whether the item is currently selected.

Property
SidebarIdentityRow.SelectedStatus
public IObservable<bool> SelectedStatus

Gets an observable for the selected status.

Property
SidebarIdentityRow.CurrentRendered
public IComponent CurrentRendered

Gets the component that is currently rendered.

Property
SidebarIdentityRow.Identifier
public string Identifier { get; private set; }

Gets the full identifier of the item, including group identifiers.

Property
SidebarIdentityRow.OwnIdentifier
public string OwnIdentifier

Gets the own identifier of the item, without group identifiers.

Methods

NameDescription
AddGroupIdentifierAdds a group identifier prefix to the item's identifier.
ShowShows the item.
CollapseCollapses the item.
SetSubtitleSets the second line - an e-mail address, a company, an environment. Null or empty leaves the row a single line rather than an empty one.
CommandsThe commands drawn before the row's own - a search, a back arrow, the control that collapses the rail. Replaces whatever was set before.
CommandsOnHoverKeeps the commands out of sight until the pointer is on the row, the way an ordinary row's commands behave. The default is the other way round, because the row's commands are usually the only way to what they open.
SeparatedDraws a divider on the row's outer edge - above a row at the bottom of the rail, below one at the top - running the full width of the sidebar rather than stopping at its padding.
SelectedSets whether the row is selected - what marks the page it opens as the one being shown.
NotSortableMarks the item as not sortable, which is what a row of chrome wants.
ClassAdds a class to both renderings of the item.
TooltipSets the tooltip shown on the collapsed rail, where the row is the picture alone. None - the default - shows the name and the second line.
OnClickAdds a click event handler to the row itself. The commands are separate buttons, so pressing one is not pressing the row.
OnContextMenuAdds a context menu event handler.
OnRenderedAdds a rendered event handler.
RenderClosedRenders the item for the closed state of the sidebar.
RenderOpenRenders the item for the open state of the sidebar.
SetTitleTextReplaces the name on the first line. Kept protected so each row can name it for what it holds - the account's name, the product's name - and keep whatever else follows from it in step.
SetTitleBadgePuts an element on the name's line, after the name - a label that qualifies the name itself rather than adding a second line under it, like the environment a brand's application runs in. The name gives way before it does: a name too long for the row is ellipsized and the label stays whole. The name and the label share a line of their own only while there is a label, so a row without one keeps exactly the markup it always had.
FitRailToTextHas the open rail the row sits on grow to the width its name and second line need, so neither is ellipsized - for the row whose text is what the rail is for, the application's name. The rail never shrinks below the width it was given; this only raises its floor. The row measures itself rather than asking for a number, because what the text has to share the row with - the rail's padding, the logo, the gap, the strip of commands - is the stylesheet's and a skin's to change. The room the text has now is subtracted from the rail's width, and what the text wants is added back: whatever else is on the row cancels out, and so does the rail's own width. So the answer only moves with what is on the row, and that is when it is measured: each time the open row is mounted, when the text or the commands change, and once the fonts arrive. Never on a resize - a rail being dragged wider would otherwise force a layout read and restyle the whole sidebar on every frame, to write the number it already had.
TitleLineWidthThe width the name's line wants: the name, and with a label after it the distance from the end of the name as drawn to the end of the label - the gap and the label, whatever a skin makes them, and the same whether or not the name is ellipsized at the moment, since the label follows it.
OnOpenRowRemovedThe open row comes off the rail every time the rail closes, and the collapsed picture goes on in the same pass. The floor stays then - the stylesheet ignores it on a closed rail, and the rail opens straight to it - and goes only when the row has left the rail altogether.
RailToFitThe sidebar the row is on, unless that is a child sidebar shifted into another (ShiftTo): a child fills its host's panel and the host owns the width, so a child's row is left to ellipsize rather than widen a rail that is not its own.
SetPrimaryCommandThe row's own command, drawn last - settings on a profile, configuration on a brand.
SetSecondaryCommandThe row's second command, drawn after the first - logging out, on a profile.
RefreshDefaultTooltipThe tooltip the collapsed rail gets when the caller has not set one: the name, and the second line after it where there is one. Re-applied whenever either changes, and left alone once a tooltip has been set by hand.
Method
SidebarIdentityRow.AddGroupIdentifier
public void AddGroupIdentifier(string groupIdentifier)

Adds a group identifier prefix to the item's identifier.

Method
SidebarIdentityRow.Show
public void Show()

Shows the item.

Method
SidebarIdentityRow.Collapse
public void Collapse()

Collapses the item.

Method
SidebarIdentityRow.SetSubtitle
public T SetSubtitle(string subtitle)

Sets the second line - an e-mail address, a company, an environment. Null or empty leaves the row a single line rather than an empty one.

Parameters

subtitle
The text for the second line.

Returns

The current instance of the type.

Method
SidebarIdentityRow.Commands
public T Commands(params SidebarCommand[] commands)

The commands drawn before the row's own - a search, a back arrow, the control that collapses the rail. Replaces whatever was set before.

Parameters

commands
The commands.

Returns

The current instance of the type.

Method
SidebarIdentityRow.CommandsOnHover
public T CommandsOnHover(bool onHover = true)

Keeps the commands out of sight until the pointer is on the row, the way an ordinary row's commands behave. The default is the other way round, because the row's commands are usually the only way to what they open.

Parameters

onHover
Whether the commands wait for a hover.

Returns

The current instance of the type.

Method
SidebarIdentityRow.Separated
public T Separated(bool separated = true)

Draws a divider on the row's outer edge - above a row at the bottom of the rail, below one at the top - running the full width of the sidebar rather than stopping at its padding.

Parameters

separated
Whether to draw the divider.

Returns

The current instance of the type.

Method
SidebarIdentityRow.Selected
public T Selected(bool isSelected = true)

Sets whether the row is selected - what marks the page it opens as the one being shown.

Parameters

isSelected
Whether the row is selected.

Returns

The current instance of the type.

Method
SidebarIdentityRow.NotSortable
public T NotSortable()

Marks the item as not sortable, which is what a row of chrome wants.

Returns

The current instance of the type.

Method
SidebarIdentityRow.Class
public T Class(string className)

Adds a class to both renderings of the item.

Parameters

className
The class name.

Returns

The current instance of the type.

Method
SidebarIdentityRow.Tooltip
Overload
Tooltip(string)Sets the tooltip shown on the collapsed rail, where the row is the picture alone. None - the default - shows the name and the second line.
Tooltip(IComponent)Sets the tooltip component shown on the collapsed rail.
Tooltip(string)
public T Tooltip(string text)

Sets the tooltip shown on the collapsed rail, where the row is the picture alone. None - the default - shows the name and the second line.

Parameters

text string
The tooltip text.

Returns

The current instance of the type.

Tooltip(IComponent)
public T Tooltip(IComponent tooltip)

Sets the tooltip component shown on the collapsed rail.

Parameters

tooltip IComponent
The tooltip component.

Returns

The current instance of the type.

Method
SidebarIdentityRow.OnClick
Overload
OnClick(Action)Adds a click event handler to the row itself. The commands are separate buttons, so pressing one is not pressing the row.
OnClick(Action<Button, MouseEvent>)Adds a click event handler with button and mouse event arguments.
OnClick(Action)
public T OnClick(Action action)

Adds a click event handler to the row itself. The commands are separate buttons, so pressing one is not pressing the row.

Parameters

action Action
The event handler action.

Returns

The current instance of the type.

OnClick(Action<Button, MouseEvent>)
public T OnClick(Action<Button, MouseEvent> action)

Adds a click event handler with button and mouse event arguments.

Parameters

action Action<Button, MouseEvent>
The event handler action.

Returns

The current instance of the type.

Method
SidebarIdentityRow.OnContextMenu
public T OnContextMenu(Action<Button, MouseEvent> action)

Adds a context menu event handler.

Parameters

action
The event handler action.

Returns

The current instance of the type.

Method
SidebarIdentityRow.OnRendered
public ISidebarItem OnRendered(Action<HTMLElement> onRendered)

Adds a rendered event handler.

Parameters

onRendered
The rendered event handler.

Returns

The current instance of the type.

Method
SidebarIdentityRow.RenderClosed
public IComponent RenderClosed()

Renders the item for the closed state of the sidebar.

Method
SidebarIdentityRow.RenderOpen
public IComponent RenderOpen()

Renders the item for the open state of the sidebar.

Method
SidebarIdentityRow.SetTitleText
protected void SetTitleText(string title)

Replaces the name on the first line. Kept protected so each row can name it for what it holds - the account's name, the product's name - and keep whatever else follows from it in step.

Parameters

title
The name.
Method
SidebarIdentityRow.SetTitleBadge
protected void SetTitleBadge(HTMLElement badge, string text)

Puts an element on the name's line, after the name - a label that qualifies the name itself rather than adding a second line under it, like the environment a brand's application runs in. The name gives way before it does: a name too long for the row is ellipsized and the label stays whole. The name and the label share a line of their own only while there is a label, so a row without one keeps exactly the markup it always had.

Parameters

badge
The element to put after the name, or null to remove the one there.
text
What the label says, for the collapsed rail's tooltip, which has no room for the element.
Method
SidebarIdentityRow.FitRailToText
protected void FitRailToText()

Has the open rail the row sits on grow to the width its name and second line need, so neither is ellipsized - for the row whose text is what the rail is for, the application's name. The rail never shrinks below the width it was given; this only raises its floor. The row measures itself rather than asking for a number, because what the text has to share the row with - the rail's padding, the logo, the gap, the strip of commands - is the stylesheet's and a skin's to change. The room the text has now is subtracted from the rail's width, and what the text wants is added back: whatever else is on the row cancels out, and so does the rail's own width. So the answer only moves with what is on the row, and that is when it is measured: each time the open row is mounted, when the text or the commands change, and once the fonts arrive. Never on a resize - a rail being dragged wider would otherwise force a layout read and restyle the whole sidebar on every frame, to write the number it already had.

Method
SidebarIdentityRow.TitleLineWidth
private double TitleLineWidth()

The width the name's line wants: the name, and with a label after it the distance from the end of the name as drawn to the end of the label - the gap and the label, whatever a skin makes them, and the same whether or not the name is ellipsized at the moment, since the label follows it.

Method
SidebarIdentityRow.OnOpenRowRemoved
private void OnOpenRowRemoved()

The open row comes off the rail every time the rail closes, and the collapsed picture goes on in the same pass. The floor stays then - the stylesheet ignores it on a closed rail, and the rail opens straight to it - and goes only when the row has left the rail altogether.

Method
SidebarIdentityRow.RailToFit
private HTMLElement RailToFit()

The sidebar the row is on, unless that is a child sidebar shifted into another (ShiftTo): a child fills its host's panel and the host owns the width, so a child's row is left to ellipsize rather than widen a rail that is not its own.

Method
SidebarIdentityRow.SetPrimaryCommand
protected void SetPrimaryCommand(SidebarCommand command)

The row's own command, drawn last - settings on a profile, configuration on a brand.

Parameters

command
The command, or null to remove it.
Method
SidebarIdentityRow.SetSecondaryCommand
protected void SetSecondaryCommand(SidebarCommand command)

The row's second command, drawn after the first - logging out, on a profile.

Parameters

command
The command, or null to remove it.
Method
SidebarIdentityRow.RefreshDefaultTooltip
private void RefreshDefaultTooltip()

The tooltip the collapsed rail gets when the caller has not set one: the name, and the second line after it where there is one. Re-applied whenever either changes, and left alone once a tooltip has been set by hand.

Fields

NameDescription
RAIL_MIN_WIDTH_VARIABLEThe width the open rail needs for the row's text to be drawn whole, written on the rail by FitRailToText and turned into a min-width by tss.sidebar.css only while the rail is open - a variable rather than the property itself, so the closed rail's 54px and the page and navbar layouts are the stylesheet's to keep.
RAIL_FITS_CLASSThe class that tells the stylesheet the rail carries RAIL_MIN_WIDTH_VARIABLE.
Field
SidebarIdentityRow.RAIL_MIN_WIDTH_VARIABLE
private const string RAIL_MIN_WIDTH_VARIABLE = "--tss-sidebar-identity-min-width"

The width the open rail needs for the row's text to be drawn whole, written on the rail by FitRailToText and turned into a min-width by tss.sidebar.css only while the rail is open - a variable rather than the property itself, so the closed rail's 54px and the page and navbar layouts are the stylesheet's to keep.

Field
SidebarIdentityRow.RAIL_FITS_CLASS
private const string RAIL_FITS_CLASS = "tss-sidebar-fits-identity"

The class that tells the stylesheet the rail carries RAIL_MIN_WIDTH_VARIABLE.

SidebarSectionHeader

A heading at the top of a sidebar that names the section it shows: a glyph, a name and an optional description line. It does not respond to the pointer, takes no tab stop and has no commands. Use it where a Sidenav to the left picks the section.

class

SidebarSectionHeader

public class SidebarSectionHeader : ISidebarItem

The row at the top of a sidebar that names the section the sidebar is showing: the section's glyph, its name and an optional line saying what is in it ("Data, AI and delivery"). It has the shape and height of SidebarBrand but is a heading rather than a control: it does not answer the pointer, takes no tab stop and carries no commands. Use it where a rail to the left (a Sidenav) picks the section and the sidebar beside it lists what is in it. On the collapsed rail the header is the glyph alone, with the name (and the second line) in its tooltip.

Namespace
Tesserae
Implements
ISidebarItem

Constructors

NameDescription
SidebarSectionHeaderInitializes a new instance of the SidebarSectionHeader class.
Constructor
SidebarSectionHeader
public SidebarSectionHeader(string identifier, UIcons icon, string title, string subtitle = null, UIconsWeight weight = UIconsWeight.Regular)

Initializes a new instance of the SidebarSectionHeader class.

Parameters

identifier
The identifier for the item.
icon
The section's glyph.
title
The section's name.
subtitle
What is in the section. None leaves the header a single line.
weight
The glyph's weight.

Properties

NameDescription
IsSelectedGets or sets whether the item is currently selected. A heading is not a destination, so this is only carried for the sidebar's sake.
CurrentRenderedGets the component that is currently rendered.
IdentifierGets the full identifier of the item, including group identifiers.
OwnIdentifierGets the own identifier of the item, without group identifiers.
Property
SidebarSectionHeader.IsSelected
public bool IsSelected { get; set; }

Gets or sets whether the item is currently selected. A heading is not a destination, so this is only carried for the sidebar's sake.

Property
SidebarSectionHeader.CurrentRendered
public IComponent CurrentRendered

Gets the component that is currently rendered.

Property
SidebarSectionHeader.Identifier
public string Identifier { get; private set; }

Gets the full identifier of the item, including group identifiers.

Property
SidebarSectionHeader.OwnIdentifier
public string OwnIdentifier

Gets the own identifier of the item, without group identifiers.

Methods

NameDescription
AddGroupIdentifierAdds a group identifier prefix to the item's identifier.
ShowShows the item.
CollapseCollapses the item.
SetTitleSets the section's name.
SetSubtitleSets the second line. Null or empty leaves the header a single line.
SeparatedDraws a divider under the header, run out to the sidebar's own edges, between it and the rows it heads.
NotSortableMarks the item as not draggable in a sortable sidebar.
RenderClosedRenders the item for the closed state of the sidebar.
RenderOpenRenders the item for the open state of the sidebar.
Method
SidebarSectionHeader.AddGroupIdentifier
public void AddGroupIdentifier(string groupIdentifier)

Adds a group identifier prefix to the item's identifier.

Method
SidebarSectionHeader.Show
public void Show()

Shows the item.

Method
SidebarSectionHeader.Collapse
public void Collapse()

Collapses the item.

Method
SidebarSectionHeader.SetTitle
public SidebarSectionHeader SetTitle(string title)

Sets the section's name.

Parameters

title
The name.

Returns

The current instance of the type.

Method
SidebarSectionHeader.SetSubtitle
public SidebarSectionHeader SetSubtitle(string subtitle)

Sets the second line. Null or empty leaves the header a single line.

Parameters

subtitle
What is in the section.

Returns

The current instance of the type.

Method
SidebarSectionHeader.Separated
public SidebarSectionHeader Separated(bool separated = true)

Draws a divider under the header, run out to the sidebar's own edges, between it and the rows it heads.

Parameters

separated
Whether to draw it.

Returns

The current instance of the type.

Method
SidebarSectionHeader.NotSortable
public SidebarSectionHeader NotSortable()

Marks the item as not draggable in a sortable sidebar.

Returns

The current instance of the type.

Method
SidebarSectionHeader.RenderClosed
public IComponent RenderClosed()

Renders the item for the closed state of the sidebar.

Method
SidebarSectionHeader.RenderOpen
public IComponent RenderOpen()

Renders the item for the open state of the sidebar.

SidebarStatusCard

A card at the top of a sidebar showing what its section is doing: a glyph and name, a status line with a coloured dot, and an optional progress bar with a caption for a running job. Every part can be updated after it is on screen.

class

SidebarStatusCard

public class SidebarStatusCard : ISidebarItem

A card at the top of a sidebar that says what the section it heads is doing right now: a glyph and the section's name, a status line ("Index healthy · 2.4M nodes") with a dot in the status's tone, and optionally a progress bar with a caption under it for a job that is running ("Re-index 72% · 4 min left"). Every part can be changed after it is on screen, so it is meant to be kept up to date from whatever reports the state. On the collapsed rail the card is the glyph alone, with the progress drawn as a short bar under it and the whole text in its tooltip.

Namespace
Tesserae
Implements
ISidebarItem

Constructors

NameDescription
SidebarStatusCardInitializes a new instance of the SidebarStatusCard class.
Constructor
SidebarStatusCard
public SidebarStatusCard(string identifier, UIcons icon, string title, string status = null, UIconsWeight weight = UIconsWeight.Regular)

Initializes a new instance of the SidebarStatusCard class.

Parameters

identifier
The identifier for the item.
icon
The section's glyph.
title
The section's name.
status
The status line. None leaves the card without one.
weight
The glyph's weight.

Properties

NameDescription
IsSelectedGets or sets whether the item is currently selected. A status card is not a destination, so this is only carried for the sidebar's sake.
CurrentRenderedGets the component that is currently rendered.
IdentifierGets the full identifier of the item, including group identifiers.
OwnIdentifierGets the own identifier of the item, without group identifiers.
Property
SidebarStatusCard.IsSelected
public bool IsSelected { get; set; }

Gets or sets whether the item is currently selected. A status card is not a destination, so this is only carried for the sidebar's sake.

Property
SidebarStatusCard.CurrentRendered
public IComponent CurrentRendered

Gets the component that is currently rendered.

Property
SidebarStatusCard.Identifier
public string Identifier { get; private set; }

Gets the full identifier of the item, including group identifiers.

Property
SidebarStatusCard.OwnIdentifier
public string OwnIdentifier

Gets the own identifier of the item, without group identifiers.

Methods

NameDescription
AddGroupIdentifierAdds a group identifier prefix to the item's identifier.
ShowShows the item.
CollapseCollapses the item.
SetTitleSets the section's name.
SetStatusSets the status line. Null or empty hides it.
SuccessDraws the status dot in the success colour.
WarningDraws the status dot in the warning colour.
DangerDraws the status dot in the danger colour.
NeutralDraws the status dot in the neutral colour, which is the default.
ProgressShows a progress bar for a running job, with an optional caption under it.
IndeterminateShows an indeterminate progress bar, for a job that cannot say how far along it is.
ClearProgressRemoves the progress bar and its caption.
OnClickRuns an action when the card is clicked, typically to open the page with the full status.
NotSortableMarks the item as not draggable in a sortable sidebar.
RenderClosedRenders the item for the closed state of the sidebar.
RenderOpenRenders the item for the open state of the sidebar.
Method
SidebarStatusCard.AddGroupIdentifier
public void AddGroupIdentifier(string groupIdentifier)

Adds a group identifier prefix to the item's identifier.

Method
SidebarStatusCard.Show
public void Show()

Shows the item.

Method
SidebarStatusCard.Collapse
public void Collapse()

Collapses the item.

Method
SidebarStatusCard.SetTitle
public SidebarStatusCard SetTitle(string title)

Sets the section's name.

Parameters

title
The name.

Returns

The current instance of the type.

Method
SidebarStatusCard.SetStatus
public SidebarStatusCard SetStatus(string status)

Sets the status line. Null or empty hides it.

Parameters

status
The status, e.g. "Index healthy · 2.4M nodes".

Returns

The current instance of the type.

Method
SidebarStatusCard.Success
public SidebarStatusCard Success()

Draws the status dot in the success colour.

Returns

The current instance of the type.

Method
SidebarStatusCard.Warning
public SidebarStatusCard Warning()

Draws the status dot in the warning colour.

Returns

The current instance of the type.

Method
SidebarStatusCard.Danger
public SidebarStatusCard Danger()

Draws the status dot in the danger colour.

Returns

The current instance of the type.

Method
SidebarStatusCard.Neutral
public SidebarStatusCard Neutral()

Draws the status dot in the neutral colour, which is the default.

Returns

The current instance of the type.

Method
SidebarStatusCard.Progress
public SidebarStatusCard Progress(float percent, string caption = null)

Shows a progress bar for a running job, with an optional caption under it.

Parameters

percent
How far along the job is, from 0 to 100.
caption
The caption, e.g. "Re-index 72% · 4 min left". None leaves the bar on its own.

Returns

The current instance of the type.

Method
SidebarStatusCard.Indeterminate
public SidebarStatusCard Indeterminate(string caption = null)

Shows an indeterminate progress bar, for a job that cannot say how far along it is.

Parameters

caption
The caption. None leaves the bar on its own.

Returns

The current instance of the type.

Method
SidebarStatusCard.ClearProgress
public SidebarStatusCard ClearProgress()

Removes the progress bar and its caption.

Returns

The current instance of the type.

Method
SidebarStatusCard.OnClick
public SidebarStatusCard OnClick(Action onClick)

Runs an action when the card is clicked, typically to open the page with the full status.

Parameters

onClick
What clicking the card does.

Returns

The current instance of the type.

Method
SidebarStatusCard.NotSortable
public SidebarStatusCard NotSortable()

Marks the item as not draggable in a sortable sidebar.

Returns

The current instance of the type.

Method
SidebarStatusCard.RenderClosed
public IComponent RenderClosed()

Renders the item for the closed state of the sidebar.

Method
SidebarStatusCard.RenderOpen
public IComponent RenderOpen()

Renders the item for the open state of the sidebar.

SidebarSeparator

A divider between groups of sidebar items, optionally with a label.

class

SidebarSeparator

public class SidebarSeparator : ISidebarItem
Namespace
Tesserae
Implements
ISidebarItem

SidebarPageBar

The bar at the top of the content while a sidebar renders as a page (Sidebar.AsPage): a back button that brings the sidebar back, the brand, the page title and room for commands.

class

SidebarPageBar

public sealed class SidebarPageBar : IComponent

The bar at the top of the content while a Sidebar renders as a page (AsPage): a back button that brings the sidebar back, the app's brand and the title of the page on screen, with room for commands on the right.

Remarks

It is part of the content rather than of the sidebar, since the sidebar is hidden while the content is on screen, and it draws itself only while its sidebar is a page - so it can stay mounted on every layout and cost a desktop nothing.

Namespace
Tesserae
Implements
IComponent

Constructors

NameDescription
SidebarPageBarInitializes a new instance of the SidebarPageBar class.
Constructor
SidebarPageBar
public SidebarPageBar(Sidebar sidebar)

Initializes a new instance of the SidebarPageBar class.

Parameters

sidebar
The sidebar its back button brings back.

Properties

NameDescription
TitleGets or sets the title of the page on screen.
Property
SidebarPageBar.Title
public string Title { get ; set ; }

Gets or sets the title of the page on screen.

Methods

NameDescription
BrandSets the brand shown between the back button and the title - typically the app's logo.
SetTitleSets the title of the page on screen.
CommandsReplaces the commands on the right of the bar.
RenderRenders the bar.
Method
SidebarPageBar.Brand
public SidebarPageBar Brand(IComponent brand)

Sets the brand shown between the back button and the title - typically the app's logo.

Parameters

brand
The brand, or null for none.

Returns

The current instance.

Method
SidebarPageBar.SetTitle
public SidebarPageBar SetTitle(string title)

Sets the title of the page on screen.

Parameters

title
The title.

Returns

The current instance.

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

Replaces the commands on the right of the bar.

Parameters

commands
The commands.

Returns

The current instance.

Method
SidebarPageBar.Render
public HTMLElement Render()

Renders the bar.

Returns

The rendered HTMLElement.

SidebarComponent

A sidebar item that is simply a component of the host's own (a list, a picker, a whole panel), for the parts of a sidebar that buttons and separators can't express. A chat history, a tree of spaces, a filter form: whatever it is, it keeps its own state and only asks the sidebar for a place to stand. The closed (icon-rail) state gets a component of its own; passing none leaves the item out of the rail entirely, which is usually what a list wants.

class

SidebarComponent

public class SidebarComponent : ISidebarItem

A sidebar item that is simply a component of the host's own - a list, a picker, a whole panel - for the parts of a sidebar that buttons and separators can't express. A chat history, a tree of spaces, a filter form: whatever it is, it keeps its own state and only asks the sidebar for a place to stand. The closed (icon-rail) state gets a component of its own, since almost nothing that is worth putting here fits in a 48px rail. Passing none - the default - leaves the item out of the rail entirely, which is usually what a list wants.

Namespace
Tesserae
Implements
ISidebarItem

Constructors

NameDescription
SidebarComponentInitializes a new instance of the SidebarComponent class.
Constructor
SidebarComponent
public SidebarComponent(string identifier, IComponent component, IComponent closedComponent = null)

Initializes a new instance of the SidebarComponent class.

Parameters

identifier
The identifier for the item.
component
What the item shows while the sidebar is open.
closedComponent
What it shows while the sidebar is collapsed to its rail. Null - the default - shows nothing at all there.

Properties

NameDescription
IsSelectedGets or sets whether the item is currently selected. A hosted component owns its own selection, so this is only carried for the sidebar's sake.
CurrentRenderedGets the component that is currently rendered.
IdentifierGets the full identifier of the item, including group identifiers.
OwnIdentifierGets the own identifier of the item, without group identifiers.
Property
SidebarComponent.IsSelected
public bool IsSelected { get; set; }

Gets or sets whether the item is currently selected. A hosted component owns its own selection, so this is only carried for the sidebar's sake.

Property
SidebarComponent.CurrentRendered
public IComponent CurrentRendered

Gets the component that is currently rendered.

Property
SidebarComponent.Identifier
public string Identifier { get; private set; }

Gets the full identifier of the item, including group identifiers.

Property
SidebarComponent.OwnIdentifier
public string OwnIdentifier

Gets the own identifier of the item, without group identifiers.

Methods

NameDescription
AddGroupIdentifierAdds a group identifier prefix to the item's identifier.
ShowShows the item.
CollapseCollapses the item.
NotSortableMarks the item as not draggable in a sortable sidebar - which is what a hosted component usually wants, since it is a region rather than an entry in a list.
GrowLets the item take the leftover height of the sidebar's middle section, for a component that scrolls its own content (a list of chats, a tree).
RenderClosedRenders the item for the closed state of the sidebar.
RenderOpenRenders the item for the open state of the sidebar.
Method
SidebarComponent.AddGroupIdentifier
public void AddGroupIdentifier(string groupIdentifier)

Adds a group identifier prefix to the item's identifier.

Method
SidebarComponent.Show
public void Show()

Shows the item.

Method
SidebarComponent.Collapse
public void Collapse()

Collapses the item.

Method
SidebarComponent.NotSortable
public SidebarComponent NotSortable()

Marks the item as not draggable in a sortable sidebar - which is what a hosted component usually wants, since it is a region rather than an entry in a list.

Method
SidebarComponent.Grow
public SidebarComponent Grow()

Lets the item take the leftover height of the sidebar's middle section, for a component that scrolls its own content (a list of chats, a tree).

Method
SidebarComponent.RenderClosed
public IComponent RenderClosed()

Renders the item for the closed state of the sidebar.

Method
SidebarComponent.RenderOpen
public IComponent RenderOpen()

Renders the item for the open state of the sidebar.

interface

ISidebarItem

public interface ISidebarItem

Defines the interface for items that can be displayed within a Sidebar.

Namespace
Tesserae

Properties

NameDescription
IsSelectedGets or sets whether the item is currently selected.
CurrentRenderedGets the component that is currently rendered.
IdentifierGets the full identifier of the item, including group identifiers.
OwnIdentifierGets the own identifier of the item, without group identifiers.
Property
ISidebarItem.IsSelected
bool IsSelected { get; set; }

Gets or sets whether the item is currently selected.

Property
ISidebarItem.CurrentRendered
IComponent CurrentRendered { get; }

Gets the component that is currently rendered.

Property
ISidebarItem.Identifier
string Identifier { get; }

Gets the full identifier of the item, including group identifiers.

Property
ISidebarItem.OwnIdentifier
string OwnIdentifier { get; }

Gets the own identifier of the item, without group identifiers.

Methods

NameDescription
RenderClosedRenders the item for the closed (collapsed) state of the sidebar.
RenderOpenRenders the item for the open (expanded) state of the sidebar.
ShowShows the item.
CollapseCollapses the item.
AddGroupIdentifierAdds a group identifier prefix to the item's identifier.
Method
ISidebarItem.RenderClosed
IComponent RenderClosed()

Renders the item for the closed (collapsed) state of the sidebar.

Method
ISidebarItem.RenderOpen
IComponent RenderOpen()

Renders the item for the open (expanded) state of the sidebar.

Method
ISidebarItem.Show
void Show()

Shows the item.

Method
ISidebarItem.Collapse
void Collapse()

Collapses the item.

Method
ISidebarItem.AddGroupIdentifier
void AddGroupIdentifier(string groupIdentifier)

Adds a group identifier prefix to the item's identifier.

See also