Sha256: 1a58da0b54f102d16af88716956ed362a4ed4ab2dd8e8c9a779520d39ccfe396
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 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 class_methods do def component_css_tag ViewComponentScopedCss::CurrentContext.render_if_need(self) 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, **tag_options, &block) safe_join( [ self.class.component_css_tag, content_tag( name, class: [self.class.component_identifier_for_css, tag_options[:class]].compact.join(" "), **component_options, &block ) ].compact ) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
view_component_scoped_css-0.2.0 | lib/view_component_scoped_css/base.rb |