view_component-scoped_styles 0.8.1 → 0.8.3

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: 7a5b9375fce9459d0ff5176843540baf0af45fc19c75771f9e55a23bd400f0ad
4
- data.tar.gz: b153dd8c88aabf25dbfdbcb1a74584f35a7c58a57b1394de77fad68765f16b18
3
+ metadata.gz: 11d8e3379f898df14de704b6cf85d52511347b83968941fe15b1f50c40f4e84b
4
+ data.tar.gz: 8f6ca431aad7a2ef07953a913f0819fb01c5c07aaf8332ecd4874c013cd4e766
5
5
  SHA512:
6
- metadata.gz: b43ff7e5452e2cddfe8e40dcabcffe184dcab1ca0d8a43bc037689b6c3b742440a3eba4805ad17727304b1e5404739638d13c45f45eed4e965bf10861a3ed2c4
7
- data.tar.gz: c53b57921b99b62b247f080087152056dcefc9529dbe00b5c213fa5ce8511baadcd906739991fba0c72b4d96e23f2733dce637ec3084134c6e0e4112c22a50d4
6
+ metadata.gz: e7185f8787fe5e6a1da003263da693223521b2f710269c426d936af8df6f6b9268450450ff1e2d8a8e10c5b49667b76649e3b0d4c439422514ddba45703378c1
7
+ data.tar.gz: e26733e488cac418042f5ebf920bf670e06592c1df023044f8587db4b64db108abe067c8a82c7cc46d305b6569bf1555baa69955c0145021c78b0a2e233a4921
data/README.md CHANGED
@@ -65,16 +65,27 @@ Learn more about sidecar [here](https://viewcomponent.org/guide/generators.html#
65
65
  bin/rails generate view_component:component Example title --sidecar
66
66
  ```
67
67
 
68
- With automatic stylesheet generation enabled in `config/application.rb`, `config/ENVIRONMENT.rb`, or wherever you configure ViewComponent:
68
+ `view_component:component` creates a `.css` file by default, adds
69
+ `include ViewComponent::ScopedStyles` to the component class, and sets
70
+ `class="<%= component_class %>"` on the generated ERB template. With `--sidecar`,
71
+ the stylesheet is placed in the sidecar directory. No stylesheet configuration
72
+ is needed.
73
+
74
+ Pass `--no-stylesheet` to skip CSS generation for one component. To disable it
75
+ for the app, add this to `config/application.rb`:
69
76
 
70
77
  ```ruby
71
- # Ensure sidebar is enabled
72
- config.view_component.generate.sidecar = true
73
- # Then generate stylesheets via
74
- config.view_component.generate.stylesheet = true
78
+ config.generators do |g|
79
+ g.component stylesheet: false
80
+ end
75
81
  ```
76
82
 
77
- `view_component:component` also creates the sidecar `.css` file, adds `include ViewComponent::ScopedStyles` to the component class, and sets `class="<%= component_class %>"` on the generated ERB template. You can pass `--no-stylesheet` to skip CSS generation for a single component.
83
+ Pass `--stylesheet` to generate CSS when the app default is disabled. You can
84
+ also use `g.view_component stylesheet: false`. Settings under `g.component`
85
+ take precedence, including an explicit `false`.
86
+
87
+ Remove `config.view_component.generate.stylesheet = true` from existing apps.
88
+ ViewComponent does not support that option and rejects it starting in 4.21.
78
89
 
79
90
  ```bash
80
91
  bin/rails generate view_component:component Example title --sidecar
@@ -1,10 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Optional ViewComponent generator settings (in config/application.rb, config/ENVIRONMENT.rb, or wherever you configure ViewComponent):
4
- # Ensure sidebar is enabled
4
+ # Ensure sidecar is enabled
5
5
  # config.view_component.generate.sidecar = true
6
- # Then generate stylesheets via
7
- # config.view_component.generate.stylesheet = true
6
+ # Scoped stylesheets are generated by default. To disable generation:
7
+ # config.generators do |g|
8
+ # g.component stylesheet: false
9
+ # end
8
10
 
9
11
  ViewComponent::ScopedStyles.configure do |config|
10
12
  # Where ViewComponent classes live (relative to Rails.root). Default: "app/components"
@@ -6,8 +6,7 @@ require "generators/view_component/component/component_generator"
6
6
  module ViewComponent
7
7
  module Generators
8
8
  class ComponentGenerator
9
- class_option :stylesheet, type: :boolean,
10
- default: ViewComponent::Base.config.generate.stylesheet
9
+ class_option :stylesheet, type: :boolean, default: true
11
10
 
12
11
  hook_for :stylesheet, type: :boolean
13
12
  end
@@ -6,8 +6,18 @@ require "rails/railtie"
6
6
  module ViewComponent
7
7
  module ScopedStyles
8
8
  class Railtie < Rails::Railtie
9
- generators do
9
+ generators do |app|
10
10
  require_relative "component_generator_hook"
11
+
12
+ options = app.config.generators.options
13
+ namespace = %i[component view_component rails].find do |name|
14
+ options.fetch(name, {}).key?(:stylesheet)
15
+ end
16
+ default = namespace ? options[namespace][:stylesheet] : true
17
+
18
+ ViewComponent::Generators::ComponentGenerator.class_option(
19
+ :stylesheet, type: :boolean, default: default
20
+ )
11
21
  end
12
22
 
13
23
  config.after_initialize do
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ViewComponent
4
4
  module ScopedStyles
5
- VERSION = "0.8.1"
5
+ VERSION = "0.8.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component-scoped_styles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Edwards
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  - !ruby/object:Gem::Version
147
147
  version: '0'
148
148
  requirements: []
149
- rubygems_version: 4.0.10
149
+ rubygems_version: 4.0.20
150
150
  specification_version: 4
151
151
  summary: Scoped, colocated CSS for ViewComponent components.
152
152
  test_files: []