The news in a LiveView: a button with the count of unread entries, the
panel it opens, and the announcement of the moment. They read @tayori,
from Tayori.Live.
<Tayori.Components.news_button tayori={@tayori} />
<Tayori.Components.news_panel tayori={@tayori} />
<Tayori.Components.announcement tayori={@tayori} />Put the button where the app's header has its icons, and the panel and
the announcement once in the layout (they are fixed to the page). They
need tayori.css (and tayori-sumi.css for Sumi), and the Tayori
hook, which shows the dates in the reader's time zone and language (see
the In the app guide).
The panel lists the newest entries as cards: a cover, the categories, the date, the title and the summary. A card opens its entry in the panel, whole, with its reactions. Escape goes back, then closes.
news/1 and entry/1 are the list and an entry alone, for a page of
the app's own.
Summary
Functions
The entry announced to the reader now, if the app has the
:announcements feature and the admin announced one: a popup, a toast
or a banner, as the admin chose, with its button. Dismissing it is
remembered for the reader on every device.
A category's pill, in its colour.
An entry's cover image.
One entry, whole, in the translation Tayori.news/2 chose for the reader.
A list of entries, whole: their cover, categories, date, title and body.
The button that opens the panel, with the count of unread entries. Its accessible name says the count ("What's new, 2 new updates").
The panel of the news: the newest entries as cards, the pinned ones first, with a "New" mark on those the reader had not seen; the categories to filter by; an entry open whole; "Show more", and a link to the public page. Escape goes back to the list, then closes; so does a click outside.
The reactions of an entry: each emoji with its count; the reader's own are pressed.
Functions
The entry announced to the reader now, if the app has the
:announcements feature and the admin announced one: a popup, a toast
or a banner, as the admin chose, with its button. Dismissing it is
remembered for the reader on every device.
Attributes
tayori(Tayori.Live.State) (required)
A category's pill, in its colour.
Attributes
key(:string) (required)categories(:map) - Defaults to%{}.locale(:string) - Defaults tonil.locales(:list) - Defaults to[].
An entry's cover image.
Attributes
cover(:map) (required)class(:string) - Defaults tonil.loading(:string) - Defaults to"lazy".
One entry, whole, in the translation Tayori.news/2 chose for the reader.
Attributes
entry(Tayori.Entry) (required)new(:boolean) - Defaults tofalse.messages(:map) (required)categories(:map) - Defaults to%{}.locales(:list) - Defaults to[].href(:string) - Defaults tonil.heading(:string) - Defaults to"h3".cover(:boolean) - Defaults totrue.
Slots
footer
A list of entries, whole: their cover, categories, date, title and body.
Attributes
entries(:list) (required) - entries with theirtranslation, fromTayori.news/2.messages(:map) - the words, fromTayori.Messages.for_locale/2. Defaults tonil.seen_before(DateTime) - entries published after it are marked New. Defaults tonil.page(:string) - the public page: each title links to its entry. Defaults tonil.heading(:string) - the element of the titles. Defaults to"h3".categories(:map) - the categories by key (Tayori.Categories.by_key/0). Defaults to%{}.
The button that opens the panel, with the count of unread entries. Its accessible name says the count ("What's new, 2 new updates").
Attributes
tayori(Tayori.Live.State) (required)class(:any) - classes of the button, besidestayori-button. Defaults tonil.label(:boolean) - show the word "What's new" beside the icon. Defaults tofalse.- Global attributes are accepted.
The panel of the news: the newest entries as cards, the pinned ones first, with a "New" mark on those the reader had not seen; the categories to filter by; an entry open whole; "Show more", and a link to the public page. Escape goes back to the list, then closes; so does a click outside.
Attributes
tayori(Tayori.Live.State) (required)class(:any) - Defaults tonil.- Global attributes are accepted.
The reactions of an entry: each emoji with its count; the reader's own are pressed.
Attributes
entry_id(:string) (required)reactions(:any) (required) -{counts, mine}ofTayori.Reactions.for_entries/2.emoji(:list) (required)messages(:map) (required)disabled(:boolean) - a visitor sees the counts and cannot react. Defaults tofalse.event(:string) - Defaults to"tayori:react".