Fragiola

API: primitives (@fragiola/calendar-react)

NowIndicator

The current time in today's column with nowIndicator(), positioned at its fraction of the day and moved by the engine's clock.

NowIndicator marks the current time in today's Calendar.Column, with the nowIndicator() feature from @fragiola/calendar-react/now-indicator. It renders a div positioned at now's fraction of the column (position: absolute, top); the line, the dot and the time it may show are yours.

Behaviour

  • It renders only in today's column, and only once the engine runs (a server render has no "now"): render it in every column, it shows in the right one.
  • The engine moves it at each nowIndicator({ interval }) tick (default a minute), from the injected clock (now on the model or the root), and refreshes "today" at the display zone's midnight.
  • It is aria-hidden.
  • Without nowIndicator() in the model's features it renders nothing and warns once.

Usage

import { Calendar } from "@fragiola/calendar-react";
import { NowIndicator } from "@fragiola/calendar-react/now-indicator";

export function NowColumns() {
    return (
        <Calendar.Columns>
            {(column) => (
                <Calendar.Column column={column}>
                    <NowIndicator className="now">
                        {({ position }) => <span className="now-time">{position.time}</span>}
                    </NowIndicator>
                </Calendar.Column>
            )}
        </Calendar.Columns>
    );
}
.now {
    inset-inline: 0;
    border-block-start: 2px solid red;
}

useNowPosition (on the hooks page) gives the same position anywhere.

Now indicator
Gallery

Attributes

attributevalue
data-calendar-partdata-calendar-part="now-indicator"
aria-hiddentrue
styleposition: absolute, top (structural)

Props

In Vue: the same props (in kebab-case in a template), and slots in place of children; see Vue primitives.

In Angular: a directive on your element, the props as its inputs, templates in place of children; see Angular primitives.

NowIndicatorProps takes the common props and any div attribute, and:

proptypedescription
childrenReactNode, or (state: NowIndicatorState) => ReactNodewhat it shows (a line, a dot): elements, or a function of its state

State

NowIndicatorState:

fieldtypedescription
positionNowPositionwhere now is: today (date), the wall-clock time (HH:mm), its fraction of the column (top)