Lingo.Component.Modal (Lingo v0.4.2)

Copy Markdown View Source

Builders for modals and their inputs. Open one with Lingo.Context.show_modal/2; the submission reaches Lingo.Bot.handle_modal/2, with field values keyed by custom id.

show_modal!(ctx, Modal.modal("feedback", "Feedback", [
  Modal.label("Subject", Modal.text_input("subject", required: true)),
  Modal.label("Details", Modal.text_input("body", style: :paragraph))
]))

Summary

Functions

A checkbox. Option: :default.

A multiple-choice group. Options: :min_values, :max_values and :required.

A file upload field. Options: :min_values, :max_values, :required and :file_types.

A label and optional :description around an input.

A modal with a title and up to 5 labeled inputs.

A single-choice group. Option: :required.

A text field. Options: :style (:short or :paragraph), :placeholder, :min_length, :max_length, :required and :value. Wrap it in label/3, or give the label as the second argument.

Functions

checkbox(custom_id, opts \\ [])

@spec checkbox(
  String.t(),
  keyword()
) :: map()

A checkbox. Option: :default.

checkbox_group(custom_id, options, opts \\ [])

@spec checkbox_group(String.t(), [map()], keyword()) :: map()

A multiple-choice group. Options: :min_values, :max_values and :required.

file_upload(custom_id, opts \\ [])

@spec file_upload(
  String.t(),
  keyword()
) :: map()

A file upload field. Options: :min_values, :max_values, :required and :file_types.

label(text, component, opts \\ [])

@spec label(String.t(), map(), keyword()) :: map()

A label and optional :description around an input.

modal(custom_id, title, components)

@spec modal(String.t(), String.t(), [map()]) :: map()

A modal with a title and up to 5 labeled inputs.

radio_group(custom_id, options, opts \\ [])

@spec radio_group(String.t(), [map()], keyword()) :: map()

A single-choice group. Option: :required.

text_input(custom_id, label_or_opts \\ [], opts \\ [])

@spec text_input(String.t(), String.t() | keyword(), keyword()) :: map()

A text field. Options: :style (:short or :paragraph), :placeholder, :min_length, :max_length, :required and :value. Wrap it in label/3, or give the label as the second argument.