Sha256: ef2de2657eceaebfeaac66406a79eeb6f0af3318b4bb399c860769d75da4fb02

Contents?: true

Size: 712 Bytes

Versions: 20

Compression:

Stored size: 712 Bytes

Contents

# frozen_string_literal: true

module Proscenium::CssModule
  extend ActiveSupport::Autoload

  autoload :Path
  autoload :Transformer

  class TransformError < StandardError
    def initialize(name, additional_msg = nil)
      msg = "Failed to transform CSS module `#{name}`"
      msg << ' - ' << additional_msg if additional_msg

      super msg
    end
  end

  # Accepts one or more CSS class names, and transforms them into CSS module names.
  #
  # @param name [String,Symbol,Array<String,Symbol>]
  def css_module(*names)
    cssm.class_names(*names, require_prefix: false).map { |name, _| name }.join(' ')
  end

  private

  def cssm
    @cssm ||= Transformer.new(self.class.css_module_path)
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
proscenium-0.11.0-x86_64-linux lib/proscenium/css_module.rb
proscenium-0.11.0-aarch64-linux lib/proscenium/css_module.rb
proscenium-0.11.0-arm64-darwin lib/proscenium/css_module.rb
proscenium-0.11.0-x86_64-darwin lib/proscenium/css_module.rb
proscenium-0.11.0.pre.13-x86_64-linux lib/proscenium/css_module.rb
proscenium-0.11.0.pre.13-aarch64-linux lib/proscenium/css_module.rb
proscenium-0.11.0.pre.13-arm64-darwin lib/proscenium/css_module.rb
proscenium-0.11.0.pre.13-x86_64-darwin lib/proscenium/css_module.rb
proscenium-0.11.0.pre.12-x86_64-linux lib/proscenium/css_module.rb
proscenium-0.11.0.pre.12-aarch64-linux lib/proscenium/css_module.rb
proscenium-0.11.0.pre.12-arm64-darwin lib/proscenium/css_module.rb
proscenium-0.11.0.pre.12-x86_64-darwin lib/proscenium/css_module.rb
proscenium-0.11.0.pre.11-x86_64-linux lib/proscenium/css_module.rb
proscenium-0.11.0.pre.11-aarch64-linux lib/proscenium/css_module.rb
proscenium-0.11.0.pre.11-arm64-darwin lib/proscenium/css_module.rb
proscenium-0.11.0.pre.11-x86_64-darwin lib/proscenium/css_module.rb
proscenium-0.11.0.pre.10-x86_64-linux lib/proscenium/css_module.rb
proscenium-0.11.0.pre.10-aarch64-linux lib/proscenium/css_module.rb
proscenium-0.11.0.pre.10-arm64-darwin lib/proscenium/css_module.rb
proscenium-0.11.0.pre.10-x86_64-darwin lib/proscenium/css_module.rb