Skip to content

Commit b7cc43d

Browse files
committed
v1.5.5
1 parent 6fdfe49 commit b7cc43d

5 files changed

Lines changed: 38 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Changelog
2+
### 1.5.5 - 2023-09-18 02:15:19
3+
4+
- adds an attribute to `hide_close_button` in the modal header
5+
26
### 1.5.4 - 2023-09-13 04:05:32
37

48
- Changed close icon svg to Heroicons

assets/default.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ select.has-error:not(.phx-no-feedback) {
12391239
}
12401240

12411241
input[type="file_input"].has-error:not(.phx-no-feedback) {
1242-
@apply !border-danger-500 !rounded-md focus:!border-danger-500 !text-danger-900 !placeholder-danger-700 !bg-danger-50 file:!border-none dark:!border-none dark:!bg-[#160B0B] dark:text-danger-400;
1242+
@apply !border-danger-500 !rounded-md focus:!border-danger-500 !text-danger-900 !placeholder-danger-700 !bg-danger-50 file:!border-none dark:!border-none dark:!bg-gray-950 dark:text-danger-400;
12431243
}
12441244

12451245
/* If in tailwind.config.json, darkMode: 'class', use this: */

lib/petal_components/modal.ex

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ defmodule PetalComponents.Modal do
2222
default: true,
2323
doc: "whether the modal should close when a user hits escape"
2424

25+
attr :hide_close_button, :boolean,
26+
default: false,
27+
doc: "whether or not the modal should have a close button in the header"
28+
2529
attr :max_width, :string,
2630
default: "md",
2731
values: ["sm", "md", "lg", "xl", "2xl", "full"],
@@ -57,15 +61,16 @@ defmodule PetalComponents.Modal do
5761
<div class="pc-modal__header__text">
5862
<%= @title %>
5963
</div>
60-
61-
<button
62-
type="button"
63-
phx-click={hide_modal(@close_modal_target, @id)}
64-
class="pc-modal__header__button"
65-
>
66-
<div class="sr-only">Close</div>
67-
<Heroicons.x_mark class="pc-modal__header__close-svg" />
68-
</button>
64+
<%= unless @hide_close_button do %>
65+
<button
66+
type="button"
67+
phx-click={hide_modal(@close_modal_target, @id)}
68+
class="pc-modal__header__button"
69+
>
70+
<div class="sr-only">Close</div>
71+
<Heroicons.x_mark class="pc-modal__header__close-svg" />
72+
</button>
73+
<% end %>
6974
</div>
7075
</div>
7176
<!-- Content -->

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ defmodule PetalComponents.MixProject do
22
use Mix.Project
33

44
@source_url "https://github.com/petalframework/petal_components"
5-
@version "1.5.4"
5+
@version "1.5.5"
66

77
def project do
88
[

test/petal/modal_test.exs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,22 @@ defmodule PetalComponents.ModalTest do
9090

9191
refute html =~ ~s{phx-window-keydown}
9292
end
93+
94+
test "hide_close_button" do
95+
assigns = %{}
96+
97+
html =
98+
rendered_to_string(~H"""
99+
<.modal></.modal>
100+
""")
101+
102+
assert html =~ "<svg"
103+
104+
html =
105+
rendered_to_string(~H"""
106+
<.modal hide_close_button></.modal>
107+
""")
108+
109+
refute html =~ "<svg"
110+
end
93111
end

0 commit comments

Comments
 (0)