strada-rails 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ba041b765b36676475aae45a8ed1c4a396a82384f3c920dd9b5da13c8ba354d
4
- data.tar.gz: c2982c99194493b435c821f44695d8812bd2418d656648d1b70eee0060209531
3
+ metadata.gz: 740926ca9ab2b6efe5fd77b47845ed644e69194012650288f455878dabb2590e
4
+ data.tar.gz: 3dd01fd9b07941f80858b0dc75fd891945070a71842550938d243a3005da0241
5
5
  SHA512:
6
- metadata.gz: 790e4154a5b8a7233559253412fe44fe72bd1e8bff0a142f1b6ed0df21a9715b8a95e1536f1bedb4a0d0504c41b0645099c75561c4d0487736465089a0dda9ee
7
- data.tar.gz: 3710682666422aaafcb85c924a568deacde3b9cd7383848ac79212fbbd942778538e2db64fb6cc3f7bb03f3efb6082cdc2734de98fe651fc27585f95777ae2fe
6
+ metadata.gz: 171a27456df5587e48bb5ac64647f63108bcfc537054d975e0ae90894e0690c98bce6e1ca86eb7eb0ddf8dcf7bec1214716d0f22f6ad5093427afa132a4d1e93
7
+ data.tar.gz: 1766d2e43d0a65fefc410174d69664a4fb4cedcce1466bd46507f294f73c7fd900fd3bf626f97d617c33edbfac96b623b9584322a9497b3c610514e33dcd2386
data/.DS_Store ADDED
Binary file
@@ -14,9 +14,16 @@
14
14
  display: none;
15
15
  }
16
16
 
17
+ /*
18
+ * Hide when the "menu" component is registered.
19
+ */
20
+ [data-bridge-components~=menu] [data-controller~=bridge--menu] {
21
+ display: none;
22
+ }
23
+
17
24
  /*
18
25
  * Hide when the "flash-message" component is registered.
19
26
  */
20
27
  [data-bridge-components~=flash-message] [data-controller~=bridge--flash-message] {
21
- display: none
28
+ display: none;
22
29
  }
@@ -0,0 +1,46 @@
1
+ import { BridgeComponent } from "@hotwired/strada"
2
+ import { BridgeElement } from "@hotwired/strada"
3
+
4
+ // Example
5
+ // https://github.com/lazaronixon/strada-rails/wiki/Menu
6
+ export default class extends BridgeComponent {
7
+ static component = "menu"
8
+ static targets = [ "title", "item" ]
9
+
10
+ show(event) {
11
+ if (this.enabled) {
12
+ event.stopImmediatePropagation()
13
+ this.notifyBridgeToDisplayMenu(event)
14
+ }
15
+ }
16
+
17
+ notifyBridgeToDisplayMenu(event) {
18
+ const title = new BridgeElement(this.titleTarget).title
19
+ const items = this.makeMenuItems(this.itemTargets)
20
+
21
+ this.send("display", { title, items }, message => {
22
+ const selectedIndex = message.data.selectedIndex
23
+ const selectedItem = new BridgeElement(this.itemTargets[selectedIndex])
24
+
25
+ selectedItem.click()
26
+ })
27
+ }
28
+
29
+ makeMenuItems(elements) {
30
+ const items = elements.map((element, index) => this.menuItem(element, index))
31
+ const enabledItems = items.filter(item => item)
32
+
33
+ return enabledItems
34
+ }
35
+
36
+ menuItem(element, index) {
37
+ const bridgeElement = new BridgeElement(element)
38
+
39
+ if (bridgeElement.disabled) return null
40
+
41
+ return {
42
+ title: bridgeElement.title,
43
+ index: index
44
+ }
45
+ }
46
+ }
@@ -12,7 +12,7 @@ export default class extends BridgeComponent {
12
12
  const title = this.bridgeElement.title
13
13
 
14
14
  this.send("connect", { title }, () => {
15
- this.element.click()
15
+ this.bridgeElement.click()
16
16
  })
17
17
  }
18
18
  }
@@ -1,3 +1,3 @@
1
1
  module Strada
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strada-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nixon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-29 00:00:00.000000000 Z
11
+ date: 2023-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -31,6 +31,7 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - ".DS_Store"
34
35
  - CHANGELOG.md
35
36
  - CODE_OF_CONDUCT.md
36
37
  - LICENSE.txt
@@ -55,6 +56,7 @@ files:
55
56
  - lib/install/app/assets/stylesheets/strada.css
56
57
  - lib/install/app/javascript/controllers/bridge/flash_message_controller.js
57
58
  - lib/install/app/javascript/controllers/bridge/form_controller.js
59
+ - lib/install/app/javascript/controllers/bridge/menu_controller.js
58
60
  - lib/install/app/javascript/controllers/bridge/nav_button_controller.js
59
61
  - lib/install/strada_with_importmap.rb
60
62
  - lib/install/strada_with_node.rb