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 +4 -4
- data/README.md +17 -6
- data/lib/generators/view_component/scoped_styles/templates/view_component_scoped_styles.rb.tt +5 -3
- data/lib/view_component/scoped_styles/component_generator_hook.rb +1 -2
- data/lib/view_component/scoped_styles/railtie.rb +11 -1
- data/lib/view_component/scoped_styles/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 11d8e3379f898df14de704b6cf85d52511347b83968941fe15b1f50c40f4e84b
|
|
4
|
+
data.tar.gz: 8f6ca431aad7a2ef07953a913f0819fb01c5c07aaf8332ecd4874c013cd4e766
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
config.view_component.generate.stylesheet = true
|
|
78
|
+
config.generators do |g|
|
|
79
|
+
g.component stylesheet: false
|
|
80
|
+
end
|
|
75
81
|
```
|
|
76
82
|
|
|
77
|
-
|
|
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
|
data/lib/generators/view_component/scoped_styles/templates/view_component_scoped_styles.rb.tt
CHANGED
|
@@ -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
|
|
4
|
+
# Ensure sidecar is enabled
|
|
5
5
|
# config.view_component.generate.sidecar = true
|
|
6
|
-
#
|
|
7
|
-
# config.
|
|
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
|
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.
|
|
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.
|
|
149
|
+
rubygems_version: 4.0.20
|
|
150
150
|
specification_version: 4
|
|
151
151
|
summary: Scoped, colocated CSS for ViewComponent components.
|
|
152
152
|
test_files: []
|