proscenium 0.12.0-x86_64-linux → 0.13.0-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b1f55f355634fb97a5426b2c4c7cac21138cd0d92d3644d767f7865746fc1c6
4
- data.tar.gz: a8ff6d75ba6e92654b1cd0f6d71e59bc976cb0194ae79c787e409defe78184cb
3
+ metadata.gz: 8b06b3f27b0e88ebb7099a1808384cddb0571d3076ad837639da2a35961c1d54
4
+ data.tar.gz: 70f56abacaed489a8811632e80cd7e8c35a79299f3a2a92b7f2a37bf317f46dd
5
5
  SHA512:
6
- metadata.gz: 65cd3db84bd43ec4cf43437fbee1de74bb58f58a8b945a38aa23008bc5b8abfaca26b6763dbd51930f43903ab53077b17e9f575944de3e472d98b16e1604c13b
7
- data.tar.gz: 1b24eaadcb999f60851b4c53c7285b067b63764b8cc62f5fcc9f98a8f930c4adc9f628f4763f0dbefcc08abefa078bac08dc84fc088bb88c576a2bc60ca1e6cf
6
+ metadata.gz: 8f6752edbf44f243a3b81f852f5d825ea206140fbf2b2d595834ed9af7b8780284370cd4ab643f44f4ed030996a9d0a3afc2ebe71affc70557f3b6e156531f17
7
+ data.tar.gz: 46751b69cdbfc67faf5964f360e8b66a1fbb34958368a1fbb48bdc67c93a63b177c8c5daedd86f39101dd2e2f269a878277b3b8a979f1b8e121efe0c5bac9af3
data/README.md CHANGED
@@ -552,6 +552,13 @@ css_module 'mypackage/button@big_button'
552
552
  # => "big_button"
553
553
  ```
554
554
 
555
+ `css_module` also accepts a `path` keyword argument, which allows you to specify the path to the CSS
556
+ file. Note that this will use the given path for all class names passed to that instance of `css_module`.
557
+
558
+ ```ruby
559
+ css_module :my_module_name, path: Rails.root.join('app/components/button.css')
560
+ ```
561
+
555
562
  #### In your JavaScript
556
563
 
557
564
  Importing a CSS module from JS will automatically append the stylesheet to the document's head. And the result of the import will be an object of CSS class to module names.
@@ -18,16 +18,20 @@ module Proscenium::CssModule
18
18
  # Accepts one or more CSS class names, and transforms them into CSS module names.
19
19
  #
20
20
  # @param name [String,Symbol,Array<String,Symbol>]
21
+ # @param path [Pathname] the path to the CSS module file to use for the transformation.
21
22
  # @return [String] the transformed CSS module names concatenated as a string.
22
- def css_module(*names)
23
- cssm.class_names(*names, require_prefix: false).map { |name, _| name }.join(' ')
23
+ def css_module(*names, path: nil)
24
+ transformer = path.nil? ? cssm : Transformer.new(path)
25
+ transformer.class_names(*names, require_prefix: false).map { |name, _| name }.join(' ')
24
26
  end
25
27
 
26
28
  # @param name [String,Symbol,Array<String,Symbol>]
29
+ # @param path [Pathname] the path to the CSS file to use for the transformation.
27
30
  # @return [String] the transformed CSS module names concatenated as a string.
28
- def class_names(*names)
31
+ def class_names(*names, path: nil)
29
32
  names = names.flatten.compact
30
- cssm.class_names(*names).map { |name, _| name }.join(' ') unless names.empty?
33
+ transformer = path.nil? ? cssm : Transformer.new(path)
34
+ transformer.class_names(*names).map { |name, _| name }.join(' ') unless names.empty?
31
35
  end
32
36
 
33
37
  private
Binary file
@@ -20,11 +20,24 @@ module Proscenium
20
20
  #
21
21
  # @see CssModule::Transformer#class_names
22
22
  # @param name [String,Symbol,Array<String,Symbol>]
23
- def css_module(*names)
24
- path = Pathname.new(@lookup_context.find(@virtual_path).identifier).sub_ext('')
25
- CssModule::Transformer.new(path).class_names(*names, require_prefix: false).map do |name, _|
26
- name
27
- end.join(' ')
23
+ # @param path [Pathname] the path to the CSS module file to use for the transformation.
24
+ # @return [String] the transformed CSS module names concatenated as a string.
25
+ def css_module(*names, path: nil)
26
+ path ||= Pathname.new(@lookup_context.find(@virtual_path).identifier).sub_ext('')
27
+ CssModule::Transformer.new(path).class_names(*names, require_prefix: false)
28
+ .map { |name, _| name }.join(' ')
29
+ end
30
+
31
+ # @param name [String,Symbol,Array<String,Symbol>]
32
+ # @param path [Pathname] the path to the CSS file to use for the transformation.
33
+ # @return [String] the transformed CSS module names concatenated as a string.
34
+ def class_names(*names, path: nil)
35
+ names = names.flatten.compact
36
+
37
+ return if names.empty?
38
+
39
+ path ||= Pathname.new(@lookup_context.find(@virtual_path).identifier).sub_ext('')
40
+ CssModule::Transformer.new(path).class_names(*names).map { |name, _| name }.join(' ')
28
41
  end
29
42
 
30
43
  def include_stylesheets(**options)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Proscenium
4
- VERSION = '0.12.0'
4
+ VERSION = '0.13.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proscenium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Joel Moss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-10 00:00:00.000000000 Z
11
+ date: 2023-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  - !ruby/object:Gem::Version
150
150
  version: '0'
151
151
  requirements: []
152
- rubygems_version: 3.4.21
152
+ rubygems_version: 3.4.22
153
153
  signing_key:
154
154
  specification_version: 4
155
155
  summary: The engine powering your Rails frontend