css_modules 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21b9fabe952b1363c961b54679fc160c266a4015
4
- data.tar.gz: 055009fe0234af3921b944ef78971844ca5f5076
3
+ metadata.gz: c35e16ca5e8afa7babee60ed35eee0bdc5348626
4
+ data.tar.gz: 3e028eab6b1ee508b100acc7f63e10896c865e26
5
5
  SHA512:
6
- metadata.gz: d2bacefe1455169e48a20efe29caa16ed6ce85cc56f8dee9dd0535062f6245a19e3d2a66c558ce6a0988c0cf8153f840875e0400e7f434464d3b527ec67c53f7
7
- data.tar.gz: 7bc30bd4c1c1a1c97b262aedd2f98616d89c4214fd4d63bc660c66e3fb91605b8f3ff1e6950319c4334bd7ed2ede9795c8121b6a29fc5fbd5d151f827ab7defd
6
+ metadata.gz: 1eb0f5526ea2707e4d0eeda968b45d8d06a48996476678c4fb81bbb71a8adfac7dfd86c4907b6f635775f1408adc3c538d2a13067dbf4de799dba1c31014fde9
7
+ data.tar.gz: 1d27222c3e2dfbc76d496ec97e7ced78cfb09a7efc212c6c7c31f4f3f4b9ef0c9ac4cb2b42409c3203ba4b13402e928993ab3fde72d3ccc710690cbda1bcfd2d
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Build Status](https://travis-ci.org/rmosolgo/css_modules.svg?branch=master)](https://travis-ci.org/rmosolgo/css_modules)
4
4
  [![Gem Version](https://badge.fury.io/rb/css_modules.svg)](https://badge.fury.io/rb/css_modules)
5
5
 
6
- An alternative to "magic string" classnames in Sass or SCSS. Currently supports Sprockets 2 only 😖.
6
+ An alternative to "magic string" classnames in Sass or SCSS.
7
7
 
8
8
  Thanks to [Fatih Kadir Akın](https://twitter.com/fkadev) for his post, ["How I Implemented CSS Modules in Ruby on Rails, Easily"](https://medium.com/@fkadev/how-i-implemented-css-modules-to-ruby-on-rails-easily-abb324ce22d), which led the way on this idea!
9
9
 
@@ -158,8 +158,6 @@ $ gem install css_modules
158
158
  - Warn when not all styles are used?
159
159
  - Sprockets require CSS to JS? `require_styles` ?
160
160
  - Support plain `.css`
161
- - Support Sprockets 3+
162
- - Test on different Sass versions
163
161
  - Check for hash collisions in development
164
162
  - Fix sprockets cache: a new version of this gem should expire an old cache
165
163
 
@@ -1,3 +1,3 @@
1
1
  module CSSModules
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -7,9 +7,19 @@ module CSSModules
7
7
  # helper CSSModules::ViewHelper
8
8
  # end
9
9
  module ViewHelper
10
- # @overload css_module(module_name, selector_name)
10
+ # @overload css_module(module_name)
11
11
  # Apply the styles from `module_name` for `selector_name`
12
12
  #
13
+ # @example Passing a module to a partial
14
+ # style_module = css_module("events_index")
15
+ # render(partial: "header", locals: { style_module: style_module })
16
+ #
17
+ # @param module_name [String]
18
+ # @return [StyleModule] helper for modulizing selectors within `module_name`
19
+ #
20
+ # @overload css_module(module_name, selector_names, bare_selector_names)
21
+ # Apply the styles from `module_name` for `selector_names`
22
+ #
13
23
  # @example Getting a selector within a module
14
24
  # css_module("events_index", "header")
15
25
  # # => "..." (opaque string which matches the stylesheet)
@@ -29,26 +39,30 @@ module CSSModules
29
39
  # <% end %>
30
40
  #
31
41
  # @param module_name [String]
32
- # @yieldparam [ModuleLookup] a helper for modulizing selectors within `module_name`
33
- # @return [void]
42
+ # @yieldparam [StyleModule] a helper for modulizing selectors within `module_name`
43
+ # @return [StyleModule] a helper for modulizing selectors within `module_name`
34
44
  def css_module(module_name, selector_names = nil, bare_selector_names = nil, &block)
35
- lookup = ModuleLookup.new(module_name)
45
+ lookup = StyleModule.new(module_name)
36
46
 
37
47
  if selector_names.nil? && block_given?
38
48
  yield(lookup)
39
- nil
49
+ lookup
40
50
  elsif selector_names.present?
41
51
  lookup.selector(selector_names.to_s, bare_selector_names.to_s)
42
52
  else
43
- raise("css_module must be called with a module_name and either selector_names or a block")
53
+ lookup
44
54
  end
45
55
  end
46
56
 
47
- class ModuleLookup
57
+ class StyleModule
48
58
  def initialize(module_name)
49
59
  @module_name = module_name
50
60
  end
51
61
 
62
+ def name
63
+ @module_name
64
+ end
65
+
52
66
  # @see {ViewHelper#css_module}
53
67
  # @param selector_names [String]
54
68
  # @param bare_selector_names [String]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: css_modules
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo