better_ui 0.4.0 → 0.5.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 (52) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +165 -105
  3. data/app/components/better_ui/application/alert_component.html.erb +1 -1
  4. data/app/components/better_ui/application/alert_component.rb +95 -89
  5. data/app/components/better_ui/application/card_component.html.erb +24 -0
  6. data/app/components/better_ui/application/card_component.rb +53 -0
  7. data/app/components/better_ui/application/card_container_component.html.erb +8 -0
  8. data/app/components/better_ui/application/card_container_component.rb +14 -0
  9. data/app/components/better_ui/application/toast_component.rb +92 -57
  10. data/app/components/better_ui/general/avatar_component.html.erb +19 -0
  11. data/app/components/better_ui/general/avatar_component.rb +171 -0
  12. data/app/components/better_ui/general/badge_component.html.erb +19 -0
  13. data/app/components/better_ui/general/badge_component.rb +123 -0
  14. data/app/components/better_ui/general/breadcrumb_component.html.erb +7 -31
  15. data/app/components/better_ui/general/breadcrumb_component.rb +64 -66
  16. data/app/components/better_ui/general/button_component.html.erb +4 -4
  17. data/app/components/better_ui/general/button_component.rb +64 -95
  18. data/app/components/better_ui/general/heading_component.html.erb +3 -3
  19. data/app/components/better_ui/general/heading_component.rb +76 -70
  20. data/app/components/better_ui/general/icon_component.html.erb +1 -1
  21. data/app/components/better_ui/general/icon_component.rb +22 -23
  22. data/app/components/better_ui/general/link_component.html.erb +17 -0
  23. data/app/components/better_ui/general/link_component.rb +132 -0
  24. data/app/components/better_ui/general/panel_component.rb +62 -56
  25. data/app/components/better_ui/general/spinner_component.html.erb +15 -0
  26. data/app/components/better_ui/general/spinner_component.rb +79 -0
  27. data/app/components/better_ui/general/table_component.html.erb +56 -20
  28. data/app/components/better_ui/general/table_component.rb +106 -80
  29. data/app/components/better_ui/theme_helper.rb +77 -75
  30. data/app/views/components/better_ui/general/table/_custom_body_row.html.erb +17 -0
  31. data/app/views/components/better_ui/general/table/_custom_footer_rows.html.erb +17 -0
  32. data/app/views/components/better_ui/general/table/_custom_header_rows.html.erb +12 -0
  33. data/lib/better_ui/engine.rb +4 -10
  34. data/lib/better_ui/version.rb +1 -1
  35. data/lib/better_ui.rb +4 -0
  36. data/lib/generators/better_ui/stylesheet_generator.rb +96 -0
  37. data/lib/generators/better_ui/templates/README +56 -0
  38. data/lib/generators/better_ui/templates/components/_avatar.scss +151 -0
  39. data/lib/generators/better_ui/templates/components/_badge.scss +142 -0
  40. data/lib/generators/better_ui/templates/components/_breadcrumb.scss +107 -0
  41. data/lib/generators/better_ui/templates/components/_button.scss +106 -0
  42. data/lib/generators/better_ui/templates/components/_card.scss +69 -0
  43. data/lib/generators/better_ui/templates/components/_heading.scss +180 -0
  44. data/lib/generators/better_ui/templates/components/_icon.scss +90 -0
  45. data/lib/generators/better_ui/templates/components/_link.scss +130 -0
  46. data/lib/generators/better_ui/templates/components/_panel.scss +144 -0
  47. data/lib/generators/better_ui/templates/components/_spinner.scss +132 -0
  48. data/lib/generators/better_ui/templates/components/_table.scss +105 -0
  49. data/lib/generators/better_ui/templates/components/_variables.scss +33 -0
  50. data/lib/generators/better_ui/templates/components_stylesheet.scss +66 -0
  51. metadata +51 -22
  52. data/app/helpers/better_ui_application_helper.rb +0 -99
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2242792aeee217a121cb73ec14ccc317d8f9c7af9e3dcdcf52629d05eca55731
4
- data.tar.gz: 86015104cb387605208eaa8f9ffbdeb3764542fd089e09cf2dd011cecc37640b
3
+ metadata.gz: 317837f4f80e12e6ab860a7a134e9f17e01f5db2d86f5b178a4c9a2bc9588f3a
4
+ data.tar.gz: 8815e3b40a461070b9cb178ee1a7e1e8abaccbf6cea7366ab5c079db174429f4
5
5
  SHA512:
