better_ui 0.2.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/app/components/better_ui/application/main/component.html.erb +1 -1
  3. data/app/components/better_ui/application/sidebar/component.html.erb +77 -18
  4. data/app/components/better_ui/application/sidebar/component.rb +63 -5
  5. data/app/components/better_ui/general/accordion/component.html.erb +5 -0
  6. data/app/components/better_ui/general/accordion/component.rb +92 -0
  7. data/app/components/better_ui/general/accordion/item_component.html.erb +12 -0
  8. data/app/components/better_ui/general/accordion/item_component.rb +176 -0
  9. data/app/components/better_ui/general/button/component.html.erb +8 -8
  10. data/app/components/better_ui/general/button/component.rb +11 -11
  11. data/app/components/better_ui/general/dropdown/component.html.erb +21 -7
  12. data/app/components/better_ui/general/dropdown/component.rb +27 -54
  13. data/app/components/better_ui/general/dropdown/item_component.rb +2 -1
  14. data/app/components/better_ui/general/field/component.html.erb +3 -3
  15. data/app/components/better_ui/general/field/component.rb +3 -3
  16. data/app/components/better_ui/general/grid/cell_component.html.erb +3 -0
  17. data/app/components/better_ui/general/grid/cell_component.rb +390 -0
  18. data/app/components/better_ui/general/grid/component.html.erb +3 -0
  19. data/app/components/better_ui/general/grid/component.rb +301 -0
  20. data/app/components/better_ui/general/heading/component.html.erb +1 -1
  21. data/app/components/better_ui/general/icon/component.rb +2 -1
  22. data/app/components/better_ui/general/input/checkbox/component.rb +10 -10
  23. data/app/components/better_ui/general/input/pin/component.html.erb +1 -0
  24. data/app/components/better_ui/general/input/pin/component.rb +201 -0
  25. data/app/components/better_ui/general/input/radio/component.rb +10 -10
  26. data/app/components/better_ui/general/input/rating/component.html.erb +4 -0
  27. data/app/components/better_ui/general/input/rating/component.rb +272 -0
  28. data/app/components/better_ui/general/input/select/component.html.erb +76 -14
  29. data/app/components/better_ui/general/input/select/component.rb +166 -101
  30. data/app/components/better_ui/general/input/toggle/component.html.erb +5 -0
  31. data/app/components/better_ui/general/input/toggle/component.rb +242 -0
  32. data/app/components/better_ui/general/link/component.rb +1 -1
  33. data/app/components/better_ui/general/modal/component.html.erb +5 -42
  34. data/app/components/better_ui/general/modal/component.rb +22 -140
  35. data/app/components/better_ui/general/modal/modal_component.html.erb +52 -0
  36. data/app/components/better_ui/general/modal/modal_component.rb +160 -0
  37. data/app/components/better_ui/general/tabs/component.html.erb +10 -2
  38. data/app/components/better_ui/general/tabs/component.rb +26 -8
  39. data/app/components/better_ui/general/tabs/panel_component.rb +1 -1
  40. data/app/components/better_ui/general/tabs/tab_component.rb +1 -1
  41. data/app/components/better_ui/general/text/component.html.erb +1 -0
  42. data/app/components/better_ui/general/text/component.rb +194 -0
  43. data/app/helpers/better_ui/application_helper.rb +11 -4
  44. data/app/helpers/better_ui/general/components/accordion/accordion_helper.rb +73 -0
  45. data/app/helpers/better_ui/general/components/button/button_helper.rb +6 -6
  46. data/app/helpers/better_ui/general/components/dropdown/dropdown_helper.rb +9 -0
  47. data/app/helpers/better_ui/general/components/dropdown/item_helper.rb +13 -7
  48. data/app/helpers/better_ui/general/components/field/field_helper.rb +4 -4
  49. data/app/helpers/better_ui/general/components/grid/grid_helper.rb +145 -0
  50. data/app/helpers/better_ui/general/components/input/pin/pin_helper.rb +76 -0
  51. data/app/helpers/better_ui/general/components/input/rating/rating_helper.rb +70 -0
  52. data/app/helpers/better_ui/general/components/input/select/select_helper.rb +47 -31
  53. data/app/helpers/better_ui/general/components/input/toggle/toggle_helper.rb +77 -0
  54. data/app/helpers/better_ui/general/components/modal/modal_helper.rb +34 -44
  55. data/app/helpers/better_ui/general/components/tabs/tabs_helper.rb +59 -26
  56. data/app/helpers/better_ui/general/components/text/text_helper.rb +83 -0
  57. data/lib/better_ui/version.rb +1 -1
  58. data/lib/better_ui.rb +1 -0
  59. metadata +26 -2
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BetterUi
4
+ module General
5
+ module Components
6
+ module Input
7
+ module Rating
8
+ module RatingHelper
9
+ # Renderizza un componente Rating (Input) interattivo con stelle per valutazioni e feedback.
10
+ #
11
+ # @param name [String] Nome del campo rating (obbligatorio se non readonly)
12
+ # @param value [Float, Integer] Valore del rating attuale (0.0 - max_stars)
13
+ # @param max_stars [Integer] Numero massimo di stelle (default: 5)
14
+ # @param readonly [Boolean] Se il rating è in sola lettura
15
+ # @param half_stars [Boolean] Se supportare mezze stelle
16
+ # @param theme [Symbol] Tema del componente (:default, :yellow, :orange, :red, :pink, :purple, :blue, :green, :gray)
17
+ # @param size [Symbol] Dimensione del componente (:small, :medium, :large)
18
+ # @param show_value [Boolean] Se mostrare il valore numerico accanto alle stelle
19
+ # @param form [ActionView::Helpers::FormBuilder, nil] Form builder Rails opzionale
20
+ # @param classes [String] Classi CSS aggiuntive
21
+ # @param options [Hash] Opzioni aggiuntive per attributi HTML
22
+ #
23
+ # @return [String] HTML del componente Rating renderizzato
24
+ #
25
+ # @example Uso base per inserimento rating
26
+ # <%= bui_input_rating(name: 'review_rating') %>
27
+ #
28
+ # @example Rating read-only per visualizzazione
29
+ # <%= bui_input_rating(value: 4.5, readonly: true, show_value: true) %>
30
+ #
31
+ # @example Con tema e dimensioni personalizzate
32
+ # <%= bui_input_rating(name: 'quality', theme: :orange, size: :large, max_stars: 10) %>
33
+ #
34
+ # @example Con Rails form builder
35
+ # <%= form_with model: @review do |form| %>
36
+ # <%= bui_input_rating(name: :rating, form: form, value: @review.rating, show_value: true) %>
37
+ # <% end %>
38
+ #
39
+ # @example Rating con mezze stelle e valore preimpostato
40
+ # <%= bui_input_rating(
41
+ # name: 'service_rating',
42
+ # value: 3.5,
43
+ # half_stars: true,
44
+ # theme: :green,
45
+ # size: :medium,
46
+ # show_value: true
47
+ # ) %>
48
+ def bui_input_rating(name: nil, value: 0, max_stars: 5, readonly: false, half_stars: true,
49
+ theme: :default, size: :medium, show_value: false, form: nil,
50
+ classes: '', **options)
51
+ render BetterUi::General::Input::Rating::Component.new(
52
+ name: name,
53
+ value: value,
54
+ max_stars: max_stars,
55
+ readonly: readonly,
56
+ half_stars: half_stars,
57
+ theme: theme,
58
+ size: size,
59
+ show_value: show_value,
60
+ form: form,
61
+ classes: classes,
62
+ **options
63
+ )
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -6,45 +6,59 @@ module BetterUi
6
6
  module Input
