Sidebar
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.
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
public sealed class Sidebar : IComponent, IBindableComponent<bool>A Sidebar component that can be collapsed or expanded, containing header, middle, and footer sections.
- Namespace
- Tesserae
- Implements
- IComponent, IBindableComponent<bool>
Constructors
| Name | Description |
|---|---|
| Sidebar | Initializes a new instance of the Sidebar class. |
Properties
| Name | Description |
|---|---|
| IsClosed | Gets or sets whether the sidebar is closed. |
| IsShifted | Gets whether the sidebar is currently showing the shifted (child) sidebar. |
| ShiftedSidebar | Gets the child sidebar that is currently mounted for shifting, if any. |
public bool IsClosed { get ; set ; }Gets or sets whether the sidebar is closed.
public bool IsShiftedGets whether the sidebar is currently showing the shifted (child) sidebar.
Methods
| Name | Description |
|---|---|
| Secondary | Sets the sidebar background to the secondary background color. |
| Sortable | Sets whether the middle content items are sortable. |
| AsNavbar | Configures the sidebar to render as a navbar. |
| Closed | Sets whether the sidebar is closed. |
| Toggle | Toggles the closed state of the sidebar. |
| ShiftTo | Slides horizontally into a child sidebar, used when navigating into an interface that has its own sidebar. The child sidebar is rendered inside this one and follows its open/closed state. Only one depth level is supported: shifting into another child replaces the current one. Call ShiftBack to slide back into this sidebar. |
| ShiftBack | Slides back from the child sidebar into this sidebar. |
| OnShiftChanged | Adds a handler that is called whenever the sidebar shifts into the child sidebar (true) or back (false). |
| AddHeader | Adds an item to the sidebar header section. |
| InsertAfterHeader | Inserts an item after another item in the sidebar header section. |
| AddContent | Adds an item to the middle content section. |
| InsertAfterContent | Inserts an item after another item in the middle content section. |
| RemoveContent | Removes an item from the middle content section. |
| AddFooter | Adds an item to the sidebar footer section. |
| InsertAfterFooter | Inserts an item after another item in the sidebar footer section. |
| Clear | Clears all sections of the sidebar. |
| ClearHeader | Clears the header section. |
| ClearContent | Clears the middle content section. |
| ClearFooter | Clears the footer section. |
| Render | Renders the sidebar. |
| AsObservable | Returns an observable that tracks the closed/open state of the sidebar. |
| SetBoundValue | Programmatically opens or closes the sidebar as part of a two-way binding. |
| LoadSorting | Loads the sorting order for sidebar items. Should be called after all items have been added. |
| GetCurrentSorting | Gets the current sorting order of all items in the sidebar. |
| Refresh | Refreshes the sidebar rendering. |
| OnSortingChanged | Adds a sorting change event handler. |
| Search | Searches/Filters the sidebar content items. |
| GetOwnIdentifier | Gets the own identifier of an item by removing group identifier prefix. |
public Sidebar Secondary()Sets the sidebar background to the secondary background color.
Returns
The current instance of the type.
public void Sortable(bool sortable = true)Sets whether the middle content items are sortable.
Parameters
- sortable
- Whether items are sortable.
public Sidebar Closed(bool isClosed = true)Sets whether the sidebar is closed.
Parameters
- isClosed
- Whether the sidebar is closed.
Returns
The current instance of the type.
public Sidebar Toggle()Toggles the closed state of the sidebar.
Returns
The current instance of the type.
public Sidebar ShiftTo(Sidebar child)Slides horizontally into a child sidebar, used when navigating into an interface that has its own sidebar. The child sidebar is rendered inside this one and follows its open/closed state. Only one depth level is supported: shifting into another child replaces the current one. Call ShiftBack to slide back into this sidebar.
Parameters
- child
- The sidebar to shift into.
Returns
The current instance of the type.
public Sidebar ShiftBack()Slides back from the child sidebar into this sidebar.
Returns
The current instance of the type.
public Sidebar OnShiftChanged(Action<bool> onShiftChanged)Adds a handler that is called whenever the sidebar shifts into the child sidebar (true) or back (false).
Parameters
- onShiftChanged
- The event handler.
Returns
The current instance of the type.
public Sidebar AddHeader(ISidebarItem item)Adds an item to the sidebar header section.
Parameters
- item
- The item to add.
Returns
The current instance of the type.
public Sidebar InsertAfterHeader(ISidebarItem item, ISidebarItem addAfter)Inserts an item after another item in the sidebar header section.
Parameters
- item
- The item to insert.
- addAfter
- The item to insert after.
Returns
The current instance of the type.
public Sidebar AddContent(ISidebarItem item)Adds an item to the middle content section.
Parameters
- item
- The item to add.
Returns
The current instance of the type.
public Sidebar InsertAfterContent(ISidebarItem item, ISidebarItem addAfter)Inserts an item after another item in the middle content section.
Parameters
- item
- The item to insert.
- addAfter
- The item to insert after.
Returns
The current instance of the type.
public Sidebar RemoveContent(ISidebarItem item)Removes an item from the middle content section.
Parameters
- item
- The item to remove.
Returns
The current instance of the type.
public IObservable<bool> AsObservable()Returns an observable that tracks the closed/open state of the sidebar.
public void SetBoundValue(bool value)Programmatically opens or closes the sidebar as part of a two-way binding.
public void LoadSorting(Dictionary<string, string[]> itemOrder)Loads the sorting order for sidebar items. Should be called after all items have been added.
Parameters
- itemOrder
- A dictionary mapping group identifiers to ordered item identifiers.
public Dictionary<string, string[]> GetCurrentSorting()Gets the current sorting order of all items in the sidebar.
Returns
A dictionary mapping group identifiers to ordered item identifiers.
public void OnSortingChanged(Action<Dictionary<string, string[]>> onSortingChanged)Adds a sorting change event handler.
Parameters
- onSortingChanged
- The event handler.
public void Search(string searchTerm)Searches/Filters the sidebar content items.
Parameters
- searchTerm
- The term to search for.
Fields
| Name | Description |
|---|---|
| SIDEBAR_TRANSITION_TIME | The transition time for sidebar animations in milliseconds. |
| ROOT_SIDEBAR_FOR_ORDERING | The root identifier used for ordering. |
| GroupIdentifierSeparator | The separator used between group identifiers and item identifiers. |
public const int SIDEBAR_TRANSITION_TIME = 300The transition time for sidebar animations in milliseconds.
public const string ROOT_SIDEBAR_FOR_ORDERING = "ROOT"The root identifier used for ordering.
public class SidebarButton : ISearchableSidebarItemA Button component for use within a Sidebar, supporting both open and closed states.
- Namespace
- Tesserae
- Implements
- ISearchableSidebarItem
Properties
| Name | Description |
|---|---|
| IsSelected | Gets or sets whether the button is currently selected. |
| CurrentRendered | Gets the component that is currently rendered. |
| Identifier | Gets the full identifier of the button. |
| OwnIdentifier | Gets the own identifier of the button. |
public bool IsSelected { get ; set ; }Gets or sets whether the button is currently selected.
public IComponent CurrentRenderedGets the component that is currently rendered.
public string Identifier { get; private set; }Gets the full identifier of the button.
Methods
| Name | Description |
|---|---|
| AddGroupIdentifier | Adds a group identifier prefix to the button's identifier. |
| Show | Shows the button. |
| Collapse | Collapses the button. |
| NotSortable | Marks the button as not sortable. |
| ClearProgress | Clears the progress indication background. |
| Progress | Sets a progress indication background. |
| SetText | Sets the text of the button. |
| CommandsAlwaysVisible | Ensures that commands associated with the button are always visible when the sidebar is open. |
| Light | Sets the button to use a light style. |
| Rounded | Renders the button with rounded corners (defaults to a fully rounded "pill" shape), matching the rounded SidebarSearchBox style. |
| AsSearchBox | 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. |
| Danger | Sets the button to use a danger style. |
| Default | Sets the button to use the default style. |
| Success | Sets the button to use a success style. |
| Primary | Sets the button to use the primary style. |
| Selected | Sets whether the button is selected. |
| Tooltip | Sets a tooltip for the closed state button. |
| OpenedTooltip | Sets a tooltip for the open state button. |
| OnClick | Adds a click event handler to the button. |
| OnOpenIconClick | Adds a click event handler to the icon when the button is open. |
| Id | Sets the ID of the button. |
| OnContextMenu | Adds a context menu event handler to the button. |
| SetIcon | Sets the icon for the button. |
| OnRendered | Adds a rendered event handler. |
| RenderClosed | Renders the button for the closed state of the sidebar. |
| RenderOpen | Renders the button for the open state of the sidebar. |
public void AddGroupIdentifier(string groupIdentifier)Adds a group identifier prefix to the button's identifier.
public SidebarButton NotSortable()Marks the button as not sortable.
Returns
The current instance of the type.
public SidebarButton ClearProgress()Clears the progress indication background.
Returns
The current instance of the type.
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.
public SidebarButton SetText(string text)Sets the text of the button.
Parameters
- text
- The text.
Returns
The current instance of the type.
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.
public SidebarButton Light()Sets the button to use a light style.
Returns
The current instance of the type.
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.
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.
public SidebarButton Danger()Sets the button to use a danger style.
Returns
The current instance of the type.
public SidebarButton Default()Sets the button to use the default style.
Returns
The current instance of the type.
public SidebarButton Success()Sets the button to use a success style.
Returns
The current instance of the type.
public SidebarButton Primary()Sets the button to use the primary style.
Returns
The current instance of the type.
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.
| 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.
| 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.
| 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. |
| 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.
public SidebarButton Id(string id)Sets the ID of the button.
Parameters
- id
- The ID.
Returns
The current instance of the type.
| 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. |
| 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.
public ISidebarItem OnRendered(Action<HTMLElement> onRendered)Adds a rendered event handler.
Parameters
- onRendered
- The rendered event handler.
Returns
The current instance of the type.
public IComponent RenderClosed()Renders the button for the closed state of the sidebar.
public sealed class SidebarPivot : ISearchableSidebarItem- Namespace
- Tesserae
- Implements
- ISearchableSidebarItem
public class SidebarSearchBox : ISidebarItem- Namespace
- Tesserae
- Implements
- ISidebarItem
Properties
| Name | Description |
|---|---|
| Text | 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
| Name | Description |
|---|---|
| Rounded | 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. |
| SetText | Sets the text in the box, without raising OnSearch. |
| Focus | Puts the caret in the box. |
| 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. |
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.
public SidebarSearchBox SetText(string text)Sets the text in the box, without raising OnSearch.
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.
public class SidebarCommand : IComponentA Command component for use within a Sidebar, typically appearing as a small action button.
- Namespace
- Tesserae
- Implements
- IComponent
Methods
| Name | Description |
|---|---|
| Foreground | Sets the foreground color of the command button. |
| HookToParentContextMenu | Configures the command to hook into the parent's context menu event. |
| Background | Sets the background color of the command button. |
| Default | Sets the command to use the default style. |
| Primary | Sets the command to use the primary style. |
| Success | Sets the command to use the success style. |
| Danger | Sets the command to use the danger style. |
| Tooltip | Sets a tooltip for the command. |
| OnClickMenu | Configures the command to show a menu when clicked. |
| ShowMenu | Shows the associated menu for the command. |
| RaiseOnClick | Programmatically raises the click event. |
| RaiseOnContextMenu | Programmatically raises the context menu event. |
| OnClick | Adds a click event handler. |
| OnContextMenu | Adds a context menu event handler. |
| SetIcon | Sets the icon for the command. |
| Render | Renders the sidebar command. |
public SidebarCommand Foreground(string color)Sets the foreground color of the command button.
Parameters
- color
- The color.
Returns
The current instance of the type.
public SidebarCommand HookToParentContextMenu()Configures the command to hook into the parent's context menu event.
Returns
The current instance of the type.
public SidebarCommand Background(string color)Sets the background color of the command button.
Parameters
- color
- The color.
Returns
The current instance of the type.
public SidebarCommand Default()Sets the command to use the default style.
Returns
The current instance of the type.
public SidebarCommand Primary()Sets the command to use the primary style.
Returns
The current instance of the type.
public SidebarCommand Success()Sets the command to use the success style.
Returns
The current instance of the type.
public SidebarCommand Danger()Sets the command to use the danger style.
Returns
The current instance of the type.
| 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.
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.
public SidebarCommand RaiseOnClick(MouseEvent mouseEvent)Programmatically raises the click event.
Parameters
- mouseEvent
- The mouse event arguments.
Returns
The current instance of the type.
public SidebarCommand RaiseOnContextMenu(MouseEvent mouseEvent)Programmatically raises the context menu event.
Parameters
- mouseEvent
- The mouse event arguments.
Returns
The current instance of the type.
| Overload | |
|---|---|
| OnClick(Action) | Adds a click event handler. |
| OnClick(Action<Button, MouseEvent>) | Adds a click event handler with button and mouse event arguments. |
| 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. |
| 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.
public class SidebarCommands : ISidebarItemA component for grouping multiple SidebarCommand items into a single line within a Sidebar.
- Namespace
- Tesserae
- Implements
- ISidebarItem
Properties
| Name | Description |
|---|---|
| IsSelected | Gets or sets whether the group is currently selected. |
| CurrentRendered | Gets the component that is currently rendered. |
| Identifier | Gets the full identifier of the command group. |
| OwnIdentifier | Gets the own identifier of the command group. |
public bool IsSelected { get; set; }Gets or sets whether the group is currently selected.
public IComponent CurrentRendered { get; private set; }Gets the component that is currently rendered.
public string Identifier { get; private set; }Gets the full identifier of the command group.
Methods
| Name | Description |
|---|---|
| RenderOpen | Renders the commands for the open state of the sidebar. |
| Show | Shows the commands. |
| Collapse | Collapses the commands. |
| RenderOpenFull | Renders all commands for the open state without truncation. |
| RenderClosed | Renders the commands for the closed state of the sidebar. |
| AlignEnd | Aligns the commands to the end of the line. |
| NotSortable | Marks the commands as not sortable. |
| AddGroupIdentifier | Adds a group identifier prefix to the command group's identifier. |
public IComponent RenderOpen()Renders the commands for the open state of the sidebar.
public IComponent RenderOpenFull()Renders all commands for the open state without truncation.
public IComponent RenderClosed()Renders the commands for the closed state of the sidebar.
public SidebarCommands AlignEnd()Aligns the commands to the end of the line.
Returns
The current instance of the type.
public SidebarCommands NotSortable()Marks the commands as not sortable.
Returns
The current instance of the type.
public class SidebarText : ISidebarItemA Text component for use within a Sidebar, supporting both open and closed states.
- Namespace
- Tesserae
- Implements
- ISidebarItem
Constructors
| Name | Description |
|---|---|
| SidebarText | Initializes a new instance of the SidebarText class. |
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
| Name | Description |
|---|---|
| CurrentRendered | Gets the component that is currently rendered. |
| IsSelected | Gets or sets whether the item is currently selected. |
| Identifier | Gets the full identifier of the text component. |
| OwnIdentifier | Gets the own identifier of the text component. |
public IComponent CurrentRenderedGets the component that is currently rendered.
public bool IsSelected { get; set; }Gets or sets whether the item is currently selected.
public string Identifier { get; private set; }Gets the full identifier of the text component.
Methods
| Name | Description |
|---|---|
| Show | Shows the text component. |
| Collapse | Collapses the text component. |
| NotSortable | Marks the text component as not sortable. |
| AddGroupIdentifier | Adds a group identifier prefix to the text component's identifier. |
| SetText | Sets the text content for the open state. |
| Foreground | Sets the foreground color of the text. |
| PT | Sets the top padding of the text. |
| PB | Sets the bottom padding of the text. |
| PL | Sets the left padding of the text. |
| RenderClosed | Renders the text for the closed state of the sidebar. |
| RenderOpen | Renders the text for the open state of the sidebar. |
public SidebarText NotSortable()Marks the text component as not sortable.
Returns
The current instance of the type.
public void AddGroupIdentifier(string groupIdentifier)Adds a group identifier prefix to the text component's identifier.
public SidebarText SetText(string text)Sets the text content for the open state.
Parameters
- text
- The text.
Returns
The current instance of the type.
public SidebarText Foreground(string color)Sets the foreground color of the text.
Parameters
- color
- The color.
Returns
The current instance of the type.
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.
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.
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.
public IComponent RenderClosed()Renders the text for the closed state of the sidebar.
public class SidebarBadge : IComponentA Badge component for sidebar items, often used to display counts or status indicators.
- Namespace
- Tesserae
- Implements
- IComponent
Constructors
| Name | Description |
|---|---|
| SidebarBadge | Initializes a new instance of the SidebarBadge class. |
| 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.
Methods
| Name | Description |
|---|---|
| SemiTransparent | Sets the badge icon to be semi-transparent. |
| Foreground | Sets the foreground color of the badge. |
| Background | Sets the background color of the badge. |
| Default | Sets the badge to use the default style. |
| Primary | Sets the badge to use the primary style. |
| Success | Sets the badge to use the success style. |
| Danger | Sets the badge to use the danger style. |
| Tooltip | Sets a tooltip for the badge. |
| SetIcon | Sets the icon for the badge. |
| SetBadge | Sets the text content of the badge. |
| Render | Renders the sidebar badge. |
public SidebarBadge SemiTransparent()Sets the badge icon to be semi-transparent.
Returns
The current instance of the type.
public SidebarBadge Foreground(string color)Sets the foreground color of the badge.
Parameters
- color
- The color.
Returns
The current instance of the type.
public SidebarBadge Background(string color)Sets the background color of the badge.
Parameters
- color
- The color.
Returns
The current instance of the type.
public SidebarBadge Default()Sets the badge to use the default style.
Returns
The current instance of the type.
public SidebarBadge Primary()Sets the badge to use the primary style.
Returns
The current instance of the type.
public SidebarBadge Success()Sets the badge to use the success style.
Returns
The current instance of the type.
public SidebarBadge Danger()Sets the badge to use the danger style.
Returns
The current instance of the type.
| 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.
| 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.
public SidebarBadge SetBadge(string badge)Sets the text content of the badge.
Parameters
- badge
- The badge text.
Returns
The current instance of the type.
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.
public class SidebarComponent : ISidebarItemA 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
| Name | Description |
|---|---|
| SidebarComponent | Initializes a new instance of the SidebarComponent class. |
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
| Name | Description |
|---|---|
| IsSelected | 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. |
| CurrentRendered | Gets the component that is currently rendered. |
| Identifier | Gets the full identifier of the item, including group identifiers. |
| OwnIdentifier | Gets the own identifier of the item, without group identifiers. |
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.
public IComponent CurrentRenderedGets the component that is currently rendered.
public string Identifier { get; private set; }Gets the full identifier of the item, including group identifiers.
Methods
| Name | Description |
|---|---|
| AddGroupIdentifier | Adds a group identifier prefix to the item's identifier. |
| Show | Shows the item. |
| Collapse | Collapses the item. |
| 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. |
| 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). |
| RenderClosed | Renders the item for the closed state of the sidebar. |
| RenderOpen | Renders the item for the open state of the sidebar. |
public void AddGroupIdentifier(string groupIdentifier)Adds a group identifier prefix to the item's identifier.
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.
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).
public IComponent RenderClosed()Renders the item for the closed state of the sidebar.
public interface ISidebarItemDefines the interface for items that can be displayed within a Sidebar.
- Namespace
- Tesserae
Properties
| Name | Description |
|---|---|
| IsSelected | Gets or sets whether the item is currently selected. |
| CurrentRendered | Gets the component that is currently rendered. |
| Identifier | Gets the full identifier of the item, including group identifiers. |
| OwnIdentifier | Gets the own identifier of the item, without group identifiers. |
bool IsSelected { get; set; }Gets or sets whether the item is currently selected.
IComponent CurrentRendered { get; }Gets the component that is currently rendered.
string Identifier { get; }Gets the full identifier of the item, including group identifiers.
Methods
| Name | Description |
|---|---|
| RenderClosed | Renders the item for the closed (collapsed) state of the sidebar. |
| RenderOpen | Renders the item for the open (expanded) state of the sidebar. |
| Show | Shows the item. |
| Collapse | Collapses the item. |
| AddGroupIdentifier | Adds a group identifier prefix to the item's identifier. |
IComponent RenderClosed()Renders the item for the closed (collapsed) state of the sidebar.
IComponent RenderOpen()Renders the item for the open (expanded) state of the sidebar.