inertiax-ui 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Modal.svelte ADDED
@@ -0,0 +1,95 @@
1
+ <script module>
2
+ import { mount, unmount } from 'svelte';
3
+ import { Frame } from 'inertiax-svelte'
4
+ import Modal from './Modal.svelte';
5
+ import { cubicOut } from 'svelte/easing';
6
+
7
+ export function modal(node) {
8
+ node.addEventListener('click', (e) => {
9
+ e.preventDefault()
10
+ const href = node.getAttribute('href')
11
+ const modal = mount(Modal, {
12
+ target: document.body,
13
+ props: {
14
+ src: href,
15
+ close: () => {
16
+ unmount(modal, {outro: true})
17
+ }
18
+ }
19
+ })
20
+ })
21
+ }
22
+
23
+
24
+ function variable(node, { delay = 0 }) {
25
+ // duration on desktop is 300, on mobile 400
26
+ const duration = window.innerWidth > 768 ? 300 : 400;
27
+ return {
28
+ delay,
29
+ duration,
30
+ easing: cubicOut,
31
+ tick: (t) => {
32
+ node.style.setProperty("--progress", t);
33
+ },
34
+ // css: (t) => `--transition: ${t}`
35
+ };
36
+ }
37
+ </script>
38
+
39
+ <script>
40
+ import { fade,scale } from 'svelte/transition';
41
+ const { src, close } = $props()
42
+ </script>
43
+
44
+ <div class="modal_wrapper">
45
+ <!-- svelte-ignore a11y_click_events_have_key_events,a11y_no_static_element_interactions -->
46
+ <div class="modal_bg" onclick={close} transition:fade></div>
47
+ <div class="modal layout" aria-modal="true" role="dialog" transition:variable>
48
+ <Frame {src} />
49
+ <nav>
50
+ <button onclick={close} aria-label="Close modal">
51
+ <div class="i-material-symbols-light:close-rounded">Close</div>
52
+ </button>
53
+ </nav>
54
+ </div>
55
+ </div>
56
+
57
+ <style>
58
+ .modal_wrapper {
59
+
60
+ }
61
+ .modal_bg {
62
+ background: rgba(0, 0, 0, 0.7);
63
+ position: absolute;
64
+ top: 0;
65
+ left: 0;
66
+ width: 100%;
67
+ height: 100%;
68
+ /* z-index: -1; */
69
+ }
70
+ nav {
71
+ grid-area: header;
72
+ display: flex;
73
+ justify-content: flex-end;
74
+ button {
75
+ font-size: 1.5rem;
76
+
77
+ }
78
+ }
79
+ .modal {
80
+ position: fixed;
81
+ bottom: 0;
82
+ transform: translateY(calc((1 - var(--progress)) * 100%));
83
+ background-color: #00000022;
84
+ border: 1px solid #333;
85
+ border-top-left-radius: 2rem;
86
+ border-top-right-radius: 2rem;
87
+ backdrop-filter: blur(8px);
88
+ }
89
+
90
+ @media (min-width: 640px) {
91
+ .modal {
92
+ max-width: 400px;
93
+ }
94
+ }
95
+ </style>
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # Inertia X UI
2
+
3
+ A collection of Svelte components for [Inertia X](https://github.com/buhrmi/inertiax).
4
+
5
+ ## Modal
6
+
7
+ The Modal component displays an Inertia X Frame within a modal. It can be created via the `modal` action:
8
+
9
+ ```svelte
10
+ <script>
11
+ import { modal } from 'inertiax-ui'
12
+ </script>
13
+
14
+ <a href="/profile/edit" use:modal>Edit profile</a>
15
+ ```
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export { default as Modal } from './Modal.svelte';
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "inertiax-ui",
3
+ "version": "0.0.1",
4
+ "description": "UI component library for Inertia X",
5
+ "type": "module",
6
+ "svelte": "./Modal.svelte",
7
+ "main": "./index.js",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./index.d.ts",
11
+ "svelte": "./Modal.svelte",
12
+ "default": "./index.js"
13
+ },
14
+ "./Modal.svelte": "./Modal.svelte"
15
+ },
16
+ "files": [
17
+ "index.js",
18
+ "Modal.svelte",
19
+ "index.d.ts"
20
+ ],
21
+ "peerDependencies": {
22
+ "svelte": "^5.0.0",
23
+ "inertiax-svelte": "^11.0.8"
24
+ }
25
+ }