Class: ViewComponent::ScopedStyles::Configuration

Inherits:
Object
  • Object
show all
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.components_layer = "components"
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



28
29
30
31
# File 'lib/view_component/scoped_styles/configuration.rb', line 28

def initialize
  @components_path = File.join("app", "components")
  @components_layer = nil
end

Instance Attribute Details

#components_layerString?

Optional CSS cascade layer name for generated styles in app/assets/stylesheets/components.scoped.css.

When set, the bundled stylesheet is wrapped in @layer <name> { … } so you can control specificity relative to other layers in your app.

Returns:

  • (String, nil)

    default: nil (no layer wrapper)



26
27
28
# File 'lib/view_component/scoped_styles/configuration.rb', line 26

def components_layer
  @components_layer
end

#components_pathString

Directory where ViewComponent classes live, relative to Rails.root.

Returns:

  • (String)

    default: “app/components”



17
18
19
# File 'lib/view_component/scoped_styles/configuration.rb', line 17

def components_path
  @components_path
end