7
7
  module Select
8
8
  module SelectHelper
9
- # Renders a Select component for selection fields from option lists.
9
+ # Renderizza un componente Select personalizzato con ricerca, animazioni e multi-selezione.
10
10
  #
11
- # @param name [String] Name of the select field
12
- # @param options [Array<Hash>] Array of select options in format [{value: 'value', label: 'label'}, ...]
13
- # @param selected [String, Array, nil] Selected value or values
14
- # @param required [Boolean] Whether the field is required
15
- # @param disabled [Boolean] Whether the field is disabled
16
- # @param multiple [Boolean] Whether multiple options can be selected
17
- # @param theme [Symbol] Component theme (:default, :white, :red, :rose, :orange, :green, :blue, :yellow, :violet)
18
- # @param size [Symbol] Component size (:small, :medium, :large)
11
+ # @param name [String] Nome del campo select (obbligatorio)
12
+ # @param options [Array<Hash>] Array di opzioni nel formato [{value: 'value', label: 'label'}, ...]
13
+ # @param selected [String, Array, nil] Valore/i selezionato/i
14
+ # @param required [Boolean] Se il campo è obbligatorio
15
+ # @param disabled [Boolean] Se il campo è disabilitato
16
+ # @param multiple [Boolean] Se multiple opzioni possono essere selezionate
17
+ # @param searchable [Boolean] Se abilitare la ricerca
18
+ # @param theme [Symbol] Tema del componente (:default, :white, :red, :rose, :orange, :green, :blue, :yellow, :violet)
19
+ # @param size [Symbol] Dimensione del componente (:small, :medium, :large)
19
20
  # @param rounded [Symbol] Border radius (:none, :small, :medium, :large, :full)
