DevactionUI.Calendar.Layout (devaction_ui v0.2.3)

Copy Markdown View Source

Where the events of one day go in a column of hours: the pure geometry behind the week view with hours.

An event is a map with starts_at and, optionally, ends_at (both Time). One without ends_at lasts 30 minutes and one that ends before it starts lasts 15. Events that overlap in time share the width of the column: each gets a column of its own (left and width, as percentages of the day) and the ones that do not touch keep the full width. top and height are percentages of the hours shown, so the caller needs to know no pixel size. An event that crosses the edge of the range is cut at the edge, one fully outside it is not placed, and one without starts_at is not placed either (it is an all-day event).

Summary

Functions

The minutes since midnight of a time.

The events of a day placed in the column of the hours in hours (a range such as 8..17, the last hour included).

Types

placed()

@type placed() :: %{
  event: map(),
  top: float(),
  height: float(),
  left: float(),
  width: float()
}

Functions

minutes(time)

@spec minutes(Time.t()) :: non_neg_integer()

The minutes since midnight of a time.

place(events, hours)

@spec place([map()], Range.t()) :: [placed()]

The events of a day placed in the column of the hours in hours (a range such as 8..17, the last hour included).