MishkaBlogWeb.Templates.EditionChips (Mishka Blog v0.0.1)

Copy Markdown View Source

The language chips of a translated blog record: one per edition, the record's own first, each opening that edition.

The post, collection and tag lists show one row per document rather than one per translation (MishkaCmsCore.LanguageEditions), so these chips are the way to a translation without searching for it. A card draws them as row/1, a table row as inline/1; both click show_edition with the edition's id, which the list's page answers.

The siblings are read off the record's language_variants (or master_language_variants), so the table has to preload them — see editions/1.

See MishkaBlogWeb.Templates.CollectionCard and MishkaBlogWeb.Templates.PostCard.

Summary

Functions

A record's sibling editions — the same record in other languages — each with its own colour.

The chips of a table row's cell, all of them wrapping.

The labelled chip row of a card.

Functions

editions(record)

@spec editions(map()) :: [map()]

A record's sibling editions — the same record in other languages — each with its own colour.

Needs the sibling relationship loaded; a record that has no group, or whose siblings did not arrive, has none.

inline(assigns)

The chips of a table row's cell, all of them wrapping.

id scopes the chips' DOM ids, so it has to differ between the rows of one page — the record's id does. Nothing is drawn when editions is empty, so the cell can fall back to a plain language badge.

Attributes

  • id (:string) (required)
  • record (:map) (required)
  • editions (:list) (required)
  • accent (:map) (required)
  • event (:string) - Defaults to "show_edition".

row(assigns)

The labelled chip row of a card.

The label and the first shown chips share one line that never reflows: the rest open underneath rather than pushing the row they came from. id is the card's own DOM id, which scopes the -editions-more, -editions-less and -editions-rest elements the toggle flips (MishkaCmsCoreWeb.Templates.CardChrome.expand_editions/1).

Attributes

  • id (:string) (required)
  • record (:map) (required)
  • editions (:list) (required)
  • accent (:map) (required)
  • shown (:integer) - Defaults to 2.
  • event (:string) - Defaults to "show_edition".
  • class (:any) - Defaults to nil.