Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ erl_crash.dump
prima-*.tar

# Ignore assets that are produced by build tools.
/priv/static/assets/
# /priv/static/assets/
/demo/priv/static/assets/

# Ignore digested assets cache.
Expand Down
21 changes: 14 additions & 7 deletions assets/js/hooks/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export default {
},

setupElements() {
this.autoClose = Object.hasOwn(this.el.dataset, 'primaAutoClose')

if (!this.ref("modal-panel")) {
this.async = true
}
Expand Down Expand Up @@ -126,18 +128,23 @@ export default {
}
},

handleModalClose() {
this.restoreBodyScroll()
this.maybeExecJS(this.ref("modal-overlay"), "js-hide");
this.maybeExecJS(this.ref("modal-panel"), "js-hide");
this.maybeExecJS(this.ref("modal-loader"), "js-hide");
if (this.async) {
this.ref("modal-panel").dataset.primaDirty = true
handleModalClose(e) {
if (this.autoClose || !e) {
this.restoreBodyScroll()
this.maybeExecJS(this.ref("modal-overlay"), "js-hide");
this.maybeExecJS(this.ref("modal-panel"), "js-hide");
this.maybeExecJS(this.ref("modal-loader"), "js-hide");
if (this.async) {
this.ref("modal-panel").dataset.primaDirty = true
}
} else {
this.maybeExecJS(this.el, "js-hide");
}
},

handleOverlayHideEnd() {
this.maybeExecJS(this.el, "js-hide");
this.js().hide(this.el)
this.el.setAttribute('aria-hidden', 'true')
this.restoreFocusedElement()
},
Expand Down
6 changes: 2 additions & 4 deletions lib/prima/dropdown.ex
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,7 @@ defmodule Prima.Dropdown do
attr :class, :string, default: ""
attr :disabled, :boolean, default: false
attr :as, :any, default: nil

# Workaround - unfortunately there seems to be no way to pass through arbitrary assigns without emitting compile warnings
# Since dropdown items are often rendered as links, we add the <.link> attributes here as well.
attr :rest, :global, include: ~w(navigate patch href)
attr :args, :map, default: %{}
slot :inner_block, required: true

@doc """
Expand All @@ -149,6 +146,7 @@ defmodule Prima.Dropdown do
* `class` - CSS classes for styling the menu item
* `disabled` - Boolean to mark the item as disabled (default: false)
* `as` - Custom function component to render instead of the default div element
* `args` - A map of args passed directly to the `as` function

## Examples

Expand Down
4 changes: 3 additions & 1 deletion lib/prima/modal.ex
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ defmodule Prima.Modal do
attr :id, :string, required: true
attr :class, :string, default: ""
attr :on_close, JS, default: %JS{}
attr :auto_close, :boolean, default: true
attr :show, :boolean, default: false
attr :portal, :boolean, default: true

Expand Down Expand Up @@ -175,7 +176,8 @@ defmodule Prima.Modal do
<div
id={@id}
js-show={JS.show()}
js-hide={@on_close |> JS.hide()}
js-hide={@on_close}
data-prima-auto-close={@auto_close}
data-prima-show={@show}
style="display: none;"
phx-hook="Modal"
Expand Down
Loading
Loading