Class: ViewComponent::ScopedStyles::Configuration
- Inherits:
-
Object
- Object
- ViewComponent::ScopedStyles::Configuration
- Defined in:
- lib/view_component/scoped_styles/configuration.rb
Overview
Global settings for ViewComponent::ScopedStyles.
Configure in an initializer:
ViewComponent::ScopedStyles.configure do |config|
config.components_path = File.join("app", "view_components")
config.assets_path = File.join("app", "assets", "stylesheets")
config.stylesheet_name = "components.scoped.css"
config.components_layer = "components"
end
Instance Attribute Summary collapse
-
#assets_path ⇒ String
Directory where the bundled scoped stylesheet is written, relative to Rails.root.
-
#components_layer ⇒ String?
Optional CSS cascade layer name for the bundled scoped stylesheet.
-
#components_path ⇒ String
Directory where ViewComponent classes live, relative to Rails.root.
-
#css_class_prefix ⇒ String
Prefix prepended to scoped class names (e.g. “c-” → “c-a1b2c3d4”).
-
#stylesheet_name ⇒ String
Filename of the bundled scoped stylesheet within #assets_path.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
44 45 46 47 48 49 50 |
# File 'lib/view_component/scoped_styles/configuration.rb', line 44 def initialize @components_path = File.join("app", "components") @assets_path = File.join("app", "assets", "stylesheets") @stylesheet_name = "components.scoped.css" @components_layer = nil @css_class_prefix = "c-" end |
Instance Attribute Details
#assets_path ⇒ String
Directory where the bundled scoped stylesheet is written, relative to Rails.root.
24 25 26 |
# File 'lib/view_component/scoped_styles/configuration.rb', line 24 def assets_path @assets_path end |
#components_layer ⇒ String?
Optional CSS cascade layer name for the bundled scoped stylesheet.
When set, the bundled stylesheet is wrapped in @layer <name> { … } so you can control specificity relative to other layers in your app.
37 38 39 |
# File 'lib/view_component/scoped_styles/configuration.rb', line 37 def components_layer @components_layer end |
#components_path ⇒ String
Directory where ViewComponent classes live, relative to Rails.root.
19 20 21 |
# File 'lib/view_component/scoped_styles/configuration.rb', line 19 def components_path @components_path end |
#css_class_prefix ⇒ String
Prefix prepended to scoped class names (e.g. “c-” → “c-a1b2c3d4”).
42 43 44 |
# File 'lib/view_component/scoped_styles/configuration.rb', line 42 def css_class_prefix @css_class_prefix end |
#stylesheet_name ⇒ String
Filename of the bundled scoped stylesheet within #assets_path.
29 30 31 |
# File 'lib/view_component/scoped_styles/configuration.rb', line 29 def stylesheet_name @stylesheet_name end |