Current section
Files
Jump to
Current section
Files
lib/dev_joy/scene/note.ex
defmodule DevJoy.Scene.Note do
@moduledoc """
The note is visually represented as a titled text that can be used
as a notice, chapter information, or any other type of information
which appears before or after content,
or even between dialogs to explain words used in dialog content.
> ### Usage {: .info}
>
> The [`note`](`t:t/0`) always requires its [`content`](`t:content/0`) and [`title`](`t:title/0`).
> You can also optionally specify additional [`data`](`t:data/0`).
>
> ```elixir
> defmodule MyApp.SceneName do
> use DevJoy.Scene
>
> part :note do
> note "Note title", "Note content"
>
> note "Note title", [some: :data], "Note content"
>
> note "Note title", [some: :data] do
> "Note content"
> end
> end
> end
> ```
"""
@enforce_keys ~w[content title]a
@doc """
The [`note`](`t:t/0`) structure contains the following keys:
- [`content`](`t:content/0`) - a content of the note
- [`data`](`t:data/0`) - a keyword list of additional note data
- [`title`](`t:title/0`) - a title of the note
"""
@doc section: :main
defstruct [:content, :title, data: []]
@typedoc """
The type representing the [`note`](`__struct__/0`) structure.
"""
@typedoc section: :main
@type t :: %__MODULE__{
content: content(),
data: data(),
title: title()
}
@typedoc """
The type representing the content of the note.
"""
@typedoc section: :field
@type content :: String.t()
@typedoc """
The type representing the additional data of the note.
"""
@typedoc section: :field
@type data :: Keyword.t()
@typedoc """
The type representing the title of the note.
"""
@typedoc section: :field
@type title :: String.t()
end