defmodule ReflectOS.Kernel.Section.Definition do
@moduledoc """
Holds the section definition struct.
## Struct Fields
* **name** [required]: The name of the section type when it's
displayed in the Console UI.
* **icon** [required]: An SVG in raw string format which will be displayed
next to section in the Console UI.
* **description** [optional]: A short description of what the section does.
If provided, must be a single arity function an argument called `assigns` which returns a compiled `HEEx` component. The best way to accomplish this is to
use the `Phoenix.LiveView.sigil_H/2` macro.
* **auto_align** [optional, default: false]: A boolean indicating if the
ReflectOS layout should inject styles into the `opts` argument in the
section's`init_section` based on where the section appears in the layout. For
example, if your section appears on the right side of the screen, the layout
might inject a `text_align: right` style.
## Example
Here is the `Timer` example from the `ReflectOS.Kernel.Section` documentation:
%Definition{
name: "Timer",
icon: \"\"\"
\"\"\",
description: fn assigns ->
~H\"\"\"
This section allows you to configure a timer for your ReflectOS dashboard, which will count down to zero.
To start a new time after it reaches zero, simply update the sections configuration with a new timer.
\"\"\"
end
}
"""
@enforce_keys [:name, :icon]
@type t :: %__MODULE__{
name: binary(),
icon: binary(),
description: (map() -> Macro.t()) | nil,
auto_align: boolean()
}
defstruct name: nil,
description: nil,
icon: nil,
auto_align: false
end