better_ui 0.3.0 → 0.6.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/app/components/better_ui/application/main/component.html.erb +1 -1
- data/app/components/better_ui/application/sidebar/component.html.erb +25 -3
- data/app/components/better_ui/application/sidebar/component.rb +62 -5
- data/app/components/better_ui/general/button/component.html.erb +8 -8
- data/app/components/better_ui/general/button/component.rb +11 -11
- data/app/components/better_ui/general/dropdown/component.html.erb +7 -4
- data/app/components/better_ui/general/dropdown/component.rb +23 -1
- data/app/components/better_ui/general/field/component.html.erb +3 -3
- data/app/components/better_ui/general/field/component.rb +3 -3
- data/app/components/better_ui/general/grid/cell_component.html.erb +3 -0
- data/app/components/better_ui/general/grid/cell_component.rb +390 -0
- data/app/components/better_ui/general/grid/component.html.erb +3 -0
- data/app/components/better_ui/general/grid/component.rb +301 -0
- data/app/components/better_ui/general/heading/component.html.erb +1 -1
- data/app/components/better_ui/general/icon/component.rb +2 -1
- data/app/components/better_ui/general/input/checkbox/component.rb +10 -10
- data/app/components/better_ui/general/input/pin/component.html.erb +1 -0
- data/app/components/better_ui/general/input/pin/component.rb +201 -0
- data/app/components/better_ui/general/input/radio/component.rb +10 -10
- data/app/components/better_ui/general/input/rating/component.html.erb +4 -0
- data/app/components/better_ui/general/input/rating/component.rb +272 -0
- data/app/components/better_ui/general/input/select/component.html.erb +76 -14
- data/app/components/better_ui/general/input/select/component.rb +166 -101
- data/app/components/better_ui/general/input/toggle/component.html.erb +5 -0
- data/app/components/better_ui/general/input/toggle/component.rb +242 -0
- data/app/components/better_ui/general/link/component.rb +1 -1
- data/app/components/better_ui/general/text/component.html.erb +1 -0
- data/app/components/better_ui/general/text/component.rb +194 -0
- data/app/helpers/better_ui/application_helper.rb +7 -0
- data/app/helpers/better_ui/general/components/button/button_helper.rb +6 -6
- data/app/helpers/better_ui/general/components/dropdown/dropdown_helper.rb +9 -0
- data/app/helpers/better_ui/general/components/dropdown/item_helper.rb +13 -7
- data/app/helpers/better_ui/general/components/field/field_helper.rb +4 -4
- data/app/helpers/better_ui/general/components/grid/grid_helper.rb +145 -0
- data/app/helpers/better_ui/general/components/input/pin/pin_helper.rb +76 -0
- data/app/helpers/better_ui/general/components/input/rating/rating_helper.rb +70 -0
- data/app/helpers/better_ui/general/components/input/select/select_helper.rb +47 -31
- data/app/helpers/better_ui/general/components/input/toggle/toggle_helper.rb +77 -0
- data/app/helpers/better_ui/general/components/text/text_helper.rb +83 -0
- data/lib/better_ui/version.rb +1 -1
- data/lib/better_ui.rb +1 -0
- metadata +19 -4
- data/app/helpers/better_ui/general/components/accordion.rb +0 -11
- data/app/helpers/better_ui/general/components/modal.rb +0 -11
@@ -6,45 +6,59 @@ module BetterUi
|
|
6
6
|
module Input
|
7
7
|
module Select
|
8
8
|
module SelectHelper
|
9
|
-
#
|
9
|
+
# Renderizza un componente Select personalizzato con ricerca, animazioni e multi-selezione.
|
10
10
|
#
|
11
|
-
# @param name [String]
|
12
|
-
# @param options [Array<Hash>] Array
|
13
|
-
# @param selected [String, Array, nil]
|
14
|
-
# @param required [Boolean]
|
15
|
-
# @param disabled [Boolean]
|
16
|
-
# @param multiple [Boolean]
|
17
|
-
# @param
|
18
|
-
# @param
|
11
|
+
# @param name [String] Nome del campo select (obbligatorio)
|
12
|
+
# @param options [Array<Hash>] Array di opzioni nel formato [{value: 'value', label: 'label'}, ...]
|
13
|
+
# @param selected [String, Array, nil] Valore/i selezionato/i
|
14
|
+
# @param required [Boolean] Se il campo è obbligatorio
|
15
|
+
# @param disabled [Boolean] Se il campo è disabilitato
|
16
|
+
# @param multiple [Boolean] Se multiple opzioni possono essere selezionate
|
17
|
+
# @param searchable [Boolean] Se abilitare la ricerca
|
18
|
+
# @param theme [Symbol] Tema del componente (:default, :white, :red, :rose, :orange, :green, :blue, :yellow, :violet)
|
19
|
+
# @param size [Symbol] Dimensione del componente (:small, :medium, :large)
|
19
20
|
# @param rounded [Symbol] Border radius (:none, :small, :medium, :large, :full)
|
20
|
-
# @param placeholder [String
|
21
|
-
# @param
|
22
|
-
# @param
|
23
|
-
# @param
|
24
|
-
# @param
|
21
|
+
# @param placeholder [String] Testo placeholder per il trigger
|
22
|
+
# @param search_placeholder [String] Testo placeholder per il campo search
|
23
|
+
# @param max_height [String] Altezza massima del dropdown (default: "300px")
|
24
|
+
# @param form [ActionView::Helpers::FormBuilder, nil] Form builder Rails opzionale
|
25
|
+
# @param classes [String] Classi CSS aggiuntive
|
26
|
+
# @param options [Hash] Opzioni aggiuntive per attributi HTML
|
25
27
|
#
|
26
|
-
# @return [String]
|
28
|
+
# @return [String] HTML del componente Select renderizzato
|
27
29
|
#
|
28
|
-
# @example
|
29
|
-
# <%= bui_input_select(name: 'country', options: [{value: 'it', label: '
|
30
|
+
# @example Uso base
|
31
|
+
# <%= bui_input_select(name: 'country', options: [{value: 'it', label: 'Italia'}, {value: 'us', label: 'USA'}]) %>
|
30
32
|
#
|
31
|
-
# @example
|
32
|
-
# <%= bui_input_select(name: '
|
33
|
+
# @example Con selezione multipla
|
34
|
+
# <%= bui_input_select(name: 'skills', multiple: true, options: skills_options) %>
|
33
35
|
#
|
34
|
-
# @example
|
35
|
-
# <%= bui_input_select(name: '
|
36
|
+
# @example Con ricerca e temi
|
37
|
+
# <%= bui_input_select(name: 'category', searchable: true, theme: :blue, options: categories) %>
|
36
38
|
#
|
37
|
-
# @example
|
38
|
-
# <%= bui_input_select(name: '
|
39
|
+
# @example Con dimensioni personalizzate
|
40
|
+
# <%= bui_input_select(name: 'priority', size: :large, options: priorities, selected: 'high') %>
|
39
41
|
#
|
40
|
-
# @example
|
42
|
+
# @example Con Rails form builder
|
41
43
|
# <%= form_with model: @user do |form| %>
|
42
|
-
# <%= bui_input_select(name: :
|
44
|
+
# <%= bui_input_select(name: :role, form: form, options: role_options, theme: :green) %>
|
43
45
|
# <% end %>
|
46
|
+
#
|
47
|
+
# @example Con opzioni avanzate
|
48
|
+
# <%= bui_input_select(
|
49
|
+
# name: 'tags',
|
50
|
+
# multiple: true,
|
51
|
+
# searchable: true,
|
52
|
+
# placeholder: 'Seleziona tag...',
|
53
|
+
# search_placeholder: 'Cerca tag...',
|
54
|
+
# max_height: '200px',
|
55
|
+
# options: tag_options,
|
56
|
+
# selected: ['ruby', 'rails']
|
57
|
+
# ) %>
|
44
58
|
def bui_input_select(name:, options:, selected: nil, required: false, disabled: false,
|
45
|
-
|
46
|
-
|
47
|
-
|
59
|
+
multiple: false, searchable: true, theme: :default, size: :medium,
|
60
|
+
rounded: :medium, placeholder: nil, search_placeholder: nil,
|
61
|
+
max_height: "300px", form: nil, classes: '', **html_options)
|
48
62
|
render BetterUi::General::Input::Select::Component.new(
|
49
63
|
name: name,
|
50
64
|
options: options,
|
@@ -52,13 +66,15 @@ module BetterUi
|
|
52
66
|
required: required,
|
53
67
|
disabled: disabled,
|
54
68
|
multiple: multiple,
|
69
|
+
searchable: searchable,
|
55
70
|
theme: theme,
|
56
71
|
size: size,
|
57
72
|
rounded: rounded,
|
58
73
|
placeholder: placeholder,
|
59
|
-
|
74
|
+
search_placeholder: search_placeholder,
|
75
|
+
max_height: max_height,
|
60
76
|
form: form,
|
61
|
-
|
77
|
+
classes: classes,
|
62
78
|
**html_options
|
63
79
|
)
|
64
80
|
end
|
@@ -67,4 +83,4 @@ module BetterUi
|
|
67
83
|
end
|
68
84
|
end
|
69
85
|
end
|
70
|
-
end
|
86
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BetterUi
|
4
|
+
module General
|
5
|
+
module Components
|
6
|
+
module Input
|
7
|
+
module Toggle
|
8
|
+
module ToggleHelper
|
9
|
+
# Renderizza un componente Toggle/Switch moderno per sostituire i checkbox tradizionali.
|
10
|
+
#
|
11
|
+
# @param name [String] Nome del campo toggle (obbligatorio)
|
12
|
+
# @param value [String] Valore del toggle quando è attivo (default: "1")
|
13
|
+
# @param checked [Boolean] Se il toggle è attivo
|
14
|
+
# @param required [Boolean] Se il campo è obbligatorio
|
15
|
+
# @param disabled [Boolean] Se il campo è disabilitato
|
16
|
+
# @param label [String, nil] Testo della label associata al toggle
|
17
|
+
# @param label_position [Symbol] Posizione della label (:left, :right)
|
18
|
+
# @param theme [Symbol] Tema del componente (:default, :white, :red, :rose, :orange, :green, :blue, :yellow, :violet)
|
19
|
+
# @param size [Symbol] Dimensione del componente (:small, :medium, :large)
|
20
|
+
# @param form [ActionView::Helpers::FormBuilder, nil] Form builder Rails opzionale
|
21
|
+
# @param classes [String] Classi CSS aggiuntive
|
22
|
+
# @param options [Hash] Opzioni aggiuntive per attributi HTML
|
23
|
+
#
|
24
|
+
# @return [String] HTML del componente Toggle renderizzato
|
25
|
+
#
|
26
|
+
# @example Uso base
|
27
|
+
# <%= bui_input_toggle(name: 'notifications') %>
|
28
|
+
#
|
29
|
+
# @example Con label e stato iniziale
|
30
|
+
# <%= bui_input_toggle(name: 'dark_mode', label: 'Modalità scura', checked: true) %>
|
31
|
+
#
|
32
|
+
# @example Con tema e dimensioni
|
33
|
+
# <%= bui_input_toggle(name: 'premium', label: 'Account Premium', theme: :green, size: :large) %>
|
34
|
+
#
|
35
|
+
# @example Con posizione label e stato disabilitato
|
36
|
+
# <%= bui_input_toggle(name: 'maintenance', label: 'Modalità manutenzione', label_position: :left, disabled: true) %>
|
37
|
+
#
|
38
|
+
# @example Con Rails form builder
|
39
|
+
# <%= form_with model: @user do |form| %>
|
40
|
+
# <%= bui_input_toggle(name: :email_notifications, form: form, label: 'Notifiche email', theme: :blue) %>
|
41
|
+
# <%= bui_input_toggle(name: :sms_notifications, form: form, label: 'Notifiche SMS', theme: :green) %>
|
42
|
+
# <% end %>
|
43
|
+
#
|
44
|
+
# @example Con attributi HTML personalizzati
|
45
|
+
# <%= bui_input_toggle(
|
46
|
+
# name: 'api_access',
|
47
|
+
# label: 'Accesso API',
|
48
|
+
# theme: :violet,
|
49
|
+
# size: :small,
|
50
|
+
# required: true,
|
51
|
+
# data: { action: 'toggle-api-access' },
|
52
|
+
# 'aria-describedby': 'api-help-text'
|
53
|
+
# ) %>
|
54
|
+
def bui_input_toggle(name:, value: '1', checked: false, required: false, disabled: false,
|
55
|
+
label: nil, label_position: :right, theme: :default, size: :medium,
|
56
|
+
form: nil, classes: '', **options)
|
57
|
+
render BetterUi::General::Input::Toggle::Component.new(
|
58
|
+
name: name,
|
59
|
+
value: value,
|
60
|
+
checked: checked,
|
61
|
+
required: required,
|
62
|
+
disabled: disabled,
|
63
|
+
label: label,
|
64
|
+
label_position: label_position,
|
65
|
+
theme: theme,
|
66
|
+
size: size,
|
67
|
+
form: form,
|
68
|
+
classes: classes,
|
69
|
+
**options
|
70
|
+
)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BetterUi
|
4
|
+
module General
|
5
|
+
module Components
|
6
|
+
module Text
|
7
|
+
module TextHelper
|
8
|
+
# Genera un testo usando BetterUi::General::Text::Component
|
9
|
+
#
|
10
|
+
# @param text [String] testo da mostrare (nil se si usa blocco)
|
11
|
+
# @param theme [Symbol] tema del colore (:default, :white, :red, :blue, etc.)
|
12
|
+
# @param size [Symbol] dimensione (:xs, :small, :medium, :large, :xl, :"2xl")
|
13
|
+
# @param align [Symbol] allineamento (:left, :center, :right, :justify)
|
14
|
+
# @param weight [Symbol] peso font (:thin, :light, :normal, :medium, :semibold, :bold, :extrabold)
|
15
|
+
# @param style [Symbol] stile (:normal, :italic, :underline, :line_through)
|
16
|
+
# @param classes [String] classi CSS aggiuntive
|
17
|
+
# @param html_options [Hash] opzioni HTML aggiuntive
|
18
|
+
# @return [String] HTML del testo renderizzato
|
19
|
+
#
|
20
|
+
# @example Uso base
|
21
|
+
# bui_text("Testo semplice")
|
22
|
+
# bui_text("Testo importante", theme: :blue, weight: :bold)
|
23
|
+
#
|
24
|
+
# @example Con dimensioni e stili
|
25
|
+
# bui_text("Titolo grande", size: :xl, weight: :bold)
|
26
|
+
# bui_text("Testo sottile", theme: :muted, size: :small)
|
27
|
+
#
|
28
|
+
# @example Con allineamento
|
29
|
+
# bui_text("Testo centrato", align: :center)
|
30
|
+
# bui_text("Testo giustificato", align: :justify)
|
31
|
+
#
|
32
|
+
# @example Con stili tipografici
|
33
|
+
# bui_text("Testo corsivo", style: :italic)
|
34
|
+
# bui_text("Testo sottolineato", style: :underline)
|
35
|
+
#
|
36
|
+
# @example Con blocco Ruby
|
37
|
+
# bui_text(theme: :green, weight: :semibold) do
|
38
|
+
# "Contenuto complesso con <strong>HTML</strong>".html_safe
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# @example Con attributi HTML personalizzati
|
42
|
+
# bui_text("Testo con ID",
|
43
|
+
# theme: :blue,
|
44
|
+
# id: "my-text",
|
45
|
+
# data: { action: "click->handler#process" })
|
46
|
+
#
|
47
|
+
# @example Per sostituire paragrafi standard
|
48
|
+
# # Invece di: <p class="text-gray-600">Descrizione</p>
|
49
|
+
# bui_text("Descrizione", theme: :gray)
|
50
|
+
#
|
51
|
+
# @example Combinazioni complesse
|
52
|
+
# bui_text("Messaggio di errore",
|
53
|
+
# theme: :red,
|
54
|
+
# size: :small,
|
55
|
+
# weight: :medium,
|
56
|
+
# classes: "mb-2")
|
57
|
+
def bui_text(
|
58
|
+
text = nil,
|
59
|
+
theme: :default,
|
60
|
+
size: :medium,
|
61
|
+
align: :left,
|
62
|
+
weight: :normal,
|
63
|
+
style: :normal,
|
64
|
+
classes: '',
|
65
|
+
**html_options,
|
66
|
+
&block
|
67
|
+
)
|
68
|
+
render BetterUi::General::Text::Component.new(
|
69
|
+
text: text,
|
70
|
+
theme: theme,
|
71
|
+
size: size,
|
72
|
+
align: align,
|
73
|
+
weight: weight,
|
74
|
+
style: style,
|
75
|
+
classes: classes,
|
76
|
+
**html_options
|
77
|
+
), &block
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/better_ui/version.rb
CHANGED
data/lib/better_ui.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: better_ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alessiobussolari
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2025-06-
|
12
|
+
date: 2025-06-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -141,6 +141,10 @@ files:
|
|
141
141
|
- app/components/better_ui/general/dropdown/item_component.rb
|
142
142
|
- app/components/better_ui/general/field/component.html.erb
|
143
143
|
- app/components/better_ui/general/field/component.rb
|
144
|
+
- app/components/better_ui/general/grid/cell_component.html.erb
|
145
|
+
- app/components/better_ui/general/grid/cell_component.rb
|
146
|
+
- app/components/better_ui/general/grid/component.html.erb
|
147
|
+
- app/components/better_ui/general/grid/component.rb
|
144
148
|
- app/components/better_ui/general/heading/component.html.erb
|
145
149
|
- app/components/better_ui/general/heading/component.rb
|
146
150
|
- app/components/better_ui/general/icon/component.html.erb
|
@@ -149,8 +153,12 @@ files:
|
|
149
153
|
- app/components/better_ui/general/input/checkbox/component.rb
|
150
154
|
- app/components/better_ui/general/input/datetime/component.html.erb
|
151
155
|
- app/components/better_ui/general/input/datetime/component.rb
|
156
|
+
- app/components/better_ui/general/input/pin/component.html.erb
|
157
|
+
- app/components/better_ui/general/input/pin/component.rb
|
152
158
|
- app/components/better_ui/general/input/radio/component.html.erb
|
153
159
|
- app/components/better_ui/general/input/radio/component.rb
|
160
|
+
- app/components/better_ui/general/input/rating/component.html.erb
|
161
|
+
- app/components/better_ui/general/input/rating/component.rb
|
154
162
|
- app/components/better_ui/general/input/select/component.html.erb
|
155
163
|
- app/components/better_ui/general/input/select/component.rb
|
156
164
|
- app/components/better_ui/general/input/select/select_component.html.erb
|
@@ -159,6 +167,8 @@ files:
|
|
159
167
|
- app/components/better_ui/general/input/text/component.rb
|
160
168
|
- app/components/better_ui/general/input/textarea/component.html.erb
|
161
169
|
- app/components/better_ui/general/input/textarea/component.rb
|
170
|
+
- app/components/better_ui/general/input/toggle/component.html.erb
|
171
|
+
- app/components/better_ui/general/input/toggle/component.rb
|
162
172
|
- app/components/better_ui/general/link/component.html.erb
|
163
173
|
- app/components/better_ui/general/link/component.rb
|
164
174
|
- app/components/better_ui/general/modal/component.html.erb
|
@@ -195,6 +205,8 @@ files:
|
|
195
205
|
- app/components/better_ui/general/tabs/tab_component.rb
|
196
206
|
- app/components/better_ui/general/tag/component.html.erb
|
197
207
|
- app/components/better_ui/general/tag/component.rb
|
208
|
+
- app/components/better_ui/general/text/component.html.erb
|
209
|
+
- app/components/better_ui/general/text/component.rb
|
198
210
|
- app/components/better_ui/general/tooltip/component.html.erb
|
199
211
|
- app/components/better_ui/general/tooltip/component.rb
|
200
212
|
- app/controllers/better_ui/application_controller.rb
|
@@ -204,7 +216,6 @@ files:
|
|
204
216
|
- app/helpers/better_ui/application/components/navbar/navbar_helper.rb
|
205
217
|
- app/helpers/better_ui/application/components/sidebar/sidebar_helper.rb
|
206
218
|
- app/helpers/better_ui/application_helper.rb
|
207
|
-
- app/helpers/better_ui/general/components/accordion.rb
|
208
219
|
- app/helpers/better_ui/general/components/accordion/accordion_helper.rb
|
209
220
|
- app/helpers/better_ui/general/components/alert/alert_helper.rb
|
210
221
|
- app/helpers/better_ui/general/components/avatar/avatar_helper.rb
|
@@ -217,17 +228,20 @@ files:
|
|
217
228
|
- app/helpers/better_ui/general/components/dropdown/dropdown_helper.rb
|
218
229
|
- app/helpers/better_ui/general/components/dropdown/item_helper.rb
|
219
230
|
- app/helpers/better_ui/general/components/field/field_helper.rb
|
231
|
+
- app/helpers/better_ui/general/components/grid/grid_helper.rb
|
220
232
|
- app/helpers/better_ui/general/components/heading/heading_helper.rb
|
221
233
|
- app/helpers/better_ui/general/components/icon/icon_helper.rb
|
222
234
|
- app/helpers/better_ui/general/components/input/checkbox/checkbox_helper.rb
|
223
235
|
- app/helpers/better_ui/general/components/input/datetime/datetime_helper.rb
|
236
|
+
- app/helpers/better_ui/general/components/input/pin/pin_helper.rb
|
224
237
|
- app/helpers/better_ui/general/components/input/radio/radio_helper.rb
|
225
238
|
- app/helpers/better_ui/general/components/input/radio_group/radio_group_helper.rb
|
239
|
+
- app/helpers/better_ui/general/components/input/rating/rating_helper.rb
|
226
240
|
- app/helpers/better_ui/general/components/input/select/select_helper.rb
|
227
241
|
- app/helpers/better_ui/general/components/input/text/text_helper.rb
|
228
242
|
- app/helpers/better_ui/general/components/input/textarea/textarea_helper.rb
|
243
|
+
- app/helpers/better_ui/general/components/input/toggle/toggle_helper.rb
|
229
244
|
- app/helpers/better_ui/general/components/link/link_helper.rb
|
230
|
-
- app/helpers/better_ui/general/components/modal.rb
|
231
245
|
- app/helpers/better_ui/general/components/modal/modal_helper.rb
|
232
246
|
- app/helpers/better_ui/general/components/pagination/pagination_helper.rb
|
233
247
|
- app/helpers/better_ui/general/components/panel/panel_helper.rb
|
@@ -244,6 +258,7 @@ files:
|
|
244
258
|
- app/helpers/better_ui/general/components/tabs/tab_helper.rb
|
245
259
|
- app/helpers/better_ui/general/components/tabs/tabs_helper.rb
|
246
260
|
- app/helpers/better_ui/general/components/tag/tag_helper.rb
|
261
|
+
- app/helpers/better_ui/general/components/text/text_helper.rb
|
247
262
|
- app/helpers/better_ui/general/components/tooltip/tooltip_helper.rb
|
248
263
|
- app/jobs/better_ui/application_job.rb
|
249
264
|
- app/mailers/better_ui/application_mailer.rb
|