6
- metadata.gz: df1b73b3f9c3782a562ef7b585fd9bbac50c45fc8cc9661fe6ff8aa335c53f988c65ce4ab430c7c6dc82d74419b9dd80e026ad50c4533742b7940153fba2e653
7
- data.tar.gz: 1010406d6a425b0ca48e1acf0af262634a7f5babf54edd34dfd6c7b6943dbdb1a18c250d800f68b9e41ec7bc94d095a8ed9d3e3ca7efb540bbb3ddbe4d310105
6
+ metadata.gz: 0fb96fb9537391b7448ffde247cd8d9ae4916dac0cfcd17c4efe912b061dfd05986368ebe6563549c58ce0909e9a509474ac885e136d133214f806437925726d
7
+ data.tar.gz: de95bf54dcd6fa022f5afa5c0867d65b7a78e8f24cab637aa7cf098f0bf01f5cabdac5e6c7b36ba1aba14833682b17174e1d229a4d428f5646d92ee876ad42f4
data/README.md CHANGED
@@ -3,63 +3,66 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/better_ui.svg)](https://badge.fury.io/rb/better_ui)
4
4
  [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
5
5
 
6
- > Componenti UI eleganti, coerenti e facilmente integrabili per le tue applicazioni Rails
6
+ > Elegant, consistent, and easily integrable UI components for your Rails applications
7
7
 
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.
8
+ BetterUI is a Rails gem that provides reusable UI components with built-in documentation. Designed to be lightweight, customizable, and easy to use, it helps you build beautiful and consistent interfaces without JavaScript.
9
9
 
10
- ## ✨ Caratteristiche principali
10
+ ## ✨ Key Features
11
11
 
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
12
+ - **Pure Design** - Elegant, fully CSS UI components, no JavaScript
13
+ - **Easy Integration** - Mountable Rails engine that integrates seamlessly with your app
14
+ - **Built-in Documentation** - View examples and documentation directly in your browser
15
+ - **Highly Customizable** - Easily adapt the style to your brand
16
+ - **Modular Components** - Use only what you need
17
+ - **Component Previews** - View and interact with components using Lookbook
18
18
 
19
- ## 📦 Componenti disponibili
19
+ ## 📦 Available Components
20
20
 
21
- | Componente | Descrizione |
21
+ | Component | Description |
22
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) |
33
-
34
- ## 🚀 Installazione
35
-
36
- Aggiungi questa riga al Gemfile della tua applicazione:
23
+ | **Button** | Styled buttons with primary, secondary, success, danger variants |
24
+ | **Alert** | Informational, success, warning, and error messages |
25
+ | **Card** | Flexible containers with header, body, and footer |
26
+ | **Modal** | Modal dialog windows |
27
+ | **Tabs** | Tab navigation |
28
+ | **Navbar** | Responsive navigation bar with dropdown menu support |
29
+ | **Sidebar** | Side menu with hierarchical navigation support |
30
+ | **Toast** | Temporary notifications with timer and animations |
31
+ | **Header** | Page headers with title, subtitle, breadcrumb, and actions |
32
+ | **Badge** | Labels with support for icons, colors, and outline variants |
33
+ | **Spinner** | Loading indicators with various themes and sizes |
34
+ | **Avatar** | User avatars with support for images, initials, and online status |
35
+ | **Form Elements** | Styled input fields (coming soon) |
36
+
37
+ ## 🚀 Installation
38
+
39
+ Add this line to your application's Gemfile:
37
40
 
38
41
  ```ruby
39
42
  gem 'better_ui', '~> 0.1.0'
40
43
  ```
41
44
 
42
- E poi esegui:
45
+ And then execute:
43
46
 
44
47
  ```bash
45
48
  $ bundle install
46
49
  ```
47
50
 
48
- ## ⚙️ Configurazione
51
+ ## ⚙️ Configuration
49
52
 
50
- ### Monta l'engine
53
+ ### Mount the Engine
51
54
 
52
- Aggiungi questo al tuo file `config/routes.rb`:
55
+ Add this to your `config/routes.rb` file:
53
56
 
54
57
  ```ruby
55
58
  Rails.application.routes.draw do
56
59
  mount BetterUi::Engine => '/better_ui'
57
60
 
58
- # ... altre tue route
61
+ # ... your other routes
59
62
  end
60
63
  ```
61
64
 
62
- ### Includi gli assets
65
+ ### Include the Assets
63
66
 
64
67
  In `app/assets/stylesheets/application.css`:
65
68
 
@@ -69,92 +72,149 @@ In `app/assets/stylesheets/application.css`:
69
72
  */
70
73
  ```
71
74
 
72
- ## 🎮 Utilizzo
75
+ ## 🎮 Usage
73
76
 
74
- Una volta installato, puoi iniziare ad usare i componenti:
77
+ Once installed, you can start using the components:
75
78
 
76
79
  ```erb
77
80
  <%# Button %>
78
- <%= better_ui_button("Salva", type: "primary") %>
81
+ <%= better_ui_button("Save", type: "primary") %>
79
82
 
80
83
  <%# Alert %>
81
- <%= better_ui_alert("Operazione completata", type: "success") %>
84
+ <%= better_ui_alert("Operation completed", type: "success") %>
82
85
 
83
86
  <%# Card %>
84
87
  <%= better_ui_card do %>
85
- <%= better_ui_card_header("Titolo Card") %>
88
+ <%= better_ui_card_header("Card Title") %>
86
89
  <%= better_ui_card_body do %>
87
- <p>Contenuto della card...</p>
90
+ <p>Card content...</p>
88
91
  <% end %>
89
92
  <% end %>
90
93
 
91
- <%# Header con breadcrumb %>
94
+ <%# Header with breadcrumb %>
92
95
  <%= render BetterUi::Application::HeaderComponent.new(
93
96
  title: "Dashboard",
94
- subtitle: "Gestisci tutto da qui",
97
+ subtitle: "Manage everything from here",
95
98
  breadcrumbs: [
96
99
  { text: "Home", url: "/" },
97
100
  { text: "Dashboard" }
98
101
  ],
99
102
  actions: [
100
- { content: button_html("Nuovo", "primary") }
103
+ { content: button_html("New", "primary") }
101
104
  ]
102
105
  ) %>
103
106
  ```
104
107
 
105
- Visita `/better_ui` nella tua applicazione per vedere la documentazione completa e gli esempi.
108
+ Visit `/better_ui` in your application to see the complete documentation and examples.
106
109
 
107
- ### Il componente Header
110
+ ### The Header Component
108
111
 
109
- Il componente Header è progettato per creare intestazioni di pagina complete con numerose funzionalità:
112
+ The Header component is designed to create complete page headers with numerous features:
110
113
 
111
114
  ```erb
112
115
  <%= render BetterUi::Application::HeaderComponent.new(
113
116
  title: {
114
- text: "Impostazioni",
117
+ text: "Settings",
115
118
  icon: "settings"
116
119
  },
117
- subtitle: "Configura le preferenze del sistema",
120
+ subtitle: "Configure system preferences",
118
121
  breadcrumbs: [
119
122
  { text: "Home", url: "/" },
120
123
  { text: "Admin", url: "/admin" },
121
- { text: "Impostazioni" }
124
+ { text: "Settings" }
122
125
  ],
123
126
  variant: :modern,
124
127
  fixed: :top,
125
128
  show_breadcrumbs: true,
126
129
  actions: [
127
- { content: button_html("Salva", "primary") },
128
- { content: button_html("Annulla", "secondary") }
130
+ { content: button_html("Save", "primary") },
131
+ { content: button_html("Cancel", "secondary") }
129
132
  ]
130
133
  ) %>
131
134
  ```
132
135
 
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
136
+ The component supports:
137
+ - Title with optional integrated icon
138
+ - Descriptive subtitle
139
+ - Complete breadcrumbs with navigation links
140
+ - Contextual actions (buttons, menus, etc.)
141
+ - Style variants: modern, light, dark, primary, transparent
142
+ - Fixed positioning (top or bottom)
143
+ - Breadcrumb visibility control
144
+
145
+ ### Component Previews with Lookbook
146
+
147
+ BetterUI integrates [Lookbook](https://github.com/allmarkedup/lookbook) to preview UI components:
148
+
149
+ 1. Access `/better_ui/lookbook` in your application to view the component catalog
150
+ 2. Explore available variants and configurations for each component
151
+ 3. View source code and generated markup
152
+ 4. Interact with components in real-time
153
+
154
+ Lookbook is only available in development and test environments.
155
+
156
+ ## 🎨 Customization
157
+
158
+ ### Generate a Custom Stylesheet
159
+
160
+ BetterUI includes a generator to create a base stylesheet for customizing components:
161
+
162
+ ```bash
163
+ # Generate a stylesheet with the default "custom" prefix
164
+ rails generate better_ui:stylesheet
165
+
166
+ # Generate a stylesheet with a custom prefix
167
+ rails generate better_ui:stylesheet --prefix=my_theme
168
+ ```
169
+
170
+ This will create:
171
+ 1. A main SCSS file with imports for all components
172
+ 2. Individual SCSS files for each component in the `app/assets/stylesheets/components/` directory
173
+ 3. Special `*_overrides.scss` files for each component that allow you to override styles without modifying the original files
174
+
175
+ ### Component Overrides System ✨
141
176
 
142
- ### Preview dei componenti con Lookbook
177
+ One of BetterUI's most powerful features is the automatic generation of override files:
178
+
179
+ ```bash
180
+ # Generate override files for all components
181
+ rails generate better_ui:stylesheet
182
+ ```
143
183
 
144
- BetterUI integra [Lookbook](https://github.com/allmarkedup/lookbook) per visualizzare in anteprima i componenti UI:
184
+ This creates special `*_overrides.scss` files that:
185
+ - Contain empty classes matching the original component files
186
+ - Allow for clean customization without modifying the original styles
187
+ - Support both standard and nested SCSS class structures
188
+ - Include helpful comments for easier modification
189
+
190
+ Example override file structure:
191
+ ```scss
192
+ /* ==============================
193
+ * Button Component Overrides
194
+ * ==============================
195
+ * This file contains empty classes to override default styles.
196
+ * Add your customizations here.
197
+ */
145
198
 
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
199
+ .bui-button-primary {
200
+ // Override styles for .bui-button-primary here
201
+ }
150
202
 
151
- Lookbook è disponibile solo negli ambienti di sviluppo e test.
203
+ .bui-button-secondary {
204
+ // Override styles for .bui-button-secondary here
205
+ }
152
206
 
153
- ## 🎮 Personalizzazione
207
+ // Nested class overrides
208
+ .bui-button-with-icon {
209
+ .bui-icon {
210
+ // Override nested styles here
211
+ }
212
+ }
213
+ ```
154
214
 
155
- ### Usa l'inizializzatore
215
+ ### Use the Initializer
156
216
 
157
- Crea un file `config/initializers/better_ui.rb`:
217
+ Create a `config/initializers/better_ui.rb` file:
158
218
 
159
219
  ```ruby
160
220
  BetterUi.configure do |config|
@@ -168,92 +228,92 @@ BetterUi.configure do |config|
168
228
  end
169
229
  ```
170
230
 
171
- ### Personalizza gli stili
231
+ ### Customize Styles
172
232
 
173
- Sovrascrivi gli stili CSS nel tuo foglio di stile:
233
+ Override CSS styles in your stylesheet:
174
234
 
175
235
  ```css
176
236
  .better-ui-button-primary {
177
- background-color: #8b5cf6; /* Viola personalizzato */
237
+ background-color: #8b5cf6; /* Custom purple */
178
238
  border-color: #8b5cf6;
179
239
  }
180
240
  ```
181
241
 
182
- ## 🛠 Sviluppo
242
+ ## 🛠 Development
183
243
 
184
- BetterUI utilizza una app dummy integrata per lo sviluppo e i test. Ecco come iniziare:
244
+ BetterUI uses an integrated dummy app for development and testing. Here's how to get started:
185
245
 
186
- ### Setup iniziale
246
+ ### Initial Setup
187
247
 
188
248
  ```bash
189
- # Clona il repository
249
+ # Clone the repository
190
250
  git clone https://github.com/alessiobussolari/better_ui.git
191
251
  cd better_ui
192
252
 
193
- # Installa le dipendenze
253
+ # Install dependencies
194
254
  bin/setup
195
255
  ```
196
256
 
197
- ### Avvia l'applicazione di test
257
+ ### Start the Test Application
198
258
 
199
- Per vedere i componenti in azione e lavorare sulla documentazione:
259
+ To see components in action and work on documentation:
200
260
 
201
261
  ```bash
202
- # Avvia il server di test
262
+ # Start the test server
203
263
  cd test/dummy
204
264
  bin/rails server
205
265
 
206
- # Oppure dalla directory principale
266
+ # Or from the main directory
207
267
  bin/rails server -b 0.0.0.0
208
268
  ```
209
269
 
210
- Visita `http://localhost:3000/better_ui` nel tuo browser per vedere la documentazione e testare i componenti.
270
+ Visit `http://localhost:3000/better_ui` in your browser to see the documentation and test the components.
211
271
 
212
- ### Flusso di sviluppo
272
+ ### Development Flow
213
273
 
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`
274
+ 1. **Create a branch**: `git checkout -b feature/new-component`
275
+ 2. **Implement the component**: Add helpers in `app/helpers/better_ui/application_helper.rb`
276
+ 3. **Add CSS**: Insert styles in `app/assets/stylesheets/better_ui/application.css`
277
+ 4. **Document**: Create Markdown files in `docs/components/`
278
+ 5. **Test**: Verify in the dummy app that everything works correctly
279
+ 6. **Run tests**: `rake test`
220
280
 
221
- ### Build e rilascio
281
+ ### Build and Release
222
282
 
223
- Per buildare la gemma localmente:
283
+ To build the gem locally:
224
284
 
225
285
  ```bash
226
286
  bundle exec rake build
227
287
  ```
228
288
 
229
- Per installare la versione in sviluppo:
289
+ To install the development version:
230
290
 
231
291
  ```bash
232
292
  bundle exec rake install
233
293
  ```
234
294
 
235
- ## 🤝 Contribuire
295
+ ## 🤝 Contributing
236
296
 
237
- I contributi sono benvenuti e apprezzati! Ecco come puoi aiutare:
297
+ Contributions are welcome and appreciated! Here's how you can help:
238
298
 
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**
299
+ 1. **Fork** the repository on GitHub
300
+ 2. **Clone** your fork: `git clone https://github.com/YOUR-USERNAME/better_ui.git`
301
+ 3. **Create** a branch for your feature: `git checkout -b feature/amazing-improvement`
302
+ 4. **Commit** your changes: `git commit -am 'Add an amazing feature'`
303
+ 5. **Push** to the branch: `git push origin feature/amazing-improvement`
304
+ 6. Submit a **Pull Request**
245
305
 
246
- ### Linee guida
306
+ ### Guidelines
247
307
 
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
308
+ - Follow the existing code style
309
+ - Write tests for new features
310
+ - Update documentation
311
+ - Create components that work without JavaScript
252
312
 
253
- ## 📄 Licenza
313
+ ## 📄 License
254
314
 
255
- BetterUI è disponibile come open source sotto i termini della [Licenza MIT](https://opensource.org/licenses/MIT).
315
+ BetterUI is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
256
316
 
257
317
  ---
258
318
 
259
- Realizzato con ❤️ da [Alessio Bussolari](https://github.com/alessiobussolari)
319
+ Made with ❤️ by [Alessio Bussolari](https://github.com/alessiobussolari)
@@ -24,4 +24,4 @@
24
24
  <%= render BetterUi::General::IconComponent.new(name: "xmark") %>
25
25
  </button>
26
26
  <% end %>
27
- </div>
27
+ </div>