better_ui 0.3.0 โ 0.4.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.
Potentially problematic release.
This version of better_ui might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +174 -216
- data/app/assets/javascripts/better_ui/controllers/navbar_controller.js +138 -0
- data/app/assets/javascripts/better_ui/controllers/sidebar_controller.js +211 -0
- data/app/assets/javascripts/better_ui/controllers/toast_controller.js +161 -0
- data/app/assets/javascripts/better_ui/index.js +159 -0
- data/app/assets/javascripts/better_ui/toast_manager.js +77 -0
- data/app/assets/stylesheets/better_ui/application.css +30 -0
- data/app/components/better_ui/application/alert_component.html.erb +27 -0
- data/app/components/better_ui/application/alert_component.rb +196 -0
- data/app/components/better_ui/application/header_component.html.erb +88 -0
- data/app/components/better_ui/application/header_component.rb +188 -0
- data/app/components/better_ui/application/navbar_component.html.erb +294 -0
- data/app/components/better_ui/application/navbar_component.rb +249 -0
- data/app/components/better_ui/application/sidebar_component.html.erb +207 -0
- data/app/components/better_ui/application/sidebar_component.rb +318 -0
- data/app/components/better_ui/application/toast_component.html.erb +35 -0
- data/app/components/better_ui/application/toast_component.rb +188 -0
- data/app/components/better_ui/general/breadcrumb_component.html.erb +39 -0
- data/app/components/better_ui/general/breadcrumb_component.rb +132 -0
- data/app/components/better_ui/general/{button/component.html.erb โ button_component.html.erb} +7 -7
- data/app/components/better_ui/general/button_component.rb +193 -0
- data/app/components/better_ui/general/heading_component.html.erb +25 -0
- data/app/components/better_ui/general/heading_component.rb +142 -0
- data/app/components/better_ui/general/icon_component.html.erb +2 -0
- data/app/components/better_ui/general/icon_component.rb +101 -0
- data/app/components/better_ui/general/panel_component.html.erb +27 -0
- data/app/components/better_ui/general/panel_component.rb +97 -0
- data/app/components/better_ui/general/table_component.html.erb +37 -0
- data/app/components/better_ui/general/table_component.rb +141 -0
- data/app/components/better_ui/theme_helper.rb +169 -0
- data/app/controllers/better_ui/application_controller.rb +1 -0
- data/app/controllers/better_ui/docs_controller.rb +34 -0
- data/app/helpers/better_ui_application_helper.rb +99 -0
- data/app/views/layouts/component_preview.html.erb +32 -0
- data/config/initializers/lookbook.rb +12 -12
- data/config/routes.rb +13 -0
- data/lib/better_ui/engine.rb +42 -5
- data/lib/better_ui/version.rb +1 -1
- data/lib/better_ui.rb +20 -4
- metadata +117 -157
- data/app/components/better_ui/application/card/component.html.erb +0 -20
- data/app/components/better_ui/application/card/component.rb +0 -214
- data/app/components/better_ui/application/main/component.html.erb +0 -9
- data/app/components/better_ui/application/main/component.rb +0 -123
- data/app/components/better_ui/application/navbar/component.html.erb +0 -92
- data/app/components/better_ui/application/navbar/component.rb +0 -136
- data/app/components/better_ui/application/sidebar/component.html.erb +0 -227
- data/app/components/better_ui/application/sidebar/component.rb +0 -130
- data/app/components/better_ui/general/accordion/component.html.erb +0 -5
- data/app/components/better_ui/general/accordion/component.rb +0 -92
- data/app/components/better_ui/general/accordion/item_component.html.erb +0 -12
- data/app/components/better_ui/general/accordion/item_component.rb +0 -176
- data/app/components/better_ui/general/alert/component.html.erb +0 -32
- data/app/components/better_ui/general/alert/component.rb +0 -242
- data/app/components/better_ui/general/avatar/component.html.erb +0 -20
- data/app/components/better_ui/general/avatar/component.rb +0 -301
- data/app/components/better_ui/general/badge/component.html.erb +0 -23
- data/app/components/better_ui/general/badge/component.rb +0 -248
- data/app/components/better_ui/general/breadcrumb/component.html.erb +0 -15
- data/app/components/better_ui/general/breadcrumb/component.rb +0 -187
- data/app/components/better_ui/general/button/component.rb +0 -214
- data/app/components/better_ui/general/divider/component.html.erb +0 -10
- data/app/components/better_ui/general/divider/component.rb +0 -226
- data/app/components/better_ui/general/dropdown/component.html.erb +0 -25
- data/app/components/better_ui/general/dropdown/component.rb +0 -170
- data/app/components/better_ui/general/dropdown/divider_component.html.erb +0 -1
- data/app/components/better_ui/general/dropdown/divider_component.rb +0 -41
- data/app/components/better_ui/general/dropdown/item_component.html.erb +0 -6
- data/app/components/better_ui/general/dropdown/item_component.rb +0 -119
- data/app/components/better_ui/general/field/component.html.erb +0 -27
- data/app/components/better_ui/general/field/component.rb +0 -37
- data/app/components/better_ui/general/heading/component.html.erb +0 -22
- data/app/components/better_ui/general/heading/component.rb +0 -257
- data/app/components/better_ui/general/icon/component.html.erb +0 -7
- data/app/components/better_ui/general/icon/component.rb +0 -239
- data/app/components/better_ui/general/input/checkbox/component.html.erb +0 -5
- data/app/components/better_ui/general/input/checkbox/component.rb +0 -238
- data/app/components/better_ui/general/input/datetime/component.html.erb +0 -5
- data/app/components/better_ui/general/input/datetime/component.rb +0 -223
- data/app/components/better_ui/general/input/radio/component.html.erb +0 -5
- data/app/components/better_ui/general/input/radio/component.rb +0 -230
- data/app/components/better_ui/general/input/select/component.html.erb +0 -16
- data/app/components/better_ui/general/input/select/component.rb +0 -184
- data/app/components/better_ui/general/input/select/select_component.html.erb +0 -5
- data/app/components/better_ui/general/input/select/select_component.rb +0 -37
- data/app/components/better_ui/general/input/text/component.html.erb +0 -5
- data/app/components/better_ui/general/input/text/component.rb +0 -171
- data/app/components/better_ui/general/input/textarea/component.html.erb +0 -5
- data/app/components/better_ui/general/input/textarea/component.rb +0 -166
- data/app/components/better_ui/general/link/component.html.erb +0 -18
- data/app/components/better_ui/general/link/component.rb +0 -258
- data/app/components/better_ui/general/modal/component.html.erb +0 -5
- data/app/components/better_ui/general/modal/component.rb +0 -47
- data/app/components/better_ui/general/modal/modal_component.html.erb +0 -52
- data/app/components/better_ui/general/modal/modal_component.rb +0 -160
- data/app/components/better_ui/general/pagination/component.html.erb +0 -85
- data/app/components/better_ui/general/pagination/component.rb +0 -216
- data/app/components/better_ui/general/panel/component.html.erb +0 -28
- data/app/components/better_ui/general/panel/component.rb +0 -249
- data/app/components/better_ui/general/progress/component.html.erb +0 -11
- data/app/components/better_ui/general/progress/component.rb +0 -160
- data/app/components/better_ui/general/spinner/component.html.erb +0 -35
- data/app/components/better_ui/general/spinner/component.rb +0 -93
- data/app/components/better_ui/general/table/component.html.erb +0 -5
- data/app/components/better_ui/general/table/component.rb +0 -217
- data/app/components/better_ui/general/table/tbody_component.html.erb +0 -3
- data/app/components/better_ui/general/table/tbody_component.rb +0 -30
- data/app/components/better_ui/general/table/td_component.html.erb +0 -3
- data/app/components/better_ui/general/table/td_component.rb +0 -44
- data/app/components/better_ui/general/table/tfoot_component.html.erb +0 -3
- data/app/components/better_ui/general/table/tfoot_component.rb +0 -28
- data/app/components/better_ui/general/table/th_component.html.erb +0 -6
- data/app/components/better_ui/general/table/th_component.rb +0 -51
- data/app/components/better_ui/general/table/thead_component.html.erb +0 -3
- data/app/components/better_ui/general/table/thead_component.rb +0 -28
- data/app/components/better_ui/general/table/tr_component.html.erb +0 -3
- data/app/components/better_ui/general/table/tr_component.rb +0 -30
- data/app/components/better_ui/general/tabs/component.html.erb +0 -11
- data/app/components/better_ui/general/tabs/component.rb +0 -120
- data/app/components/better_ui/general/tabs/panel_component.html.erb +0 -3
- data/app/components/better_ui/general/tabs/panel_component.rb +0 -37
- data/app/components/better_ui/general/tabs/tab_component.html.erb +0 -13
- data/app/components/better_ui/general/tabs/tab_component.rb +0 -111
- data/app/components/better_ui/general/tag/component.html.erb +0 -3
- data/app/components/better_ui/general/tag/component.rb +0 -104
- data/app/components/better_ui/general/tooltip/component.html.erb +0 -7
- data/app/components/better_ui/general/tooltip/component.rb +0 -239
- data/app/helpers/better_ui/application/components/card/card_helper.rb +0 -96
- data/app/helpers/better_ui/application/components/card.rb +0 -11
- data/app/helpers/better_ui/application/components/main/main_helper.rb +0 -64
- data/app/helpers/better_ui/application/components/navbar/navbar_helper.rb +0 -77
- data/app/helpers/better_ui/application/components/sidebar/sidebar_helper.rb +0 -51
- data/app/helpers/better_ui/application_helper.rb +0 -55
- data/app/helpers/better_ui/general/components/accordion/accordion_helper.rb +0 -73
- data/app/helpers/better_ui/general/components/accordion.rb +0 -11
- data/app/helpers/better_ui/general/components/alert/alert_helper.rb +0 -57
- data/app/helpers/better_ui/general/components/avatar/avatar_helper.rb +0 -29
- data/app/helpers/better_ui/general/components/badge/badge_helper.rb +0 -53
- data/app/helpers/better_ui/general/components/breadcrumb/breadcrumb_helper.rb +0 -37
- data/app/helpers/better_ui/general/components/button/button_helper.rb +0 -65
- data/app/helpers/better_ui/general/components/container/container_helper.rb +0 -60
- data/app/helpers/better_ui/general/components/divider/divider_helper.rb +0 -63
- data/app/helpers/better_ui/general/components/dropdown/divider_helper.rb +0 -32
- data/app/helpers/better_ui/general/components/dropdown/dropdown_helper.rb +0 -79
- data/app/helpers/better_ui/general/components/dropdown/item_helper.rb +0 -62
- data/app/helpers/better_ui/general/components/field/field_helper.rb +0 -26
- data/app/helpers/better_ui/general/components/heading/heading_helper.rb +0 -72
- data/app/helpers/better_ui/general/components/icon/icon_helper.rb +0 -16
- data/app/helpers/better_ui/general/components/input/checkbox/checkbox_helper.rb +0 -81
- data/app/helpers/better_ui/general/components/input/datetime/datetime_helper.rb +0 -91
- data/app/helpers/better_ui/general/components/input/radio/radio_helper.rb +0 -79
- data/app/helpers/better_ui/general/components/input/radio_group/radio_group_helper.rb +0 -124
- data/app/helpers/better_ui/general/components/input/select/select_helper.rb +0 -70
- data/app/helpers/better_ui/general/components/input/text/text_helper.rb +0 -138
- data/app/helpers/better_ui/general/components/input/textarea/textarea_helper.rb +0 -73
- data/app/helpers/better_ui/general/components/link/link_helper.rb +0 -89
- data/app/helpers/better_ui/general/components/modal/modal_helper.rb +0 -85
- data/app/helpers/better_ui/general/components/modal.rb +0 -11
- data/app/helpers/better_ui/general/components/pagination/pagination_helper.rb +0 -82
- data/app/helpers/better_ui/general/components/panel/panel_helper.rb +0 -83
- data/app/helpers/better_ui/general/components/progress/progress_helper.rb +0 -53
- data/app/helpers/better_ui/general/components/spinner/spinner_helper.rb +0 -19
- data/app/helpers/better_ui/general/components/table/table_helper.rb +0 -53
- data/app/helpers/better_ui/general/components/table/tbody_helper.rb +0 -13
- data/app/helpers/better_ui/general/components/table/td_helper.rb +0 -19
- data/app/helpers/better_ui/general/components/table/tfoot_helper.rb +0 -13
- data/app/helpers/better_ui/general/components/table/th_helper.rb +0 -19
- data/app/helpers/better_ui/general/components/table/thead_helper.rb +0 -13
- data/app/helpers/better_ui/general/components/table/tr_helper.rb +0 -13
- data/app/helpers/better_ui/general/components/tabs/panel_helper.rb +0 -62
- data/app/helpers/better_ui/general/components/tabs/tab_helper.rb +0 -55
- data/app/helpers/better_ui/general/components/tabs/tabs_helper.rb +0 -95
- data/app/helpers/better_ui/general/components/tag/tag_helper.rb +0 -26
- data/app/helpers/better_ui/general/components/tooltip/tooltip_helper.rb +0 -60
- data/app/views/layouts/better_ui/application.html.erb +0 -17
- data/lib/better_ui/railtie.rb +0 -20
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2242792aeee217a121cb73ec14ccc317d8f9c7af9e3dcdcf52629d05eca55731
|
|
4
|
+
data.tar.gz: 86015104cb387605208eaa8f9ffbdeb3764542fd089e09cf2dd011cecc37640b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: df1b73b3f9c3782a562ef7b585fd9bbac50c45fc8cc9661fe6ff8aa335c53f988c65ce4ab430c7c6dc82d74419b9dd80e026ad50c4533742b7940153fba2e653
|
|
7
|
+
data.tar.gz: 1010406d6a425b0ca48e1acf0af262634a7f5babf54edd34dfd6c7b6943dbdb1a18c250d800f68b9e41ec7bc94d095a8ed9d3e3ca7efb540bbb3ddbe4d310105
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -1,301 +1,259 @@
|
|
|
1
|
-
# BetterUI
|
|
1
|
+
# BetterUI ๐จ
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://badge.fury.io/rb/better_ui)
|
|
4
|
+
[](LICENSE)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
- ๐ **Documentazione Interattiva**: Preview Lookbook integrate per tutti i componenti
|
|
7
|
-
- ๐ง **Altamente Personalizzabile**: Opzioni di configurazione flessibili per ogni componente
|
|
8
|
-
- ๐ **Production Ready**: Componenti testati che seguono le best practices
|
|
9
|
-
- ๐ฑ **Responsive**: Tutti i componenti sono mobile-first e responsive
|
|
10
|
-
- โฟ **Accessibile**: Costruiti pensando all'accessibilitร
|
|
6
|
+
> Componenti UI eleganti, coerenti e facilmente integrabili per le tue applicazioni Rails
|
|
11
7
|
|
|
12
|
-
|
|
8
|
+
BetterUI รจ una gemma Rails che fornisce componenti UI riutilizzabili con documentazione integrata. Progettata per essere leggera, personalizzabile e facile da usare, ti aiuta a costruire interfacce belle e consistenti senza JavaScript.
|
|
13
9
|
|
|
14
|
-
|
|
10
|
+
## โจ Caratteristiche principali
|
|
15
11
|
|
|
16
|
-
|
|
12
|
+
- **Design puro** - Componenti UI eleganti e completamente CSS, senza JavaScript
|
|
13
|
+
- **Facile integrazione** - Engine Rails montabile che si integra perfettamente con la tua app
|
|
14
|
+
- **Documentazione integrata** - Visualizza esempi e documentazione direttamente nel browser
|
|
15
|
+
- **Altamente personalizzabile** - Adatta facilmente lo stile al tuo brand
|
|
16
|
+
- **Componenti modulari** - Usa solo ciรฒ di cui hai bisogno
|
|
17
|
+
- **Preview dei componenti** - Visualizza e interagisci con i componenti usando Lookbook
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
- **26 Componenti**: Libreria completa organizzata per scopo
|
|
20
|
-
- **Sistema Input Unificato**: Componenti input supportano 14+ tipi (text, email, password, number, date, time, etc.)
|
|
21
|
-
- **Documentazione Interattiva**: Integrazione Lookbook con preview live
|
|
22
|
-
- **Sistema Helper**: Helper Rails-friendly con integrazione form builder
|
|
23
|
-
- **Tematizzazione Consistente**: 9 temi standard (default, white, red, rose, orange, green, blue, yellow, violet)
|
|
24
|
-
- **Dimensionamento Flessibile**: 3 dimensioni standard (small, medium, large) con 5 opzioni border radius
|
|
25
|
-
- **Accessibilitร **: Componenti progettati seguendo le best practices di accessibilitร
|
|
19
|
+
## ๐ฆ Componenti disponibili
|
|
26
20
|
|
|
27
|
-
|
|
21
|
+
| Componente | Descrizione |
|
|
22
|
+
|------------|-------------|
|
|
23
|
+
| **Button** | Pulsanti stilizzati con varianti primary, secondary, success, danger |
|
|
24
|
+
| **Alert** | Messaggi informativi, successi, avvisi ed errori |
|
|
25
|
+
| **Card** | Contenitori flessibili con header, body e footer |
|
|
26
|
+
| **Modal** | Finestre di dialogo modali |
|
|
27
|
+
| **Tabs** | Navigazione a schede |
|
|
28
|
+
| **Navbar** | Barra di navigazione responsive con supporto per menu dropdown |
|
|
29
|
+
| **Sidebar** | Menu laterale con supporto per navigazione gerarchica |
|
|
30
|
+
| **Toast** | Notifiche temporanee con timer e animazioni |
|
|
31
|
+
| **Header** | Intestazioni di pagina con titolo, sottotitolo, breadcrumb e azioni |
|
|
32
|
+
| **Form Elements** | Campi di input stilizzati (in arrivo) |
|
|
28
33
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
```ruby
|
|
32
|
-
gem "better_ui"
|
|
33
|
-
```
|
|
34
|
+
## ๐ Installazione
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
Aggiungi questa riga al Gemfile della tua applicazione:
|
|
36
37
|
|
|
37
38
|
```ruby
|
|
38
|
-
gem
|
|
39
|
-
gem "lookbook", group: :development
|
|
39
|
+
gem 'better_ui', '~> 0.1.0'
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
E poi esegui:
|
|
43
43
|
|
|
44
44
|
```bash
|
|
45
45
|
$ bundle install
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
##
|
|
48
|
+
## โ๏ธ Configurazione
|
|
49
49
|
|
|
50
|
-
###
|
|
50
|
+
### Monta l'engine
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
Aggiungi questo al tuo file `config/routes.rb`:
|
|
53
53
|
|
|
54
54
|
```ruby
|
|
55
55
|
Rails.application.routes.draw do
|
|
56
|
-
mount BetterUi::Engine =>
|
|
57
|
-
|
|
56
|
+
mount BetterUi::Engine => '/better_ui'
|
|
57
|
+
|
|
58
|
+
# ... altre tue route
|
|
58
59
|
end
|
|
59
60
|
```
|
|
60
61
|
|
|
61
|
-
###
|
|
62
|
-
|
|
63
|
-
Per accedere alla documentazione interattiva dei componenti durante lo sviluppo, monta Lookbook in `config/routes.rb`:
|
|
62
|
+
### Includi gli assets
|
|
64
63
|
|
|
65
|
-
|
|
66
|
-
Rails.application.routes.draw do
|
|
67
|
-
# Monta Lookbook solo in development
|
|
68
|
-
mount Lookbook::Engine => "/lookbook" if Rails.env.development?
|
|
64
|
+
In `app/assets/stylesheets/application.css`:
|
|
69
65
|
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
```css
|
|
67
|
+
/*
|
|
68
|
+
*= require better_ui/application
|
|
69
|
+
*/
|
|
72
70
|
```
|
|
73
71
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
### 3. Includi Tailwind CSS
|
|
77
|
-
|
|
78
|
-
Assicurati che la tua applicazione includa Tailwind CSS, dato che i componenti BetterUI si basano sulle classi Tailwind. Se non hai Tailwind CSS installato, segui la [guida ufficiale di installazione Tailwind CSS](https://tailwindcss.com/docs/guides/ruby-on-rails).
|
|
79
|
-
|
|
80
|
-
## Utilizzo
|
|
72
|
+
## ๐ฎ Utilizzo
|
|
81
73
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
### Metodi Helper (Raccomandato)
|
|
74
|
+
Una volta installato, puoi iniziare ad usare i componenti:
|
|
85
75
|
|
|
86
76
|
```erb
|
|
87
|
-
<%#
|
|
88
|
-
<%=
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
) %>
|
|
77
|
+
<%# Button %>
|
|
78
|
+
<%= better_ui_button("Salva", type: "primary") %>
|
|
79
|
+
|
|
80
|
+
<%# Alert %>
|
|
81
|
+
<%= better_ui_alert("Operazione completata", type: "success") %>
|
|
82
|
+
|
|
83
|
+
<%# Card %>
|
|
84
|
+
<%= better_ui_card do %>
|
|
85
|
+
<%= better_ui_card_header("Titolo Card") %>
|
|
86
|
+
<%= better_ui_card_body do %>
|
|
87
|
+
<p>Contenuto della card...</p>
|
|
88
|
+
<% end %>
|
|
89
|
+
<% end %>
|
|
96
90
|
|
|
97
|
-
<%#
|
|
98
|
-
<%=
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
91
|
+
<%# Header con breadcrumb %>
|
|
92
|
+
<%= render BetterUi::Application::HeaderComponent.new(
|
|
93
|
+
title: "Dashboard",
|
|
94
|
+
subtitle: "Gestisci tutto da qui",
|
|
95
|
+
breadcrumbs: [
|
|
96
|
+
{ text: "Home", url: "/" },
|
|
97
|
+
{ text: "Dashboard" }
|
|
98
|
+
],
|
|
99
|
+
actions: [
|
|
100
|
+
{ content: button_html("Nuovo", "primary") }
|
|
101
|
+
]
|
|
103
102
|
) %>
|
|
103
|
+
```
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
<%= bui_card(title: 'Profilo Utente', theme: :white) do %>
|
|
107
|
-
<p>Contenuto informazioni utente qui</p>
|
|
108
|
-
<% end %>
|
|
105
|
+
Visita `/better_ui` nella tua applicazione per vedere la documentazione completa e gli esempi.
|
|
109
106
|
|
|
110
|
-
|
|
111
|
-
<%= form_with model: @user do |form| %>
|
|
112
|
-
<%= bui_input_text(name: 'name', form: form, required: true) %>
|
|
113
|
-
<%= bui_input_text(name: 'email', type: :email, form: form) %>
|
|
114
|
-
<%= bui_button('Salva', type: :submit, theme: :blue) %>
|
|
115
|
-
<% end %>
|
|
116
|
-
```
|
|
107
|
+
### Il componente Header
|
|
117
108
|
|
|
118
|
-
|
|
109
|
+
Il componente Header รจ progettato per creare intestazioni di pagina complete con numerose funzionalitร :
|
|
119
110
|
|
|
120
111
|
```erb
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
112
|
+
<%= render BetterUi::Application::HeaderComponent.new(
|
|
113
|
+
title: {
|
|
114
|
+
text: "Impostazioni",
|
|
115
|
+
icon: "settings"
|
|
116
|
+
},
|
|
117
|
+
subtitle: "Configura le preferenze del sistema",
|
|
118
|
+
breadcrumbs: [
|
|
119
|
+
{ text: "Home", url: "/" },
|
|
120
|
+
{ text: "Admin", url: "/admin" },
|
|
121
|
+
{ text: "Impostazioni" }
|
|
122
|
+
],
|
|
123
|
+
variant: :modern,
|
|
124
|
+
fixed: :top,
|
|
125
|
+
show_breadcrumbs: true,
|
|
126
|
+
actions: [
|
|
127
|
+
{ content: button_html("Salva", "primary") },
|
|
128
|
+
{ content: button_html("Annulla", "secondary") }
|
|
129
|
+
]
|
|
134
130
|
) %>
|
|
135
131
|
```
|
|
136
132
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
-
|
|
142
|
-
-
|
|
143
|
-
-
|
|
144
|
-
|
|
145
|
-
### Approccio Styling
|
|
133
|
+
Il componente supporta:
|
|
134
|
+
- Titolo con opzionale icona integrata
|
|
135
|
+
- Sottotitolo descrittivo
|
|
136
|
+
- Breadcrumbs completi con link di navigazione
|
|
137
|
+
- Azioni contestuali (pulsanti, menu, ecc.)
|
|
138
|
+
- Varianti di stile: modern, light, dark, primary, transparent
|
|
139
|
+
- Posizionamento fisso (in alto o in basso)
|
|
140
|
+
- Controllo della visibilitร dei breadcrumb
|
|
146
141
|
|
|
147
|
-
|
|
142
|
+
### Preview dei componenti con Lookbook
|
|
148
143
|
|
|
149
|
-
|
|
150
|
-
# Le costanti del componente definiscono le opzioni di styling
|
|
151
|
-
BUTTON_THEME_CLASSES = {
|
|
152
|
-
default: 'bg-gray-100 text-gray-900 hover:bg-gray-200',
|
|
153
|
-
blue: 'bg-blue-600 text-white hover:bg-blue-700',
|
|
154
|
-
green: 'bg-green-600 text-white hover:bg-green-700'
|
|
155
|
-
}.freeze
|
|
156
|
-
|
|
157
|
-
BUTTON_SIZE_CLASSES = {
|
|
158
|
-
small: 'px-3 py-1.5 text-sm',
|
|
159
|
-
medium: 'px-4 py-2 text-base',
|
|
160
|
-
large: 'px-6 py-3 text-lg'
|
|
161
|
-
}.freeze
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
## Componenti Disponibili
|
|
144
|
+
BetterUI integra [Lookbook](https://github.com/allmarkedup/lookbook) per visualizzare in anteprima i componenti UI:
|
|
165
145
|
|
|
166
|
-
|
|
146
|
+
1. Accedi a `/better_ui/lookbook` nella tua applicazione per visualizzare il catalogo componenti
|
|
147
|
+
2. Esplora le varianti e le configurazioni disponibili per ogni componente
|
|
148
|
+
3. Visualizza il codice sorgente e il markup generato
|
|
149
|
+
4. Interagisci con i componenti in tempo reale
|
|
167
150
|
|
|
168
|
-
|
|
151
|
+
Lookbook รจ disponibile solo negli ambienti di sviluppo e test.
|
|
169
152
|
|
|
170
|
-
|
|
153
|
+
## ๐ฎ Personalizzazione
|
|
171
154
|
|
|
172
|
-
|
|
173
|
-
- **Main**: Area contenuto principale dell'applicazione con layout responsive
|
|
174
|
-
- **Navbar**: Barra di navigazione superiore con supporto contenuto flessibile
|
|
175
|
-
- **Sidebar**: Navigazione laterale collassabile
|
|
155
|
+
### Usa l'inizializzatore
|
|
176
156
|
|
|
177
|
-
|
|
157
|
+
Crea un file `config/initializers/better_ui.rb`:
|
|
178
158
|
|
|
179
|
-
|
|
159
|
+
```ruby
|
|
160
|
+
BetterUi.configure do |config|
|
|
161
|
+
config.button_defaults = {
|
|
162
|
+
class: 'rounded-lg text-sm'
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
config.alert_defaults = {
|
|
166
|
+
dismissible: true
|
|
167
|
+
}
|
|
168
|
+
end
|
|
169
|
+
```
|
|
180
170
|
|
|
181
|
-
|
|
171
|
+
### Personalizza gli stili
|
|
182
172
|
|
|
183
|
-
|
|
184
|
-
- **Avatar**: Immagini profilo utente con supporto fallback
|
|
185
|
-
- **Badge**: Indicatori di stato e etichette
|
|
186
|
-
- **Progress**: Barre di progresso e indicatori di caricamento
|
|
187
|
-
- **Spinner**: Animazioni di caricamento
|
|
188
|
-
- **Tooltip**: Overlay di aiuto contestuale e informazioni
|
|
173
|
+
Sovrascrivi gli stili CSS nel tuo foglio di stile:
|
|
189
174
|
|
|
190
|
-
|
|
175
|
+
```css
|
|
176
|
+
.better-ui-button-primary {
|
|
177
|
+
background-color: #8b5cf6; /* Viola personalizzato */
|
|
178
|
+
border-color: #8b5cf6;
|
|
179
|
+
}
|
|
180
|
+
```
|
|
191
181
|
|
|
192
|
-
|
|
193
|
-
- **Divider**: Separatori di contenuto visivi
|
|
194
|
-
- **Heading**: Intestazioni con tipografia consistente
|
|
195
|
-
- **Icon**: Sistema icone SVG con libreria estesa
|
|
196
|
-
- **Link**: Elementi anchor potenziati con supporto theme
|
|
197
|
-
- **Panel**: Sezioni di contenuto organizzate
|
|
198
|
-
- **Table**: Tabelle dati con sorting e funzionalitร responsive
|
|
199
|
-
- **Tag**: Elementi di categorizzazione ed etichettatura
|
|
182
|
+
## ๐ Sviluppo
|
|
200
183
|
|
|
201
|
-
|
|
184
|
+
BetterUI utilizza una app dummy integrata per lo sviluppo e i test. Ecco come iniziare:
|
|
202
185
|
|
|
203
|
-
|
|
204
|
-
- **Field**: Wrapper campo form con supporto label e validazione
|
|
205
|
-
- **Input**: Sistema input unificato che supporta 14+ tipi:
|
|
206
|
-
- **Text**: text, email, password, search, url, tel
|
|
207
|
-
- **Number**: number, range
|
|
208
|
-
- **Date/Time**: date, datetime-local, time, month, week
|
|
209
|
-
- **File**: upload file
|
|
210
|
-
- **Color**: color picker
|
|
211
|
-
- **Checkbox**: Opzioni multi-selezione
|
|
212
|
-
- **Radio**: Opzioni selezione singola
|
|
213
|
-
- **Select**: Selezioni dropdown
|
|
214
|
-
- **Textarea**: Input testo multi-riga
|
|
186
|
+
### Setup iniziale
|
|
215
187
|
|
|
216
|
-
|
|
188
|
+
```bash
|
|
189
|
+
# Clona il repository
|
|
190
|
+
git clone https://github.com/alessiobussolari/better_ui.git
|
|
191
|
+
cd better_ui
|
|
217
192
|
|
|
218
|
-
|
|
193
|
+
# Installa le dipendenze
|
|
194
|
+
bin/setup
|
|
195
|
+
```
|
|
219
196
|
|
|
220
|
-
|
|
197
|
+
### Avvia l'applicazione di test
|
|
221
198
|
|
|
222
|
-
|
|
199
|
+
Per vedere i componenti in azione e lavorare sulla documentazione:
|
|
223
200
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
201
|
+
```bash
|
|
202
|
+
# Avvia il server di test
|
|
203
|
+
cd test/dummy
|
|
204
|
+
bin/rails server
|
|
227
205
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
<%= render BetterUi::General::Button::Component.new(
|
|
231
|
-
label: "Button Personalizzato",
|
|
232
|
-
classes: "my-custom-class hover:scale-105"
|
|
233
|
-
) %>
|
|
206
|
+
# Oppure dalla directory principale
|
|
207
|
+
bin/rails server -b 0.0.0.0
|
|
234
208
|
```
|
|
235
209
|
|
|
236
|
-
|
|
210
|
+
Visita `http://localhost:3000/better_ui` nel tuo browser per vedere la documentazione e testare i componenti.
|
|
237
211
|
|
|
238
|
-
|
|
239
|
-
2. **Configurazione Componenti**: Configura opzioni di default in `config/initializers/better_ui.rb`
|
|
240
|
-
3. **Integrazione TailwindCSS**: Tutto lo styling usa classi TailwindCSS per massima flessibilitร
|
|
241
|
-
4. **Estensioni Componenti**: Estendi componenti esistenti o crea i tuoi seguendo i pattern stabiliti
|
|
212
|
+
### Flusso di sviluppo
|
|
242
213
|
|
|
243
|
-
|
|
214
|
+
1. **Crea un branch**: `git checkout -b feature/nuovo-componente`
|
|
215
|
+
2. **Implementa il componente**: Aggiungi helper in `app/helpers/better_ui/application_helper.rb`
|
|
216
|
+
3. **Aggiungi CSS**: Inserisci gli stili in `app/assets/stylesheets/better_ui/application.css`
|
|
217
|
+
4. **Documenta**: Crea file Markdown in `docs/components/`
|
|
218
|
+
5. **Testa**: Verifica nell'app dummy che tutto funzioni correttamente
|
|
219
|
+
6. **Esegui i test**: `rake test`
|
|
244
220
|
|
|
245
|
-
|
|
221
|
+
### Build e rilascio
|
|
222
|
+
|
|
223
|
+
Per buildare la gemma localmente:
|
|
246
224
|
|
|
247
225
|
```bash
|
|
248
|
-
|
|
226
|
+
bundle exec rake build
|
|
249
227
|
```
|
|
250
228
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
I componenti BetterUI supportano tutti i browser moderni che supportano:
|
|
254
|
-
|
|
255
|
-
- CSS Grid e Flexbox
|
|
256
|
-
- Funzionalitร JavaScript ES6+
|
|
257
|
-
- Tailwind CSS
|
|
258
|
-
|
|
259
|
-
## Contributing
|
|
260
|
-
|
|
261
|
-
1. Forka il repository
|
|
262
|
-
2. Crea il tuo branch feature (`git checkout -b feature/componente-fantastico`)
|
|
263
|
-
3. Aggiungi il tuo componente con test e preview Lookbook
|
|
264
|
-
4. Committa le tue modifiche (`git commit -am 'Aggiungi componente fantastico'`)
|
|
265
|
-
5. Pusha al branch (`git push origin feature/componente-fantastico`)
|
|
266
|
-
6. Crea una Pull Request
|
|
267
|
-
|
|
268
|
-
### Setup Development
|
|
229
|
+
Per installare la versione in sviluppo:
|
|
269
230
|
|
|
270
231
|
```bash
|
|
271
|
-
|
|
272
|
-
cd better_ui
|
|
273
|
-
bundle install
|
|
274
|
-
cd test/dummy
|
|
275
|
-
bundle exec rails server
|
|
232
|
+
bundle exec rake install
|
|
276
233
|
```
|
|
277
234
|
|
|
278
|
-
|
|
235
|
+
## ๐ค Contribuire
|
|
279
236
|
|
|
280
|
-
|
|
237
|
+
I contributi sono benvenuti e apprezzati! Ecco come puoi aiutare:
|
|
281
238
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
-
|
|
286
|
-
|
|
287
|
-
|
|
239
|
+
1. **Fork** il repository su GitHub
|
|
240
|
+
2. **Clona** il tuo fork: `git clone https://github.com/TUO-USERNAME/better_ui.git`
|
|
241
|
+
3. **Crea** un branch per la tua feature: `git checkout -b feature/incredibile-miglioramento`
|
|
242
|
+
4. **Committa** i tuoi cambiamenti: `git commit -am 'Aggiunge una funzionalitร incredibile'`
|
|
243
|
+
5. **Pusha** al branch: `git push origin feature/incredibile-miglioramento`
|
|
244
|
+
6. Invia una **Pull Request**
|
|
288
245
|
|
|
289
|
-
|
|
246
|
+
### Linee guida
|
|
290
247
|
|
|
291
|
-
|
|
248
|
+
- Segui lo stile di codice esistente
|
|
249
|
+
- Scrivi test per le nuove funzionalitร
|
|
250
|
+
- Aggiorna la documentazione
|
|
251
|
+
- Crea componenti che funzionano senza JavaScript
|
|
292
252
|
|
|
293
|
-
##
|
|
253
|
+
## ๐ Licenza
|
|
294
254
|
|
|
295
|
-
|
|
296
|
-
- ๐ [Issue Tracker](https://github.com/alessiobussolari/better_ui/issues)
|
|
297
|
-
- ๐ฌ [Discussioni](https://github.com/alessiobussolari/better_ui/discussions)
|
|
255
|
+
BetterUI รจ disponibile come open source sotto i termini della [Licenza MIT](https://opensource.org/licenses/MIT).
|
|
298
256
|
|
|
299
257
|
---
|
|
300
258
|
|
|
301
|
-
|
|
259
|
+
Realizzato con โค๏ธ da [Alessio Bussolari](https://github.com/alessiobussolari)
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// Navbar controller per gestire il comportamento del menu mobile e dei dropdown
|
|
2
|
+
import { Controller } from "@hotwired/stimulus"
|
|
3
|
+
|
|
4
|
+
export default class extends Controller {
|
|
5
|
+
static targets = ["menu", "dropdown", "submenu"]
|
|
6
|
+
|
|
7
|
+
connect() {
|
|
8
|
+
// Verifica se siamo su mobile e aggiorna lo stato del menu
|
|
9
|
+
this.updateMenuState();
|
|
10
|
+
|
|
11
|
+
// Aggiungi un event listener per il resize della finestra
|
|
12
|
+
window.addEventListener("resize", this.updateMenuState.bind(this));
|
|
13
|
+
|
|
14
|
+
// Chiudi menu quando si clicca su un link (solo su mobile)
|
|
15
|
+
if (this.hasMenuTarget) {
|
|
16
|
+
const links = this.menuTarget.querySelectorAll("a");
|
|
17
|
+
links.forEach(link => {
|
|
18
|
+
link.addEventListener("click", () => {
|
|
19
|
+
// Se siamo su mobile, chiudi il menu
|
|
20
|
+
if (window.innerWidth < 768) {
|
|
21
|
+
this.closeMenu();
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Aggiungi listener per i click all'esterno del menu
|
|
28
|
+
document.addEventListener("click", this.handleClickOutside.bind(this))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
disconnect() {
|
|
32
|
+
// Rimuovi event listener per il resize della finestra
|
|
33
|
+
window.removeEventListener("resize", this.updateMenuState.bind(this));
|
|
34
|
+
|
|
35
|
+
// Rimuovi listener al disconnette
|
|
36
|
+
document.removeEventListener("click", this.handleClickOutside.bind(this))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Metodo per alternare l'apertura/chiusura del menu
|
|
40
|
+
toggleMenu(event) {
|
|
41
|
+
event.stopPropagation()
|
|
42
|
+
const isExpanded = this.menuTarget.classList.contains("hidden") === false
|
|
43
|
+
|
|
44
|
+
if (isExpanded) {
|
|
45
|
+
this.closeMenu()
|
|
46
|
+
} else {
|
|
47
|
+
this.openMenu()
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Metodo per chiudere il menu
|
|
52
|
+
closeMenu() {
|
|
53
|
+
this.menuTarget.classList.add("hidden")
|
|
54
|
+
|
|
55
|
+
// Aggiorna l'attributo aria-expanded
|
|
56
|
+
const button = this.element.querySelector("[aria-controls='navbar-menu']")
|
|
57
|
+
if (button) {
|
|
58
|
+
button.setAttribute("aria-expanded", "false")
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Metodo per aggiornare lo stato del menu in base alla dimensione della finestra
|
|
63
|
+
updateMenuState() {
|
|
64
|
+
if (this.hasMenuTarget) {
|
|
65
|
+
// Se siamo su desktop (md breakpoint - 768px)
|
|
66
|
+
if (window.innerWidth >= 768) {
|
|
67
|
+
// Assicurati che il menu sia visibile su desktop
|
|
68
|
+
this.menuTarget.classList.remove("hidden");
|
|
69
|
+
this.menuTarget.classList.add("md:block");
|
|
70
|
+
} else {
|
|
71
|
+
// Su mobile, nascondi il menu di default
|
|
72
|
+
this.menuTarget.classList.add("hidden");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Aggiorna l'attributo aria-expanded
|
|
76
|
+
const button = this.element.querySelector("[aria-controls='navbar-menu']");
|
|
77
|
+
if (button) {
|
|
78
|
+
const isExpanded = window.innerWidth >= 768 ? "true" : "false";
|
|
79
|
+
button.setAttribute("aria-expanded", isExpanded);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
openMenu() {
|
|
85
|
+
this.menuTarget.classList.remove("hidden")
|
|
86
|
+
|
|
87
|
+
// Chiudi tutti i dropdown nel menu mobile
|
|
88
|
+
if (this.hasSubmenuTarget) {
|
|
89
|
+
this.submenuTargets.forEach(submenu => {
|
|
90
|
+
submenu.classList.add("hidden")
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Aggiorna stato del pulsante
|
|
95
|
+
event.currentTarget.setAttribute("aria-expanded", "true")
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
toggleDropdown(event) {
|
|
99
|
+
event.stopPropagation()
|
|
100
|
+
const button = event.currentTarget
|
|
101
|
+
const dropdownId = button.getAttribute("aria-controls")
|
|
102
|
+
const dropdown = document.getElementById(dropdownId)
|
|
103
|
+
|
|
104
|
+
if (dropdown) {
|
|
105
|
+
const isExpanded = button.getAttribute("aria-expanded") === "true"
|
|
106
|
+
|
|
107
|
+
if (isExpanded) {
|
|
108
|
+
dropdown.classList.add("hidden")
|
|
109
|
+
button.setAttribute("aria-expanded", "false")
|
|
110
|
+
} else {
|
|
111
|
+
// Chiudi tutti gli altri dropdown prima di aprire quello corrente
|
|
112
|
+
if (this.hasSubmenuTarget) {
|
|
113
|
+
this.submenuTargets.forEach(submenu => {
|
|
114
|
+
if (submenu.id !== dropdownId) {
|
|
115
|
+
submenu.classList.add("hidden")
|
|
116
|
+
|
|
117
|
+
// Trova e aggiorna il pulsante associato
|
|
118
|
+
const associatedButton = this.element.querySelector(`[aria-controls='${submenu.id}']`)
|
|
119
|
+
if (associatedButton) {
|
|
120
|
+
associatedButton.setAttribute("aria-expanded", "false")
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
dropdown.classList.remove("hidden")
|
|
127
|
+
button.setAttribute("aria-expanded", "true")
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
handleClickOutside(event) {
|
|
133
|
+
// Chiudi il menu se si fa clic all'esterno
|
|
134
|
+
if (this.element.contains(event.target) === false) {
|
|
135
|
+
this.closeMenu()
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|