Attributes to apply to the avatar element
The fullTime
helper displays a formatted time string wrapped in a
The highlight
helper searches for a word phrase in a string, and wraps
matches with the tag.
The string to highlight.
Optional
phrase: string | RegExpThe word or words to highlight.
Optional
length: numberThe number of characters to truncate the string to. The string will be truncated surrounding the first match.
The humanTime
helper displays a time in a human-friendly time-ago format
(e.g. '12 days ago'), wrapped in a
The icon
helper displays an icon.
The full icon class, prefix and the icon’s name.
Any other attributes to apply.
The listItems
helper wraps an array of components in the provided tag,
stripping out any unnecessary Separator
components.
By default, this tag is an <li>
tag, but this is customisable through the
second function parameter, customTag
.
The punctuateSeries
helper formats a list of strings (e.g. names) to read
fluently in the application's locale.
punctuateSeries(['Toby', 'Franz', 'Dominion']) // Toby, Franz, and Dominion
')}
The useronline
helper displays a green circle if the user is online.
The username
helper displays a user's username in a
tag. If the user doesn't exist, the username will be displayed as [deleted].
The abbreviateNumber
utility converts a number to a shorter localized form.
abbreviateNumber(1234);
// "1.2K"
The anchorScroll
utility saves the scroll position relative to an element,
and then restores it after a callback has been run.
This is useful if a redraw will change the page's content above the viewport. Normally doing this will result in the content in the viewport being pushed down or pulled up. By wrapping the redraw with this utility, the scroll position can be anchor to an element that is in or below the viewport, so the content in the viewport will stay the same.
The element to anchor the scroll position to.
The callback to run that will change page content.
Rest
...inputs: ClassValue[]The computed
utility creates a function that will cache its output until
any of the dependent values are dirty.
Rest
...args: [...string[], ((this, ...args) => T)]Escapes the RegExp
special characters in input
.
Protected
handlers: Record<string, unknown>Arrays of registered event handlers, grouped by the event name.
Unregister an event handler.
The name of the event.
The function that handles the event.
Register an event handler.
The name of the event.
The function to handle the event.
Register an event handler so that it will run only once, and then unregister itself.
The name of the event.
The function to handle the event.
The extract
utility deletes a property from an object and returns its
value.
The object that owns the property
The name of the property to extract
The value of the property
Extract the text nodes from a virtual element.
The formatNumber
utility localizes a number into a string with the
appropriate punctuation based on the provided locale otherwise will default to the users locale.
formatNumber(1234);
// 1,234
The humanTime
utility converts a date to a localized, human-readable time-
ago string.
The isDark
utility converts a hex color to rgb, and then calculates a YIQ
value in order to get the appropriate brightness value. See
https://www.w3.org/TR/AERT/#color-contrast for references.
A YIQ value >= 128 corresponds to a light color according to the W3C standards, but we use a custom threshold for each light and dark modes to preserve design consistency.
Returns if the passed value is an object.
In this context, "object" refers to any non-primitive value, including arrays, function, maps, dates, and more.
isObject({}); // true
isObject([]); // true
isObject(function () {}); // true
isObject(Object(1)); // true
isObject(null); // false
isObject(1); // false
isObject("hello world"); // false
The liveHumanTimes
initializer sets up a loop every 1 second to update
timestamps rendered with the humanTime
helper.
The mapRoutes
utility converts a map of named application routes into a
format that can be understood by Mithril, and wraps them in route resolvers
to provide each route with the current route name.
The mixin
utility assigns the properties of a set of 'mixin' objects to
the prototype of a parent object.
The class to extend the new class from.
Rest
...mixins: Record<string, any>[]The objects to mix in.
A new class that extends Parent and contains the mixins.
class MyClass extends mixin(ExistingClass, evented, etc) {}
Mithril 2 does not completely rerender the page if a route change leads to the same route (or the same component handling a different route). This util calls m.route.set, forcing a reonit.
Convert the given string to a unique color.
Check if class A is the same as or a subclass of class B.
An event handler factory that makes it simpler to implement data binding for component event listeners.
The handler created by this factory passes the DOM element's attribute identified by the first argument to the callback (usually a bidirectional Mithril stream: https://mithril.js.org/stream.html#bidirectional-bindings).
Replaces m.withAttr for Mithril 2.0.
Generated using TypeDoc v0.24.8
The
avatar
helper displays a user's avatar.