SuperintelligenceWeb.CoreComponents (superintelligence v0.1.0)

Provides core UI components.

Summary

Functions

Renders a back navigation link.

Renders a button.

Generates a generic error message.

Renders flash notices.

Shows the flash group with standard titles and content.

Renders a header with title.

Renders a Heroicon.

Renders an input with label and error messages.

Renders a label.

Renders a list of items.

Renders a simple form.

Renders a table with generic styling.

Translates an error message using gettext.

Translates the errors for a field from a keyword list of errors.

Functions

back(assigns)

Renders a back navigation link.

Attributes

  • navigate (:any) (required)

Slots

  • inner_block (required)

button(assigns)

Renders a button.

Attributes

  • type (:string) - Defaults to nil.
  • class (:string) - Defaults to nil.
  • Global attributes are accepted. Supports all globals plus: ["disabled", "form", "name", "value"].

Slots

  • inner_block (required)

error(assigns)

Generates a generic error message.

Slots

  • inner_block (required)

flash(assigns)

Renders flash notices.

Attributes

  • flash (:map) - the map of flash messages. Defaults to %{}.
  • title (:string) - Defaults to nil.
  • kind (:atom) - used for styling and flash lookup. Must be one of :info, or :error.
  • Global attributes are accepted. the arbitrary HTML attributes to add to the flash.

Slots

  • inner_block - the optional inner block that renders the flash message.

flash_group(assigns)

Shows the flash group with standard titles and content.

Attributes

  • flash (:map) (required) - the map of flash messages.
  • id (:string) - the optional id of flash container. Defaults to "flash-group".

header(assigns)

Renders a header with title.

Attributes

  • class (:string) - Defaults to nil.

Slots

  • inner_block (required)
  • subtitle
  • actions

hide(js \\ %JS{}, selector)

hide_modal(js \\ %JS{}, id)

icon(assigns)

Renders a Heroicon.

Heroicons come in three styles – outline, solid, and mini. By default, the outline style is used, but solid and mini may be applied by using the -solid and -mini suffix.

You can customize the size and colors of the icons by setting width, height, and background color classes.

Icons are extracted from the deps/heroicons directory and bundled within your compiled app.css by the plugin in your assets/tailwind.config.js.

Examples

<.icon name="hero-x-mark-solid" />
<.icon name="hero-arrow-path" class="ml-1 w-3 h-3 animate-spin" />

Attributes

  • name (:string) (required)
  • class (:string) - Defaults to nil.

input(assigns)

Renders an input with label and error messages.

Attributes

  • id (:any) - Defaults to nil.
  • name (:any)
  • label (:string) - Defaults to nil.
  • value (:any)
  • type (:string) - Defaults to "text". Must be one of "checkbox", "color", "date", "datetime-local", "email", "file", "month", "number", "password", "range", "search", "select", "tel", "text", "textarea", "time", "url", or "week".
  • field (Phoenix.HTML.FormField) - a form field struct retrieved from the form, for example: @form[:email].
  • errors (:list) - Defaults to [].
  • checked (:boolean) - the checked flag for checkbox inputs.
  • prompt (:string) - the prompt for select inputs. Defaults to nil.
  • options (:list) - the options to pass to Phoenix.HTML.Form.options_for_select/2.
  • multiple (:boolean) - the multiple flag for select inputs. Defaults to false.
  • Global attributes are accepted. Supports all globals plus: ["accept", "autocomplete", "capture", "cols", "disabled", "form", "list", "max", "maxlength", "min", "minlength", "multiple", "pattern", "placeholder", "readonly", "required", "rows", "size", "step"].

label(assigns)

Renders a label.

Attributes

  • for (:string) - Defaults to nil.

Slots

  • inner_block (required)

list(assigns)

Renders a list of items.

Slots

  • item (required) - Accepts attributes:
    • title (:string) (required)

show(js \\ %JS{}, selector)

show_modal(js \\ %JS{}, id)

simple_form(assigns)

Renders a simple form.

Attributes

  • for (:any) (required) - the datastructure for the form.
  • as (:any) - the server side parameter to collect all input under. Defaults to nil.
  • Global attributes are accepted. the arbitrary HTML attributes to apply to the form tag. Supports all globals plus: ["autocomplete", "name", "rel", "action", "enctype", "method", "novalidate", "target", "multipart"].

Slots

  • inner_block (required)
  • actions - the slot for form actions, such as a submit button.

table(assigns)

Renders a table with generic styling.

Attributes

  • id (:string) (required)
  • rows (:list) (required)
  • row_id (:any) - the function for generating the row id. Defaults to nil.
  • row_click (:any) - the function for handling phx-click on each row. Defaults to nil.
  • row_item (:any) - the function for mapping each row before calling the :col and :action slots. Defaults to &Function.identity/1.

Slots

  • col (required) - Accepts attributes:
    • label (:string)
  • action - the slot for showing user actions in the last table column.

translate_error(arg)

Translates an error message using gettext.

translate_errors(errors, field)

Translates the errors for a field from a keyword list of errors.