20
- # @param placeholder [String, nil] Placeholder text for the field (creates an initial disabled option)
21
- # @param classes [String] Additional CSS classes
22
- # @param form [ActionView::Helpers::FormBuilder, nil] Optional Rails form builder
23
- # @param options_html [Hash] Additional HTML attributes for option tags
24
- # @param html_options [Hash] Additional HTML attributes for the select tag
21
+ # @param placeholder [String] Testo placeholder per il trigger
22
+ # @param search_placeholder [String] Testo placeholder per il campo search
23
+ # @param max_height [String] Altezza massima del dropdown (default: "300px")
24
+ # @param form [ActionView::Helpers::FormBuilder, nil] Form builder Rails opzionale
25
+ # @param classes [String] Classi CSS aggiuntive
26
+ # @param options [Hash] Opzioni aggiuntive per attributi HTML
25
27
  #
26
- # @return [String] Rendered HTML of the Select component
28
+ # @return [String] HTML del componente Select renderizzato
27
29
  #
28
- # @example Basic select
29
- # <%= bui_input_select(name: 'country', options: [{value: 'it', label: 'Italy'}, {value: 'fr', label: 'France'}]) %>
30
+ # @example Uso base
31
+ # <%= bui_input_select(name: 'country', options: [{value: 'it', label: 'Italia'}, {value: 'us', label: 'USA'}]) %>
30
32
  #
31
- # @example Select with selected option
32
- # <%= bui_input_select(name: 'role', options: roles_array, selected: 'admin') %>
33
+ # @example Con selezione multipla
34
+ # <%= bui_input_select(name: 'skills', multiple: true, options: skills_options) %>
33
35
  #
34
- # @example Multiple select
35
- # <%= bui_input_select(name: 'languages[]', options: languages_array, multiple: true, selected: ['en', 'fr']) %>
36
+ # @example Con ricerca e temi
37
+ # <%= bui_input_select(name: 'category', searchable: true, theme: :blue, options: categories) %>
36
38
  #
37
- # @example Select with custom theme and size
38
- # <%= bui_input_select(name: 'category', options: categories_array, theme: :blue, size: :large) %>
39
+ # @example Con dimensioni personalizzate
40
+ # <%= bui_input_select(name: 'priority', size: :large, options: priorities, selected: 'high') %>
39
41
  #
40
- # @example With Rails form builder
42
+ # @example Con Rails form builder
41
43
  # <%= form_with model: @user do |form| %>
42
- # <%= bui_input_select(name: :country_id, options: countries_array, form: form, required: true) %>
44
+ # <%= bui_input_select(name: :role, form: form, options: role_options, theme: :green) %>
43
45
  # <% end %>
