The cookie notice, a bordered card anchored to the bottom of the page.
It has a short text, three actions (preferences, only the necessary, accept all) and, when the person asks for the preferences, the list of cookie categories each with its own switch.
It is a role="dialog" that is not modal (aria-modal="false"): the page behind stays usable, so nothing
traps the focus and nothing takes it on mount. The server owns what is open and what is chosen: open shows
the categories, preferences_event toggles them, necessary_event and accept_event answer the notice and
category_event (with phx-value-id) flips a category; events are strings or %JS{}, and target serves a
LiveComponent. A category with locked is on and cannot change (the necessary ones).
The DevactionUI.CookieConsent hook handles the keyboard and the focus: Esc closes only the categories (it
presses the preferences button, so the server decides), opening them moves the focus to the first switch you can
change when it was the preferences button that had it, and closing them returns it to the button if it was lost.
fixed (the default) anchors the notice to the bottom of the viewport; with fixed={false} it flows in the
page, for a preview.
Summary
Functions
The cookie notice.
Functions
@spec banner(map()) :: Phoenix.LiveView.Rendered.t()
The cookie notice.
Attributes
id(:string) (required)title(:string) (required) - the bold lead of the text; it names the dialog.open(:boolean) - whether the list of categories is shown. Defaults tofalse.fixed(:boolean) - anchored to the bottom of the viewport. Defaults totrue.privacy_label(:string) - the text of the link to the privacy policy. Defaults tonil.privacy_href(:string) - Defaults tonil.preferences_label(:string) (required)preferences_event(:any) - string or%JS{}; togglesopenon the server. Defaults tonil.necessary_label(:string) (required)necessary_event(:any) - Defaults tonil.accept_label(:string) (required)accept_event(:any) - Defaults tonil.category_event(:any) - string or%JS{}, withphx-value-idof the category. Defaults tonil.target(:any) - aphx-target(a@myself) when used inside a LiveComponent. Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
inner_block(required) - the text of the notice, after the title.category- a kind of cookie with its switch. Accepts attributes:id(:string) (required)title(:string) (required)description(:string)checked(:boolean)locked(:boolean) - on and unchangeable.