view_component-scoped_styles 0.8.0 → 0.8.2
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 99036b6a74c47fa492904ea9d68dca4354d62f97071e45a6da2cc2ace09b4a70
|
|
4
|
+
data.tar.gz: 9d12f41dc240f8cc9b5b9526bd1462b17681edb64d4bcd85ef87c8863cdb7773
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 57fd226b7dad095ce6a37caf2cca43a8bc934ce9e8309c49f1409ce4956896330cf663c6eaaa59459655b0c850f212520c97b52bf81bb659795b7768f2e4fb76
|
|
7
|
+
data.tar.gz: 6dfb4eece1a9e1f18850fe239449462c436b5a8d07d0314203df954e212aaafc5a3e6833f017eef19075dfccc07b3becc9e607ee00d92e0d76b13d1baf3efbd7
|
data/README.md
CHANGED
|
@@ -70,12 +70,18 @@ With automatic stylesheet generation enabled in `config/application.rb`, `config
|
|
|
70
70
|
```ruby
|
|
71
71
|
# Ensure sidebar is enabled
|
|
72
72
|
config.view_component.generate.sidecar = true
|
|
73
|
-
#
|
|
74
|
-
config.
|
|
73
|
+
# Generate scoped stylesheets alongside components
|
|
74
|
+
config.generators do |g|
|
|
75
|
+
g.view_component stylesheet: true
|
|
76
|
+
end
|
|
75
77
|
```
|
|
76
78
|
|
|
77
79
|
`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.
|
|
78
80
|
|
|
81
|
+
Replace `config.view_component.generate.stylesheet = true` in existing apps with
|
|
82
|
+
the `config.generators` block above. ViewComponent does not support a `stylesheet`
|
|
83
|
+
configuration option and rejects it in versions with strict configuration validation.
|
|
84
|
+
|
|
79
85
|
```bash
|
|
80
86
|
bin/rails generate view_component:component Example title --sidecar
|
|
81
87
|
|
|
@@ -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: false
|
|
11
10
|
|
|
12
11
|
hook_for :stylesheet, type: :boolean
|
|
13
12
|
end
|
|
@@ -16,9 +16,12 @@ module ViewComponent
|
|
|
16
16
|
component_class.instance_variable_get(:@component_id)
|
|
17
17
|
styles = component_class.component_styles
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
FileUtils.mkdir_p(File.dirname(stylesheet_path))
|
|
20
|
+
File.open("#{stylesheet_path}.lock", "a") do |lock|
|
|
21
|
+
lock.flock(File::LOCK_EX)
|
|
22
|
+
ensure_stylesheet_exists!
|
|
23
|
+
update_stylesheet_with(component_name, styles)
|
|
24
|
+
end
|
|
22
25
|
end
|
|
23
26
|
|
|
24
27
|
private
|
|
@@ -26,7 +29,6 @@ module ViewComponent
|
|
|
26
29
|
def ensure_stylesheet_exists!
|
|
27
30
|
return if File.exist?(stylesheet_path)
|
|
28
31
|
|
|
29
|
-
FileUtils.mkdir_p(File.dirname(stylesheet_path))
|
|
30
32
|
File.write(stylesheet_path, initial_content)
|
|
31
33
|
end
|
|
32
34
|
|
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.2
|
|
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: []
|