Sha256: 78b8e32999e20695c14ea02c6e2bb9c2631804d974343052b775c1ef8ca84050

Contents?: true

Size: 503 Bytes

Versions: 9

Compression:

Stored size: 503 Bytes

Contents

# frozen_string_literal: true

class Proscenium::CssModule
  def initialize(path)
    @path = "#{path}.module.css"

    return unless Rails.application.config.proscenium.side_load

    Proscenium::SideLoad.append! Rails.root.join(@path)
  end

  # Returns an Array of class names generated from the given CSS module `names`.
  def class_names(*names)
    names.flatten.compact.map { |name| "#{name}#{hash}" }
  end

  private

  def hash
    @hash ||= Digest::SHA1.hexdigest("/#{@path}")[..7]
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
proscenium-0.1.0.alpha3-arm64-darwin lib/proscenium/css_module.rb
proscenium-0.1.0.alpha3-x86_64-darwin lib/proscenium/css_module.rb
proscenium-0.1.0.alpha3-x86_64-linux lib/proscenium/css_module.rb
proscenium-0.1.0.alpha2-x86_64-linux lib/proscenium/css_module.rb
proscenium-0.1.0.alpha2-x86_64-darwin lib/proscenium/css_module.rb
proscenium-0.1.0.alpha2-arm64-darwin lib/proscenium/css_module.rb
proscenium-0.1.0.alpha1-x86_64-linux lib/proscenium/css_module.rb
proscenium-0.1.0.alpha1-x86_64-darwin lib/proscenium/css_module.rb
proscenium-0.1.0.alpha1-arm64-darwin lib/proscenium/css_module.rb