46
+ #
47
+ # @example Con opzioni avanzate
48
+ # <%= bui_input_select(
49
+ # name: 'tags',
50
+ # multiple: true,
51
+ # searchable: true,
52
+ # placeholder: 'Seleziona tag...',
53
+ # search_placeholder: 'Cerca tag...',
54
+ # max_height: '200px',
55
+ # options: tag_options,
56
+ # selected: ['ruby', 'rails']
57
+ # ) %>
44
58
  def bui_input_select(name:, options:, selected: nil, required: false, disabled: false,
45
- multiple: false, theme: :default, size: :medium, rounded: :medium,
46
- placeholder: nil, classes: '', form: nil, options_html: {}, **html_options)
47
-
59
+ multiple: false, searchable: true, theme: :default, size: :medium,
60
+ rounded: :medium, placeholder: nil, search_placeholder: nil,
61
+ max_height: "300px", form: nil, classes: '', **html_options)
48
62
  render BetterUi::General::Input::Select::Component.new(
49
63
  name: name,
50
64
  options: options,
@@ -52,13 +66,15 @@ module BetterUi
52
66
  required: required,
53
67
  disabled: disabled,
54
68
  multiple: multiple,
69
+ searchable: searchable,
55
70
  theme: theme,
56
71
  size: size,
57
72
  rounded: rounded,
58
73
  placeholder: placeholder,
59
- classes: classes,
74
+ search_placeholder: search_placeholder,
75
+ max_height: max_height,
60
76
  form: form,
61
- options_html: options_html,
77
+ classes: classes,
62
78
  **html_options
63
79
  )
64
80
  end
@@ -67,4 +83,4 @@ module BetterUi
67
83
  end
68
84
  end
69
85
  end
70
- end
86
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BetterUi
4
+ module General
5
+ module Components
6
+ module Input
7
+ module Toggle
8
+ module ToggleHelper
9
+ # Renderizza un componente Toggle/Switch moderno per sostituire i checkbox tradizionali.
10
+ #
11
+ # @param name [String] Nome del campo toggle (obbligatorio)
12
+ # @param value [String] Valore del toggle quando è attivo (default: "1")
13
+ # @param checked [Boolean] Se il toggle è attivo
14
+ # @param required [Boolean] Se il campo è obbligatorio
15
+ # @param disabled [Boolean] Se il campo è disabilitato
16
+ # @param label [String, nil] Testo della label associata al toggle
17
+ # @param label_position [Symbol] Posizione della label (:left, :right)
18
+ # @param theme [Symbol] Tema del componente (:default, :white, :red, :rose, :orange, :green, :blue, :yellow, :violet)
19
+ # @param size [Symbol] Dimensione del componente (:small, :medium, :large)
20
+ # @param form [ActionView::Helpers::FormBuilder, nil] Form builder Rails opzionale
21
+ # @param classes [String] Classi CSS aggiuntive
22
+ # @param options [Hash] Opzioni aggiuntive per attributi HTML
23
+ #
24
+ # @return [String] HTML del componente Toggle renderizzato
25
+ #
26
+ # @example Uso base
27
+ # <%= bui_input_toggle(name: 'notifications') %>
28
+ #
29
+ # @example Con label e stato iniziale
30
+ # <%= bui_input_toggle(name: 'dark_mode', label: 'Modalità scura', checked: true) %>
31
+ #
32
+ # @example Con tema e dimensioni
33
+ # <%= bui_input_toggle(name: 'premium', label: 'Account Premium', theme: :green, size: :large) %>
34
+ #
35
+ # @example Con posizione label e stato disabilitato
36
+ # <%= bui_input_toggle(name: 'maintenance', label: 'Modalità manutenzione', label_position: :left, disabled: true) %>
37
+ #
38
+ # @example Con Rails form builder
39
+ # <%= form_with model: @user do |form| %>
40
+ # <%= bui_input_toggle(name: :email_notifications, form: form, label: 'Notifiche email', theme: :blue) %>
41
+ # <%= bui_input_toggle(name: :sms_notifications, form: form, label: 'Notifiche SMS', theme: :green) %>
42
+ # <% end %>
43
+ #
44
+ # @example Con attributi HTML personalizzati
45
+ # <%= bui_input_toggle(
46
+ # name: 'api_access',
47
+ # label: 'Accesso API',
48
+ # theme: :violet,
49
+ # size: :small,
50
+ # required: true,
51
+ # data: { action: 'toggle-api-access' },
52
+ # 'aria-describedby': 'api-help-text'
53
+ # ) %>
54
+ def bui_input_toggle(name:, value: '1', checked: false, required: false, disabled: false,
55
+ label: nil, label_position: :right, theme: :default, size: :medium,
56
+ form: nil, classes: '', **options)
57
+ render BetterUi::General::Input::Toggle::Component.new(
58
+ name: name,
59
+ value: value,
60
+ checked: checked,
61
+ required: required,
62
+ disabled: disabled,
63
+ label: label,
64
+ label_position: label_position,
65
+ theme: theme,
66
+ size: size,
67
+ form: form,
68
+ classes: classes,
69
+ **options
70
+ )
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -3,14 +3,11 @@ module BetterUi
3
3
  module Components
