fluxbit_view_components 0.1.0 → 0.3.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.
- checksums.yaml +4 -4
- data/README.md +7 -1
- data/app/components/fluxbit/form/check_box_component.rb +56 -0
- data/app/components/fluxbit/form/component.rb +20 -25
- data/app/components/fluxbit/form/dropzone_component.html.erb +39 -0
- data/app/components/fluxbit/form/dropzone_component.rb +39 -0
- data/app/components/fluxbit/form/field_component.rb +26 -0
- data/app/components/fluxbit/form/form_builder_component.rb +5 -7
- data/app/components/fluxbit/form/{helper_text_component.rb → help_text_component.rb} +8 -3
- data/app/components/fluxbit/form/label_component.rb +32 -29
- data/app/components/fluxbit/form/range_component.rb +52 -0
- data/app/components/fluxbit/form/select_component.rb +88 -0
- data/app/components/fluxbit/form/text_field_component.rb +168 -0
- data/app/components/fluxbit/form/toggle_component.html.erb +23 -0
- data/app/components/fluxbit/form/toggle_component.rb +81 -0
- data/app/components/fluxbit/form/upload_image_component.html.erb +50 -0
- data/app/components/fluxbit/form/upload_image_component.rb +50 -0
- data/app/helpers/fluxbit/classes_helper.rb +0 -12
- data/app/helpers/fluxbit/components_helper.rb +23 -51
- data/app/helpers/fluxbit/form_builder.rb +87 -0
- data/lib/fluxbit/config/form/check_box_component.rb +19 -0
- data/lib/fluxbit/config/form/dropzone_component.rb +20 -0
- data/lib/fluxbit/config/form/{helper_text_component.rb → help_text_component.rb} +1 -1
- data/lib/fluxbit/config/form/label_component.rb +30 -0
- data/lib/fluxbit/config/form/range_component.rb +15 -0
- data/lib/fluxbit/config/form/text_field_component.rb +76 -0
- data/{app/components/fluxbit/form/toggle_input_component.rb → lib/fluxbit/config/form/toggle_component.rb} +28 -115
- data/lib/fluxbit/templates/darkmode.js.template +7 -0
- data/lib/fluxbit/templates/tailwind.config.js.template +4 -0
- data/lib/fluxbit/view_components/version.rb +1 -3
- data/lib/fluxbit/view_components.rb +7 -1
- data/lib/install/install.rb +57 -47
- data/lib/tasks/fluxbit_view_components_tasks.rake +30 -10
- metadata +25 -25
- data/LICENSE.txt +0 -20
- data/app/components/fluxbit/form/checkbox_input_component.rb +0 -61
- data/app/components/fluxbit/form/datepicker_component.rb +0 -7
- data/app/components/fluxbit/form/radio_input_component.rb +0 -21
- data/app/components/fluxbit/form/range_input_component.rb +0 -51
- data/app/components/fluxbit/form/select_free_input_component.rb +0 -77
- data/app/components/fluxbit/form/select_input_component.rb +0 -21
- data/app/components/fluxbit/form/spacer_input_component.rb +0 -12
- data/app/components/fluxbit/form/text_input_component.rb +0 -225
- data/app/components/fluxbit/form/textarea_input_component.rb +0 -57
- data/app/components/fluxbit/form/upload_image_input_component.html.erb +0 -48
- data/app/components/fluxbit/form/upload_image_input_component.rb +0 -66
- data/app/components/fluxbit/form/upload_input_component.html.erb +0 -12
- data/app/components/fluxbit/form/upload_input_component.rb +0 -47
- data/lib/fluxbit/view_components/codemods/v3_slot_setters.rb +0 -222
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Fluxbit::Config::Form::TextFieldComponent
|
4
|
+
mattr_accessor :color, default: :default
|
5
|
+
mattr_accessor :sizing, default: 0
|
6
|
+
|
7
|
+
# rubocop: disable Layout/LineLength, Metrics/BlockLength
|
8
|
+
mattr_accessor :styles do
|
9
|
+
{
|
10
|
+
default: "mt-1 block w-full border disabled:cursor-not-allowed disabled:opacity-50 disabled:text-slate-900 disabled:dark:text-slate-400 disabled:bg-slate-100 disabled:dark:bg-slate-700",
|
11
|
+
text: {
|
12
|
+
default: "text-slate-900 dark:text-white",
|
13
|
+
success: "text-green-900",
|
14
|
+
failure: "text-red-900",
|
15
|
+
info: "text-cyan-900",
|
16
|
+
warning: "text-yellow-900"
|
17
|
+
},
|
18
|
+
ring: {
|
19
|
+
default: "focus:ring-blue-500 dark:focus:ring-blue-500",
|
20
|
+
success: "focus:ring-green-500",
|
21
|
+
failure: "focus:ring-red-500",
|
22
|
+
info: "focus:ring-cyan-500",
|
23
|
+
warning: "focus:ring-yellow-500"
|
24
|
+
},
|
25
|
+
bg: {
|
26
|
+
default: "bg-slate-50 dark:bg-slate-700",
|
27
|
+
success: "bg-green-50 dark:bg-green-100",
|
28
|
+
failure: "bg-red-50 dark:bg-red-100",
|
29
|
+
info: "bg-cyan-50 dark:bg-cyan-100",
|
30
|
+
warning: "bg-yellow-50 dark:bg-yellow-100"
|
31
|
+
},
|
32
|
+
placeholder: {
|
33
|
+
default: "dark:placeholder-slate-400",
|
34
|
+
success: "placeholder-green-700",
|
35
|
+
failure: "placeholder-red-700",
|
36
|
+
info: "placeholder-cyan-700",
|
37
|
+
warning: "placeholder-yellow-700"
|
38
|
+
},
|
39
|
+
border: {
|
40
|
+
default: "border-slate-300 focus:border-blue-500 dark:border-slate-600 dark:focus:border-blue-500",
|
41
|
+
success: "border-green-500 focus:border-green-500 dark:border-green-400",
|
42
|
+
failure: "border-red-500 focus:border-red-500 dark:border-red-400",
|
43
|
+
info: "border-cyan-500 focus:border-cyan-500 dark:border-cyan-400",
|
44
|
+
warning: "border-yellow-500 focus:border-yellow-500 dark:border-yellow-400"
|
45
|
+
},
|
46
|
+
shadow: "shadow-xs dark:shadow-xs-light",
|
47
|
+
icon: "pl-10",
|
48
|
+
right_icon: "pr-10",
|
49
|
+
sizing_md_addon: "p-2.5 rounded-none rounded-r-lg flex-1 min-w-0 text-sm",
|
50
|
+
sizes: [
|
51
|
+
"p-2.5 text-sm rounded-lg",
|
52
|
+
"p-4 sm:text-md rounded-lg",
|
53
|
+
"p-2 rounded-lg sm:text-xs"
|
54
|
+
],
|
55
|
+
additional_icons: {
|
56
|
+
class: {
|
57
|
+
default: "mt-1 w-4 h-4 text-slate-500 dark:text-slate-400",
|
58
|
+
success: "mt-1 w-4 h-4 text-green-500 dark:text-green-400",
|
59
|
+
failure: "mt-1 w-4 h-4 text-red-500 dark:text-red-400",
|
60
|
+
info: "mt-1 w-4 h-4 text-cyan-500 dark:text-cyan-400",
|
61
|
+
warning: "mt-1 w-4 h-4 text-yellow-500 dark:text-yellow-400"
|
62
|
+
},
|
63
|
+
icon: "absolute inset-y-0 left-0 flex items-center pl-3",
|
64
|
+
right_icon: "absolute inset-y-0 right-0 flex items-center pr-3",
|
65
|
+
addon: {
|
66
|
+
default: "mt-1 inline-flex items-center px-3 text-sm text-slate-900 bg-slate-200 border border-r-0 border-slate-300 rounded-l-md dark:bg-slate-600 dark:text-slate-400 dark:border-slate-600",
|
67
|
+
success: "mt-1 inline-flex items-center px-3 text-sm text-green-900 bg-green-200 border border-r-0 border-green-300 rounded-l-md dark:bg-green-600 dark:text-green-400 dark:border-green-600",
|
68
|
+
failure: "mt-1 inline-flex items-center px-3 text-sm text-red-900 bg-red-200 border border-r-0 border-red-300 rounded-l-md dark:bg-red-600 dark:text-red-400 dark:border-red-600",
|
69
|
+
info: "mt-1 inline-flex items-center px-3 text-sm text-cyan-900 bg-cyan-200 border border-r-0 border-cyan-300 rounded-l-md dark:bg-cyan-600 dark:text-cyan-400 dark:border-cyan-600",
|
70
|
+
warning: "mt-1 inline-flex items-center px-3 text-sm text-yellow-900 bg-yellow-200 border border-r-0 border-yellow-300 rounded-l-md dark:bg-yellow-600 dark:text-yellow-400 dark:border-yellow-600"
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
end
|
75
|
+
# rubocop: enable Layout/LineLength, Metrics/BlockLength
|
76
|
+
end
|
@@ -1,22 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
module Fluxbit::Config::Form::ToggleComponent
|
4
|
+
mattr_accessor :color, default: :default
|
5
|
+
mattr_accessor :unchecked_color, default: :default
|
6
|
+
mattr_accessor :button_color, default: :default
|
7
|
+
mattr_accessor :invert_label, default: false
|
8
|
+
mattr_accessor :sizing, default: 1
|
9
|
+
|
4
10
|
# rubocop: disable Layout/LineLength, Metrics/BlockLength
|
5
|
-
|
11
|
+
mattr_accessor :styles do
|
6
12
|
{
|
7
|
-
|
8
|
-
|
9
|
-
base2: "relative inline-flex items-center",
|
10
|
-
no_helper_text: "mb-5",
|
11
|
-
active: {
|
12
|
-
on: "cursor-pointer",
|
13
|
-
off: "cursor-not-allowed opacity-50"
|
14
|
-
},
|
15
|
-
label: "ml-3 text-sm font-medium text-slate-900 dark:text-slate-300",
|
16
|
-
input: "sr-only peer"
|
17
|
-
},
|
13
|
+
label: "text-sm rtl:text-right font-medium text-gray-700 dark:text-gray-200 flex items-center",
|
14
|
+
input: "w-4 h-4 bg-gray-100 border-gray-300 dark:ring-offset-gray-800 focus:ring-2 rounded-sm dark:bg-gray-700 dark:border-gray-600 sr-only peer",
|
18
15
|
toggle: {
|
19
|
-
base: "
|
16
|
+
base: "me-3 shrink-0 rounded-full peer-focus:ring-4 peer-checked:after:translate-x-full peer-checked:rtl:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:border after:rounded-full after:transition-all relative",
|
20
17
|
checked: {
|
21
18
|
default: "peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 peer-checked:bg-blue-600",
|
22
19
|
success: "peer-focus:ring-green-300 dark:peer-focus:ring-green-800 peer-checked:bg-green-600",
|
@@ -58,109 +55,25 @@ class Fluxbit::Form::ToggleInputComponent < Fluxbit::Form::Component
|
|
58
55
|
light_indigo: "bg-indigo-200 dark:bg-indigo-700 dark:border-indigo-600 after:border-indigo-300",
|
59
56
|
light_pink: "bg-pink-200 dark:bg-pink-700 dark:border-pink-600 after:border-pink-300"
|
60
57
|
},
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
58
|
+
button: {
|
59
|
+
default: "after:bg-white",
|
60
|
+
success: "after:bg-green-500",
|
61
|
+
failure: "after:bg-red-500",
|
62
|
+
info: "after:bg-cyan-500"
|
63
|
+
|
64
|
+
},
|
65
|
+
sizes: [
|
66
|
+
"w-9 h-5 after:top-[2px] after:start-[2px] after:h-4 after:w-4",
|
67
|
+
"w-11 h-6 after:top-0.5 after:start-[2px] after:h-5 after:w-5",
|
68
|
+
"w-14 h-7 after:top-0.5 after:start-[4px] after:h-6 after:w-6"
|
69
|
+
],
|
70
|
+
active: {
|
71
|
+
on: "cursor-pointer",
|
72
|
+
off: "cursor-not-allowed opacity-50"
|
73
|
+
},
|
74
|
+
invert_label: "ms-3"
|
70
75
|
}
|
71
76
|
}
|
72
77
|
end
|
73
78
|
# rubocop: enable Layout/LineLength, Metrics/BlockLength
|
74
|
-
|
75
|
-
renders_one :helper, "Fluxbit::Form::HelperTextComponent"
|
76
|
-
|
77
|
-
def initialize(form: nil, field: nil, color: nil, unchecked_color: :default, sizing: :md,
|
78
|
-
right_sided: false, label: nil, helper_text: nil, helper_popover: nil,
|
79
|
-
helper_popover_placement: "right", **props)
|
80
|
-
super
|
81
|
-
@form = form
|
82
|
-
@field = field
|
83
|
-
@object = form&.object
|
84
|
-
@right_sided = right_sided
|
85
|
-
@sizing = sizing.in?(styles[:toggle][:sizes].keys) ? sizing : :md
|
86
|
-
@color = valid_color(color)
|
87
|
-
@unchecked_color = unchecked_color.in?(styles[:toggle][:unchecked].keys) ? unchecked_color : :default
|
88
|
-
@props = props
|
89
|
-
@label = label_value(label, @object, field, id)
|
90
|
-
@helper_text = define_helper_text(helper_text, @object, field)
|
91
|
-
@helper_popover = define_helper_popover(helper_popover, @object, field)
|
92
|
-
@helper_popover_placement = helper_popover_placement
|
93
|
-
@label_class = "ml-2" unless right_sided
|
94
|
-
|
95
|
-
# Input
|
96
|
-
@props[:type] = "checkbox"
|
97
|
-
declare_classes
|
98
|
-
end
|
99
|
-
|
100
|
-
def valid_color(color)
|
101
|
-
return color if styles[:toggle][:checked].key?(color)
|
102
|
-
return :failure if errors.present?
|
103
|
-
|
104
|
-
:default
|
105
|
-
end
|
106
|
-
|
107
|
-
def declare_classes
|
108
|
-
add(class: styles[:root][:input], to: @props)
|
109
|
-
|
110
|
-
# Root
|
111
|
-
@root_element = { class: "#{styles[:root][:base]} #{styles[:root][:active][(@props[:disabled] ? :off : :on)]}" }
|
112
|
-
|
113
|
-
# Toggle
|
114
|
-
@toggle_element = {
|
115
|
-
class:
|
116
|
-
[
|
117
|
-
styles[:toggle][:base],
|
118
|
-
styles[:toggle][:unchecked][@unchecked_color],
|
119
|
-
styles[:toggle][:checked][@color],
|
120
|
-
styles[:toggle][:sizes][@sizing]
|
121
|
-
].join(" ")
|
122
|
-
}
|
123
|
-
end
|
124
|
-
|
125
|
-
def input
|
126
|
-
if @form.nil?
|
127
|
-
content_tag :input, content, @props
|
128
|
-
else
|
129
|
-
@form.check_box(@field, **@props)
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
def toggle
|
134
|
-
content_tag :div, "", @toggle_element
|
135
|
-
end
|
136
|
-
|
137
|
-
def toggle_input
|
138
|
-
content_tag :div, safe_join(input, toggle), class: styles[:root][:base2]
|
139
|
-
end
|
140
|
-
|
141
|
-
def label_container
|
142
|
-
content_tag(:label, safe_join(toggle_input, label), @root_element)
|
143
|
-
end
|
144
|
-
|
145
|
-
def left_sided
|
146
|
-
safe_join label_container, (helper? ? helper : helper_text)
|
147
|
-
end
|
148
|
-
|
149
|
-
def right_sided
|
150
|
-
content_tag :label, class: styles[:right_sided][:top] do
|
151
|
-
safe_join(
|
152
|
-
content_tag(
|
153
|
-
:div,
|
154
|
-
safe_join(label, (helper? ? helper : helper_text)),
|
155
|
-
class: styles[:right_sided][:inside]
|
156
|
-
),
|
157
|
-
toggle_input
|
158
|
-
)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
def call
|
163
|
-
add(class: styles[:root][:no_helper_text], to: @root_element) if @helper_text.nil? && !helper?
|
164
|
-
@right_sided ? right_sided : left_sided
|
165
|
-
end
|
166
79
|
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<script>
|
2
|
+
if (localStorage.getItem('color-theme') === 'dark' || (!('color-theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
3
|
+
document.documentElement.classList.add('dark');
|
4
|
+
} else {
|
5
|
+
document.documentElement.classList.remove('dark')
|
6
|
+
}
|
7
|
+
</script>
|
@@ -9,7 +9,13 @@ module Fluxbit
|
|
9
9
|
|
10
10
|
module Config
|
11
11
|
module Form
|
12
|
-
require "fluxbit/config/form/
|
12
|
+
require "fluxbit/config/form/help_text_component"
|
13
|
+
require "fluxbit/config/form/check_box_component"
|
14
|
+
require "fluxbit/config/form/dropzone_component"
|
15
|
+
require "fluxbit/config/form/label_component"
|
16
|
+
require "fluxbit/config/form/range_component"
|
17
|
+
require "fluxbit/config/form/text_field_component"
|
18
|
+
require "fluxbit/config/form/toggle_component"
|
13
19
|
end
|
14
20
|
|
15
21
|
require "fluxbit/config/alert_component"
|
data/lib/install/install.rb
CHANGED
@@ -1,64 +1,74 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
gem_path = Gem.loaded_specs["fluxbit_view_components"].full_gem_path
|
4
|
+
template_path = File.join(gem_path, "lib/fluxbit/templates/tailwind.config.js.template")
|
5
|
+
darkmode_path = File.join(gem_path, "lib/fluxbit/templates/darkmode.js.template")
|
6
|
+
layout_path = Rails.root.join("app/views/layouts/application.html.erb")
|
7
|
+
importmap_binstub = Rails.root.join("bin/importmap")
|
8
|
+
importmap_config = Rails.root.join("config/importmap.rb")
|
9
|
+
stimulus_path = Rails.root.join("app/javascript/controllers/index.js")
|
10
|
+
package_json_path = Rails.root.join("package.json")
|
11
|
+
tailwind_config_path = Rails.root.join("tailwind.config.js")
|
12
|
+
stylesheets_path = Rails.root.join("app/assets/stylesheets/application.tailwind.css")
|
7
13
|
|
8
|
-
|
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>/
|
14
|
+
say = ->(msg, color = :green) { puts color == :red ? "\e[31m#{msg}\e[0m" : "\e[32m#{msg}\e[0m" }
|
11
15
|
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
Bundler.with_unbundled_env do
|
17
|
+
say.call "- Adding TailwindCSS gems..."
|
18
|
+
system "bundle add tailwindcss-ruby"
|
19
|
+
system "bundle add tailwindcss-rails"
|
20
|
+
end
|
15
21
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
say.call "- Running tailwindcss:install..."
|
23
|
+
system "#{RbConfig.ruby} ./bin/rails tailwindcss:install"
|
24
|
+
|
25
|
+
say.call "- Installing Flowbite via npm..."
|
26
|
+
system "npm install flowbite --save"
|
27
|
+
|
28
|
+
say.call "- Copying tailwind.config.js from template..."
|
29
|
+
if File.exist?(template_path)
|
30
|
+
FileUtils.cp(template_path, tailwind_config_path)
|
31
|
+
say.call " tailwind.config.js copied successfully!"
|
23
32
|
else
|
24
|
-
say "
|
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."
|
33
|
+
say.call " tailwind.config.js.template not found at #{template_path}.", :red
|
28
34
|
end
|
29
35
|
|
30
|
-
if
|
31
|
-
|
36
|
+
if stylesheets_path.exist?
|
37
|
+
say.call "- Updating CSS with Flowbite imports..."
|
38
|
+
content = File.read(stylesheets_path)
|
39
|
+
content.prepend("@import \"flowbite/src/themes/default\";\n")
|
40
|
+
content << "\n@plugin \"flowbite/plugin\";\n@source \"../../../node_modules/flowbite\";\n@config \"../../../tailwind.config.js\";\n@custom-variant dark (&:where(.dark, .dark *));\n\n"
|
41
|
+
File.write(stylesheets_path, content)
|
42
|
+
else
|
43
|
+
say.call "⚠️ Couldn't find application.tailwind.css, skipping CSS modifications", :red
|
44
|
+
end
|
32
45
|
|
33
|
-
|
34
|
-
|
35
|
-
run "bin/importmap pin @rails/request.js --download"
|
36
|
-
end
|
46
|
+
if layout_path.exist?
|
47
|
+
say.call "- Updating layout to include Fluxbit styles..."
|
37
48
|
|
38
|
-
|
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"))
|
49
|
+
layout_content = File.read(layout_path)
|
44
50
|
|
45
|
-
|
46
|
-
|
47
|
-
|
51
|
+
if layout_content.include?("<head>")
|
52
|
+
darkmode_content = File.read(darkmode_path)
|
53
|
+
gsub_file layout_path.to_s, "</head>", "#{darkmode_content}\n</head>"
|
54
|
+
say.call " Added darkmode js before </head> tag."
|
55
|
+
else
|
56
|
+
say.call "</head> tag is not found in application layout.", :red
|
57
|
+
say.call " Add darkmode js manually before the </head> tag."
|
48
58
|
end
|
49
59
|
|
50
|
-
say "Add fluxbit-view-components package"
|
51
|
-
run "yarn add fluxbit-view-components"
|
52
|
-
end
|
53
60
|
|
54
|
-
if
|
55
|
-
|
56
|
-
|
57
|
-
|
61
|
+
if layout_content.include?("<body")
|
62
|
+
# gsub_file layout_path.to_s, "<html", "<html class=\"<%= fx_html_class %>\""
|
63
|
+
gsub_file layout_path.to_s, "<body>", "<body class=\"<%= fx_body_class %>\">"
|
64
|
+
else
|
65
|
+
say.call "<body> tag is not found in application layout.", :red
|
66
|
+
say.call " Replace <html> and <body> manually as instructed."
|
58
67
|
end
|
59
68
|
else
|
60
|
-
say "Default
|
61
|
-
say " Add
|
62
|
-
say "
|
63
|
-
say " registerFluxbitControllers(Stimulus)"
|
69
|
+
say.call "❌ Default application.html.erb is missing!", :red
|
70
|
+
say.call " 1. Add stylesheet_link_tag inside <head>"
|
71
|
+
say.call " 2. Replace <html> and <body> manually."
|
64
72
|
end
|
73
|
+
|
74
|
+
say.call "✅ Fluxbit ViewComponents install completed!"
|
@@ -1,22 +1,42 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "fluxbit/view_components/codemods/v3_slot_setters"
|
4
|
-
|
5
3
|
namespace :fluxbit_view_components do
|
6
4
|
desc "Setup Fluxbit::ViewComponents for the app"
|
7
5
|
task :install do
|
8
6
|
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/install.rb", __dir__)}"
|
9
7
|
end
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
desc "Copy Fluxbit ViewComponents to the application (default value of destination is app/components/fluxbit)"
|
10
|
+
task :copy_components, [ :destination ] do |t, args|
|
11
|
+
require "fileutils"
|
12
|
+
|
13
|
+
gem_path = Gem.loaded_specs["fluxbit_view_components"].full_gem_path
|
14
|
+
components_source = File.join(gem_path, "app/components/fluxbit")
|
15
|
+
components_destination = args[:destination] || Rails.root.join("app/components/fluxbit")
|
16
|
+
|
17
|
+
if Dir.exist?(components_source)
|
18
|
+
FileUtils.mkdir_p(components_destination)
|
19
|
+
FileUtils.cp_r("#{components_source}/.", components_destination)
|
20
|
+
puts "✅ Components copied to #{components_destination}"
|
21
|
+
else
|
22
|
+
puts "❌ Components source directory not found at #{components_source}"
|
23
|
+
end
|
15
24
|
end
|
16
25
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
26
|
+
desc "Copy Fluxbit ViewComponents Previews to the application (default value of destination is test/components/previews/fluxbit)"
|
27
|
+
task :copy_previews, [ :destination ] do |t, args|
|
28
|
+
require "fileutils"
|
29
|
+
|
30
|
+
gem_path = Gem.loaded_specs["fluxbit_view_components"].full_gem_path
|
31
|
+
previews_source = File.join(gem_path, "previews/fluxbit")
|
32
|
+
previews_destination = args[:destination] || Rails.root.join("test/components/previews/fluxbit")
|
33
|
+
|
34
|
+
if Dir.exist?(previews_source)
|
35
|
+
FileUtils.mkdir_p(previews_destination)
|
36
|
+
FileUtils.cp_r("#{previews_source}/.", previews_destination)
|
37
|
+
puts "✅ Previews copied to #{previews_destination}"
|
38
|
+
else
|
39
|
+
puts "❌ Previews source directory not found at #{previews_source}"
|
40
|
+
end
|
21
41
|
end
|
22
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluxbit_view_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arthur Molina
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: anyicon
|
@@ -142,14 +141,12 @@ dependencies:
|
|
142
141
|
- - ">="
|
143
142
|
- !ruby/object:Gem::Version
|
144
143
|
version: '0'
|
145
|
-
description:
|
146
144
|
email:
|
147
145
|
- arthurmolina@gmail.com
|
148
146
|
executables: []
|
149
147
|
extensions: []
|
150
148
|
extra_rdoc_files: []
|
151
149
|
files:
|
152
|
-
- LICENSE.txt
|
153
150
|
- README.md
|
154
151
|
- app/components/fluxbit/alert_component.rb
|
155
152
|
- app/components/fluxbit/avatar_component.rb
|
@@ -160,24 +157,21 @@ files:
|
|
160
157
|
- app/components/fluxbit/card_component.rb
|
161
158
|
- app/components/fluxbit/component.rb
|
162
159
|
- app/components/fluxbit/flex_component.rb
|
163
|
-
- app/components/fluxbit/form/
|
160
|
+
- app/components/fluxbit/form/check_box_component.rb
|
164
161
|
- app/components/fluxbit/form/component.rb
|
165
|
-
- app/components/fluxbit/form/
|
162
|
+
- app/components/fluxbit/form/dropzone_component.html.erb
|
163
|
+
- app/components/fluxbit/form/dropzone_component.rb
|
164
|
+
- app/components/fluxbit/form/field_component.rb
|
166
165
|
- app/components/fluxbit/form/form_builder_component.rb
|
167
|
-
- app/components/fluxbit/form/
|
166
|
+
- app/components/fluxbit/form/help_text_component.rb
|
168
167
|
- app/components/fluxbit/form/label_component.rb
|
169
|
-
- app/components/fluxbit/form/
|
170
|
-
- app/components/fluxbit/form/
|
171
|
-
- app/components/fluxbit/form/
|
172
|
-
- app/components/fluxbit/form/
|
173
|
-
- app/components/fluxbit/form/
|
174
|
-
- app/components/fluxbit/form/
|
175
|
-
- app/components/fluxbit/form/
|
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
|
168
|
+
- app/components/fluxbit/form/range_component.rb
|
169
|
+
- app/components/fluxbit/form/select_component.rb
|
170
|
+
- app/components/fluxbit/form/text_field_component.rb
|
171
|
+
- app/components/fluxbit/form/toggle_component.html.erb
|
172
|
+
- app/components/fluxbit/form/toggle_component.rb
|
173
|
+
- app/components/fluxbit/form/upload_image_component.html.erb
|
174
|
+
- app/components/fluxbit/form/upload_image_component.rb
|
181
175
|
- app/components/fluxbit/gravatar_component.rb
|
182
176
|
- app/components/fluxbit/heading_component.rb
|
183
177
|
- app/components/fluxbit/modal_component.rb
|
@@ -187,6 +181,7 @@ files:
|
|
187
181
|
- app/components/fluxbit/tooltip_component.rb
|
188
182
|
- app/helpers/fluxbit/classes_helper.rb
|
189
183
|
- app/helpers/fluxbit/components_helper.rb
|
184
|
+
- app/helpers/fluxbit/form_builder.rb
|
190
185
|
- config/deploy.yml
|
191
186
|
- config/locales/en.yml
|
192
187
|
- lib/fluxbit/config/alert_component.rb
|
@@ -195,7 +190,13 @@ files:
|
|
195
190
|
- lib/fluxbit/config/button_component.rb
|
196
191
|
- lib/fluxbit/config/card_component.rb
|
197
192
|
- lib/fluxbit/config/flex_component.rb
|
198
|
-
- lib/fluxbit/config/form/
|
193
|
+
- lib/fluxbit/config/form/check_box_component.rb
|
194
|
+
- lib/fluxbit/config/form/dropzone_component.rb
|
195
|
+
- lib/fluxbit/config/form/help_text_component.rb
|
196
|
+
- lib/fluxbit/config/form/label_component.rb
|
197
|
+
- lib/fluxbit/config/form/range_component.rb
|
198
|
+
- lib/fluxbit/config/form/text_field_component.rb
|
199
|
+
- lib/fluxbit/config/form/toggle_component.rb
|
199
200
|
- lib/fluxbit/config/gravatar_component.rb
|
200
201
|
- lib/fluxbit/config/heading_component.rb
|
201
202
|
- lib/fluxbit/config/modal_component.rb
|
@@ -204,8 +205,9 @@ files:
|
|
204
205
|
- lib/fluxbit/config/tab_component.rb
|
205
206
|
- lib/fluxbit/config/text_component.rb
|
206
207
|
- lib/fluxbit/config/tooltip_component.rb
|
208
|
+
- lib/fluxbit/templates/darkmode.js.template
|
209
|
+
- lib/fluxbit/templates/tailwind.config.js.template
|
207
210
|
- lib/fluxbit/view_components.rb
|
208
|
-
- lib/fluxbit/view_components/codemods/v3_slot_setters.rb
|
209
211
|
- lib/fluxbit/view_components/engine.rb
|
210
212
|
- lib/fluxbit/view_components/version.rb
|
211
213
|
- lib/fluxbit_view_components.rb
|
@@ -216,7 +218,6 @@ licenses:
|
|
216
218
|
- MIT
|
217
219
|
metadata:
|
218
220
|
allowed_push_host: https://rubygems.org
|
219
|
-
post_install_message:
|
220
221
|
rdoc_options: []
|
221
222
|
require_paths:
|
222
223
|
- lib
|
@@ -231,8 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
231
232
|
- !ruby/object:Gem::Version
|
232
233
|
version: '0'
|
233
234
|
requirements: []
|
234
|
-
rubygems_version: 3.
|
235
|
-
signing_key:
|
235
|
+
rubygems_version: 3.6.7
|
236
236
|
specification_version: 4
|
237
237
|
summary: ViewComponents for Fluxbit Design System
|
238
238
|
test_files: []
|
data/LICENSE.txt
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright 2021 Dan Gamble
|
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.
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Fluxbit::Form::CheckboxInputComponent < Fluxbit::Form::Component
|
4
|
-
# rubocop: disable Layout/LineLength
|
5
|
-
cattr_accessor :styles do
|
6
|
-
{
|
7
|
-
checkbox: "rounded-sm",
|
8
|
-
base: "w-4 h-4 text-blue-600 bg-slate-100 border-gray-300 focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-slate-700 dark:border-slate-600",
|
9
|
-
label: {
|
10
|
-
with_helper: "font-medium text-slate-900 dark:text-slate-300",
|
11
|
-
base: "ml-2 text-sm font-medium text-slate-900 dark:text-slate-300"
|
12
|
-
},
|
13
|
-
input_div: "flex items-center h-5",
|
14
|
-
helper_div: "ml-2 text-sm",
|
15
|
-
no_helper_div: "flex items-center"
|
16
|
-
}
|
17
|
-
end
|
18
|
-
# rubocop: enable Layout/LineLength
|
19
|
-
|
20
|
-
def initialize(form: nil, field: nil, label: nil, helper_text: nil, helper_popover: nil,
|
21
|
-
helper_popover_placement: "right", **props)
|
22
|
-
super
|
23
|
-
@form = form
|
24
|
-
@field = field
|
25
|
-
@object = form&.object
|
26
|
-
@props = props
|
27
|
-
@label = label_value(label, @object, field, id)
|
28
|
-
@helper_text = define_helper_text(helper_text, @object, field)
|
29
|
-
@helper_popover = define_helper_popover(helper_popover, @object, field)
|
30
|
-
@helper_popover_placement = helper_popover_placement
|
31
|
-
|
32
|
-
@props[:type] = @props[:type].to_s.in?(%w[checkbox radio]) ? @props[:type].to_s : "checkbox"
|
33
|
-
add(class: styles[:checkbox], to: @props, first_element: true) if @props[:type] == "checkbox"
|
34
|
-
add(class: styles[:base], to: @props, first_element: true)
|
35
|
-
end
|
36
|
-
|
37
|
-
def input
|
38
|
-
if @form.nil?
|
39
|
-
content_tag :input, content, @props
|
40
|
-
else
|
41
|
-
@form.text_field(@field, **@props)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def call
|
46
|
-
if @helper_text
|
47
|
-
content_tag :div, { class: "flex" } do
|
48
|
-
concat content_tag(:div, input, { class: styles[:input_div] })
|
49
|
-
concat content_tag(:div, { class: styles[:helper_div] }) do
|
50
|
-
concat label
|
51
|
-
concat helper_text
|
52
|
-
end
|
53
|
-
end
|
54
|
-
else
|
55
|
-
content_tag :div, { class: styles[:no_helper_div] } do
|
56
|
-
concat input
|
57
|
-
concat label
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|