better_ui 0.1.1 → 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/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/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/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/helpers/better_ui/application_helper.rb +9 -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/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/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/lib/better_ui/version.rb +1 -1
- metadata +25 -1
@@ -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,95 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module General
|
3
|
+
module Components
|
4
|
+
module Modal
|
5
|
+
module ModalHelper
|
6
|
+
# Helper per renderizzare un modal
|
7
|
+
#
|
8
|
+
# @param title [String] Il titolo del modal (obbligatorio)
|
9
|
+
# @param theme [Symbol] Il tema dell'header del modal
|
10
|
+
# @param size [Symbol] La dimensione del modal
|
11
|
+
# @param rounded [Symbol] Il border radius del modal
|
12
|
+
# @param backdrop [Boolean] Se mostrare l'overlay di sfondo cliccabile
|
13
|
+
# @param closable [Boolean] Se mostrare il pulsante di chiusura
|
14
|
+
# @param classes [String] Classi CSS aggiuntive per il contenitore
|
15
|
+
# @param html_options [Hash] Attributi HTML aggiuntivi
|
16
|
+
#
|
17
|
+
# @option theme [Symbol] :default (default) Header con sfondo grigio chiaro
|
18
|
+
# @option theme [Symbol] :white Header con sfondo bianco
|
19
|
+
# @option theme [Symbol] :red Header con sfondo rosso chiaro
|
20
|
+
# @option theme [Symbol] :rose Header con sfondo rosa chiaro
|
21
|
+
# @option theme [Symbol] :orange Header con sfondo arancione chiaro
|
22
|
+
# @option theme [Symbol] :green Header con sfondo verde chiaro
|
23
|
+
# @option theme [Symbol] :blue Header con sfondo blu chiaro
|
24
|
+
# @option theme [Symbol] :yellow Header con sfondo giallo chiaro
|
25
|
+
# @option theme [Symbol] :violet Header con sfondo violetto chiaro
|
26
|
+
#
|
27
|
+
# @option size [Symbol] :small (max-w-sm) Modal piccolo
|
28
|
+
# @option size [Symbol] :medium (max-w-md, default) Modal medio
|
29
|
+
# @option size [Symbol] :large (max-w-2xl) Modal grande
|
30
|
+
#
|
31
|
+
# @option rounded [Symbol] :none (rounded-none) Nessun border radius
|
32
|
+
# @option rounded [Symbol] :small (rounded-md) Border radius piccolo
|
33
|
+
# @option rounded [Symbol] :medium (rounded-lg, default) Border radius medio
|
34
|
+
# @option rounded [Symbol] :large (rounded-xl) Border radius grande
|
35
|
+
# @option rounded [Symbol] :full (rounded-full) Border radius completo
|
36
|
+
#
|
37
|
+
# @return [String] HTML del modal
|
38
|
+
#
|
39
|
+
# @example Utilizzo base
|
40
|
+
# <%= bui_modal(title: "Conferma azione") do %>
|
41
|
+
# <p>Sei sicuro di voler continuare?</p>
|
42
|
+
# <% end %>
|
43
|
+
#
|
44
|
+
# @example Con tema, dimensione e border radius
|
45
|
+
# <%= bui_modal(title: "Attenzione", theme: :red, size: :large, rounded: :large) do %>
|
46
|
+
# <p>Questa azione non può essere annullata.</p>
|
47
|
+
# <% end %>
|
48
|
+
#
|
49
|
+
# @example Senza backdrop
|
50
|
+
# <%= bui_modal(title: "Informazioni", backdrop: false) do %>
|
51
|
+
# <p>Contenuto del modal senza overlay di sfondo.</p>
|
52
|
+
# <% end %>
|
53
|
+
#
|
54
|
+
# @example Non chiudibile
|
55
|
+
# <%= bui_modal(title: "Caricamento", closable: false) do %>
|
56
|
+
# <p>Operazione in corso...</p>
|
57
|
+
# <% end %>
|
58
|
+
#
|
59
|
+
# @example Con bottoni di azione
|
60
|
+
# <%= bui_modal(title: "Elimina elemento", theme: :red) do %>
|
61
|
+
# <p>Sei sicuro di voler eliminare questo elemento?</p>
|
62
|
+
# <p class="text-sm text-gray-600 mt-2">Questa azione non può essere annullata.</p>
|
63
|
+
#
|
64
|
+
# <div class="flex justify-end space-x-3 mt-6">
|
65
|
+
# <%= bui_button(label: "Annulla", type: :white, size: :medium) %>
|
66
|
+
# <%= bui_button(label: "Elimina", type: :red, size: :medium) %>
|
67
|
+
# </div>
|
68
|
+
# <% end %>
|
69
|
+
def bui_modal(
|
70
|
+
title:,
|
71
|
+
theme: :default,
|
72
|
+
size: :medium,
|
73
|
+
rounded: :medium,
|
74
|
+
backdrop: true,
|
75
|
+
closable: true,
|
76
|
+
classes: nil,
|
77
|
+
**html_options,
|
78
|
+
&block
|
79
|
+
)
|
80
|
+
render BetterUi::General::Modal::Component.new(
|
81
|
+
title: title,
|
82
|
+
theme: theme,
|
83
|
+
size: size,
|
84
|
+
rounded: rounded,
|
85
|
+
backdrop: backdrop,
|
86
|
+
closable: closable,
|
87
|
+
classes: classes,
|
88
|
+
**html_options
|
89
|
+
), &block
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BetterUi
|
4
|
+
module General
|
5
|
+
module Components
|
6
|
+
module Pagination
|
7
|
+
module PaginationHelper
|
8
|
+
# Genera un componente di navigazione paginata per liste e tabelle
|
9
|
+
#
|
10
|
+
# @param current_page [Integer] La pagina corrente (1-indexed)
|
11
|
+
# @param total_pages [Integer] Il numero totale di pagine
|
12
|
+
# @param path [String] L'URL base per costruire i link di paginazione
|
13
|
+
# @param theme [Symbol] Il tema del componente (:default, :blue, :red, :green, :yellow, :violet, :orange, :rose, :white)
|
14
|
+
# @param size [Symbol] La dimensione del componente (:small, :medium, :large)
|
15
|
+
# @param window [Integer] Il numero di pagine da mostrare intorno alla pagina corrente (default: 2)
|
16
|
+
# @param show_info [Boolean] Se mostrare le informazioni sui risultati (default: false)
|
17
|
+
# @param per_page [Integer] Il numero di elementi per pagina (richiesto se show_info è true)
|
18
|
+
# @param classes [String] Classi CSS aggiuntive
|
19
|
+
# @param form [FormBuilder, nil] Form builder per l'integrazione con Rails form (opzionale)
|
20
|
+
# @param options [Hash] Attributi HTML aggiuntivi
|
21
|
+
# @return [String] Il markup HTML del componente pagination
|
22
|
+
#
|
23
|
+
# @example Uso base standalone
|
24
|
+
# <%= bui_pagination(current_page: 3, total_pages: 10, path: '/products') %>
|
25
|
+
#
|
26
|
+
# @example Con tema e dimensione personalizzati
|
27
|
+
# <%= bui_pagination(
|
28
|
+
# current_page: 5,
|
29
|
+
# total_pages: 20,
|
30
|
+
# path: '/articles',
|
31
|
+
# theme: :blue,
|
32
|
+
# size: :large
|
33
|
+
# ) %>
|
34
|
+
#
|
35
|
+
# @example Con informazioni sui risultati
|
36
|
+
# <%= bui_pagination(
|
37
|
+
# current_page: 2,
|
38
|
+
# total_pages: 8,
|
39
|
+
# path: '/users',
|
40
|
+
# show_info: true,
|
41
|
+
# per_page: 25,
|
42
|
+
# theme: :green
|
43
|
+
# ) %>
|
44
|
+
#
|
45
|
+
# @example Con finestra di pagine personalizzata
|
46
|
+
# <%= bui_pagination(
|
47
|
+
# current_page: 10,
|
48
|
+
# total_pages: 50,
|
49
|
+
# path: '/orders',
|
50
|
+
# window: 3,
|
51
|
+
# size: :small
|
52
|
+
# ) %>
|
53
|
+
#
|
54
|
+
# @example Con attributi HTML aggiuntivi
|
55
|
+
# <%= bui_pagination(
|
56
|
+
# current_page: 1,
|
57
|
+
# total_pages: 5,
|
58
|
+
# path: '/dashboard',
|
59
|
+
# classes: 'my-4',
|
60
|
+
# data: { turbo_frame: 'content' }
|
61
|
+
# ) %>
|
62
|
+
def bui_pagination(current_page:, total_pages:, path:, theme: :default, size: :medium,
|
63
|
+
window: 2, show_info: false, per_page: nil, classes: '',
|
64
|
+
form: nil, **options)
|
65
|
+
render BetterUi::General::Pagination::Component.new(
|
66
|
+
current_page: current_page,
|
67
|
+
total_pages: total_pages,
|
68
|
+
path: path,
|
69
|
+
theme: theme,
|
70
|
+
size: size,
|
71
|
+
window: window,
|
72
|
+
show_info: show_info,
|
73
|
+
per_page: per_page,
|
74
|
+
classes: classes,
|
75
|
+
**options
|
76
|
+
)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BetterUi
|
4
|
+
module General
|
5
|
+
module Components
|
6
|
+
module Tabs
|
7
|
+
module PanelHelper
|
8
|
+
# Crea un pannello di contenuto associato a una tab
|
9
|
+
#
|
10
|
+
# @param id [String] l'identificatore univoco del pannello (deve corrispondere al target della tab)
|
11
|
+
# @param active [Boolean] se questo pannello è attualmente visibile
|
12
|
+
# @param classes [String] classi CSS aggiuntive da applicare al pannello
|
13
|
+
# @param options [Hash] attributi HTML aggiuntivi da applicare all'elemento
|
14
|
+
# @param block [Proc] il contenuto del pannello
|
15
|
+
# @return [String] l'HTML del pannello
|
16
|
+
#
|
17
|
+
# @example Uso base
|
18
|
+
# <%= bui_tab_panel(id: "generale", active: true) do %>
|
19
|
+
# <h3>Impostazioni Generali</h3>
|
20
|
+
# <p>Contenuto del pannello generale...</p>
|
21
|
+
# <% end %>
|
22
|
+
#
|
23
|
+
# @example Pannello nascosto
|
24
|
+
# <%= bui_tab_panel(id: "sicurezza") do %>
|
25
|
+
# <h3>Sicurezza</h3>
|
26
|
+
# <p>Contenuto del pannello sicurezza...</p>
|
27
|
+
# <% end %>
|
28
|
+
#
|
29
|
+
# @example Con classi personalizzate
|
30
|
+
# <%= bui_tab_panel(id: "notifiche", classes: "p-6 bg-gray-50") do %>
|
31
|
+
# <h3>Notifiche</h3>
|
32
|
+
# <p>Contenuto del pannello notifiche...</p>
|
33
|
+
# <% end %>
|
34
|
+
#
|
35
|
+
# @example Con attributi personalizzati
|
36
|
+
# <%= bui_tab_panel(id: "dashboard", data: { testid: "dashboard-panel" }) do %>
|
37
|
+
# <div class="grid grid-cols-2 gap-4">
|
38
|
+
# <div>Statistiche</div>
|
39
|
+
# <div>Grafici</div>
|
40
|
+
# </div>
|
41
|
+
# <% end %>
|
42
|
+
#
|
43
|
+
# @example Con form Rails
|
44
|
+
# <%= bui_tab_panel(id: "profile") do %>
|
45
|
+
# <%= form_with model: @user do |form| %>
|
46
|
+
# <%= form.text_field :name, class: "form-input" %>
|
47
|
+
# <%= form.submit "Salva", class: "btn btn-primary" %>
|
48
|
+
# <% end %>
|
49
|
+
# <% end %>
|
50
|
+
def bui_tab_panel(id:, active: false, classes: '', **options, &block)
|
51
|
+
render BetterUi::General::Tabs::PanelComponent.new(
|
52
|
+
id: id,
|
53
|
+
active: active,
|
54
|
+
classes: classes,
|
55
|
+
**options
|
56
|
+
), &block
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BetterUi
|
4
|
+
module General
|
5
|
+
module Components
|
6
|
+
module Tabs
|
7
|
+
module TabHelper
|
8
|
+
# Crea una singola tab all'interno di un container tabs
|
9
|
+
#
|
10
|
+
# @param text [String] il testo da visualizzare nella tab
|
11
|
+
# @param target [String] l'ID del pannello associato a questa tab
|
12
|
+
# @param active [Boolean] se questa tab è attualmente attiva
|
13
|
+
# @param icon [String] il nome dell'icona opzionale da visualizzare
|
14
|
+
# @param disabled [Boolean] se questa tab è disabilitata
|
15
|
+
# @param badge [String] il testo/numero del badge opzionale
|
16
|
+
# @param theme [Symbol] il tema di colore della tab (:default, :blue, :red, :green, :yellow, :violet, :orange, :rose, :white)
|
17
|
+
# @param size [Symbol] la dimensione della tab (:small, :medium, :large)
|
18
|
+
# @param classes [String] classi CSS aggiuntive da applicare alla tab
|
19
|
+
# @param options [Hash] attributi HTML aggiuntivi da applicare all'elemento
|
20
|
+
# @return [String] l'HTML della tab
|
21
|
+
#
|
22
|
+
# @example Uso base
|
23
|
+
# <%= bui_tab(text: "Generale", target: "generale", active: true) %>
|
24
|
+
#
|
25
|
+
# @example Con icona e badge
|
26
|
+
# <%= bui_tab(text: "Messaggi", target: "messages", icon: "envelope", badge: "3") %>
|
27
|
+
#
|
28
|
+
# @example Tab disabilitata
|
29
|
+
# <%= bui_tab(text: "Premium", target: "premium", disabled: true, icon: "star") %>
|
30
|
+
#
|
31
|
+
# @example Con temi personalizzati
|
32
|
+
# <%= bui_tab(text: "Errori", target: "errors", theme: :red, badge: "12") %>
|
33
|
+
#
|
34
|
+
# @example Con attributi personalizzati
|
35
|
+
# <%= bui_tab(text: "Settings", target: "settings", classes: "font-bold", data: { testid: "settings-tab" }) %>
|
36
|
+
def bui_tab(text:, target:, active: false, icon: nil, disabled: false, badge: nil,
|
37
|
+
theme: :default, size: :medium, classes: '', **options)
|
38
|
+
render BetterUi::General::Tabs::TabComponent.new(
|
39
|
+
text: text,
|
40
|
+
target: target,
|
41
|
+
active: active,
|
42
|
+
icon: icon,
|
43
|
+
disabled: disabled,
|
44
|
+
badge: badge,
|
45
|
+
theme: theme,
|
46
|
+
size: size,
|
47
|
+
classes: classes,
|
48
|
+
**options
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BetterUi
|
4
|
+
module General
|
5
|
+
module Components
|
6
|
+
module Tabs
|
7
|
+
module TabsHelper
|
8
|
+
# Crea un container di navigazione tabs per organizzare contenuti correlati
|
9
|
+
#
|
10
|
+
# @param variant [Symbol] lo stile delle tabs (:pills, :underline, :bordered, :minimal)
|
11
|
+
# @param theme [Symbol] il tema di colore delle tabs (:default, :blue, :red, :green, :yellow, :violet, :orange, :rose, :white)
|
12
|
+
# @param size [Symbol] la dimensione delle tabs (:small, :medium, :large)
|
13
|
+
# @param orientation [Symbol] l'orientamento delle tabs (:horizontal, :vertical)
|
14
|
+
# @param classes [String] classi CSS aggiuntive da applicare al container
|
15
|
+
# @param options [Hash] attributi HTML aggiuntivi da applicare all'elemento
|
16
|
+
# @param block [Proc] il contenuto delle tabs (le singole tab)
|
17
|
+
# @return [String] l'HTML del container tabs
|
18
|
+
#
|
19
|
+
# @example Uso base
|
20
|
+
# <%= bui_tabs do %>
|
21
|
+
# <%= bui_tab(text: "Generale", target: "generale", active: true) %>
|
22
|
+
# <%= bui_tab(text: "Sicurezza", target: "sicurezza") %>
|
23
|
+
# <% end %>
|
24
|
+
#
|
25
|
+
# @example Con temi e dimensioni
|
26
|
+
# <%= bui_tabs(variant: :underline, theme: :blue, size: :large) do %>
|
27
|
+
# <%= bui_tab(text: "Dashboard", target: "dashboard", active: true, icon: "chart-bar") %>
|
28
|
+
# <%= bui_tab(text: "Impostazioni", target: "settings", icon: "cog-6-tooth") %>
|
29
|
+
# <% end %>
|
30
|
+
#
|
31
|
+
# @example Tabs verticali
|
32
|
+
# <%= bui_tabs(orientation: :vertical, variant: :pills) do %>
|
33
|
+
# <%= bui_tab(text: "Profilo", target: "profile") %>
|
34
|
+
# <%= bui_tab(text: "Account", target: "account") %>
|
35
|
+
# <% end %>
|
36
|
+
#
|
37
|
+
# @example Con attributi personalizzati
|
38
|
+
# <%= bui_tabs(classes: "my-4", data: { testid: "main-tabs" }) do %>
|
39
|
+
# <%= bui_tab(text: "Home", target: "home", active: true) %>
|
40
|
+
# <% end %>
|
41
|
+
#
|
42
|
+
# @example Con Rails form builder
|
43
|
+
# <%= bui_tabs(form: form, variant: :bordered) do %>
|
44
|
+
# <%= bui_tab(text: "Dati personali", target: "personal") %>
|
45
|
+
# <%= bui_tab(text: "Contatti", target: "contacts") %>
|
46
|
+
# <% end %>
|
47
|
+
def bui_tabs(variant: :pills, theme: :default, size: :medium, orientation: :horizontal,
|
48
|
+
classes: '', form: nil, **options, &block)
|
49
|
+
render BetterUi::General::Tabs::Component.new(
|
50
|
+
variant: variant,
|
51
|
+
theme: theme,
|
52
|
+
size: size,
|
53
|
+
orientation: orientation,
|
54
|
+
classes: classes,
|
55
|
+
**options
|
56
|
+
), &block
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/better_ui/version.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.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alessiobussolari
|
@@ -129,6 +129,12 @@ files:
|
|
129
129
|
- app/components/better_ui/general/button/component.rb
|
130
130
|
- app/components/better_ui/general/divider/component.html.erb
|
131
131
|
- app/components/better_ui/general/divider/component.rb
|
132
|
+
- app/components/better_ui/general/dropdown/component.html.erb
|
133
|
+
- app/components/better_ui/general/dropdown/component.rb
|
134
|
+
- app/components/better_ui/general/dropdown/divider_component.html.erb
|
135
|
+
- app/components/better_ui/general/dropdown/divider_component.rb
|
136
|
+
- app/components/better_ui/general/dropdown/item_component.html.erb
|
137
|
+
- app/components/better_ui/general/dropdown/item_component.rb
|
132
138
|
- app/components/better_ui/general/field/component.html.erb
|
133
139
|
- app/components/better_ui/general/field/component.rb
|
134
140
|
- app/components/better_ui/general/heading/component.html.erb
|
@@ -151,6 +157,10 @@ files:
|
|
151
157
|
- app/components/better_ui/general/input/textarea/component.rb
|
152
158
|
- app/components/better_ui/general/link/component.html.erb
|
153
159
|
- app/components/better_ui/general/link/component.rb
|
160
|
+
- app/components/better_ui/general/modal/component.html.erb
|
161
|
+
- app/components/better_ui/general/modal/component.rb
|
162
|
+
- app/components/better_ui/general/pagination/component.html.erb
|
163
|
+
- app/components/better_ui/general/pagination/component.rb
|
154
164
|
- app/components/better_ui/general/panel/component.html.erb
|
155
165
|
- app/components/better_ui/general/panel/component.rb
|
156
166
|
- app/components/better_ui/general/progress/component.html.erb
|
@@ -171,6 +181,12 @@ files:
|
|
171
181
|
- app/components/better_ui/general/table/thead_component.rb
|
172
182
|
- app/components/better_ui/general/table/tr_component.html.erb
|
173
183
|
- app/components/better_ui/general/table/tr_component.rb
|
184
|
+
- app/components/better_ui/general/tabs/component.html.erb
|
185
|
+
- app/components/better_ui/general/tabs/component.rb
|
186
|
+
- app/components/better_ui/general/tabs/panel_component.html.erb
|
187
|
+
- app/components/better_ui/general/tabs/panel_component.rb
|
188
|
+
- app/components/better_ui/general/tabs/tab_component.html.erb
|
189
|
+
- app/components/better_ui/general/tabs/tab_component.rb
|
174
190
|
- app/components/better_ui/general/tag/component.html.erb
|
175
191
|
- app/components/better_ui/general/tag/component.rb
|
176
192
|
- app/components/better_ui/general/tooltip/component.html.erb
|
@@ -189,6 +205,9 @@ files:
|
|
189
205
|
- app/helpers/better_ui/general/components/button/button_helper.rb
|
190
206
|
- app/helpers/better_ui/general/components/container/container_helper.rb
|
191
207
|
- app/helpers/better_ui/general/components/divider/divider_helper.rb
|
208
|
+
- app/helpers/better_ui/general/components/dropdown/divider_helper.rb
|
209
|
+
- app/helpers/better_ui/general/components/dropdown/dropdown_helper.rb
|
210
|
+
- app/helpers/better_ui/general/components/dropdown/item_helper.rb
|
192
211
|
- app/helpers/better_ui/general/components/field/field_helper.rb
|
193
212
|
- app/helpers/better_ui/general/components/heading/heading_helper.rb
|
194
213
|
- app/helpers/better_ui/general/components/icon/icon_helper.rb
|
@@ -200,6 +219,8 @@ files:
|
|
200
219
|
- app/helpers/better_ui/general/components/input/text/text_helper.rb
|
201
220
|
- app/helpers/better_ui/general/components/input/textarea/textarea_helper.rb
|
202
221
|
- app/helpers/better_ui/general/components/link/link_helper.rb
|
222
|
+
- app/helpers/better_ui/general/components/modal/modal_helper.rb
|
223
|
+
- app/helpers/better_ui/general/components/pagination/pagination_helper.rb
|
203
224
|
- app/helpers/better_ui/general/components/panel/panel_helper.rb
|
204
225
|
- app/helpers/better_ui/general/components/progress/progress_helper.rb
|
205
226
|
- app/helpers/better_ui/general/components/spinner/spinner_helper.rb
|
@@ -210,6 +231,9 @@ files:
|
|
210
231
|
- app/helpers/better_ui/general/components/table/th_helper.rb
|
211
232
|
- app/helpers/better_ui/general/components/table/thead_helper.rb
|
212
233
|
- app/helpers/better_ui/general/components/table/tr_helper.rb
|
234
|
+
- app/helpers/better_ui/general/components/tabs/panel_helper.rb
|
235
|
+
- app/helpers/better_ui/general/components/tabs/tab_helper.rb
|
236
|
+
- app/helpers/better_ui/general/components/tabs/tabs_helper.rb
|
213
237
|
- app/helpers/better_ui/general/components/tag/tag_helper.rb
|
214
238
|
- app/helpers/better_ui/general/components/tooltip/tooltip_helper.rb
|
215
239
|
- app/jobs/better_ui/application_job.rb
|