4
4
  module Modal
5
5
  module ModalHelper
6
- # Helper per renderizzare un modal
6
+ # Helper per renderizzare un modal con trigger e contenuto
7
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
8
+ # @param close_on_backdrop [Boolean] Se chiudere il modal cliccando sul backdrop
9
+ # @param close_on_escape [Boolean] Se chiudere il modal premendo Escape
10
+ # @param lock_scroll [Boolean] Se bloccare lo scroll del body quando il modal è aperto
14
11
  # @param classes [String] Classi CSS aggiuntive per il contenitore
15
12
  # @param html_options [Hash] Attributi HTML aggiuntivi
16
13
  #
@@ -36,54 +33,47 @@ module BetterUi
36
33
  #
37
34
  # @return [String] HTML del modal
38
35
  #
39
- # @example Utilizzo base
40
- # <%= bui_modal(title: "Conferma azione") do %>
41
- # <p>Sei sicuro di voler continuare?</p>
36
+ # @example Utilizzo base con button trigger
37
+ # <%= bui_modal do |modal| %>
38
+ # <% modal.with_trigger(label: "Apri Modal", as: :button, type: :primary) %>
39
+ # <% modal.with_modal(title: "Conferma azione") do %>
40
+ # <p>Sei sicuro di voler continuare?</p>
41
+ # <% end %>
42
42
  # <% end %>
43
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>
44
+ # @example Con link trigger
45
+ # <%= bui_modal do |modal| %>
46
+ # <% modal.with_trigger(label: "Visualizza dettagli", as: :link, variant: :underline) %>
47
+ # <% modal.with_modal(title: "Dettagli elemento", theme: :blue, size: :large) do %>
48
+ # <p>Informazioni dettagliate sull'elemento selezionato.</p>
49
+ # <% end %>
47
50
  # <% end %>
48
51
  #
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>
52
+ # @example Modal con configurazione avanzata
53
+ # <%= bui_modal(close_on_backdrop: false, lock_scroll: false) do |modal| %>
54
+ # <% modal.with_trigger(label: "Elimina", as: :button, type: :red, size: :small) %>
55
+ # <% modal.with_modal(title: "Elimina elemento", theme: :red, backdrop: true, closable: true) do %>
56
+ # <p>Sei sicuro di voler eliminare questo elemento?</p>
57
+ # <p class="text-sm text-gray-600 mt-2">Questa azione non può essere annullata.</p>
58
+ #
59
+ # <div class="flex justify-end space-x-3 mt-6">
60
+ # <%= bui_button(label: "Annulla", type: :white, size: :medium) %>
61
+ # <%= bui_button(label: "Elimina", type: :red, size: :medium) %>
62
+ # </div>
63
+ # <% end %>
68
64
  # <% end %>
69
65
  def bui_modal(
70
- title:,
71
- theme: :default,
72
- size: :medium,
73
- rounded: :medium,
74
- backdrop: true,
75
- closable: true,
66
+ close_on_backdrop: true,
67
+ close_on_escape: true,
68
+ lock_scroll: true,
76
69
  classes: nil,
77
70
  **html_options,
78
71
  &block
79
72
  )
80
73
  render BetterUi::General::Modal::Component.new(
81
- title: title,
82
- theme: theme,
83
- size: size,
84
- rounded: rounded,
85
- backdrop: backdrop,
86
- closable: closable,
74
+ close_on_backdrop: close_on_backdrop,
75
+ close_on_escape: close_on_escape,
76
+ lock_scroll: lock_scroll,
87
77
  classes: classes,
88
78
  **html_options
89
79
  ), &block
@@ -5,53 +5,86 @@ module BetterUi
5
5
  module Components
6
6
  module Tabs
7
7
  module TabsHelper
