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.
Trigger an event.
The name of the event.
Rest
...args: any[]Arguments to pass to event handlers.
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.
The routes
initializer defines the forum app's routes.
Get a list of controls for a discussion.
The parent component under which the controls menu will be displayed.
Protected
Get controls for a discussion which are destructive (e.g. delete).
Protected
Get controls for a discussion pertaining to moderation (e.g. rename, lock).
Rename the discussion.
Open the reply composer for the discussion. A promise will be returned, which resolves when the composer opens successfully. If the user is not logged in, they will be prompted. If they don't have permission to reply, the promise will be rejected.
Whether or not to scroll down to the last post if the discussion is being viewed.
Whether or not to force a reload of the composer component, even if it is already open for this discussion.
Protected
Get controls for a discussion pertaining to the current user (e.g. reply, follow).
The parent component under which the controls menu will be displayed.
Delete the user.
Edit the user.
Show deletion alert of user.
Shows an alert if the user has not yet confirmed their email address.
The slidable
utility adds touch gestures to an element so that it can be
slid away to reveal controls underneath, and then released to activate those
controls.
It relies on the element having children with particular CSS classes.
The function returns a record with a reset
proeprty. This is a function
which reverts the slider to its original position. This should be called,
for example, when a controls dropdown is closed.
Generated using TypeDoc v0.24.8
The
avatar
helper displays a user's avatar.