fluxbit_view_components 0.1.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.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +20 -0
  3. data/README.md +86 -0
  4. data/app/components/fluxbit/alert_component.rb +126 -0
  5. data/app/components/fluxbit/avatar_component.rb +113 -0
  6. data/app/components/fluxbit/avatar_group_component.rb +23 -0
  7. data/app/components/fluxbit/badge_component.rb +79 -0
  8. data/app/components/fluxbit/button_component.rb +97 -0
  9. data/app/components/fluxbit/button_group_component.rb +43 -0
  10. data/app/components/fluxbit/card_component.rb +135 -0
  11. data/app/components/fluxbit/component.rb +86 -0
  12. data/app/components/fluxbit/flex_component.rb +93 -0
  13. data/app/components/fluxbit/form/checkbox_input_component.rb +61 -0
  14. data/app/components/fluxbit/form/component.rb +71 -0
  15. data/app/components/fluxbit/form/datepicker_component.rb +7 -0
  16. data/app/components/fluxbit/form/form_builder_component.rb +117 -0
  17. data/app/components/fluxbit/form/helper_text_component.rb +29 -0
  18. data/app/components/fluxbit/form/label_component.rb +65 -0
  19. data/app/components/fluxbit/form/radio_input_component.rb +21 -0
  20. data/app/components/fluxbit/form/range_input_component.rb +51 -0
  21. data/app/components/fluxbit/form/select_free_input_component.rb +77 -0
  22. data/app/components/fluxbit/form/select_input_component.rb +21 -0
  23. data/app/components/fluxbit/form/spacer_input_component.rb +12 -0
  24. data/app/components/fluxbit/form/text_input_component.rb +225 -0
  25. data/app/components/fluxbit/form/textarea_input_component.rb +57 -0
  26. data/app/components/fluxbit/form/toggle_input_component.rb +166 -0
  27. data/app/components/fluxbit/form/upload_image_input_component.html.erb +48 -0
  28. data/app/components/fluxbit/form/upload_image_input_component.rb +66 -0
  29. data/app/components/fluxbit/form/upload_input_component.html.erb +12 -0
  30. data/app/components/fluxbit/form/upload_input_component.rb +47 -0
  31. data/app/components/fluxbit/gravatar_component.rb +99 -0
  32. data/app/components/fluxbit/heading_component.rb +47 -0
  33. data/app/components/fluxbit/modal_component.rb +141 -0
  34. data/app/components/fluxbit/popover_component.rb +71 -0
  35. data/app/components/fluxbit/tab_component.rb +142 -0
  36. data/app/components/fluxbit/text_component.rb +36 -0
  37. data/app/components/fluxbit/tooltip_component.rb +38 -0
  38. data/app/helpers/fluxbit/classes_helper.rb +21 -0
  39. data/app/helpers/fluxbit/components_helper.rb +75 -0
  40. data/config/deploy.yml +37 -0
  41. data/config/locales/en.yml +6 -0
  42. data/lib/fluxbit/config/alert_component.rb +59 -0
  43. data/lib/fluxbit/config/avatar_component.rb +79 -0
  44. data/lib/fluxbit/config/badge_component.rb +77 -0
  45. data/lib/fluxbit/config/button_component.rb +86 -0
  46. data/lib/fluxbit/config/card_component.rb +32 -0
  47. data/lib/fluxbit/config/flex_component.rb +63 -0
  48. data/lib/fluxbit/config/form/helper_text_component.rb +20 -0
  49. data/lib/fluxbit/config/gravatar_component.rb +19 -0
  50. data/lib/fluxbit/config/heading_component.rb +39 -0
  51. data/lib/fluxbit/config/modal_component.rb +71 -0
  52. data/lib/fluxbit/config/paragraph_component.rb +11 -0
  53. data/lib/fluxbit/config/popover_component.rb +33 -0
  54. data/lib/fluxbit/config/tab_component.rb +131 -0
  55. data/lib/fluxbit/config/text_component.rb +110 -0
  56. data/lib/fluxbit/config/tooltip_component.rb +11 -0
  57. data/lib/fluxbit/view_components/codemods/v3_slot_setters.rb +222 -0
  58. data/lib/fluxbit/view_components/engine.rb +36 -0
  59. data/lib/fluxbit/view_components/version.rb +7 -0
  60. data/lib/fluxbit/view_components.rb +30 -0
  61. data/lib/fluxbit_view_components.rb +3 -0
  62. data/lib/install/install.rb +64 -0
  63. data/lib/tasks/fluxbit_view_components_tasks.rake +22 -0
  64. metadata +238 -0
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fluxbit/view_components/version"
4
+ require "fluxbit/view_components/engine"
5
+
6
+ module Fluxbit
7
+ module ViewComponents
8
+ end
9
+
10
+ module Config
11
+ module Form
12
+ require "fluxbit/config/form/helper_text_component"
13
+ end
14
+
15
+ require "fluxbit/config/alert_component"
16
+ require "fluxbit/config/avatar_component"
17
+ require "fluxbit/config/badge_component"
18
+ require "fluxbit/config/button_component"
19
+ require "fluxbit/config/card_component"
20
+ require "fluxbit/config/flex_component"
21
+ require "fluxbit/config/gravatar_component"
22
+ require "fluxbit/config/heading_component"
23
+ require "fluxbit/config/modal_component"
24
+ require "fluxbit/config/paragraph_component"
25
+ require "fluxbit/config/popover_component"
26
+ require "fluxbit/config/tab_component"
27
+ require "fluxbit/config/text_component"
28
+ require "fluxbit/config/tooltip_component"
29
+ end
30
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fluxbit/view_components"
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ APPLICATION_LAYOUT_PATH = Rails.root.join("app/views/layouts/application.html.erb")
4
+ IMPORTMAP_BINSTUB = Rails.root.join("bin/importmap")
5
+ IMPORTMAP_CONFIG_PATH = Rails.root.join("config/importmap.rb")
6
+ STIMULUS_PATH = Rails.root.join("app/javascript/controllers/index.js")
7
+
8
+ if APPLICATION_LAYOUT_PATH.exist?
9
+ say "Add Fluxbit styles in application layout"
10
+ insert_into_file APPLICATION_LAYOUT_PATH.to_s, "\n <%= stylesheet_link_tag \"fluxbit_view_components\" %>", before: /\s*<\/head>/
11
+
12
+ if File.read(APPLICATION_LAYOUT_PATH).include?("<body>")
13
+ say "Add Fluxbit classes and inline styles for <html> in application layout"
14
+ gsub_file APPLICATION_LAYOUT_PATH.to_s, "<html", "<html class=\"<%= fluxbit_html_classes %>\" style=\"<%= fluxbit_html_styles %>\""
15
+
16
+ say "Add Fluxbit inline styles for <body> in application layout"
17
+ gsub_file APPLICATION_LAYOUT_PATH.to_s, "<body>", "<body style=\"<%= fluxbit_body_styles %>\">"
18
+ else
19
+ say "<body> tag is not found in application layout.", :red
20
+ say " Replace <html> with <html class=\"<%= fluxbit_html_classes %>\" style=\"<%= fluxbit_html_styles %>\"> in your custom layour."
21
+ say " Replace <body> with <body style=\"<%= fluxbit_body_styles %>\"> in your custom layour."
22
+ end
23
+ else
24
+ say "Default application.html.erb is missing!", :red
25
+ say " 1. Add <%= stylesheet_link_tag \"fluxbit_view_components\" %> within the <head> tag in your custom layout."
26
+ say " 2. Replace <html> with <html class=\"<%= fluxbit_html_classes %>\" style=\"<%= fluxbit_html_styles %>\"> in your custom layour."
27
+ say " 3. Replace <body> with <body style=\"<%= fluxbit_body_styles %>\"> in your custom layour."
28
+ end
29
+
30
+ if IMPORTMAP_BINSTUB.exist?
31
+ importmaps = File.read(IMPORTMAP_CONFIG_PATH)
32
+
33
+ unless importmaps.include?("@rails/request.js")
34
+ say "Pin @rails/request.js dependency"
35
+ run "bin/importmap pin @rails/request.js --download"
36
+ end
37
+
38
+ say "Pin fluxbit_view_components"
39
+ append_to_file IMPORTMAP_CONFIG_PATH do
40
+ %(pin "fluxbit-view-components", to: "fluxbit_view_components.js"\n)
41
+ end
42
+ else
43
+ package_json = File.read(Rails.root.join("package.json"))
44
+
45
+ unless package_json.include?("@rails/request.js")
46
+ say "Add @rails/request.js dependency"
47
+ run "yarn add @rails/request.js"
48
+ end
49
+
50
+ say "Add fluxbit-view-components package"
51
+ run "yarn add fluxbit-view-components"
52
+ end
53
+
54
+ if STIMULUS_PATH.exist?
55
+ say "Add Fluxbit Stimulus controllers"
56
+ append_to_file STIMULUS_PATH do
57
+ "\nimport { registerFluxbitControllers } from \"fluxbit-view-components\"\nregisterFluxbitControllers(Stimulus)\n"
58
+ end
59
+ else
60
+ say "Default Stimulus location is missing: app/javascript/controllers/index.js", :red
61
+ say " Add to your Stimulus index.js:"
62
+ say " import { registerFluxbitControllers } from \"fluxbit-view-components\""
63
+ say " registerFluxbitControllers(Stimulus)"
64
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fluxbit/view_components/codemods/v3_slot_setters"
4
+
5
+ namespace :fluxbit_view_components do
6
+ desc "Setup Fluxbit::ViewComponents for the app"
7
+ task :install do
8
+ system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/install.rb", __dir__)}"
9
+ end
10
+
11
+ task detect_legacy_slots: :environment do
12
+ ARGV.each { |a| task a.to_sym { } }
13
+ custom_paths = ARGV.compact.map { |path| Rails.root.join(path) }
14
+ Fluxbit::ViewComponents::Codemods::V3SlotSetters.new(view_path: custom_paths).call
15
+ end
16
+
17
+ task migrate_legacy_slots: :environment do
18
+ ARGV.each { |a| task a.to_sym { } }
19
+ custom_paths = ARGV.compact.map { |path| Rails.root.join(path) }
20
+ Fluxbit::ViewComponents::Codemods::V3SlotSetters.new(view_path: custom_paths, migrate: true).call
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,238 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluxbit_view_components
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Arthur Molina
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-04-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: anyicon
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 5.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 5.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: view_component
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.0
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: 4.0.0
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 3.0.0
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: 4.0.0
61
+ - !ruby/object:Gem::Dependency
62
+ name: webdrivers
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '5.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '5.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: selenium-webdriver
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '4.1'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '4.1'
89
+ - !ruby/object:Gem::Dependency
90
+ name: minitest
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '5.0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '5.0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: pry
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ - !ruby/object:Gem::Dependency
118
+ name: sprockets-rails
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: kamal
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ description:
146
+ email:
147
+ - arthurmolina@gmail.com
148
+ executables: []
149
+ extensions: []
150
+ extra_rdoc_files: []
151
+ files:
152
+ - LICENSE.txt
153
+ - README.md
154
+ - app/components/fluxbit/alert_component.rb
155
+ - app/components/fluxbit/avatar_component.rb
156
+ - app/components/fluxbit/avatar_group_component.rb
157
+ - app/components/fluxbit/badge_component.rb
158
+ - app/components/fluxbit/button_component.rb
159
+ - app/components/fluxbit/button_group_component.rb
160
+ - app/components/fluxbit/card_component.rb
161
+ - app/components/fluxbit/component.rb
162
+ - app/components/fluxbit/flex_component.rb
163
+ - app/components/fluxbit/form/checkbox_input_component.rb
164
+ - app/components/fluxbit/form/component.rb
165
+ - app/components/fluxbit/form/datepicker_component.rb
166
+ - app/components/fluxbit/form/form_builder_component.rb
167
+ - app/components/fluxbit/form/helper_text_component.rb
168
+ - app/components/fluxbit/form/label_component.rb
169
+ - app/components/fluxbit/form/radio_input_component.rb
170
+ - app/components/fluxbit/form/range_input_component.rb
171
+ - app/components/fluxbit/form/select_free_input_component.rb
172
+ - app/components/fluxbit/form/select_input_component.rb
173
+ - app/components/fluxbit/form/spacer_input_component.rb
174
+ - app/components/fluxbit/form/text_input_component.rb
175
+ - app/components/fluxbit/form/textarea_input_component.rb
176
+ - app/components/fluxbit/form/toggle_input_component.rb
177
+ - app/components/fluxbit/form/upload_image_input_component.html.erb
178
+ - app/components/fluxbit/form/upload_image_input_component.rb
179
+ - app/components/fluxbit/form/upload_input_component.html.erb
180
+ - app/components/fluxbit/form/upload_input_component.rb
181
+ - app/components/fluxbit/gravatar_component.rb
182
+ - app/components/fluxbit/heading_component.rb
183
+ - app/components/fluxbit/modal_component.rb
184
+ - app/components/fluxbit/popover_component.rb
185
+ - app/components/fluxbit/tab_component.rb
186
+ - app/components/fluxbit/text_component.rb
187
+ - app/components/fluxbit/tooltip_component.rb
188
+ - app/helpers/fluxbit/classes_helper.rb
189
+ - app/helpers/fluxbit/components_helper.rb
190
+ - config/deploy.yml
191
+ - config/locales/en.yml
192
+ - lib/fluxbit/config/alert_component.rb
193
+ - lib/fluxbit/config/avatar_component.rb
194
+ - lib/fluxbit/config/badge_component.rb
195
+ - lib/fluxbit/config/button_component.rb
196
+ - lib/fluxbit/config/card_component.rb
197
+ - lib/fluxbit/config/flex_component.rb
198
+ - lib/fluxbit/config/form/helper_text_component.rb
199
+ - lib/fluxbit/config/gravatar_component.rb
200
+ - lib/fluxbit/config/heading_component.rb
201
+ - lib/fluxbit/config/modal_component.rb
202
+ - lib/fluxbit/config/paragraph_component.rb
203
+ - lib/fluxbit/config/popover_component.rb
204
+ - lib/fluxbit/config/tab_component.rb
205
+ - lib/fluxbit/config/text_component.rb
206
+ - lib/fluxbit/config/tooltip_component.rb
207
+ - lib/fluxbit/view_components.rb
208
+ - lib/fluxbit/view_components/codemods/v3_slot_setters.rb
209
+ - lib/fluxbit/view_components/engine.rb
210
+ - lib/fluxbit/view_components/version.rb
211
+ - lib/fluxbit_view_components.rb
212
+ - lib/install/install.rb
213
+ - lib/tasks/fluxbit_view_components_tasks.rake
214
+ homepage: https://github.com/baoagency/fluxbit-view-components
215
+ licenses:
216
+ - MIT
217
+ metadata:
218
+ allowed_push_host: https://rubygems.org
219
+ post_install_message:
220
+ rdoc_options: []
221
+ require_paths:
222
+ - lib
223
+ required_ruby_version: !ruby/object:Gem::Requirement
224
+ requirements:
225
+ - - ">="
226
+ - !ruby/object:Gem::Version
227
+ version: 2.7.0
228
+ required_rubygems_version: !ruby/object:Gem::Requirement
229
+ requirements:
230
+ - - ">="
231
+ - !ruby/object:Gem::Version
232
+ version: '0'
233
+ requirements: []
234
+ rubygems_version: 3.5.16
235
+ signing_key:
236
+ specification_version: 4
237
+ summary: ViewComponents for Fluxbit Design System
238
+ test_files: []