defmodule Moon.Design.Carousel.Reel do @moduledoc false use Moon.StatelessComponent, slot: "reel" import Moon.Helpers.MakeList @doc "Id attribute for DOM element" prop(id, :string) @doc "Data-testid attribute for DOM element" prop(testid, :string) @doc "Additional Tailwind classes" prop(class, :css_class) @doc "Additional Tailwind classes for indicator" prop(indicator_class, :css_class) @doc "Item of Carousel component, see Carousel.Item" slot(item) @doc "Indicator of Carousel component, see Carousel.Indicator" slot(indicator) @doc "Default slot of Carousel.Reel, used for examples with auto-generated Carousel items" slot(default) # Internal API @doc "Will be got from Carousel in most cases" prop(autoslide_delay, :integer, from_context: :autoslide_delay) @doc "Will be got from Carousel in most cases" prop(step, :integer, from_context: :step) @doc "Will be got from Carousel in most cases" prop(value, :integer, from_context: :value) @doc "Will be got from Carousel in most cases" prop(on_change, :event, from_context: :on_change) def render(assigns) do ~F"""
{#for {item, index} <- Enum.with_index(make_list(@item))} {#if !item.is_hidden} <#slot {@indicator} context_put={ on_change: @on_change, value: to_string(index) } /> {/if} {/for}
""" end end