8
- # Crea un container di navigazione tabs per organizzare contenuti correlati
8
+ # Crea un sistema completo di tabs con navigazione e panel inclusi
9
9
  #
10
10
  # @param variant [Symbol] lo stile delle tabs (:pills, :underline, :bordered, :minimal)
11
11
  # @param theme [Symbol] il tema di colore delle tabs (:default, :blue, :red, :green, :yellow, :violet, :orange, :rose, :white)
12
12
  # @param size [Symbol] la dimensione delle tabs (:small, :medium, :large)
13
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
14
+ # @param navigation_classes [String] classi CSS aggiuntive per la navigazione
15
+ # @param panels_classes [String] classi CSS aggiuntive per i panel (default: 'mt-4')
16
+ # @param options [Hash] attributi HTML aggiuntivi da applicare all'elemento wrapper
17
+ # @param block [Proc] il contenuto che definisce navigation e panels tramite slots
18
+ # @return [String] l'HTML completo del sistema tabs
18
19
  #
19
- # @example Uso base
20
- # <%= bui_tabs do %>
21
- # <%= bui_tab(text: "Generale", target: "generale", active: true) %>
22
- # <%= bui_tab(text: "Sicurezza", target: "sicurezza") %>
20
+ # @example Uso base con slots
21
+ # <%= bui_tabs do |tabs| %>
22
+ # <% tabs.with_navigation do %>
23
+ # <%= bui_tab(text: "Tab 1", target: "tab1", active: true) %>
24
+ # <%= bui_tab(text: "Tab 2", target: "tab2") %>
25
+ # <% end %>
26
+ # <% tabs.with_panels do %>
27
+ # <%= bui_tab_panel(id: "tab1", active: true) do %>
28
+ # Contenuto del primo pannello
29
+ # <% end %>
30
+ # <%= bui_tab_panel(id: "tab2") do %>
31
+ # Contenuto del secondo pannello
32
+ # <% end %>
33
+ # <% end %>
23
34
  # <% end %>
24
35
  #
25
36
  # @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") %>
37
+ # <%= bui_tabs(variant: :underline, theme: :blue, size: :large) do |tabs| %>
38
+ # <% tabs.with_navigation do %>
39
+ # <%= bui_tab(text: "Dashboard", target: "dashboard", active: true, icon: "chart-bar") %>
40
+ # <%= bui_tab(text: "Impostazioni", target: "settings", icon: "cog-6-tooth") %>
41
+ # <% end %>
42
+ # <% tabs.with_panels do %>
43
+ # <%= bui_tab_panel(id: "dashboard", active: true) do %>
44
+ # Dashboard content...
45
+ # <% end %>
46
+ # <%= bui_tab_panel(id: "settings") do %>
47
+ # Settings content...
48
+ # <% end %>
49
+ # <% end %>
29
50
  # <% end %>
30
51
  #
31
52
  # @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") %>
53
+ # <%= bui_tabs(orientation: :vertical, variant: :pills) do |tabs| %>
54
+ # <% tabs.with_navigation do %>
55
+ # <%= bui_tab(text: "Profilo", target: "profile", active: true) %>
56
+ # <%= bui_tab(text: "Account", target: "account") %>
57
+ # <% end %>
58
+ # <% tabs.with_panels do %>
59
+ # <%= bui_tab_panel(id: "profile", active: true) do %>
60
+ # Informazioni profilo...
61
+ # <% end %>
62
+ # <%= bui_tab_panel(id: "account") do %>
63
+ # Impostazioni account...
64
+ # <% end %>
65
+ # <% end %>
35
66
  # <% end %>
36
67
  #
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") %>
68
+ # @example Con classi personalizzate
69
+ # <%= bui_tabs(navigation_classes: "border-b-2", panels_classes: "p-6 bg-gray-50") do |tabs| %>
70
+ # <% tabs.with_navigation do %>
71
+ # <%= bui_tab(text: "Home", target: "home", active: true) %>
72
+ # <% end %>
73
+ # <% tabs.with_panels do %>
74
+ # <%= bui_tab_panel(id: "home", active: true) do %>
75
+ # Home content with custom styling...
76
+ # <% end %>
77
+ # <% end %>
46
78
  # <% end %>
