Sha256: caeec649c81453e4fb2abecbe9e68f956b0dc66f8387b49c3d4a81263ad2bb68
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true module ViewComponentScopedCss # # A class for providing styles to a view component. # If you include this class, you will be able to describe scss in the namespace of each component # module Base extend ActiveSupport::Concern included do include ViewComponentScopedCss::Hook end class_methods do def reload_component_css_tag @component_css_tag = ViewComponentScopedCss::Tag.new(self).call end def component_css_tag @component_css_tag ||= ViewComponentScopedCss::Tag.new(self).call end def component_identifier @component_identifier ||= name.sub("::Component", "").underscore.split("/").join("::") end def component_identifier_for_css @component_identifier_for_css ||= ["viewcomponent", component_identifier, "component"].compact.join("::") end end def component_options {} end def component_tag_class self.class.component_identifier_for_css end def component_tag(name = ViewComponentScopedCss.config.component_tag, &block) content_tag( name, class: [self.class.component_identifier_for_css, component_options[:class]].compact.join(" "), **component_options, &block ) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
view_component_scoped_css-0.1.1 | lib/view_component_scoped_css/base.rb |
view_component_scoped_css-0.1.0 | lib/view_component_scoped_css/base.rb |