better_ui 0.1.0 → 0.2.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/MIT-LICENSE +1 -1
- data/README.md +225 -119
- data/app/assets/stylesheets/better_ui/application.css +0 -356
- data/app/components/better_ui/application/card/component.html.erb +20 -0
- data/app/components/better_ui/application/card/component.rb +214 -0
- data/app/components/better_ui/application/main/component.html.erb +9 -0
- data/app/components/better_ui/application/main/component.rb +123 -0
- data/app/components/better_ui/application/navbar/component.html.erb +92 -0
- data/app/components/better_ui/application/navbar/component.rb +136 -0
- data/app/components/better_ui/application/sidebar/component.html.erb +190 -0
- data/app/components/better_ui/application/sidebar/component.rb +129 -0
- data/app/components/better_ui/general/alert/component.html.erb +32 -0
- data/app/components/better_ui/general/alert/component.rb +242 -0
- data/app/components/better_ui/general/avatar/component.html.erb +20 -0
- data/app/components/better_ui/general/avatar/component.rb +301 -0
- data/app/components/better_ui/general/badge/component.html.erb +23 -0
- data/app/components/better_ui/general/badge/component.rb +248 -0
- data/app/components/better_ui/general/breadcrumb/component.html.erb +15 -0
- data/app/components/better_ui/general/breadcrumb/component.rb +187 -0
- data/app/components/better_ui/general/button/component.html.erb +34 -0
- data/app/components/better_ui/general/button/component.rb +214 -0
- data/app/components/better_ui/general/divider/component.html.erb +10 -0
- data/app/components/better_ui/general/divider/component.rb +226 -0
- data/app/components/better_ui/general/dropdown/component.html.erb +14 -0
- data/app/components/better_ui/general/dropdown/component.rb +219 -0
- data/app/components/better_ui/general/dropdown/divider_component.html.erb +1 -0
- data/app/components/better_ui/general/dropdown/divider_component.rb +41 -0
- data/app/components/better_ui/general/dropdown/item_component.html.erb +6 -0
- data/app/components/better_ui/general/dropdown/item_component.rb +118 -0
- data/app/components/better_ui/general/field/component.html.erb +27 -0
- data/app/components/better_ui/general/field/component.rb +37 -0
- data/app/components/better_ui/general/heading/component.html.erb +22 -0
- data/app/components/better_ui/general/heading/component.rb +257 -0
- data/app/components/better_ui/general/icon/component.html.erb +7 -0
- data/app/components/better_ui/general/icon/component.rb +239 -0
- data/app/components/better_ui/general/input/checkbox/component.html.erb +5 -0
- data/app/components/better_ui/general/input/checkbox/component.rb +238 -0
- data/app/components/better_ui/general/input/datetime/component.html.erb +5 -0
- data/app/components/better_ui/general/input/datetime/component.rb +223 -0
- data/app/components/better_ui/general/input/radio/component.html.erb +5 -0
- data/app/components/better_ui/general/input/radio/component.rb +230 -0
- data/app/components/better_ui/general/input/select/component.html.erb +16 -0
- data/app/components/better_ui/general/input/select/component.rb +184 -0
- data/app/components/better_ui/general/input/select/select_component.html.erb +5 -0
- data/app/components/better_ui/general/input/select/select_component.rb +37 -0
- data/app/components/better_ui/general/input/text/component.html.erb +5 -0
- data/app/components/better_ui/general/input/text/component.rb +171 -0
- data/app/components/better_ui/general/input/textarea/component.html.erb +5 -0
- data/app/components/better_ui/general/input/textarea/component.rb +166 -0
- data/app/components/better_ui/general/link/component.html.erb +18 -0
- data/app/components/better_ui/general/link/component.rb +258 -0
- data/app/components/better_ui/general/modal/component.html.erb +42 -0
- data/app/components/better_ui/general/modal/component.rb +165 -0
- data/app/components/better_ui/general/pagination/component.html.erb +85 -0
- data/app/components/better_ui/general/pagination/component.rb +216 -0
- data/app/components/better_ui/general/panel/component.html.erb +28 -0
- data/app/components/better_ui/general/panel/component.rb +249 -0
- data/app/components/better_ui/general/progress/component.html.erb +11 -0
- data/app/components/better_ui/general/progress/component.rb +160 -0
- data/app/components/better_ui/general/spinner/component.html.erb +35 -0
- data/app/components/better_ui/general/spinner/component.rb +93 -0
- data/app/components/better_ui/general/table/component.html.erb +5 -0
- data/app/components/better_ui/general/table/component.rb +217 -0
- data/app/components/better_ui/general/table/tbody_component.html.erb +3 -0
- data/app/components/better_ui/general/table/tbody_component.rb +30 -0
- data/app/components/better_ui/general/table/td_component.html.erb +3 -0
- data/app/components/better_ui/general/table/td_component.rb +44 -0
- data/app/components/better_ui/general/table/tfoot_component.html.erb +3 -0
- data/app/components/better_ui/general/table/tfoot_component.rb +28 -0
- data/app/components/better_ui/general/table/th_component.html.erb +6 -0
- data/app/components/better_ui/general/table/th_component.rb +51 -0
- data/app/components/better_ui/general/table/thead_component.html.erb +3 -0
- data/app/components/better_ui/general/table/thead_component.rb +28 -0
- data/app/components/better_ui/general/table/tr_component.html.erb +3 -0
- data/app/components/better_ui/general/table/tr_component.rb +30 -0
- data/app/components/better_ui/general/tabs/component.html.erb +3 -0
- data/app/components/better_ui/general/tabs/component.rb +102 -0
- data/app/components/better_ui/general/tabs/panel_component.html.erb +3 -0
- data/app/components/better_ui/general/tabs/panel_component.rb +37 -0
- data/app/components/better_ui/general/tabs/tab_component.html.erb +13 -0
- data/app/components/better_ui/general/tabs/tab_component.rb +111 -0
- data/app/components/better_ui/general/tag/component.html.erb +3 -0
- data/app/components/better_ui/general/tag/component.rb +104 -0
- data/app/components/better_ui/general/tooltip/component.html.erb +7 -0
- data/app/components/better_ui/general/tooltip/component.rb +239 -0
- data/app/helpers/better_ui/application/components/card/card_helper.rb +96 -0
- data/app/helpers/better_ui/application/components/card.rb +11 -0
- data/app/helpers/better_ui/application/components/main/main_helper.rb +64 -0
- data/app/helpers/better_ui/application/components/navbar/navbar_helper.rb +77 -0
- data/app/helpers/better_ui/application/components/sidebar/sidebar_helper.rb +51 -0
- data/app/helpers/better_ui/application_helper.rb +51 -179
- data/app/helpers/better_ui/general/components/alert/alert_helper.rb +57 -0
- data/app/helpers/better_ui/general/components/avatar/avatar_helper.rb +29 -0
- data/app/helpers/better_ui/general/components/badge/badge_helper.rb +53 -0
- data/app/helpers/better_ui/general/components/breadcrumb/breadcrumb_helper.rb +37 -0
- data/app/helpers/better_ui/general/components/button/button_helper.rb +65 -0
- data/app/helpers/better_ui/general/components/container/container_helper.rb +60 -0
- data/app/helpers/better_ui/general/components/divider/divider_helper.rb +63 -0
- data/app/helpers/better_ui/general/components/dropdown/divider_helper.rb +32 -0
- data/app/helpers/better_ui/general/components/dropdown/dropdown_helper.rb +79 -0
- data/app/helpers/better_ui/general/components/dropdown/item_helper.rb +62 -0
- data/app/helpers/better_ui/general/components/field/field_helper.rb +26 -0
- data/app/helpers/better_ui/general/components/heading/heading_helper.rb +72 -0
- data/app/helpers/better_ui/general/components/icon/icon_helper.rb +16 -0
- data/app/helpers/better_ui/general/components/input/checkbox/checkbox_helper.rb +81 -0
- data/app/helpers/better_ui/general/components/input/datetime/datetime_helper.rb +91 -0
- data/app/helpers/better_ui/general/components/input/radio/radio_helper.rb +79 -0
- data/app/helpers/better_ui/general/components/input/radio_group/radio_group_helper.rb +124 -0
- data/app/helpers/better_ui/general/components/input/select/select_helper.rb +70 -0
- data/app/helpers/better_ui/general/components/input/text/text_helper.rb +138 -0
- data/app/helpers/better_ui/general/components/input/textarea/textarea_helper.rb +73 -0
- data/app/helpers/better_ui/general/components/link/link_helper.rb +89 -0
- data/app/helpers/better_ui/general/components/modal/modal_helper.rb +95 -0
- data/app/helpers/better_ui/general/components/pagination/pagination_helper.rb +82 -0
- data/app/helpers/better_ui/general/components/panel/panel_helper.rb +83 -0
- data/app/helpers/better_ui/general/components/progress/progress_helper.rb +53 -0
- data/app/helpers/better_ui/general/components/spinner/spinner_helper.rb +19 -0
- data/app/helpers/better_ui/general/components/table/table_helper.rb +53 -0
- data/app/helpers/better_ui/general/components/table/tbody_helper.rb +13 -0
- data/app/helpers/better_ui/general/components/table/td_helper.rb +19 -0
- data/app/helpers/better_ui/general/components/table/tfoot_helper.rb +13 -0
- data/app/helpers/better_ui/general/components/table/th_helper.rb +19 -0
- data/app/helpers/better_ui/general/components/table/thead_helper.rb +13 -0
- data/app/helpers/better_ui/general/components/table/tr_helper.rb +13 -0
- data/app/helpers/better_ui/general/components/tabs/panel_helper.rb +62 -0
- data/app/helpers/better_ui/general/components/tabs/tab_helper.rb +55 -0
- data/app/helpers/better_ui/general/components/tabs/tabs_helper.rb +62 -0
- data/app/helpers/better_ui/general/components/tag/tag_helper.rb +26 -0
- data/app/helpers/better_ui/general/components/tooltip/tooltip_helper.rb +60 -0
- data/app/views/layouts/better_ui/application.html.erb +6 -124
- data/config/initializers/lookbook.rb +23 -0
- data/config/routes.rb +0 -8
- data/lib/better_ui/engine.rb +5 -19
- data/lib/better_ui/railtie.rb +20 -0
- data/lib/better_ui/version.rb +1 -1
- data/lib/better_ui.rb +4 -20
- metadata +155 -28
- data/app/controllers/better_ui/docs_controller.rb +0 -41
- data/app/views/better_ui/docs/component.html.erb +0 -365
- data/app/views/better_ui/docs/index.html.erb +0 -100
- data/app/views/better_ui/docs/show.html.erb +0 -60
@@ -0,0 +1,63 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module General
|
3
|
+
module Components
|
4
|
+
module Divider
|
5
|
+
module DividerHelper
|
6
|
+
# Genera un divider usando BetterUi::General::Divider::Component
|
7
|
+
#
|
8
|
+
# @param theme [Symbol] tema del divider (:default, :white, etc.)
|
9
|
+
# @param orientation [Symbol] orientamento del divider (:horizontal, :vertical)
|
10
|
+
# @param style [Symbol] stile della linea (:solid, :dashed, :dotted, :double)
|
11
|
+
# @param size [Symbol] dimensione della linea (:thin, :medium, :thick)
|
12
|
+
# @param label [String] testo opzionale da mostrare al centro del divider
|
13
|
+
# @param height [String] altezza per divider verticale (es. "100px", "100%")
|
14
|
+
# @param classes [String] classi CSS aggiuntive
|
15
|
+
# @param html_options [Hash] opzioni HTML per il container
|
16
|
+
# @return [String] HTML del divider renderizzato
|
17
|
+
#
|
18
|
+
# @example Uso base
|
19
|
+
# bui_divider
|
20
|
+
# bui_divider(theme: :blue, size: :thick)
|
21
|
+
#
|
22
|
+
# @example Con label
|
23
|
+
# bui_divider(label: "Oppure", theme: :red)
|
24
|
+
#
|
25
|
+
# @example Divider verticale
|
26
|
+
# bui_divider(orientation: :vertical, height: "100px", theme: :green)
|
27
|
+
#
|
28
|
+
# @example Con opzioni avanzate
|
29
|
+
# bui_divider(
|
30
|
+
# theme: :violet,
|
31
|
+
# orientation: :horizontal,
|
32
|
+
# style: :dashed,
|
33
|
+
# size: :medium,
|
34
|
+
# label: "Sezione",
|
35
|
+
# classes: "my-8",
|
36
|
+
# id: "main-divider"
|
37
|
+
# )
|
38
|
+
def bui_divider(
|
39
|
+
theme: :white,
|
40
|
+
orientation: :horizontal,
|
41
|
+
style: :solid,
|
42
|
+
size: :medium,
|
43
|
+
label: nil,
|
44
|
+
height: nil,
|
45
|
+
classes: nil,
|
46
|
+
**html_options
|
47
|
+
)
|
48
|
+
render BetterUi::General::Divider::Component.new(
|
49
|
+
theme: theme,
|
50
|
+
orientation: orientation,
|
51
|
+
style: style,
|
52
|
+
size: size,
|
53
|
+
label: label,
|
54
|
+
height: height,
|
55
|
+
classes: classes,
|
56
|
+
**html_options
|
57
|
+
)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BetterUi
|
4
|
+
module General
|
5
|
+
module Components
|
6
|
+
module Dropdown
|
7
|
+
module DividerHelper
|
8
|
+
##
|
9
|
+
# Crea un divisore per separare gruppi di elementi nel menu dropdown.
|
10
|
+
#
|
11
|
+
# @param classes [String] Classi CSS aggiuntive
|
12
|
+
# @param options [Hash] Attributi HTML aggiuntivi
|
13
|
+
#
|
14
|
+
# @return [String] Il markup HTML del divisore dropdown
|
15
|
+
#
|
16
|
+
# @example Uso base
|
17
|
+
# <%= bui_dropdown_divider %>
|
18
|
+
#
|
19
|
+
# @example Con classi personalizzate
|
20
|
+
# <%= bui_dropdown_divider(classes: "my-4") %>
|
21
|
+
#
|
22
|
+
def bui_dropdown_divider(classes: '', **options)
|
23
|
+
render BetterUi::General::Dropdown::DividerComponent.new(
|
24
|
+
classes: classes,
|
25
|
+
**options
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BetterUi
|
4
|
+
module General
|
5
|
+
module Components
|
6
|
+
module Dropdown
|
7
|
+
module DropdownHelper
|
8
|
+
##
|
9
|
+
# Crea un componente dropdown interattivo con menu contestuale.
|
10
|
+
#
|
11
|
+
# @param trigger [String] Il testo del pulsante trigger (obbligatorio)
|
12
|
+
# @param position [Symbol] La posizione del menu dropdown (:bottom, :top, :left, :right)
|
13
|
+
# @param theme [Symbol] Il tema colore del trigger (:default, :white, :red, :rose, :orange, :green, :blue, :yellow, :violet)
|
14
|
+
# @param size [Symbol] La dimensione del trigger (:small, :medium, :large)
|
15
|
+
# @param rounded [Symbol] Il border radius (:none, :small, :medium, :large, :full)
|
16
|
+
# @param animation [Symbol] Il tipo di animazione (:fade, :slide, :none)
|
17
|
+
# @param classes [String] Classi CSS aggiuntive
|
18
|
+
# @param options [Hash] Attributi HTML aggiuntivi
|
19
|
+
# @param block [Proc] Il contenuto del menu dropdown
|
20
|
+
#
|
21
|
+
# @return [String] Il markup HTML del componente dropdown
|
22
|
+
#
|
23
|
+
# @example Uso base
|
24
|
+
# <%= bui_dropdown(trigger: "Azioni") do %>
|
25
|
+
# <%= bui_dropdown_item(text: "Modifica") %>
|
26
|
+
# <% end %>
|
27
|
+
#
|
28
|
+
# @example Con posizione e tema
|
29
|
+
# <%= bui_dropdown(trigger: "Menu", position: :top, theme: :blue) do %>
|
30
|
+
# <%= bui_dropdown_item(text: "Profilo", icon: "user") %>
|
31
|
+
# <%= bui_dropdown_divider %>
|
32
|
+
# <%= bui_dropdown_item(text: "Logout", icon: "logout") %>
|
33
|
+
# <% end %>
|
34
|
+
#
|
35
|
+
# @example Con dimensioni e stile
|
36
|
+
# <%= bui_dropdown(trigger: "Opzioni", size: :large, rounded: :full, animation: :slide) do %>
|
37
|
+
# <%= bui_dropdown_item(text: "Impostazioni", icon: "cog") %>
|
38
|
+
# <% end %>
|
39
|
+
#
|
40
|
+
# @example Con link e azioni
|
41
|
+
# <%= bui_dropdown(trigger: "Utente", theme: :green) do %>
|
42
|
+
# <%= bui_dropdown_item(text: "Dashboard", href: "/dashboard") %>
|
43
|
+
# <%= bui_dropdown_item(text: "Profilo", href: "/profile") %>
|
44
|
+
# <%= bui_dropdown_divider %>
|
45
|
+
# <%= bui_dropdown_item(text: "Elimina", theme: :red, icon: "trash") %>
|
46
|
+
# <% end %>
|
47
|
+
#
|
48
|
+
# @example Con attributi HTML personalizzati
|
49
|
+
# <%= bui_dropdown(trigger: "Menu", id: "main-menu", data: { controller: "dropdown" }) do %>
|
50
|
+
# <%= bui_dropdown_item(text: "Item 1") %>
|
51
|
+
# <% end %>
|
52
|
+
#
|
53
|
+
def bui_dropdown(
|
54
|
+
trigger:,
|
55
|
+
position: :bottom,
|
56
|
+
theme: :default,
|
57
|
+
size: :medium,
|
58
|
+
rounded: :medium,
|
59
|
+
animation: :fade,
|
60
|
+
classes: '',
|
61
|
+
**options,
|
62
|
+
&block
|
63
|
+
)
|
64
|
+
render BetterUi::General::Dropdown::Component.new(
|
65
|
+
trigger: trigger,
|
66
|
+
position: position,
|
67
|
+
theme: theme,
|
68
|
+
size: size,
|
69
|
+
rounded: rounded,
|
70
|
+
animation: animation,
|
71
|
+
classes: classes,
|
72
|
+
**options
|
73
|
+
), &block
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BetterUi
|
4
|
+
module General
|
5
|
+
module Components
|
6
|
+
module Dropdown
|
7
|
+
module ItemHelper
|
8
|
+
##
|
9
|
+
# Crea un elemento del menu dropdown.
|
10
|
+
#
|
11
|
+
# @param text [String] Il testo dell'elemento (obbligatorio)
|
12
|
+
# @param icon [String] Il nome dell'icona da mostrare ("edit", "trash", "share", "user", "cog", "logout")
|
13
|
+
# @param href [String] L'URL per renderlo un link
|
14
|
+
# @param theme [Symbol] Il tema colore (:default, :white, :red, :rose, :orange, :green, :blue, :yellow, :violet)
|
15
|
+
# @param disabled [Boolean] Se l'elemento è disabilitato
|
16
|
+
# @param active [Boolean] Se l'elemento è attivo/selezionato
|
17
|
+
# @param classes [String] Classi CSS aggiuntive
|
18
|
+
# @param options [Hash] Attributi HTML aggiuntivi
|
19
|
+
#
|
20
|
+
# @return [String] Il markup HTML dell'elemento dropdown
|
21
|
+
#
|
22
|
+
# @example Uso base
|
23
|
+
# <%= bui_dropdown_item(text: "Modifica") %>
|
24
|
+
#
|
25
|
+
# @example Con icona
|
26
|
+
# <%= bui_dropdown_item(text: "Elimina", icon: "trash") %>
|
27
|
+
#
|
28
|
+
# @example Come link
|
29
|
+
# <%= bui_dropdown_item(text: "Profilo", href: "/profile", icon: "user") %>
|
30
|
+
#
|
31
|
+
# @example Con tema colorato
|
32
|
+
# <%= bui_dropdown_item(text: "Azione pericolosa", theme: :red, icon: "trash") %>
|
33
|
+
#
|
34
|
+
# @example Disabilitato
|
35
|
+
# <%= bui_dropdown_item(text: "Non disponibile", disabled: true) %>
|
36
|
+
#
|
37
|
+
def bui_dropdown_item(
|
38
|
+
text:,
|
39
|
+
icon: nil,
|
40
|
+
href: nil,
|
41
|
+
theme: :default,
|
42
|
+
disabled: false,
|
43
|
+
active: false,
|
44
|
+
classes: '',
|
45
|
+
**options
|
46
|
+
)
|
47
|
+
render BetterUi::General::Dropdown::ItemComponent.new(
|
48
|
+
text: text,
|
49
|
+
icon: icon,
|
50
|
+
href: href,
|
51
|
+
theme: theme,
|
52
|
+
disabled: disabled,
|
53
|
+
active: active,
|
54
|
+
classes: classes,
|
55
|
+
**options
|
56
|
+
)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module General
|
3
|
+
module Components
|
4
|
+
module Field
|
5
|
+
module FieldHelper
|
6
|
+
# @param label [String] Label del campo
|
7
|
+
# @param name [String] Nome del campo
|
8
|
+
# @param required [Boolean] Se il campo è obbligatorio
|
9
|
+
# @param error [String] Messaggio di errore
|
10
|
+
# @param help_text [String] Testo di aiuto
|
11
|
+
# @return [BetterUi::General::FieldComponent] Componente del campo
|
12
|
+
def bui_field(label:, name:, required: false, error: nil, help_text: nil, id: nil, &block)
|
13
|
+
render BetterUi::General::Field::Component.new(
|
14
|
+
label: label,
|
15
|
+
name: name,
|
16
|
+
required: required,
|
17
|
+
error: error,
|
18
|
+
help_text: help_text,
|
19
|
+
id: id || SecureRandom.uuid
|
20
|
+
), &block
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module General
|
3
|
+
module Components
|
4
|
+
module Heading
|
5
|
+
module HeadingHelper
|
6
|
+
# Genera un heading usando BetterUi::General::Heading::Component
|
7
|
+
#
|
8
|
+
# @param text [String] testo del heading
|
9
|
+
# @param level [Integer] livello del heading (1-6)
|
10
|
+
# @param theme [Symbol] tema del colore (:default, :white, etc.)
|
11
|
+
# @param align [Symbol] allineamento (:left, :center, :right)
|
12
|
+
# @param size [Symbol] dimensione (:small, :medium, :large)
|
13
|
+
# @param style [Symbol] stile (:normal, :bold, :italic, :underline)
|
14
|
+
# @param icon [String] icona opzionale
|
15
|
+
# @param subtitle [String] sottotitolo opzionale
|
16
|
+
# @param with_divider [Boolean] mostra linea divisoria
|
17
|
+
# @param html_options [Hash] opzioni HTML per il container
|
18
|
+
# @return [String] HTML del heading renderizzato
|
19
|
+
#
|
20
|
+
# @example Uso base
|
21
|
+
# bui_heading("Titolo principale")
|
22
|
+
# bui_heading("Sottotitolo", level: 3, theme: :blue)
|
23
|
+
#
|
24
|
+
# @example Con icona e sottotitolo
|
25
|
+
# bui_heading("Dashboard", icon: "home", subtitle: "Panoramica generale")
|
26
|
+
#
|
27
|
+
# @example Con divider
|
28
|
+
# bui_heading("Sezione", level: 2, with_divider: true, theme: :green)
|
29
|
+
#
|
30
|
+
# @example Con opzioni avanzate
|
31
|
+
# bui_heading(
|
32
|
+
# "Titolo personalizzato",
|
33
|
+
# level: 1,
|
34
|
+
# theme: :violet,
|
35
|
+
# align: :center,
|
36
|
+
# size: :large,
|
37
|
+
# style: :bold,
|
38
|
+
# icon: "star",
|
39
|
+
# subtitle: "Con tutte le opzioni",
|
40
|
+
# with_divider: true,
|
41
|
+
# id: "main-title",
|
42
|
+
# class: "custom-heading"
|
43
|
+
# )
|
44
|
+
def bui_heading(
|
45
|
+
text,
|
46
|
+
level: 2,
|
47
|
+
theme: :white,
|
48
|
+
align: :left,
|
49
|
+
size: :medium,
|
50
|
+
style: :normal,
|
51
|
+
icon: nil,
|
52
|
+
subtitle: nil,
|
53
|
+
with_divider: false,
|
54
|
+
**html_options
|
55
|
+
)
|
56
|
+
render BetterUi::General::Heading::Component.new(
|
57
|
+
level: level,
|
58
|
+
theme: theme,
|
59
|
+
align: align,
|
60
|
+
size: size,
|
61
|
+
style: style,
|
62
|
+
icon: icon,
|
63
|
+
subtitle: subtitle,
|
64
|
+
with_divider: with_divider,
|
65
|
+
**html_options
|
66
|
+
).with_content(text)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BetterUi
|
4
|
+
module General
|
5
|
+
module Components
|
6
|
+
module Input
|
7
|
+
module Checkbox
|
8
|
+
module CheckboxHelper
|
9
|
+
# Renderizza un componente Checkbox con tutti i parametri disponibili.
|
10
|
+
#
|
11
|
+
# @param name [String] Nome del campo checkbox (obbligatorio)
|
12
|
+
# @param value [String] Valore del checkbox (default: "1")
|
13
|
+
# @param checked [Boolean] Se il checkbox è selezionato
|
14
|
+
# @param required [Boolean] Se il campo è obbligatorio
|
15
|
+
# @param disabled [Boolean] Se il campo è disabilitato
|
16
|
+
# @param indeterminate [Boolean] Se il checkbox è in stato indeterminate
|
17
|
+
# @param label [String, nil] Testo della label associata al checkbox
|
18
|
+
# @param label_position [Symbol] Posizione della label (:left, :right)
|
19
|
+
# @param theme [Symbol] Tema del componente (:default, :white, :red, :rose, :orange, :green, :blue, :yellow, :violet)
|
20
|
+
# @param size [Symbol] Dimensione del componente (:small, :medium, :large)
|
21
|
+
# @param rounded [Symbol] Border radius (:none, :small, :medium, :large, :full)
|
22
|
+
# @param classes [String] Classi CSS aggiuntive
|
23
|
+
# @param form [ActionView::Helpers::FormBuilder, nil] Form builder Rails opzionale
|
24
|
+
# @param options [Hash] Opzioni aggiuntive per l'input (es. data attributes, aria attributes)
|
25
|
+
#
|
26
|
+
# @return [String] HTML del componente Checkbox renderizzato
|
27
|
+
#
|
28
|
+
# @example Uso base
|
29
|
+
# <%= bui_input_checkbox(name: 'accept_terms') %>
|
30
|
+
#
|
31
|
+
# @example Con label
|
32
|
+
# <%= bui_input_checkbox(name: 'newsletter', label: 'Iscriviti alla newsletter', checked: true) %>
|
33
|
+
#
|
34
|
+
# @example Con label a sinistra
|
35
|
+
# <%= bui_input_checkbox(name: 'terms', label: 'Accetto i termini e condizioni', label_position: :left, required: true) %>
|
36
|
+
#
|
37
|
+
# @example Con tema e dimensione personalizzati
|
38
|
+
# <%= bui_input_checkbox(name: 'important', label: 'Importante', theme: :green, size: :large) %>
|
39
|
+
#
|
40
|
+
# @example Con border radius personalizzato
|
41
|
+
# <%= bui_input_checkbox(name: 'rounded_option', label: 'Opzione arrotondata', rounded: :full) %>
|
42
|
+
#
|
43
|
+
# @example Con classi aggiuntive
|
44
|
+
# <%= bui_input_checkbox(name: 'custom', label: 'Campo personalizzato', classes: 'mb-4', checked: true) %>
|
45
|
+
#
|
46
|
+
# @example Con attributi HTML aggiuntivi
|
47
|
+
# <%= bui_input_checkbox(name: 'data-field', label: 'Campo obbligatorio', 'data-validation': 'required', 'aria-describedby': 'help-text') %>
|
48
|
+
#
|
49
|
+
# @example Con Rails form builder
|
50
|
+
# <%= form_with model: @user do |form| %>
|
51
|
+
# <%= bui_input_checkbox(name: :terms_accepted, label: 'Accetto i termini', form: form, theme: :green, required: true) %>
|
52
|
+
# <% end %>
|
53
|
+
#
|
54
|
+
# @example Stato indeterminate
|
55
|
+
# <%= bui_input_checkbox(name: 'partial_selection', label: 'Selezione parziale', indeterminate: true, theme: :blue) %>
|
56
|
+
def bui_input_checkbox(name:, value: '1', checked: false, required: false, disabled: false,
|
57
|
+
indeterminate: false, label: nil, label_position: :right, theme: :default,
|
58
|
+
size: :medium, rounded: :medium, classes: '', form: nil, **options)
|
59
|
+
render BetterUi::General::Input::Checkbox::Component.new(
|
60
|
+
name: name,
|
61
|
+
value: value,
|
62
|
+
checked: checked,
|
63
|
+
required: required,
|
64
|
+
disabled: disabled,
|
65
|
+
indeterminate: indeterminate,
|
66
|
+
label: label,
|
67
|
+
label_position: label_position,
|
68
|
+
theme: theme,
|
69
|
+
size: size,
|
70
|
+
rounded: rounded,
|
71
|
+
classes: classes,
|
72
|
+
form: form,
|
73
|
+
**options
|
74
|
+
)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BetterUi
|
4
|
+
module General
|
5
|
+
module Components
|
6
|
+
module Input
|
7
|
+
module Datetime
|
8
|
+
module DatetimeHelper
|
9
|
+
# Crea un campo input datetime unificato
|
10
|
+
#
|
11
|
+
# @param name [String] Nome del campo input (obbligatorio)
|
12
|
+
# @param type [Symbol] Tipo del campo datetime (default: :date)
|
13
|
+
# Valori disponibili: :date, :month, :week, :time
|
14
|
+
# @param value [String] Valore del campo nel formato appropriato per il tipo
|
15
|
+
# @param required [Boolean] Se il campo è obbligatorio (default: false)
|
16
|
+
# @param disabled [Boolean] Se il campo è disabilitato (default: false)
|
17
|
+
# @param min [String] Valore minimo selezionabile nel formato appropriato
|
18
|
+
# @param max [String] Valore massimo selezionabile nel formato appropriato
|
19
|
+
# @param theme [Symbol] Tema del componente (default: :default)
|
20
|
+
# Valori disponibili: :default, :white, :red, :rose, :orange, :green, :blue, :yellow, :violet
|
21
|
+
# @param size [Symbol] Dimensione del componente (default: :medium)
|
22
|
+
# Valori disponibili: :small, :medium, :large
|
23
|
+
# @param rounded [Symbol] Border radius (default: :medium)
|
24
|
+
# Valori disponibili: :none, :small, :medium, :large, :full
|
25
|
+
# @param classes [String] Classi CSS aggiuntive
|
26
|
+
# @param form [ActionView::Helpers::FormBuilder] Form builder Rails opzionale per integrazione con form
|
27
|
+
# @param options [Hash] Attributi HTML aggiuntivi da passare all'elemento input
|
28
|
+
# @return [String] HTML del componente datetime input renderizzato
|
29
|
+
#
|
30
|
+
# @example Uso base per date
|
31
|
+
# <%= bui_input_datetime(name: 'birthdate', type: :date) %>
|
32
|
+
#
|
33
|
+
# @example Input per mese con validazione
|
34
|
+
# <%= bui_input_datetime(name: 'report_month', type: :month, required: true, min: '2024-01', max: '2024-12') %>
|
35
|
+
#
|
36
|
+
# @example Input per settimana con tema
|
37
|
+
# <%= bui_input_datetime(name: 'work_week', type: :week, theme: :blue, size: :large) %>
|
38
|
+
#
|
39
|
+
# @example Input per time con stili personalizzati
|
40
|
+
# <%= bui_input_datetime(name: 'meeting_time', type: :time, theme: :green, rounded: :full) %>
|
41
|
+
#
|
42
|
+
# @example Con Rails form builder
|
43
|
+
# <%= form_with model: @event do |form| %>
|
44
|
+
# <%= bui_input_datetime(name: :start_date, type: :date, form: form, theme: :blue, required: true) %>
|
45
|
+
# <%= bui_input_datetime(name: :start_time, type: :time, form: form, theme: :green) %>
|
46
|
+
# <% end %>
|
47
|
+
def bui_input_datetime(name:, type: :date, value: nil, required: false, disabled: false,
|
48
|
+
min: nil, max: nil, theme: :default, size: :medium, rounded: :medium,
|
49
|
+
classes: '', form: nil, **options)
|
50
|
+
render BetterUi::General::Input::Datetime::Component.new(
|
51
|
+
name: name,
|
52
|
+
type: type,
|
53
|
+
value: value,
|
54
|
+
required: required,
|
55
|
+
disabled: disabled,
|
56
|
+
min: min,
|
57
|
+
max: max,
|
58
|
+
theme: theme,
|
59
|
+
size: size,
|
60
|
+
rounded: rounded,
|
61
|
+
classes: classes,
|
62
|
+
form: form,
|
63
|
+
**options
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Helper convenienza per input date
|
68
|
+
def bui_input_date(name:, **options)
|
69
|
+
bui_input_datetime(name: name, type: :date, **options)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Helper convenienza per input month
|
73
|
+
def bui_input_month(name:, **options)
|
74
|
+
bui_input_datetime(name: name, type: :month, **options)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Helper convenienza per input week
|
78
|
+
def bui_input_week(name:, **options)
|
79
|
+
bui_input_datetime(name: name, type: :week, **options)
|
80
|
+
end
|
81
|
+
|
82
|
+
# Helper convenienza per input time
|
83
|
+
def bui_input_time(name:, **options)
|
84
|
+
bui_input_datetime(name: name, type: :time, **options)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BetterUi
|
4
|
+
module General
|
5
|
+
module Components
|
6
|
+
module Input
|
7
|
+
module Radio
|
8
|
+
# Helper specifico per radio button Better UI
|
9
|
+
module RadioHelper
|
10
|
+
# Genera un radio button con stili Better UI
|
11
|
+
#
|
12
|
+
# @param name [String] Nome del campo radio (obbligatorio)
|
13
|
+
# @param value [String] Valore del radio button (obbligatorio)
|
14
|
+
# @param checked [Boolean] Se il radio è selezionato
|
15
|
+
# @param required [Boolean] Se il campo è obbligatorio
|
16
|
+
# @param disabled [Boolean] Se il campo è disabilitato
|
17
|
+
# @param label [String, nil] Testo della label associata al radio
|
18
|
+
# @param label_position [Symbol] Posizione della label (:left, :right)
|
19
|
+
# @param theme [Symbol] Tema del componente (:default, :white, :red, :rose, :orange, :green, :blue, :yellow, :violet)
|
20
|
+
# @param size [Symbol] Dimensione del componente (:small, :medium, :large)
|
21
|
+
# @param rounded [Symbol] Border radius (:none, :small, :medium, :large, :full)
|
22
|
+
# @param classes [String] Classi CSS aggiuntive
|
23
|
+
# @param form [ActionView::Helpers::FormBuilder, nil] Form builder Rails opzionale
|
24
|
+
# @param options [Hash] Opzioni aggiuntive per l'input
|
25
|
+
# @return [String] HTML del radio button renderizzato
|
26
|
+
#
|
27
|
+
# @example Gruppo radio base - Selezione genere (STESSO name, value DIVERSI)
|
28
|
+
# bui_input_radio(name: "gender", value: "male", label: "Maschio")
|
29
|
+
# bui_input_radio(name: "gender", value: "female", label: "Femmina")
|
30
|
+
# bui_input_radio(name: "gender", value: "other", label: "Altro")
|
31
|
+
#
|
32
|
+
# @example Gruppo radio con temi diversi - Priorità task
|
33
|
+
# bui_input_radio(name: "priority", value: "low", label: "Bassa", theme: :green)
|
34
|
+
# bui_input_radio(name: "priority", value: "medium", label: "Media", theme: :yellow)
|
35
|
+
# bui_input_radio(name: "priority", value: "high", label: "Alta", theme: :red, size: :large)
|
36
|
+
#
|
37
|
+
# @example Gruppo radio con Rails form builder
|
38
|
+
# <%= form_with model: @user do |form| %>
|
39
|
+
# <%= bui_input_radio(name: :role, value: "admin", label: "Amministratore", form: form) %>
|
40
|
+
# <%= bui_input_radio(name: :role, value: "user", label: "Utente", form: form) %>
|
41
|
+
# <%= bui_input_radio(name: :role, value: "guest", label: "Ospite", form: form) %>
|
42
|
+
# <% end %>
|
43
|
+
#
|
44
|
+
# @example Gruppo radio con selezione dinamica e validazione
|
45
|
+
# current_method = @user&.payment_method
|
46
|
+
# bui_input_radio(name: "payment", value: "card", label: "Carta", checked: current_method == "card", required: true)
|
47
|
+
# bui_input_radio(name: "payment", value: "bank", label: "Bonifico", checked: current_method == "bank", required: true)
|
48
|
+
# bui_input_radio(name: "payment", value: "cash", label: "Contrassegno", checked: current_method == "cash", required: true)
|
49
|
+
#
|
50
|
+
# @example Gruppo radio con attributi HTML personalizzati
|
51
|
+
# bui_input_radio(name: "notification", value: "email", label: "Email", theme: :blue, data: { action: "change->form#updateNotification" })
|
52
|
+
# bui_input_radio(name: "notification", value: "sms", label: "SMS", theme: :blue, data: { action: "change->form#updateNotification" })
|
53
|
+
# bui_input_radio(name: "notification", value: "push", label: "Push", theme: :blue, data: { action: "change->form#updateNotification" })
|
54
|
+
#
|
55
|
+
def bui_input_radio(name:, value:, checked: false, required: false, disabled: false,
|
56
|
+
label: nil, label_position: :right, theme: :default,
|
57
|
+
size: :medium, rounded: :full, classes: '', form: nil, **options)
|
58
|
+
render BetterUi::General::Input::Radio::Component.new(
|
59
|
+
name: name,
|
60
|
+
value: value,
|
61
|
+
checked: checked,
|
62
|
+
required: required,
|
63
|
+
disabled: disabled,
|
64
|
+
label: label,
|
65
|
+
label_position: label_position,
|
66
|
+
theme: theme,
|
67
|
+
size: size,
|
68
|
+
rounded: rounded,
|
69
|
+
classes: classes,
|
70
|
+
form: form,
|
71
|
+
**options
|
72
|
+
)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|