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.
- checksums.yaml +4 -4
- data/README.md +165 -105
- data/app/components/better_ui/application/alert_component.html.erb +1 -1
- data/app/components/better_ui/application/alert_component.rb +95 -89
- data/app/components/better_ui/application/card_component.html.erb +24 -0
- data/app/components/better_ui/application/card_component.rb +53 -0
- data/app/components/better_ui/application/card_container_component.html.erb +8 -0
- data/app/components/better_ui/application/card_container_component.rb +14 -0
- data/app/components/better_ui/application/toast_component.rb +92 -57
- data/app/components/better_ui/general/avatar_component.html.erb +19 -0
- data/app/components/better_ui/general/avatar_component.rb +171 -0
- data/app/components/better_ui/general/badge_component.html.erb +19 -0
- data/app/components/better_ui/general/badge_component.rb +123 -0
- data/app/components/better_ui/general/breadcrumb_component.html.erb +7 -31
- data/app/components/better_ui/general/breadcrumb_component.rb +64 -66
- data/app/components/better_ui/general/button_component.html.erb +4 -4
- data/app/components/better_ui/general/button_component.rb +64 -95
- data/app/components/better_ui/general/heading_component.html.erb +3 -3
- data/app/components/better_ui/general/heading_component.rb +76 -70
- data/app/components/better_ui/general/icon_component.html.erb +1 -1
- data/app/components/better_ui/general/icon_component.rb +22 -23
- data/app/components/better_ui/general/link_component.html.erb +17 -0
- data/app/components/better_ui/general/link_component.rb +132 -0
- data/app/components/better_ui/general/panel_component.rb +62 -56
- data/app/components/better_ui/general/spinner_component.html.erb +15 -0
- data/app/components/better_ui/general/spinner_component.rb +79 -0
- data/app/components/better_ui/general/table_component.html.erb +56 -20
- data/app/components/better_ui/general/table_component.rb +106 -80
- data/app/components/better_ui/theme_helper.rb +77 -75
- data/app/views/components/better_ui/general/table/_custom_body_row.html.erb +17 -0
- data/app/views/components/better_ui/general/table/_custom_footer_rows.html.erb +17 -0
- data/app/views/components/better_ui/general/table/_custom_header_rows.html.erb +12 -0
- data/lib/better_ui/engine.rb +4 -10
- data/lib/better_ui/version.rb +1 -1
- data/lib/better_ui.rb +4 -0
- data/lib/generators/better_ui/stylesheet_generator.rb +96 -0
- data/lib/generators/better_ui/templates/README +56 -0
- data/lib/generators/better_ui/templates/components/_avatar.scss +151 -0
- data/lib/generators/better_ui/templates/components/_badge.scss +142 -0
- data/lib/generators/better_ui/templates/components/_breadcrumb.scss +107 -0
- data/lib/generators/better_ui/templates/components/_button.scss +106 -0
- data/lib/generators/better_ui/templates/components/_card.scss +69 -0
- data/lib/generators/better_ui/templates/components/_heading.scss +180 -0
- data/lib/generators/better_ui/templates/components/_icon.scss +90 -0
- data/lib/generators/better_ui/templates/components/_link.scss +130 -0
- data/lib/generators/better_ui/templates/components/_panel.scss +144 -0
- data/lib/generators/better_ui/templates/components/_spinner.scss +132 -0
- data/lib/generators/better_ui/templates/components/_table.scss +105 -0
- data/lib/generators/better_ui/templates/components/_variables.scss +33 -0
- data/lib/generators/better_ui/templates/components_stylesheet.scss +66 -0
- metadata +51 -22
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 317837f4f80e12e6ab860a7a134e9f17e01f5db2d86f5b178a4c9a2bc9588f3a
|
4
|
+
data.tar.gz: 8815e3b40a461070b9cb178ee1a7e1e8abaccbf6cea7366ab5c079db174429f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fb96fb9537391b7448ffde247cd8d9ae4916dac0cfcd17c4efe912b061dfd05986368ebe6563549c58ce0909e9a509474ac885e136d133214f806437925726d
|
7
|
+
data.tar.gz: de95bf54dcd6fa022f5afa5c0867d65b7a78e8f24cab637aa7cf098f0bf01f5cabdac5e6c7b36ba1aba14833682b17174e1d229a4d428f5646d92ee876ad42f4
|
data/README.md
CHANGED
@@ -3,63 +3,66 @@
|
|
3
3
|
[](https://badge.fury.io/rb/better_ui)
|
4
4
|
[](LICENSE)
|
5
5
|
|
6
|
-
>
|
6
|
+
> Elegant, consistent, and easily integrable UI components for your Rails applications
|
7
7
|
|
8
|
-
BetterUI
|
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
|
-
## ✨
|
10
|
+
## ✨ Key Features
|
11
11
|
|
12
|
-
- **Design
|
13
|
-
- **
|
14
|
-
- **
|
15
|
-
- **
|
16
|
-
- **
|
17
|
-
- **
|
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
|
-
## 📦
|
19
|
+
## 📦 Available Components
|
20
20
|
|
21
|
-
|
|
21
|
+
| Component | Description |
|
22
22
|
|------------|-------------|
|
23
|
-
| **Button** |
|
24
|
-
| **Alert** |
|
25
|
-
| **Card** |
|
26
|
-
| **Modal** |
|
27
|
-
| **Tabs** |
|
28
|
-
| **Navbar** |
|
29
|
-
| **Sidebar** |
|
30
|
-
| **Toast** |
|
31
|
-
| **Header** |
|
32
|
-
| **
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
-
|
45
|
+
And then execute:
|
43
46
|
|
44
47
|
```bash
|
45
48
|
$ bundle install
|
46
49
|
```
|
47
50
|
|
48
|
-
## ⚙️
|
51
|
+
## ⚙️ Configuration
|
49
52
|
|
50
|
-
###
|
53
|
+
### Mount the Engine
|
51
54
|
|
52
|
-
|
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
|
-
# ...
|
61
|
+
# ... your other routes
|
59
62
|
end
|
60
63
|
```
|
61
64
|
|
62
|
-
###
|
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
|
-
## 🎮
|
75
|
+
## 🎮 Usage
|
73
76
|
|
74
|
-
|
77
|
+
Once installed, you can start using the components:
|
75
78
|
|
76
79
|
```erb
|
77
80
|
<%# Button %>
|
78
|
-
<%= better_ui_button("
|
81
|
+
<%= better_ui_button("Save", type: "primary") %>
|
79
82
|
|
80
83
|
<%# Alert %>
|
81
|
-
<%= better_ui_alert("
|
84
|
+
<%= better_ui_alert("Operation completed", type: "success") %>
|
82
85
|
|
83
86
|
<%# Card %>
|
84
87
|
<%= better_ui_card do %>
|
85
|
-
<%= better_ui_card_header("
|
88
|
+
<%= better_ui_card_header("Card Title") %>
|
86
89
|
<%= better_ui_card_body do %>
|
87
|
-
<p>
|
90
|
+
<p>Card content...</p>
|
88
91
|
<% end %>
|
89
92
|
<% end %>
|
90
93
|
|
91
|
-
<%# Header
|
94
|
+
<%# Header with breadcrumb %>
|
92
95
|
<%= render BetterUi::Application::HeaderComponent.new(
|
93
96
|
title: "Dashboard",
|
94
|
-
subtitle: "
|
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("
|
103
|
+
{ content: button_html("New", "primary") }
|
101
104
|
]
|
102
105
|
) %>
|
103
106
|
```
|
104
107
|
|
105
|
-
|
108
|
+
Visit `/better_ui` in your application to see the complete documentation and examples.
|
106
109
|
|
107
|
-
###
|
110
|
+
### The Header Component
|
108
111
|
|
109
|
-
|
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: "
|
117
|
+
text: "Settings",
|
115
118
|
icon: "settings"
|
116
119
|
},
|
117
|
-
subtitle: "
|
120
|
+
subtitle: "Configure system preferences",
|
118
121
|
breadcrumbs: [
|
119
122
|
{ text: "Home", url: "/" },
|
120
123
|
{ text: "Admin", url: "/admin" },
|
121
|
-
{ text: "
|
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("
|
128
|
-
{ content: button_html("
|
130
|
+
{ content: button_html("Save", "primary") },
|
131
|
+
{ content: button_html("Cancel", "secondary") }
|
129
132
|
]
|
130
133
|
) %>
|
131
134
|
```
|
132
135
|
|
133
|
-
|
134
|
-
-
|
135
|
-
-
|
136
|
-
-
|
137
|
-
-
|
138
|
-
-
|
139
|
-
-
|
140
|
-
-
|
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
|
-
|
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
|
-
|
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
|
-
|
147
|
-
|
148
|
-
|
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
|
-
|
203
|
+
.bui-button-secondary {
|
204
|
+
// Override styles for .bui-button-secondary here
|
205
|
+
}
|
152
206
|
|
153
|
-
|
207
|
+
// Nested class overrides
|
208
|
+
.bui-button-with-icon {
|
209
|
+
.bui-icon {
|
210
|
+
// Override nested styles here
|
211
|
+
}
|
212
|
+
}
|
213
|
+
```
|
154
214
|
|
155
|
-
###
|
215
|
+
### Use the Initializer
|
156
216
|
|
157
|
-
|
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
|
-
###
|
231
|
+
### Customize Styles
|
172
232
|
|
173
|
-
|
233
|
+
Override CSS styles in your stylesheet:
|
174
234
|
|
175
235
|
```css
|
176
236
|
.better-ui-button-primary {
|
177
|
-
background-color: #8b5cf6; /*
|
237
|
+
background-color: #8b5cf6; /* Custom purple */
|
178
238
|
border-color: #8b5cf6;
|
179
239
|
}
|
180
240
|
```
|
181
241
|
|
182
|
-
## 🛠
|
242
|
+
## 🛠 Development
|
183
243
|
|
184
|
-
BetterUI
|
244
|
+
BetterUI uses an integrated dummy app for development and testing. Here's how to get started:
|
185
245
|
|
186
|
-
### Setup
|
246
|
+
### Initial Setup
|
187
247
|
|
188
248
|
```bash
|
189
|
-
#
|
249
|
+
# Clone the repository
|
190
250
|
git clone https://github.com/alessiobussolari/better_ui.git
|
191
251
|
cd better_ui
|
192
252
|
|
193
|
-
#
|
253
|
+
# Install dependencies
|
194
254
|
bin/setup
|
195
255
|
```
|
196
256
|
|
197
|
-
###
|
257
|
+
### Start the Test Application
|
198
258
|
|
199
|
-
|
259
|
+
To see components in action and work on documentation:
|
200
260
|
|
201
261
|
```bash
|
202
|
-
#
|
262
|
+
# Start the test server
|
203
263
|
cd test/dummy
|
204
264
|
bin/rails server
|
205
265
|
|
206
|
-
#
|
266
|
+
# Or from the main directory
|
207
267
|
bin/rails server -b 0.0.0.0
|
208
268
|
```
|
209
269
|
|
210
|
-
|
270
|
+
Visit `http://localhost:3000/better_ui` in your browser to see the documentation and test the components.
|
211
271
|
|
212
|
-
###
|
272
|
+
### Development Flow
|
213
273
|
|
214
|
-
1. **
|
215
|
-
2. **
|
216
|
-
3. **
|
217
|
-
4. **
|
218
|
-
5. **
|
219
|
-
6. **
|
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
|
281
|
+
### Build and Release
|
222
282
|
|
223
|
-
|
283
|
+
To build the gem locally:
|
224
284
|
|
225
285
|
```bash
|
226
286
|
bundle exec rake build
|
227
287
|
```
|
228
288
|
|
229
|
-
|
289
|
+
To install the development version:
|
230
290
|
|
231
291
|
```bash
|
232
292
|
bundle exec rake install
|
233
293
|
```
|
234
294
|
|
235
|
-
## 🤝
|
295
|
+
## 🤝 Contributing
|
236
296
|
|
237
|
-
|
297
|
+
Contributions are welcome and appreciated! Here's how you can help:
|
238
298
|
|
239
|
-
1. **Fork**
|
240
|
-
2. **
|
241
|
-
3. **
|
242
|
-
4. **
|
243
|
-
5. **
|
244
|
-
6.
|
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
|
-
###
|
306
|
+
### Guidelines
|
247
307
|
|
248
|
-
-
|
249
|
-
-
|
250
|
-
-
|
251
|
-
-
|
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
|
-
## 📄
|
313
|
+
## 📄 License
|
254
314
|
|
255
|
-
BetterUI
|
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
|
-
|
319
|
+
Made with ❤️ by [Alessio Bussolari](https://github.com/alessiobussolari)
|