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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02fd9e64f88c0ae8270f7891857c1d3de61489da4a90894347d215395c22f09a
4
- data.tar.gz: a7888a8e95b7e44e4d4ec0da67fedce961c8b84b3b4fea343a35e4dc3864592d
3
+ metadata.gz: 436386cb9aedd0c0d4210ee7d89273f2f1edb3b7113a9623af14c2ca52154dc9
4
+ data.tar.gz: 8e4648b61fca5e049180035807b8369099b91487b4edd7e963dadd5c0fb4c586
5
5
  SHA512:
6
- metadata.gz: 343cc0a615f1e5454d4f2f1f989ca5f3e3348288f46954ebc26958f74e2ca2a24ac44fbdd553e3cc511ce5e1d5adb92efc5b22bf1066b7aa9fbd5b4af5b56afb
7
- data.tar.gz: adfddca0b82cb569fef6e98b080a12879aa768700f37410f63b96fae8390745c9a24c3aad9ee5af63bc2cff6eeba6291733b40c2299276b6cbe1d720c2579b9f
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
- Add this line to your application's Gemfile:
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
- And then execute:
25
+ Then run:
24
26
 
25
27
  ```bash
26
28
  bundle install
27
- rails generate ui:install
28
29
  ```
29
30
 
30
- The installer will automatically detect your asset pipeline and configure the engine appropriately.
31
+ ### JavaScript (Importmaps)
31
32
 
32
- ## Usage
33
+ For Rails 7+ with importmaps, pin the engine in `config/importmap.rb`:
33
34
 
34
- The UI Engine provides CSS variables, Stimulus controllers, and components. You configure Tailwind CSS in your application, and the installer does this automatically.
35
+ ```ruby
36
+ pin "ui", to: "ui.esm.js", preload: true
37
+ pin_all_from "ui/controllers", under: "ui/controllers"
38
+ ```
35
39
 
36
- ### JavaScript Integration
40
+ The gem automatically provides these pins via the engine.
37
41
 
38
- The engine supports two approaches for JavaScript integration:
42
+ ### JavaScript (jsbundling-rails)
39
43
 
40
- #### **Option 1: Importmaps (Rails 8 Default, Zero-Build)**
44
+ For apps using Bun, esbuild, or Webpack:
41
45
 
42
- The engine automatically configures importmap pins. Just import and use:
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
- #### **Option 2: JavaScript Bundlers (Bun, esbuild, Webpack)**
62
+ ### CSS (cssbundling-rails)
58
63
 
59
- Install the engine as an npm package:
64
+ For apps using cssbundling-rails, use the generators to get UI css copied and then imported automatically.
60
65
 
61
66
  ```bash
62
- bun add @ui/engine
63
- # or
64
- npm install @ui/engine
67
+ rails generate ui:css
68
+ rails generate ui:install
65
69
  ```
66
70
 
67
- Then import in your bundled JavaScript:
71
+ ### CSS (Propshaft/Sprockets)
68
72
 
69
- ```javascript
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
- const application = Application.start()
75
+ ```css
76
+ @import "tailwindcss";
77
+ @import "ui/application.css";
75
78
 
76
- // Register all UI controllers
77
- UI.registerControllers(application)
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 from Main Module**
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 Directly from Controller Files (Importmap)**
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
- **Tree-shaking** - Bundlers eliminate unused code
123
- **Flexibility** - Choose exactly what to import
124
- **Performance** - Load only what you need
125
- **Compatibility** - Works with both importmaps and bundlers
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
- └── stylesheets/ui/
239
- └── application.css # CSS variables (shipped with gem)
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 available)
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 available)
256
+ ├── view_components/ui/ # ViewComponents (loaded if view_component >= 3.0)
247
257
  │ ├── button_component.rb
248
258
  │ └── ...
249
259
  ├── javascript/ui/
250
- └── index.js # JavaScript entry point
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 # UI.configure settings
265
- └── engine.rb # Engine configuration
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. The generator creates `app/assets/stylesheets/application.tailwind.css`:
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 ENGINE files for Tailwind classes */
370
- @source "../../../../../app/javascript/**/*.js"; /* If local gem */
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 */