Sha256: 86aa4c085c0e436c52ed1ff4aa8a212f99b7c1797b21db0f3094e1129535a58d

Contents?: true

Size: 708 Bytes

Versions: 7

Compression:

Stored size: 708 Bytes

Contents

# frozen_string_literal: true

require 'action_view'

module ::AmberComponent
  module Helpers
    # Adds a few utility methods for working with CSS
    # inside components.
    module CssHelper
      # Helper method which creates a name for a css class or id
      # which is scoped to the current component class.
      #
      #   self.class #=> Navigation::DropdownMenuComponent
      #   css_id(:list_item) #=> "navigation-dropdown_menu_component--list_item"
      #
      # @param name [String, Symbol]
      # @return [String]
      def css_identifier(name)
        "#{self.class.name.underscore.gsub('/', '-')}--#{name.to_s.underscore}"
      end

      alias css_id css_identifier
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
amber_component-1.2.0 lib/amber_component/helpers/css_helper.rb
amber_component-1.1.1 lib/amber_component/helpers/css_helper.rb
amber_component-1.1.0 lib/amber_component/helpers/css_helper.rb
amber_component-1.0.0 lib/amber_component/helpers/css_helper.rb
amber_component-0.0.5 lib/amber_component/helpers/css_helper.rb
amber_component-0.0.4 lib/amber_component/helpers/css_helper.rb
amber_component-0.0.3 lib/amber_component/helpers/css_helper.rb