better_ui 0.1.0 → 0.1.1
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/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/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/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 +42 -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/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/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/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 +131 -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,138 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BetterUi
|
4
|
+
module General
|
5
|
+
module Components
|
6
|
+
module Input
|
7
|
+
module Text
|
8
|
+
module TextHelper
|
9
|
+
# Renderizza un componente Text Input con tutti i parametri disponibili.
|
10
|
+
#
|
11
|
+
# @param name [String] Nome del campo input (obbligatorio)
|
12
|
+
# @param value [String, nil] Valore del campo
|
13
|
+
# @param placeholder [String, nil] Placeholder del campo
|
14
|
+
# @param required [Boolean] Se il campo è obbligatorio
|
15
|
+
# @param disabled [Boolean] Se il campo è disabilitato
|
16
|
+
# @param type [Symbol] Tipo del campo input (:text, :password, :email, :tel, :url, :number, :search, :color)
|
17
|
+
# @param theme [Symbol] Tema del componente (:default, :white, :red, :rose, :orange, :green, :blue, :yellow, :violet)
|
18
|
+
# @param size [Symbol] Dimensione del componente (:small, :medium, :large)
|
19
|
+
# @param rounded [Symbol] Border radius (:none, :small, :medium, :large, :full)
|
20
|
+
# @param classes [String] Classi CSS aggiuntive
|
21
|
+
# @param form [ActionView::Helpers::FormBuilder, nil] Form builder Rails opzionale
|
22
|
+
# @param options [Hash] Opzioni aggiuntive per l'input (es. data attributes, aria attributes)
|
23
|
+
#
|
24
|
+
# @return [String] HTML del componente Text Input renderizzato
|
25
|
+
#
|
26
|
+
# @example Uso base
|
27
|
+
# <%= bui_input_text(name: 'email') %>
|
28
|
+
#
|
29
|
+
# @example Con placeholder e validazione
|
30
|
+
# <%= bui_input_text(name: 'email', placeholder: 'Inserisci la tua email', required: true) %>
|
31
|
+
#
|
32
|
+
# @example Con tema e dimensione personalizzati
|
33
|
+
# <%= bui_input_text(name: 'search', theme: :blue, size: :large, placeholder: 'Cerca...') %>
|
34
|
+
#
|
35
|
+
# @example Con border radius personalizzato
|
36
|
+
# <%= bui_input_text(name: 'username', rounded: :full, placeholder: 'Username') %>
|
37
|
+
#
|
38
|
+
# @example Con classi aggiuntive
|
39
|
+
# <%= bui_input_text(name: 'custom', classes: 'mb-4', placeholder: 'Campo personalizzato') %>
|
40
|
+
#
|
41
|
+
# @example Con attributi HTML aggiuntivi
|
42
|
+
# <%= bui_input_text(name: 'data-field', 'data-validation': 'email', 'aria-label': 'Campo email') %>
|
43
|
+
#
|
44
|
+
# @example Con Rails form builder
|
45
|
+
# <%= form_with model: @user do |form| %>
|
46
|
+
# <%= bui_input_text(name: :email, form: form, theme: :blue, placeholder: 'Email utente') %>
|
47
|
+
# <% end %>
|
48
|
+
def bui_input_text(name:, value: nil, placeholder: nil, required: false, disabled: false,
|
49
|
+
type: :text, theme: :default, size: :medium, rounded: :medium, classes: '', form: nil, **options)
|
50
|
+
render BetterUi::General::Input::Text::Component.new(
|
51
|
+
name: name,
|
52
|
+
value: value,
|
53
|
+
placeholder: placeholder,
|
54
|
+
required: required,
|
55
|
+
disabled: disabled,
|
56
|
+
type: type,
|
57
|
+
theme: theme,
|
58
|
+
size: size,
|
59
|
+
rounded: rounded,
|
60
|
+
classes: classes,
|
61
|
+
form: form,
|
62
|
+
**options
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Helper specifici per ogni tipo di input
|
67
|
+
|
68
|
+
# Input di tipo password
|
69
|
+
def bui_input_password(name:, value: nil, placeholder: nil, required: false, disabled: false,
|
70
|
+
theme: :default, size: :medium, rounded: :medium, classes: '', form: nil, **options)
|
71
|
+
bui_input_text(
|
72
|
+
name: name, value: value, placeholder: placeholder, required: required, disabled: disabled,
|
73
|
+
type: :password, theme: theme, size: size, rounded: rounded, classes: classes, form: form, **options
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Input di tipo email
|
78
|
+
def bui_input_email(name:, value: nil, placeholder: nil, required: false, disabled: false,
|
79
|
+
theme: :default, size: :medium, rounded: :medium, classes: '', form: nil, **options)
|
80
|
+
bui_input_text(
|
81
|
+
name: name, value: value, placeholder: placeholder, required: required, disabled: disabled,
|
82
|
+
type: :email, theme: theme, size: size, rounded: rounded, classes: classes, form: form, **options
|
83
|
+
)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Input di tipo tel
|
87
|
+
def bui_input_tel(name:, value: nil, placeholder: nil, required: false, disabled: false,
|
88
|
+
theme: :default, size: :medium, rounded: :medium, classes: '', form: nil, **options)
|
89
|
+
bui_input_text(
|
90
|
+
name: name, value: value, placeholder: placeholder, required: required, disabled: disabled,
|
91
|
+
type: :tel, theme: theme, size: size, rounded: rounded, classes: classes, form: form, **options
|
92
|
+
)
|
93
|
+
end
|
94
|
+
|
95
|
+
# Input di tipo url
|
96
|
+
def bui_input_url(name:, value: nil, placeholder: nil, required: false, disabled: false,
|
97
|
+
theme: :default, size: :medium, rounded: :medium, classes: '', form: nil, **options)
|
98
|
+
bui_input_text(
|
99
|
+
name: name, value: value, placeholder: placeholder, required: required, disabled: disabled,
|
100
|
+
type: :url, theme: theme, size: size, rounded: rounded, classes: classes, form: form, **options
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Input di tipo number
|
105
|
+
def bui_input_number(name:, value: nil, placeholder: nil, required: false, disabled: false,
|
106
|
+
theme: :default, size: :medium, rounded: :medium, classes: '', form: nil, **options)
|
107
|
+
bui_input_text(
|
108
|
+
name: name, value: value, placeholder: placeholder, required: required, disabled: disabled,
|
109
|
+
type: :number, theme: theme, size: size, rounded: rounded, classes: classes, form: form, **options
|
110
|
+
)
|
111
|
+
end
|
112
|
+
|
113
|
+
# Input di tipo search
|
114
|
+
def bui_input_search(name:, value: nil, placeholder: nil, required: false, disabled: false,
|
115
|
+
theme: :default, size: :medium, rounded: :medium, classes: '', form: nil, **options)
|
116
|
+
bui_input_text(
|
117
|
+
name: name, value: value, placeholder: placeholder, required: required, disabled: disabled,
|
118
|
+
type: :search, theme: theme, size: size, rounded: rounded, classes: classes, form: form, **options
|
119
|
+
)
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
# Input di tipo color
|
126
|
+
def bui_input_color(name:, value: nil, placeholder: nil, required: false, disabled: false,
|
127
|
+
theme: :default, size: :medium, rounded: :medium, classes: '', form: nil, **options)
|
128
|
+
bui_input_text(
|
129
|
+
name: name, value: value, placeholder: placeholder, required: required, disabled: disabled,
|
130
|
+
type: :color, theme: theme, size: size, rounded: rounded, classes: classes, form: form, **options
|
131
|
+
)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BetterUi
|
4
|
+
module General
|
5
|
+
module Components
|
6
|
+
module Input
|
7
|
+
module Textarea
|
8
|
+
module TextareaHelper
|
9
|
+
# Renderizza un componente Textarea con tutti i parametri disponibili.
|
10
|
+
#
|
11
|
+
# @param name [String] Nome del campo textarea (obbligatorio)
|
12
|
+
# @param value [String, nil] Valore del campo
|
13
|
+
# @param placeholder [String, nil] Placeholder del campo
|
14
|
+
# @param required [Boolean] Se il campo è obbligatorio
|
15
|
+
# @param disabled [Boolean] Se il campo è disabilitato
|
16
|
+
# @param rows [Integer] Numero di righe per la textarea
|
17
|
+
# @param theme [Symbol] Tema del componente (:default, :white, :red, :rose, :orange, :green, :blue, :yellow, :violet)
|
18
|
+
# @param size [Symbol] Dimensione del componente (:small, :medium, :large)
|
19
|
+
# @param rounded [Symbol] Border radius (:none, :small, :medium, :large, :full)
|
20
|
+
# @param classes [String] Classi CSS aggiuntive
|
21
|
+
# @param form [ActionView::Helpers::FormBuilder, nil] Form builder Rails opzionale
|
22
|
+
# @param options [Hash] Opzioni aggiuntive per la textarea (es. data attributes, aria attributes)
|
23
|
+
#
|
24
|
+
# @return [String] HTML del componente Textarea renderizzato
|
25
|
+
#
|
26
|
+
# @example Uso base
|
27
|
+
# <%= bui_input_textarea(name: 'description') %>
|
28
|
+
#
|
29
|
+
# @example Con placeholder e validazione
|
30
|
+
# <%= bui_input_textarea(name: 'message', placeholder: 'Inserisci il tuo messaggio', required: true) %>
|
31
|
+
#
|
32
|
+
# @example Con numero di righe personalizzato
|
33
|
+
# <%= bui_input_textarea(name: 'content', rows: 5, placeholder: 'Contenuto lungo...') %>
|
34
|
+
#
|
35
|
+
# @example Con tema e dimensione personalizzati
|
36
|
+
# <%= bui_input_textarea(name: 'feedback', theme: :blue, size: :large, rows: 4) %>
|
37
|
+
#
|
38
|
+
# @example Con border radius personalizzato
|
39
|
+
# <%= bui_input_textarea(name: 'notes', rounded: :large, rows: 3, placeholder: 'Note aggiuntive') %>
|
40
|
+
#
|
41
|
+
# @example Con classi aggiuntive
|
42
|
+
# <%= bui_input_textarea(name: 'custom', classes: 'mb-4', rows: 6, placeholder: 'Campo personalizzato') %>
|
43
|
+
#
|
44
|
+
# @example Con attributi HTML aggiuntivi
|
45
|
+
# <%= bui_input_textarea(name: 'data-field', rows: 4, 'data-validation': 'required', 'aria-label': 'Campo textarea') %>
|
46
|
+
#
|
47
|
+
# @example Con Rails form builder
|
48
|
+
# <%= form_with model: @post do |form| %>
|
49
|
+
# <%= bui_input_textarea(name: :content, form: form, theme: :blue, rows: 8, placeholder: 'Contenuto del post') %>
|
50
|
+
# <% end %>
|
51
|
+
def bui_input_textarea(name:, value: nil, placeholder: nil, required: false, disabled: false,
|
52
|
+
rows: 3, theme: :default, size: :medium, rounded: :medium, classes: '', form: nil, **options)
|
53
|
+
render BetterUi::General::Input::Textarea::Component.new(
|
54
|
+
name: name,
|
55
|
+
value: value,
|
56
|
+
placeholder: placeholder,
|
57
|
+
required: required,
|
58
|
+
disabled: disabled,
|
59
|
+
rows: rows,
|
60
|
+
theme: theme,
|
61
|
+
size: size,
|
62
|
+
rounded: rounded,
|
63
|
+
classes: classes,
|
64
|
+
form: form,
|
65
|
+
**options
|
66
|
+
)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module General
|
3
|
+
module Components
|
4
|
+
module Link
|
5
|
+
module LinkHelper
|
6
|
+
# Genera un link usando BetterUi::General::Link::Component
|
7
|
+
#
|
8
|
+
# @param label [String] testo del link
|
9
|
+
# @param href [String] URL di destinazione (nil per semplice testo)
|
10
|
+
# @param theme [Symbol] tema del colore (:default, :white, etc.)
|
11
|
+
# @param orientation [Symbol] orientamento (:horizontal, :vertical)
|
12
|
+
# @param style [Symbol] stile (:default, :underline, :bold, :text)
|
13
|
+
# @param size [Symbol] dimensione (:extra_small, :small, :medium, :large)
|
14
|
+
# @param icon [String] icona opzionale
|
15
|
+
# @param active [Boolean] stato attivo del link
|
16
|
+
# @param disabled [Boolean] stato disabilitato del link
|
17
|
+
# @param data [Hash] attributi data
|
18
|
+
# @param method [Symbol] metodo HTTP (per Turbo)
|
19
|
+
# @param target [String] target del link
|
20
|
+
# @param html_options [Hash] opzioni HTML aggiuntive
|
21
|
+
# @return [String] HTML del link renderizzato
|
22
|
+
#
|
23
|
+
# @example Uso base
|
24
|
+
# bui_link("Home", href: "/")
|
25
|
+
# bui_link("Contatti", href: "/contact", theme: :blue)
|
26
|
+
#
|
27
|
+
# @example Con icona
|
28
|
+
# bui_link("Dashboard", href: "/admin", icon: "home", theme: :green)
|
29
|
+
#
|
30
|
+
# @example Link attivo
|
31
|
+
# bui_link("Pagina corrente", href: "/current", active: true)
|
32
|
+
#
|
33
|
+
# @example Link disabilitato (diventa span)
|
34
|
+
# bui_link("Non disponibile", disabled: true)
|
35
|
+
#
|
36
|
+
# @example Con attributi Turbo
|
37
|
+
# bui_link("Elimina", href: "/delete", method: :delete,
|
38
|
+
# data: { confirm: "Sei sicuro?" }, theme: :red)
|
39
|
+
#
|
40
|
+
# @example Con opzioni avanzate
|
41
|
+
# bui_link(
|
42
|
+
# "Link esterno",
|
43
|
+
# href: "https://example.com",
|
44
|
+
# theme: :violet,
|
45
|
+
# orientation: :vertical,
|
46
|
+
# style: :bold,
|
47
|
+
# size: :large,
|
48
|
+
# icon: "external-link",
|
49
|
+
# target: "_blank",
|
50
|
+
# id: "external-link",
|
51
|
+
# class: "custom-link"
|
52
|
+
# )
|
53
|
+
def bui_link(
|
54
|
+
label,
|
55
|
+
href: nil,
|
56
|
+
theme: :white,
|
57
|
+
orientation: :horizontal,
|
58
|
+
style: :default,
|
59
|
+
size: :medium,
|
60
|
+
icon: nil,
|
61
|
+
active: false,
|
62
|
+
disabled: false,
|
63
|
+
data: {},
|
64
|
+
method: nil,
|
65
|
+
target: nil,
|
66
|
+
**html_options,
|
67
|
+
&block
|
68
|
+
)
|
69
|
+
render BetterUi::General::Link::Component.new(
|
70
|
+
label: label,
|
71
|
+
href: href,
|
72
|
+
theme: theme,
|
73
|
+
orientation: orientation,
|
74
|
+
style: style,
|
75
|
+
size: size,
|
76
|
+
icon: icon,
|
77
|
+
active: active,
|
78
|
+
disabled: disabled,
|
79
|
+
data: data,
|
80
|
+
method: method,
|
81
|
+
target: target,
|
82
|
+
**html_options
|
83
|
+
), &block
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module General
|
3
|
+
module Components
|
4
|
+
module Panel
|
5
|
+
module PanelHelper
|
6
|
+
# Genera un pannello usando BetterUi::General::Panel::Component
|
7
|
+
#
|
8
|
+
# @param title [String] titolo del pannello (opzionale)
|
9
|
+
# @param body [String] contenuto HTML del pannello (opzionale)
|
10
|
+
# @param header [String] header personalizzato (opzionale)
|
11
|
+
# @param footer [String] footer del pannello (opzionale)
|
12
|
+
# @param theme [Symbol] tema del colore (:default, :white, etc.)
|
13
|
+
# @param style [Symbol] stile (:default, :flat, :raised, :bordered)
|
14
|
+
# @param padding [Symbol] padding interno (:none, :small, :medium, :large)
|
15
|
+
# @param radius [Symbol] raggio dei bordi (:none, :small, :medium, :large, :full)
|
16
|
+
# @param html_options [Hash] opzioni HTML aggiuntive
|
17
|
+
# @return [String] HTML del pannello renderizzato
|
18
|
+
#
|
19
|
+
# @example Uso base
|
20
|
+
# bui_panel(title: "Dashboard")
|
21
|
+
# bui_panel(body: "Contenuto del pannello")
|
22
|
+
#
|
23
|
+
# @example Pannello completo
|
24
|
+
# bui_panel(
|
25
|
+
# title: "Impostazioni",
|
26
|
+
# body: "Configura le tue preferenze",
|
27
|
+
# footer: "Ultimo aggiornamento: oggi",
|
28
|
+
# theme: :blue
|
29
|
+
# )
|
30
|
+
#
|
31
|
+
# @example Con header personalizzato
|
32
|
+
# bui_panel(
|
33
|
+
# header: "<h2>Header Custom</h2>",
|
34
|
+
# body: "Il mio contenuto",
|
35
|
+
# theme: :green,
|
36
|
+
# style: :raised
|
37
|
+
# )
|
38
|
+
#
|
39
|
+
# @example Pannello con stili avanzati
|
40
|
+
# bui_panel(
|
41
|
+
# title: "Card Premium",
|
42
|
+
# body: "Contenuto speciale",
|
43
|
+
# theme: :violet,
|
44
|
+
# style: :bordered,
|
45
|
+
# padding: :large,
|
46
|
+
# radius: :large,
|
47
|
+
# id: "premium-panel",
|
48
|
+
# class: "special-panel"
|
49
|
+
# )
|
50
|
+
#
|
51
|
+
# @example Con contenuto block
|
52
|
+
# bui_panel(title: "Lista Utenti", theme: :white) do
|
53
|
+
# "<ul><li>Utente 1</li><li>Utente 2</li></ul>".html_safe
|
54
|
+
# end
|
55
|
+
def bui_panel(
|
56
|
+
title: nil,
|
57
|
+
body: nil,
|
58
|
+
header: nil,
|
59
|
+
footer: nil,
|
60
|
+
theme: :white,
|
61
|
+
style: :default,
|
62
|
+
padding: :medium,
|
63
|
+
radius: :small,
|
64
|
+
**html_options,
|
65
|
+
&block
|
66
|
+
)
|
67
|
+
render BetterUi::General::Panel::Component.new(
|
68
|
+
title: title,
|
69
|
+
body: body,
|
70
|
+
header: header,
|
71
|
+
footer: footer,
|
72
|
+
theme: theme,
|
73
|
+
style: style,
|
74
|
+
padding: padding,
|
75
|
+
radius: radius,
|
76
|
+
**html_options
|
77
|
+
), &block
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module General
|
3
|
+
module Components
|
4
|
+
module Progress
|
5
|
+
module ProgressHelper
|
6
|
+
# Helper per renderizzare una progress bar
|
7
|
+
#
|
8
|
+
# @param value [Integer] percentuale di completamento (0-100)
|
9
|
+
# @param theme [Symbol] tema del colore (:default, :white, :red, :rose, :orange, :green, :blue, :yellow, :violet)
|
10
|
+
# @param size [Symbol] dimensione della progress bar (:small, :medium, :large)
|
11
|
+
# @param label [Boolean] mostra etichetta con percentuale
|
12
|
+
# @param classes [String] classi CSS aggiuntive
|
13
|
+
# @param html_options [Hash] opzioni HTML aggiuntive
|
14
|
+
#
|
15
|
+
# @return [String] HTML della progress bar
|
16
|
+
#
|
17
|
+
# @example Uso base
|
18
|
+
# bui_progress(value: 75)
|
19
|
+
#
|
20
|
+
# @example Progress con etichetta
|
21
|
+
# bui_progress(value: 50, label: true, theme: :green)
|
22
|
+
#
|
23
|
+
# @example Progress personalizzata
|
24
|
+
# bui_progress(
|
25
|
+
# value: 90,
|
26
|
+
# theme: :blue,
|
27
|
+
# size: :large,
|
28
|
+
# label: true,
|
29
|
+
# classes: "my-custom-class",
|
30
|
+
# id: "main-progress"
|
31
|
+
# )
|
32
|
+
def bui_progress(
|
33
|
+
value: 0,
|
34
|
+
theme: :white,
|
35
|
+
size: :medium,
|
36
|
+
label: false,
|
37
|
+
classes: nil,
|
38
|
+
**html_options
|
39
|
+
)
|
40
|
+
render BetterUi::General::Progress::Component.new(
|
41
|
+
value: value,
|
42
|
+
theme: theme,
|
43
|
+
size: size,
|
44
|
+
label: label,
|
45
|
+
classes: classes,
|
46
|
+
**html_options
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module General
|
3
|
+
module Components
|
4
|
+
module Spinner
|
5
|
+
module SpinnerHelper
|
6
|
+
def bui_spinner(label = nil, **options)
|
7
|
+
render BetterUi::General::Spinner::Component.new(
|
8
|
+
label: label,
|
9
|
+
**options
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Supporto per la sintassi originale per compatibilità
|
14
|
+
alias_method :better_ui_general_spinner, :bui_spinner
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module General
|
3
|
+
module Components
|
4
|
+
module Table
|
5
|
+
module TableHelper
|
6
|
+
|
7
|
+
# Renderizza un componente Table per visualizzare dati strutturati in formato tabellare.
|
8
|
+
#
|
9
|
+
# @param headers [Array<String>] Intestazioni delle colonne della tabella
|
10
|
+
# @param rows [Array<Array>] Dati delle righe della tabella
|
11
|
+
# @param striped [Boolean] Applica righe alternate con colori diversi
|
12
|
+
# @param bordered [Boolean] Aggiunge bordi alla tabella
|
13
|
+
# @param hover [Boolean] Aggiunge effetto hover sulle righe
|
14
|
+
# @param responsive [Boolean] Rende la tabella responsiva (scrollabile orizzontalmente)
|
15
|
+
# @param compact [Boolean] Riduce la spaziatura interna
|
16
|
+
# @param theme [Symbol] Tema della tabella (:default, :white, :gray)
|
17
|
+
# @param size [Symbol] Dimensione della tabella (:small, :medium, :large)
|
18
|
+
# @param rounded [Symbol] Arrotondamento degli angoli (:none, :small, :medium, :large)
|
19
|
+
# @param classes [String] Classi CSS aggiuntive
|
20
|
+
# @param options [Hash] Attributi HTML aggiuntivi
|
21
|
+
#
|
22
|
+
# @return [String] HTML della tabella renderizzata
|
23
|
+
#
|
24
|
+
# @example Tabella base con intestazioni e righe
|
25
|
+
# <%= bui_table(headers: ['Nome', 'Email'], rows: [['Mario Rossi', 'mario@example.com']]) %>
|
26
|
+
#
|
27
|
+
# @example Tabella con righe alternate e bordi
|
28
|
+
# <%= bui_table(headers: ['ID', 'Prodotto', 'Prezzo'],
|
29
|
+
# rows: [[1, 'Scarpe', '€80'], [2, 'Camicia', '€40']],
|
30
|
+
# striped: true, bordered: true) %>
|
31
|
+
#
|
32
|
+
# @example Tabella con stile personalizzato
|
33
|
+
# <%= bui_table(headers: ['Data', 'Evento'],
|
34
|
+
# rows: [['10/01/2023', 'Riunione'], ['15/01/2023', 'Scadenza']],
|
35
|
+
# theme: :blue, size: :large, hover: true) %>
|
36
|
+
#
|
37
|
+
# @example Tabella responsiva per dispositivi mobili
|
38
|
+
# <%= bui_table(headers: ['Prodotto', 'Descrizione', 'Prezzo', 'Disponibilità'],
|
39
|
+
# rows: [...],
|
40
|
+
# responsive: true) %>
|
41
|
+
#
|
42
|
+
# @example Tabella con attributi HTML personalizzati
|
43
|
+
# <%= bui_table(headers: ['Nome', 'Email'],
|
44
|
+
# rows: [['Mario Rossi', 'mario@example.com']],
|
45
|
+
# id: 'users-table', 'data-sortable': true) %>
|
46
|
+
def bui_table(**options, &block)
|
47
|
+
render BetterUi::General::Table::Component.new(**options), &block
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module General
|
3
|
+
module Components
|
4
|
+
module Table
|
5
|
+
module TdHelper
|
6
|
+
def bui_td(content = nil, **options, &block)
|
7
|
+
if block_given?
|
8
|
+
render BetterUi::General::Table::TdComponent.new(**options), &block
|
9
|
+
else
|
10
|
+
render BetterUi::General::Table::TdComponent.new(**options) do
|
11
|
+
content
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module General
|
3
|
+
module Components
|
4
|
+
module Table
|
5
|
+
module ThHelper
|
6
|
+
def bui_th(content = nil, **options, &block)
|
7
|
+
if block_given?
|
8
|
+
render BetterUi::General::Table::ThComponent.new(**options), &block
|
9
|
+
else
|
10
|
+
render BetterUi::General::Table::ThComponent.new(**options) do
|
11
|
+
content
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module General
|
3
|
+
module Components
|
4
|
+
module Tag
|
5
|
+
module TagHelper
|
6
|
+
# Render un tag con le opzioni specificate
|
7
|
+
#
|
8
|
+
# @param text [String] testo del tag (obbligatorio)
|
9
|
+
# @param options [Hash] opzioni per il componente
|
10
|
+
#
|
11
|
+
# @option options [Symbol] :theme (:white) tema del colore (:default, :white, :red, etc.)
|
12
|
+
# @option options [Symbol] :size (:medium) dimensione (:small, :medium, :large)
|
13
|
+
# @option options [Symbol] :style (:filled) stile (:filled, :outline)
|
14
|
+
#
|
15
|
+
# @return [String] HTML del componente
|
16
|
+
def bui_tag(text, **options)
|
17
|
+
render BetterUi::General::Tag::Component.new(
|
18
|
+
text: text,
|
19
|
+
**options
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|