Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Carousel.Item is_hidden workaround #713

Merged
merged 6 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/moon/design/carousel/item.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ defmodule Moon.Design.Carousel.Item do
@doc "Will be got from Carousel in most cases"
prop(is_active, :boolean, from_context: :is_active)

@doc "Conditional displaying, bc of some bug with named slots in surface"
phgrey marked this conversation as resolved.
Show resolved Hide resolved
prop(is_hidden, :boolean, default: false)

def render(assigns) do
~F"""
<li
:if={!@is_hidden}
{=@id}
{=@value}
class={merge([
Expand Down
18 changes: 10 additions & 8 deletions lib/moon/design/carousel/reel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@ defmodule Moon.Design.Carousel.Reel do
"flex absolute bottom-8 left-1/2 -translate-x-1/2 rtl:flex-row-reverse",
@indicator_class
])}>
{#for {_, index} <- Enum.with_index(make_list(@item) ++ make_list(@default))}
<#slot
{@indicator}
context_put={
on_change: @on_change,
value: to_string(index)
}
/>
{#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}
</div>
"""
Expand Down