phoenix_duskmoon 4.0.0

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/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2022 Jonathan Gao
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # PhoenixDuskmoon
2
+
3
+ [![release](https://github.com/gsmlg-dev/phoenix-duskmoon-ui/actions/workflows/test-and-release.yml/badge.svg)](https://github.com/gsmlg-dev/phoenix-duskmoon-ui/actions/workflows/test-and-release.yml)
4
+
5
+ Collection of helpers to generate and manipulate Web Component.
6
+
7
+ Although this project was originally extracted from Phoenix,
8
+ it does not depend on Phoenix and can be used with any Plug
9
+ application (or even without Plug).
10
+
11
+ See the [docs](https://hexdocs.pm/phoenix_duskmoon/) for more information.
12
+
13
+ About at [Web Component](https://developer.mozilla.org/en-US/docs/Web/Web_Components)
14
+
15
+ ## Install
16
+
17
+ Add deps in `mix.exs`
18
+ ```elixir
19
+ {:phoenix_duskmoon, "~> 3.0"},
20
+ ```
21
+
22
+ Include in phoenix view helpers
23
+
24
+ ```elixir
25
+ defp html_helpers do
26
+ quote do
27
+ # import all helper functions
28
+ use PhoenixDuskmoon
29
+
30
+ # or
31
+ use PhoenixDuskmoon, :alias
32
+ ...
33
+ end
34
+ end
35
+ ```
36
+
37
+ Include `javascript`
38
+
39
+ ```javascript
40
+ import 'phoenix_duskmoon';
41
+ ```
42
+
43
+ Web Componet library is now external
44
+
45
+ ```bash
46
+ npm install @gsmlg/lit
47
+ ```
48
+
49
+ Import `css`
50
+
51
+ ```css
52
+ @import 'phoenix_duskmoon/priv/static/phoenix_duskmoon.css';
53
+ ```
54
+
55
+ Use custom hook
56
+
57
+ ```javascript
58
+ import "phoenix_duskmoon";
59
+ const WebComponentHook = window.__WebComponentHook__;
60
+ const liveSocket = new LiveSocket("/live", Socket, {hooks: { WebComponentHook }});
61
+ ```
62
+
63
+ Send custom events to live view:
64
+ ```html
65
+ <Element darkmoon-send-sync-content="load_content" phx-hook="WebComponentHook" />
66
+ <Element darkmoon-send-sync-content="load_content;loadAccepted" phx-hook="WebComponentHook" />
67
+ ```
68
+ - In the first element, when element trigger customEvents `sync-content`, also use `pushEvent` send `load_content` to live view.
69
+ - Second element are same as first, but will call `loadAccepted` on element when receive server send feedback.
70
+
71
+ Receive live view event:
72
+ ```html
73
+ <Element darkmoon-receive-update_content="updateContent" phx-hook="WebComponentHook" />
74
+ <!-- equal -->
75
+ <Element darkmoon-receive="update_content;updateContent" phx-hook="WebComponentHook" />
76
+ ```
77
+ - In this case, when live view fire `update_content` event, also trigger `updateContent` method on elmenet.
78
+ - If value(`updateContent`) is empty, trigger a same event `update_content` on element.
79
+
80
+ Import CSS
81
+
82
+ ```css
83
+ import "phoenix_duskmoon/priv/static/phoenix_duskmoon.css"
84
+ ```
85
+
86
+ ## Live Storybook
87
+
88
+ [Live Storybook](https://duskmoon-storybook.gsmlg.dev)
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "phoenix_duskmoon",
3
+ "version": "4.0.0",
4
+ "main": "./priv/static/phoenix_duskmoon.js",
5
+ "exports": {
6
+ ".": "./priv/static/phoenix_duskmoon.js",
7
+ "./css": "./priv/static/phoenix_duskmoon.css",
8
+ "./svg/mdi/*.svg": "./priv/mdi/svg/*.svg",
9
+ "./svg/bsi/*.svg": "./priv/bsi/svg/*.svg"
10
+ },
11
+ "scripts": {
12
+ "build": "mix tailwind default && mix esbuild default"
13
+ },
14
+ "files": [
15
+ "README.md",
16
+ "CHANGELOG.md",
17
+ "LICENSE",
18
+ "package.json",
19
+ "priv/static/",
20
+ "priv/svg/"
21
+ ],
22
+ "publishConfig": {
23
+ "registry": "https://registry.npmjs.org/"
24
+ },
25
+ "dependencies": {
26
+ "@gsmlg/lit": "^1.29.5",
27
+ "lit": "^2.4.1",
28
+ "lit-element": "^3.2.2",
29
+ "lit-html": "^2.4.0"
30
+ },
31
+ "devDependencies": {
32
+ "@babel/core": "^7.20.5",
33
+ "@babel/preset-env": "^7.20.2"
34
+ },
35
+ "peerDependencies": {
36
+ "@gsmlg/lit": "^1.29.5",
37
+ "lit": "^2.4.1",
38
+ "lit-element": "^3.2.2",
39
+ "lit-html": "^2.4.0"
40
+ }
41
+ }