phlexy_ui 0.1.8 → 0.1.10

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: 3e6545417ad6baf0ab1e8b33c1c23ab3513089c787ad274f08fb3094a43d9a44
4
- data.tar.gz: 13c7469dac369c048a1f78cebda90e9035457326b072b7ae2d3f6fb4bca8c35f
3
+ metadata.gz: f59d7f461c2ebf91b2bf3646cc33fa8122c9df39449f3a59879766c2230406d8
4
+ data.tar.gz: 6972f8cb458ccfdd10af9212c840f62e02ef1a8050f014c7438cc58c923fb1e9
5
5
  SHA512:
6
- metadata.gz: 870e25f3780ed7cadf59047cfe78330a429ee0f4b0e27c5f635be30df4792165304b0acd9343f341efdd22bcde9aeae5d420ce67b467c16a8bad5613efd2aa17
7
- data.tar.gz: 4a3dbfa5b575f9aaa408e216ee635fd9d23a5eae619acf5be7c92e8438683f964ba72cbc94b767e1f32375d2e791bf804916cf33320666da76e2b1ba30faf40e
6
+ metadata.gz: c4fbcc5a531c1b5c5cdb1a0eeb49bcd59a3dcf4ddd0562cd3fa297a909ea673d5b05493bb429548f5336966c668d07ea5e118b3aa7abfa8feba0ce2408a27f18
7
+ data.tar.gz: 5ecf6460831ce0047b4a1162aa5870f2adf01b2113927e9baa4f7573a82ce6494f8b4e416f1815657119e94dbdba1bad975cdd9250060ff9ec2e2ba5a3eb1d9c
@@ -16,52 +16,10 @@ module PhlexyUI
16
16
  options:
17
17
  ).then do |classes|
18
18
  if modal
19
- # TODO: Remove this abomination once Phlex 2.0 is released.
20
- #
21
- # The cleanest way to do this is with a single:
22
- #
23
- # onclick: "#{modal}.showModal()"
24
- #
25
- # However, currently, Phlex does not allow you to use the "onclick"
26
- # attribute.
27
- #
28
- # Once Phlex 2.0 is released, it will add a #safe method
29
- # that will allow us to replace this with a single line:
30
- #
31
- # onclick: safe("#{modal}.showModal()")
32
- #
33
- # For now, at least this only runs once and uses event delegation
34
- # so that it only adds a single event listener to the document.body.
35
- #
36
- # The downside is a bigger HTML payload.
37
- options[:data] ||= {}
38
- options[:data][:modal] = modal
39
- script do
40
- unsafe_raw <<~JS
41
- // Will be replaced with a single line on the <button> once Phlex 2.0 is released.
42
- (() => {
43
- if (window.PhlexyUI && window.PhlexyUI.modalInitialized) {
44
- return;
45
- }
46
-
47
- document.body.addEventListener("click", (event) => {
48
- if (event.target.tagName === 'BUTTON' &&
49
- event.target.dataset.modal) {
50
- const modal = document.getElementById(event.target.dataset.modal);
51
- if (modal) {
52
- modal.showModal();
53
- }
54
- }
55
- });
56
-
57
- if (!window.PhlexyUI) window.PhlexyUI = {};
58
- window.PhlexyUI.modalInitialized = true;
59
- })();
60
- JS
61
- end
19
+ build_button_via_unsafe_raw(classes, &)
20
+ else
21
+ public_send(as, class: classes, **options, &)
62
22
  end
63
-
64
- public_send(as, class: classes, **options, &)
65
23
  end
66
24
  end
67
25
 
@@ -69,6 +27,41 @@ module PhlexyUI
69
27
 
70
28
  attr_reader :modal
71
29
 
