Skip to content

Commit 16cbc07

Browse files
ukutahtBijay-Shre-sthaapata
authored
Use Prima for invitation modal (#5843)
* Replace invitation modal with Prima * Better focus handling * Simplify css * Remove unnecessary transition classes * Clarify comment about testing * Fix typo * Remove alpine.js initialization * Use prima 0.1.7 * Unlock autumn and rustler deps * Npm run format * Fix invitation modal reject button on mobile Co-authored-by: Bijay-Shre-stha <[email protected]> * Update assets/js/liveview/live_socket.js Co-authored-by: Artur Pata <[email protected]> --------- Co-authored-by: Bijay-Shre-stha <[email protected]> Co-authored-by: Artur Pata <[email protected]>
1 parent a07aaa6 commit 16cbc07

File tree

8 files changed

+210
-193
lines changed

8 files changed

+210
-193
lines changed

assets/js/liveview/live_socket.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/**
2-
These 3 modules are resolved from '../deps' folder,
3-
which does not exist when running the lint command in Github CI
2+
The modules below this comment block are resolved from '../deps' folder,
3+
which does not exist when running the lint command in Github CI
44
*/
55
/* eslint-disable import/no-unresolved */
66
import 'phoenix_html'
77
import { Socket } from 'phoenix'
88
import { LiveSocket } from 'phoenix_live_view'
9+
import { Modal } from 'prima'
910
import topbar from 'topbar'
1011
/* eslint-enable import/no-unresolved */
1112

@@ -14,7 +15,7 @@ import Alpine from 'alpinejs'
1415
let csrfToken = document.querySelector("meta[name='csrf-token']")
1516
let websocketUrl = document.querySelector("meta[name='websocket-url']")
1617
if (csrfToken && websocketUrl) {
17-
let Hooks = {}
18+
let Hooks = { Modal }
1819
Hooks.Metrics = {
1920
mounted() {
2021
this.handleEvent('send-metrics', ({ event_name }) => {

lib/plausible_web/components/generic.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,10 +1060,11 @@ defmodule PlausibleWeb.Components.Generic do
10601060

10611061
slot :inner_block, required: true
10621062
attr :class, :any, default: nil
1063+
attr :rest, :global
10631064

10641065
def h2(assigns) do
10651066
~H"""
1066-
<h2 class={[@class || "font-semibold leading-6 text-gray-900 dark:text-gray-100"]}>
1067+
<h2 class={[@class || "font-semibold leading-6 text-gray-900 dark:text-gray-100"]} {@rest}>
10671068
{render_slot(@inner_block)}
10681069
</h2>
10691070
"""
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
defmodule PlausibleWeb.Live.Components.PrimaModal do
2+
@moduledoc false
3+
use PlausibleWeb, :component
4+
alias Prima.Modal
5+
6+
attr :id, :string, required: true
7+
slot :inner_block, required: true
8+
9+
def modal(assigns) do
10+
~H"""
11+
<Modal.modal id={@id}>
12+
<Modal.modal_overlay
13+
transition_enter={{"ease-out duration-300", "opacity-0", "opacity-100"}}
14+
transition_leave={{"ease-in duration-200", "opacity-100", "opacity-0"}}
15+
class="fixed inset-0 bg-gray-500/75 dark:bg-gray-800/75"
16+
/>
17+
18+
<div class="fixed inset-0 w-screen overflow-y-auto">
19+
<div class="flex min-h-full items-end justify-center p-4 sm:items-center sm:p-0">
20+
<Modal.modal_panel
21+
id={@id <> "-panel"}
22+
class="relative overflow-hidden rounded-lg bg-white dark:bg-gray-900 text-left shadow-xl sm:w-full sm:max-w-lg"
23+
transition_enter={
24+
{"ease-out duration-300", "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
25+
"opacity-100 translate-y-0 sm:scale-100"}
26+
}
27+
transition_leave={
28+
{"ease-in duration-200", "opacity-100 translate-y-0 sm:scale-100",
29+
"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"}
30+
}
31+
>
32+
{render_slot(@inner_block)}
33+
</Modal.modal_panel>
34+
</div>
35+
</div>
36+
</Modal.modal>
37+
"""
38+
end
39+
40+
slot :inner_block, required: true
41+
42+
def modal_title(assigns) do
43+
~H"""
44+
<Modal.modal_title as={&h2/1}>
45+
{render_slot(@inner_block)}
46+
</Modal.modal_title>
47+
"""
48+
end
49+
end

0 commit comments

Comments
 (0)