custom_elements-rails 0.1.1 → 0.1.2
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b77ebf93580a7eb3cb83365dc83ba086f6d3bb1f20e173020039c08c5234669c
|
4
|
+
data.tar.gz: fc62a709561eeeefdae11cac69983062664d21065e058b376932258d3d1a522a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb09a978e032b95385a14b5a2e7ef060edd995981466eb941cef16c423bf27ba00ab012f9169e9502ea40c60308014b19fcdc8e3d1601b3f57c847d830cd276b
|
7
|
+
data.tar.gz: b7dc6b1f79854aa70ae148222eb8093d772cb647f927dc7d73f4d8a7b0202389c4f5f80db1f2645bb21c8982e4785aa1097365fd521521d12a9670b3100a8ebf
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Custom Elements with Rails
|
2
2
|
|
3
|
-
This gem provides a small helper and
|
3
|
+
This gem provides a small js-helper, installation and generators to use custom elements in conjunction with `importmap-rails`.
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
@@ -33,14 +33,44 @@ app/javascript
|
|
33
33
|
└── index.js
|
34
34
|
```
|
35
35
|
|
36
|
-
You can now add the `<app-hello>` custom element in your
|
36
|
+
You can now add the `<app-hello>` custom element in your HTML. No build step needed.
|
37
|
+
|
38
|
+
## How it works
|
39
|
+
|
40
|
+
`eagerDefineCustomElementsFrom("custom_elements", { prefix: "app" })` will parse the JSON-importmap rendered by the `importmap-rails` gem and register custom elements with `customElements.define(...)` to the browser's custom element registry.
|
41
|
+
|
42
|
+
```
|
43
|
+
custom_elements/hello_element.js // will register <app-hello>
|
44
|
+
```
|
45
|
+
|
46
|
+
Your `_element.js` files have to `export default` custom elements for this to work.
|
47
|
+
|
48
|
+
> [!WARNING]
|
49
|
+
> Only single word elements are support currently.
|
50
|
+
|
37
51
|
|
38
52
|
## Add a custom element
|
39
53
|
|
40
|
-
|
54
|
+
Generate a new custom element with:
|
55
|
+
|
56
|
+
```bash
|
57
|
+
$ rails generate custom_element test
|
58
|
+
```
|
59
|
+
|
60
|
+
This will generate
|
61
|
+
|
62
|
+
```
|
63
|
+
app/javascript
|
64
|
+
└── custom_elements
|
65
|
+
└── test_element.js
|
66
|
+
```
|
67
|
+
|
68
|
+
which in turn will register a `<app-test></app-test>` custom element.
|
41
69
|
|
42
70
|
## Contributing
|
43
|
-
|
71
|
+
|
72
|
+
TODO
|
44
73
|
|
45
74
|
## License
|
75
|
+
|
46
76
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: custom_elements-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Niklas Häusele
|
@@ -38,6 +38,8 @@ files:
|
|
38
38
|
- lib/custom_elements/rails.rb
|
39
39
|
- lib/custom_elements/rails/railtie.rb
|
40
40
|
- lib/custom_elements/rails/version.rb
|
41
|
+
- lib/generators/custom_element_generator.rb
|
42
|
+
- lib/generators/templates/custom_element.js.tt
|
41
43
|
- lib/install/install.rb
|
42
44
|
- lib/tasks/custom_elements/rails_tasks.rake
|
43
45
|
homepage: https://github.com/codergeek121/custom_elements-rails
|