Fragiola

API: primitives (@fragiola/calendar-react)

Calendar.SlotRow

A time grid's row at one time of day, its label and one slot cell per day, marked with the slot's time in data-time.

Calendar.SlotRow is a row of the time grid at one slot: a div with role="row" and data-time, holding the row's label and a slot per day. Its height (the slot height of your design) and its lines are yours.

Behaviour

  • One row per slot of the APG grid pattern: a rowheader (Calendar.SlotLabel), then a gridcell per day (Calendar.Slot), the cells of the roving focus.
  • Up and Down move the focus between rows in a column; the first row's Up reaches the all-day row.
  • Children as a function are called per day (the row wraps them in Calendar.Slots); children as elements let you put the label first.

Usage

import { Calendar, type TimeSlot } from "@fragiola/calendar-react";

export function Row(props: { slot: TimeSlot }) {
    return (
        <Calendar.SlotRow
            slot={props.slot}
            className={({ slot }) =>
                slot.time.endsWith(":00") ? "row row-hour" : "row"
            }
        >
            <Calendar.SlotLabel>{props.slot.time}</Calendar.SlotLabel>
            <Calendar.Slots>
                {(column) => <Calendar.Slot date={column.date} />}
            </Calendar.Slots>
        </Calendar.SlotRow>
    );
}

The class (a className function of the state in React, read from the slot prop in Vue, from the let-slot context in Angular) draws a stronger line on the full hours.

Attributes

attributevalue
data-calendar-partdata-calendar-part="slot-row"
data-timethe slot's start, HH:mm
rolerow

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.

SlotRowProps takes the common props and any div attribute (but slot), and:

proptypedescription
slotTimeSlotthe slot, from Calendar.SlotRows' children function
childrenReactNode, or (column: TimeGridColumn) => ReactNodea function called per day (<Calendar.Slot date={column.date} />), or elements: a Calendar.SlotLabel, then Calendar.Slots

State

SlotRowState:

fieldtypedescription
slotTimeSlotthe slot: its time (HH:mm) and its place in a column (top, height fractions)