Skip to content

Commit 2a3fa92

Browse files
committed
Fix content_position when set
1 parent f5ccc44 commit 2a3fa92

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/petal_components/carousel.ex

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ defmodule PetalComponents.Carousel do
1717
use Phoenix.Component
1818
import PetalComponents.Icon, only: [icon: 1]
1919
import Phoenix.LiveView.Utils, only: [random_id: 0]
20-
alias Phoenix.HTML.Link
21-
import PetalComponents.Link
2220

2321
@doc """
2422
The `carousel` component is used to create interactive carousels with customizable attributes
@@ -61,6 +59,7 @@ defmodule PetalComponents.Carousel do
6159
attr :image, :string, doc: "URL of the image to display in the slide"
6260
attr :navigate, :string, doc: "Internal route to navigate to when the slide is clicked"
6361
attr :href, :string, doc: "External URL to navigate to when the slide is clicked"
62+
attr :content_position, :string, doc: "Position of content (start, center, end)"
6463
end
6564

6665
def carousel(assigns) do
@@ -187,13 +186,22 @@ defmodule PetalComponents.Carousel do
187186
defp text_position_class(_), do: ""
188187

189188
defp slide_content(assigns) do
189+
content_position_class = case Map.get(assigns, :slide)[:content_position] do
190+
"start" -> "items-start justify-start text-left"
191+
"end" -> "items-end justify-end text-right"
192+
"center" -> "items-center justify-center text-center"
193+
_ -> "items-center justify-center text-center" # Default to center
194+
end
195+
196+
assigns = assign(assigns, :content_position_class, content_position_class)
197+
190198
~H"""
191199
<div class="pc-carousel__slide-content">
192200
<div :if={!is_nil(@image)} class="pc-carousel__image-wrapper">
193201
<img src={@image} class="pc-carousel__image" />
194202
</div>
195203
<div class="pc-carousel__content">
196-
<div class="pc-carousel__content-wrapper">
204+
<div class={"pc-carousel__content-wrapper #{@content_position_class}"}>
197205
<div class="pc-carousel__title">
198206
{@title}
199207
</div>

0 commit comments

Comments
 (0)