DevactionUI.CodeBlock (devaction_ui v0.1.0)

Copy Markdown View Source

A block of code in mono, given as the code attribute. lang: :heex colours it (components, slots, attributes, strings, expressions, comments) through DevactionUI.Highlight. tone: :dark is the ink block of a suggestion; :risk and :ok are the "your code" and "idiomatic" blocks of a lesson, tinted red and green. It keeps its own line breaks and scrolls sideways instead of widening the page.

Summary

Functions

code_block(assigns)

Attributes

  • tone (:atom) - Defaults to :dark. Must be one of :dark, :risk, :ok, or :neutral.
  • label (:string) - a mono caption above the block. Defaults to nil.
  • lang (:atom) - :heex colours the code by what each part of the template is. Defaults to nil. Must be one of nil, or :heex.
  • class (:any) - Defaults to nil.
  • code (:string) (required) - the code as text: a pre keeps every space, so it never comes from a slot.
  • Global attributes are accepted.