fernandes-ui 0.1.0 → 0.1.1
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 +61 -61
- data/app/assets/stylesheets/ui/application.css +621 -3
- data/lib/generators/ui/css_generator.rb +58 -0
- data/lib/generators/ui/install_generator.rb +140 -0
- data/lib/ui/version.rb +1 -1
- metadata +3 -3
- data/app/assets/stylesheets/ui/sonner.css +0 -610
- data/lib/generators/ui/install/install_generator.rb +0 -141
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 436386cb9aedd0c0d4210ee7d89273f2f1edb3b7113a9623af14c2ca52154dc9
|
|
4
|
+
data.tar.gz: 8e4648b61fca5e049180035807b8369099b91487b4edd7e963dadd5c0fb4c586
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3e0f6d156f7396006300fb59f63fff5d541da6a4af4903ce5c77dea65b29ae56a8becbf699a6be115345f57c5322453d44e344e282213bd314e01c71cc7d8e70
|
|
7
|
+
data.tar.gz: b9a1b0896a7ec775734ca5879b423c71b46ef2b984b0b2f234a2ee26bd11a3475b12ad32b853358be467b67379931b16ea5e9065230c60d2f28bdf1634d9e040
|
data/README.md
CHANGED
|
@@ -14,85 +14,93 @@ A Rails engine providing a component library with Tailwind CSS 4 support. Design
|
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
### Ruby Gem
|
|
18
|
+
|
|
19
|
+
Add to your Gemfile:
|
|
18
20
|
|
|
19
21
|
```ruby
|
|
20
|
-
gem "ui"
|
|
22
|
+
gem "fernandes-ui"
|
|
21
23
|
```
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
Then run:
|
|
24
26
|
|
|
25
27
|
```bash
|
|
26
28
|
bundle install
|
|
27
|
-
rails generate ui:install
|
|
28
29
|
```
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
### JavaScript (Importmaps)
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
For Rails 7+ with importmaps, pin the engine in `config/importmap.rb`:
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
```ruby
|
|
36
|
+
pin "ui", to: "ui.esm.js", preload: true
|
|
37
|
+
pin_all_from "ui/controllers", under: "ui/controllers"
|
|
38
|
+
```
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
The gem automatically provides these pins via the engine.
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
### JavaScript (jsbundling-rails)
|
|
39
43
|
|
|
40
|
-
|
|
44
|
+
For apps using Bun, esbuild, or Webpack:
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
```bash
|
|
47
|
+
bun add @fernandes/ui
|
|
48
|
+
# or
|
|
49
|
+
npm install @fernandes/ui
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Then import in your JavaScript:
|
|
43
53
|
|
|
44
54
|
```javascript
|
|
45
|
-
// app/javascript/application.js
|
|
46
55
|
import { Application } from "@hotwired/stimulus"
|
|
47
|
-
import * as UI from "ui"
|
|
56
|
+
import * as UI from "@fernandes/ui"
|
|
48
57
|
|
|
49
58
|
const application = Application.start()
|
|
50
|
-
|
|
51
|
-
// Register all UI controllers
|
|
52
59
|
UI.registerControllers(application)
|
|
53
|
-
|
|
54
|
-
console.log("UI Engine version:", UI.version)
|
|
55
60
|
```
|
|
56
61
|
|
|
57
|
-
|
|
62
|
+
### CSS (cssbundling-rails)
|
|
58
63
|
|
|
59
|
-
|
|
64
|
+
For apps using cssbundling-rails, use the generators to get UI css copied and then imported automatically.
|
|
60
65
|
|
|
61
66
|
```bash
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
npm install @ui/engine
|
|
67
|
+
rails generate ui:css
|
|
68
|
+
rails generate ui:install
|
|
65
69
|
```
|
|
66
70
|
|
|
67
|
-
|
|
71
|
+
### CSS (Propshaft/Sprockets)
|
|
68
72
|
|
|
69
|
-
|
|
70
|
-
// app/javascript/application.js
|
|
71
|
-
import { Application } from "@hotwired/stimulus"
|
|
72
|
-
import * as UI from "@ui/engine"
|
|
73
|
+
For apps using asset pipeline without bundler, import in your Tailwind config:
|
|
73
74
|
|
|
74
|
-
|
|
75
|
+
```css
|
|
76
|
+
@import "tailwindcss";
|
|
77
|
+
@import "ui/application.css";
|
|
75
78
|
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
/* Scan bundled gem files */
|
|
80
|
+
@source "../../../.bundle/ruby/*/gems/fernandes-ui-*/app/**/*.{erb,rb,js}";
|
|
78
81
|
```
|
|
79
82
|
|
|
83
|
+
## Usage
|
|
84
|
+
|
|
85
|
+
The UI Engine provides CSS variables, Stimulus controllers, and components. You configure Tailwind CSS in your application to scan the engine files.
|
|
86
|
+
|
|
80
87
|
### Selective Controller Import
|
|
81
88
|
|
|
82
89
|
You can import only the controllers you need for better performance and tree-shaking:
|
|
83
90
|
|
|
84
|
-
#### **Import Individual Controllers
|
|
91
|
+
#### **Import Individual Controllers**
|
|
85
92
|
|
|
86
93
|
```javascript
|
|
94
|
+
// With jsbundling-rails
|
|
87
95
|
import { Application } from "@hotwired/stimulus"
|
|
88
|
-
import { HelloController, DropdownController } from "ui"
|
|
96
|
+
import { HelloController, DropdownController } from "@fernandes/ui"
|
|
89
97
|
|
|
90
98
|
const application = Application.start()
|
|
91
99
|
application.register("ui--hello", HelloController)
|
|
92
100
|
application.register("ui--dropdown", DropdownController)
|
|
93
101
|
```
|
|
94
102
|
|
|
95
|
-
#### **Import
|
|
103
|
+
#### **Import from Controller Files (Importmaps)**
|
|
96
104
|
|
|
97
105
|
```javascript
|
|
98
106
|
import { Application } from "@hotwired/stimulus"
|
|
@@ -106,23 +114,22 @@ application.register("ui--hello", HelloController)
|
|
|
106
114
|
|
|
107
115
|
```javascript
|
|
108
116
|
import { Application } from "@hotwired/stimulus"
|
|
109
|
-
import { HelloController, registerControllersInto } from "ui"
|
|
117
|
+
import { HelloController, registerControllersInto } from "@fernandes/ui"
|
|
110
118
|
|
|
111
119
|
const application = Application.start()
|
|
112
120
|
|
|
113
121
|
// Register only specific controllers
|
|
114
122
|
registerControllersInto(application, {
|
|
115
123
|
"ui--hello": HelloController
|
|
116
|
-
// Don't register DropdownController
|
|
117
124
|
})
|
|
118
125
|
```
|
|
119
126
|
|
|
120
127
|
### Benefits of Selective Import
|
|
121
128
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
129
|
+
- **Tree-shaking** - Bundlers eliminate unused code
|
|
130
|
+
- **Flexibility** - Choose exactly what to import
|
|
131
|
+
- **Performance** - Load only what you need
|
|
132
|
+
- **Compatibility** - Works with both importmaps and bundlers
|
|
126
133
|
|
|
127
134
|
## Available Components
|
|
128
135
|
|
|
@@ -235,19 +242,24 @@ bun run build:css:prod
|
|
|
235
242
|
```
|
|
236
243
|
app/
|
|
237
244
|
├── assets/
|
|
238
|
-
│
|
|
239
|
-
│
|
|
245
|
+
│ ├── stylesheets/ui/
|
|
246
|
+
│ │ └── application.css # CSS variables (shipped with gem)
|
|
247
|
+
│ └── javascripts/
|
|
248
|
+
│ ├── ui.js # UMD bundle
|
|
249
|
+
│ └── ui.esm.js # ESM bundle
|
|
240
250
|
├── behaviors/ui/ # Shared behavior modules (always loaded)
|
|
241
251
|
│ ├── button_behavior.rb
|
|
242
252
|
│ └── ...
|
|
243
|
-
├── components/ui/ # Phlex components (loaded if phlex-rails
|
|
253
|
+
├── components/ui/ # Phlex components (loaded if phlex-rails >= 2.0)
|
|
244
254
|
│ ├── button.rb
|
|
245
255
|
│ └── ...
|
|
246
|
-
├── view_components/ui/ # ViewComponents (loaded if view_component
|
|
256
|
+
├── view_components/ui/ # ViewComponents (loaded if view_component >= 3.0)
|
|
247
257
|
│ ├── button_component.rb
|
|
248
258
|
│ └── ...
|
|
249
259
|
├── javascript/ui/
|
|
250
|
-
│
|
|
260
|
+
│ ├── index.js # JavaScript entry point
|
|
261
|
+
│ ├── controllers/ # Stimulus controllers
|
|
262
|
+
│ └── utils/ # Utility modules
|
|
251
263
|
├── views/ui/ # ERB partials (always available)
|
|
252
264
|
│ ├── _button.html.erb
|
|
253
265
|
│ └── ...
|
|
@@ -257,17 +269,9 @@ config/
|
|
|
257
269
|
└── importmap.rb # Importmap pins for JS modules
|
|
258
270
|
|
|
259
271
|
lib/
|
|
260
|
-
├── generators/ui/install/
|
|
261
|
-
│ ├── install_generator.rb # Installation generator
|
|
262
|
-
│ └── templates/ # Templates for host app setup
|
|
263
272
|
└── ui/
|
|
264
|
-
├── configuration.rb
|
|
265
|
-
└── engine.rb
|
|
266
|
-
|
|
267
|
-
test/dummy/ # Test application
|
|
268
|
-
├── app/assets/stylesheets/
|
|
269
|
-
│ └── application.tailwind.css # Tailwind config (NOT in engine!)
|
|
270
|
-
└── package.json # Tailwind CLI (NOT in engine!)
|
|
273
|
+
├── configuration.rb # UI.configure settings
|
|
274
|
+
└── engine.rb # Engine configuration
|
|
271
275
|
```
|
|
272
276
|
|
|
273
277
|
## Component Formats
|
|
@@ -356,7 +360,7 @@ This approach:
|
|
|
356
360
|
|
|
357
361
|
## Tailwind CSS 4 Configuration
|
|
358
362
|
|
|
359
|
-
Your application (not the engine) configures Tailwind.
|
|
363
|
+
Your application (not the engine) configures Tailwind. Create `app/assets/stylesheets/application.tailwind.css`:
|
|
360
364
|
|
|
361
365
|
```css
|
|
362
366
|
@import "tailwindcss";
|
|
@@ -366,12 +370,8 @@ Your application (not the engine) configures Tailwind. The generator creates `ap
|
|
|
366
370
|
@source "../../javascript/**/*.js";
|
|
367
371
|
@source "../../views/**/*.erb";
|
|
368
372
|
|
|
369
|
-
/* Scan
|
|
370
|
-
@source "
|
|
371
|
-
@source "../../../../../app/views/**/*.erb"; /* If local gem */
|
|
372
|
-
|
|
373
|
-
/* Or scan bundled gem (adjust path as needed) */
|
|
374
|
-
@source "../../../.bundle/ruby/*/gems/ui-*/app/**/*.{erb,rb,js}";
|
|
373
|
+
/* Scan bundled gem files */
|
|
374
|
+
@source "../../../.bundle/ruby/*/gems/fernandes-ui-*/app/**/*.{erb,rb,js}";
|
|
375
375
|
|
|
376
376
|
@theme {
|
|
377
377
|
/* Customize using engine variables */
|