css_modules 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -3
- data/lib/css_modules/version.rb +1 -1
- data/lib/css_modules/view_helper.rb +21 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c35e16ca5e8afa7babee60ed35eee0bdc5348626
|
4
|
+
data.tar.gz: 3e028eab6b1ee508b100acc7f63e10896c865e26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
|
data/lib/css_modules/version.rb
CHANGED
@@ -7,9 +7,19 @@ module CSSModules
|
|
7
7
|
# helper CSSModules::ViewHelper
|
8
8
|
# end
|
9
9
|
module ViewHelper
|
10
|
-
# @overload css_module(module_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 [
|
33
|
-
# @return [
|
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 =
|
45
|
+
lookup = StyleModule.new(module_name)
|
36
46
|
|
37
47
|
if selector_names.nil? && block_given?
|
38
48
|
yield(lookup)
|
39
|
-
|
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
|
-
|
53
|
+
lookup
|
44
54
|
end
|
45
55
|
end
|
46
56
|
|
47
|
-
class
|
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]
|