30
+ # TODO: Remove this once Phlex 2.0 is released.
31
+ #
32
+ # The cleanest way to do this is with a single:
33
+ #
34
+ # onclick: "#{Phlex::Escape.html_escape(modal)}.showModal()"
35
+ #
36
+ # However, currently, Phlex does not allow you to use the "onclick"
37
+ # attribute.
38
+ #
39
+ # Once Phlex 2.0 is released, it will add a #safe method
40
+ # that will allow us to replace this with a single line:
41
+ #
42
+ # onclick: safe("#{Phlex::Escape.html_escape(modal)}.showModal()")
43
+ def build_button_via_unsafe_raw(classes, &)
44
+ classes = Phlex::Escape.html_escape(classes.join(" "))
45
+ @options = options
46
+ .merge(onclick: "#{modal}.showModal()")
47
+ .reduce("") do |acc, (k, v)|
48
+ if k == :data
49
+ v.each do |k, v|
50
+ k = Phlex::Escape.html_escape(k)
51
+ v = Phlex::Escape.html_escape(v)
52
+ acc += " data-#{k}=\"#{v}\""
53
+ end
54
+ acc
55
+ else
56
+ k = Phlex::Escape.html_escape(k)
57
+ v = Phlex::Escape.html_escape(v)
58
+ "#{acc} #{k}=\"#{v}\""
59
+ end
60
+ end.strip
61
+
62
+ unsafe_raw %(<button class="#{classes}" #{options}>#{capture(&)}</button>)
63
+ end
64
+
72
65
  register_modifiers(
73
66
  # "sm:no-animation"
74
67
  # "md:no-animation"
@@ -10,6 +10,7 @@ module PhlexyUI
10
10
  def view_template(&)
11
11
  generate_classes!(
12
12
  component_html_class: :navbar,
13
+ modifiers_map: modifiers,
13
14
  base_modifiers:,
14
15
  options:
15
16
  ).then do |classes|
@@ -28,5 +29,52 @@ module PhlexyUI
28
29
  def end(&)
29
30
  div(class: :"navbar-end", &)
30
31
  end
32
+
33
+ register_modifiers(
34
+ # "sm:bg-primary sm:text-primary-content"
35
+ # "md:bg-primary md:text-primary-content"
36
+ # "lg:bg-primary lg:text-primary-content"
37
+ primary: "bg-primary text-primary-content",
38
+ # "sm:bg-secondary sm:text-secondary-content"
39
+ # "md:bg-secondary md:text-secondary-content"
40
+ # "lg:bg-secondary lg:text-secondary-content"
41
+ secondary: "bg-secondary text-secondary-content",
42
+ # "sm:bg-accent sm:text-accent-content"
43
+ # "md:bg-accent md:text-accent-content"
44
+ # "lg:bg-accent lg:text-accent-content"
45
+ accent: "bg-accent text-accent-content",
46
+ # "sm:bg-neutral sm:text-neutral-content"
47
+ # "md:bg-neutral md:text-neutral-content"
48
+ # "lg:bg-neutral lg:text-neutral-content"
49
+ neutral: "bg-neutral text-neutral-content",
50
+ # "sm:bg-base-100 sm:text-base-content"
51
+ # "md:bg-base-100 md:text-base-content"
52
+ # "lg:bg-base-100 lg:text-base-content"
53
+ base_100: "bg-base-100 text-base-content",
54
+ # "sm:bg-base-200 sm:text-base-content"
55
+ # "md:bg-base-200 md:text-base-content"
56
+ # "lg:bg-base-200 lg:text-base-content"
57
+ base_200: "bg-base-200 text-base-content",
58
+ # "sm:bg-base-300 sm:text-base-content"
59
+ # "md:bg-base-300 md:text-base-content"
60
+ # "lg:bg-base-300 lg:text-base-content"
61
+ base_300: "bg-base-300 text-base-content",
62
+ # "sm:bg-info sm:text-info-content"
63
+ # "md:bg-info sm:text-info-content"
64
+ # "lg:bg-info sm:text-info-content"
65
+ info: "bg-info text-info-content",
66
+ # "sm:bg-success sm:text-success-content"
67
+ # "md:bg-success md:text-success-content"
68
+ # "lg:bg-success lg:text-success-content"
69
+ success: "bg-success text-success-content",
70
+ # "sm:bg-warning sm:text-warning-content"
71
+ # "md:bg-warning md:text-warning-content"
72
+ # "lg:bg-warning lg:text-warning-content"
73
+ warning: "bg-warning text-warning-content",
74
+ # "sm:bg-error sm:text-error-content"
75
+ # "md:bg-error md:text-error-content"
76
+ # "lg:bg-error lg:text-error-content"
77
+ error: "bg-error text-error-content"
78
+ )
31
79
  end
32
80
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PhlexyUI
4
- VERSION = "0.1.8"
4
+ VERSION = "0.1.10"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phlexy_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Alejandro Aguilar Ramos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-27 00:00:00.000000000 Z
11
+ date: 2024-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: phlex
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  requirements: []
147
- rubygems_version: 3.5.10
147
+ rubygems_version: 3.5.20
148
148
  signing_key:
149
149
  specification_version: 4
150
150
  summary: PhlexyUI is a Ruby UI component library for DaisyUI using Phlex