47
79
  def bui_tabs(variant: :pills, theme: :default, size: :medium, orientation: :horizontal,
48
- classes: '', form: nil, **options, &block)
80
+ navigation_classes: '', panels_classes: 'mt-4', **options, &block)
49
81
  render BetterUi::General::Tabs::Component.new(
50
82
  variant: variant,
51
83
  theme: theme,
52
84
  size: size,
53
85
  orientation: orientation,
54
- classes: classes,
86
+ navigation_classes: navigation_classes,
87
+ panels_classes: panels_classes,
55
88
  **options
56
89
  ), &block
57
90
  end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BetterUi
4
+ module General
5
+ module Components
6
+ module Text
7
+ module TextHelper
8
+ # Genera un testo usando BetterUi::General::Text::Component
9
+ #
10
+ # @param text [String] testo da mostrare (nil se si usa blocco)
11
+ # @param theme [Symbol] tema del colore (:default, :white, :red, :blue, etc.)
12
+ # @param size [Symbol] dimensione (:xs, :small, :medium, :large, :xl, :"2xl")
13
+ # @param align [Symbol] allineamento (:left, :center, :right, :justify)
14
+ # @param weight [Symbol] peso font (:thin, :light, :normal, :medium, :semibold, :bold, :extrabold)
15
+ # @param style [Symbol] stile (:normal, :italic, :underline, :line_through)
16
+ # @param classes [String] classi CSS aggiuntive
17
+ # @param html_options [Hash] opzioni HTML aggiuntive
18
+ # @return [String] HTML del testo renderizzato
19
+ #
20
+ # @example Uso base
21
+ # bui_text("Testo semplice")
22
+ # bui_text("Testo importante", theme: :blue, weight: :bold)
23
+ #
24
+ # @example Con dimensioni e stili
25
+ # bui_text("Titolo grande", size: :xl, weight: :bold)
26
+ # bui_text("Testo sottile", theme: :muted, size: :small)
27
+ #
28
+ # @example Con allineamento
29
+ # bui_text("Testo centrato", align: :center)
30
+ # bui_text("Testo giustificato", align: :justify)
31
+ #
32
+ # @example Con stili tipografici
33
+ # bui_text("Testo corsivo", style: :italic)
34
+ # bui_text("Testo sottolineato", style: :underline)
35
+ #
36
+ # @example Con blocco Ruby
37
+ # bui_text(theme: :green, weight: :semibold) do
38
+ # "Contenuto complesso con <strong>HTML</strong>".html_safe
39
+ # end
40
+ #
41
+ # @example Con attributi HTML personalizzati
42
+ # bui_text("Testo con ID",
43
+ # theme: :blue,
44
+ # id: "my-text",
45
+ # data: { action: "click->handler#process" })
46
+ #
47
+ # @example Per sostituire paragrafi standard
48
+ # # Invece di: <p class="text-gray-600">Descrizione</p>
49
+ # bui_text("Descrizione", theme: :gray)
50
+ #
51
+ # @example Combinazioni complesse
52
+ # bui_text("Messaggio di errore",
53
+ # theme: :red,
54
+ # size: :small,
55
+ # weight: :medium,
56
+ # classes: "mb-2")
57
+ def bui_text(
58
+ text = nil,
59
+ theme: :default,
60
+ size: :medium,
61
+ align: :left,
62
+ weight: :normal,
63
+ style: :normal,
64
+ classes: '',
65
+ **html_options,
66
+ &block
67
+ )
68
+ render BetterUi::General::Text::Component.new(
69
+ text: text,
70
+ theme: theme,
71
+ size: size,
72
+ align: align,
73
+ weight: weight,
74
+ style: style,
75
+ classes: classes,
76
+ **html_options
77
+ ), &block
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -1,3 +1,3 @@
1
1
  module BetterUi
2
- VERSION = "0.2.0"
2
+ VERSION = "0.6.0"
3
3
  end
data/lib/better_ui.rb CHANGED
@@ -3,6 +3,7 @@ require "better_ui/engine"
3
3
  require "better_ui/railtie"
4
4
 
5
5
  require "font-awesome-sass"
6
+ require "view_component"
6
7
 
7
8
  module BetterUi
8
9
  # Your code goes here...