Current section
Files
Jump to
Current section
Files
src/kitazith@component@section.erl
-module(kitazith@component@section).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/kitazith/component/section.gleam").
-export([new_thumbnail/1, with_thumbnail_id/2, new/2, with_id/2, to_json/1]).
-export_type([section/0, thumbnail/0]).
-type section() :: {section,
gleam@option:option(integer()),
list(kitazith@component@text_display:text_display()),
thumbnail()}.
-type thumbnail() :: {thumbnail,
gleam@option:option(integer()),
kitazith@component@media:unfurled_media_item()}.
-file("src/kitazith/component/section.gleam", 26).
-spec new_thumbnail(kitazith@component@media:unfurled_media_item()) -> thumbnail().
new_thumbnail(Media) ->
{thumbnail, none, Media}.
-file("src/kitazith/component/section.gleam", 32).
-spec with_thumbnail_id(thumbnail(), integer()) -> thumbnail().
with_thumbnail_id(Thumbnail, Id) ->
{thumbnail, {some, Id}, erlang:element(3, Thumbnail)}.
-file("src/kitazith/component/section.gleam", 36).
-spec new(list(kitazith@component@text_display:text_display()), thumbnail()) -> section().
new(Components, Accessory) ->
{section, none, Components, Accessory}.
-file("src/kitazith/component/section.gleam", 43).
-spec with_id(section(), integer()) -> section().
with_id(Section, Id) ->
{section,
{some, Id},
erlang:element(3, Section),
erlang:element(4, Section)}.
-file("src/kitazith/component/section.gleam", 59).
-spec thumbnail_to_json(thumbnail()) -> gleam@json:json().
thumbnail_to_json(Thumbnail) ->
kitazith@internal@json_helper:object_omit_none(
[{some, {<<"type"/utf8>>, gleam@json:int(11)}},
kitazith@internal@json_helper:optional(
<<"id"/utf8>>,
erlang:element(2, Thumbnail),
fun gleam@json:int/1
),
{some,
{<<"media"/utf8>>,
kitazith@component@media:to_json(
erlang:element(3, Thumbnail)
)}}]
).
-file("src/kitazith/component/section.gleam", 47).
-spec to_json(section()) -> gleam@json:json().
to_json(Section) ->
kitazith@internal@json_helper:object_omit_none(
[{some, {<<"type"/utf8>>, gleam@json:int(9)}},
kitazith@internal@json_helper:optional(
<<"id"/utf8>>,
erlang:element(2, Section),
fun gleam@json:int/1
),
{some,
{<<"components"/utf8>>,
gleam@json:array(
erlang:element(3, Section),
fun kitazith@component@text_display:to_json/1
)}},
{some,
{<<"accessory"/utf8>>,
thumbnail_to_json(erlang:element(4, Section))}}]
).