Sha256: 00f73d3f21437fa2f35e15716a02e94bb82a7946de08e96de893886687f56648

Contents?: true

Size: 847 Bytes

Versions: 23

Compression:

Stored size: 847 Bytes

Contents

# frozen_string_literal: true

module Proscenium::CssModule
  extend ActiveSupport::Autoload

  class StylesheetNotFound < StandardError
    def initialize(pathname)
      @pathname = pathname
      super
    end

    def message
      "Stylesheet is required, but does not exist: #{@pathname}"
    end
  end

  autoload :ClassNamesResolver
  autoload :Resolver # deprecated

  # Like `css_modules`, but will raise if the stylesheet cannot be found.
  #
  # @param name [Array, String]
  def css_module!(names)
    cssm.class_names!(names).join ' '
  end

  # Accepts one or more CSS class names, and transforms them into CSS module names.
  #
  # @param name [Array, String]
  def css_module(names)
    cssm.class_names(names).join ' '
  end

  private

  def path
    self.class.path
  end

  def cssm
    @cssm ||= Resolver.new(path)
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
proscenium-0.10.0-x86_64-linux lib/proscenium/css_module.rb
proscenium-0.10.0-aarch64-linux lib/proscenium/css_module.rb
proscenium-0.10.0-arm64-darwin lib/proscenium/css_module.rb
proscenium-0.10.0-x86_64-darwin lib/proscenium/css_module.rb
proscenium-0.9.1-x86_64-linux lib/proscenium/css_module.rb
proscenium-0.9.1-aarch64-linux lib/proscenium/css_module.rb
proscenium-0.9.1-arm64-darwin lib/proscenium/css_module.rb
proscenium-0.9.1-x86_64-darwin lib/proscenium/css_module.rb
proscenium-0.9.0-x86_64-linux lib/proscenium/css_module.rb
proscenium-0.9.0-aarch64-linux lib/proscenium/css_module.rb
proscenium-0.9.0-arm64-darwin lib/proscenium/css_module.rb
proscenium-0.9.0-x86_64-darwin lib/proscenium/css_module.rb
proscenium-0.8.2-x86_64-linux lib/proscenium/css_module.rb
proscenium-0.8.2-aarch64-linux lib/proscenium/css_module.rb
proscenium-0.8.2-arm64-darwin lib/proscenium/css_module.rb
proscenium-0.8.2-x86_64-darwin lib/proscenium/css_module.rb
proscenium-0.8.0-aarch64-linux lib/proscenium/css_module.rb
proscenium-0.8.0-arm64-darwin lib/proscenium/css_module.rb
proscenium-0.8.0-x86_64-darwin lib/proscenium/css_module.rb
proscenium-0.7.0-x86_64-linux lib/proscenium/css_module.rb