rails_blocks 0.7.9 → 0.7.10

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: 8cb0e94f83c2c6c20fde784581b0407bd050ad1f
4
- data.tar.gz: df99fc13a054c67ac623498f98c09c88470443e5
3
+ metadata.gz: 9c2eaeee389ac41547e2bc5ffff58ad1fcd84e51
4
+ data.tar.gz: 26799cba32acfebe52ac62694473b3ac40afceb0
5
5
  SHA512:
6
- metadata.gz: 67b61f0e3e011b529cd631d7a25d68bd7c7121e467c1a0320556264f1d9aae00bffe853478f412ebaa111bf285edc523600cbd82dee34edc641f559eb1a697d8
7
- data.tar.gz: c15094cfdd3d710cdde4130675327a5fdf78a8b17efd4c21d37af6313d464222b6ee72b661976c09f43c5ad8fc589a4d442ba34174d8939ac14dfd64da948e8c
6
+ metadata.gz: 17c0ec7aac3c95a1c59f42c4f58924290c01336f63662414b284664321809d5ccba579d5e491eed89afbfdc28b39d3e2ac995a4c212c64348ccd7c6aa26b24b7
7
+ data.tar.gz: 313b5e1c935783241c3f1a6c9fc9ec1990711c910c2f72ab7f41405ad28c6e1d4d8e1fea7b4f8c6b2c0cead2483f7c5bd51c0066903056c84ce2ddc6fa55fa56
@@ -3,75 +3,62 @@ $bemModifierSeparator: '--'
3
3
 
4
4
  @function b-class($block)
5
5
  @return ".#{$block}"
6
-
7
- @function selectorToString($selector)
8
- $selector: inspect($selector) //cast to string
9
- $selector: str-slice($selector, 2, -2) //remove bracket
10
- @return $selector
6
+
7
+ @function e-class($block, $element)
8
+ @return ".#{$block+$bemElementSeparator+$element}"
9
+
10
+ @function m-class($selector, $modifier)
11
+ @return "#{$selector+$bemModifierSeparator+$modifier}"
11
12
 
12
13
  @function containsModifier($selector)
13
- $selector: selectorToString($selector)
14
- @if str-index($selector, $bemModifierSeparator)
15
- @return true
16
- @else
17
- @return false
14
+ $selector: inspect($selector)
15
+ @return if(str-index($selector, $bemModifierSeparator), true, false)
18
16
 
19
17
  @function containsPseudo($selector)
20
- $selector: selectorToString($selector)
21
- @if str-index($selector, ':')
22
- @return true
23
- @else
24
- @return false
18
+ $selector: inspect($selector)
19
+ @return if(str-index($selector, ':'), true, false)
25
20
 
26
21
  @function containsElement($selector)
27
- $selector: selectorToString($selector)
28
- @if str-index($selector, $bemElementSeparator)
29
- @return true
30
- @else
31
- @return false
22
+ $selector: inspect($selector)
23
+ @return if(str-index($selector, $bemElementSeparator), true, false)
32
24
 
33
25
  @function getBlock($selector)
34
- $selector: selectorToString($selector)
26
+ $selector: inspect($selector)
35
27
  $elementStart: str-index($selector, $bemElementSeparator)
36
28
  $modifierStart: str-index($selector, $bemModifierSeparator)
37
29
  $pseudoStart: str-index($selector, ':')
38
- $start: if($elementStart, $elementStart - 1, if($modifierStart, $modifierStart - 1, $pseudoStart - 1))
39
- @return str-slice($selector, 0, $start)
30
+ $start: if($elementStart, $elementStart - 1, if($modifierStart, $modifierStart - 1, if($pseudoStart, $pseudoStart - 1, -1)))
31
+ @return str-slice($selector, 2, $start) //without dot
40
32
 
41
- =b($block)
42
- .#{$block}
33
+ =b($blocks...)
34
+ $selectors: ()
35
+ @each $block in $blocks
36
+ $selectors: append($selectors, #{b-class($block)}, 'comma')
37
+ #{$selectors}
43
38
  @content
44
-
45
- =plus_b
46
- @at-root
47
- $block: &
48
- #{$block} + #{$block}
49
- @content
50
-
51
- =hover_b
52
- @at-root
53
- $block: &
54
- #{$block}:hover
55
- @content
56
39
 
57
40
  =e($elements...)
58
41
  $selectors: ()
59
- $currentSelector: &
42
+ $parentSelector: &
60
43
 
61
- @each $element in $elements
62
- @if containsModifier($currentSelector) or containsPseudo($currentSelector)
63
- $block: getBlock($currentSelector)
64
- $selectors: append($selectors, unquote('#{$currentSelector} #{$block+$bemElementSeparator+$element}'), 'comma')
65
- @else
66
- $selectors: append($selectors, unquote('#{$currentSelector+$bemElementSeparator+$element}'), 'comma')
44
+ @each $currentSelector in $parentSelector
45
+ $block: getBlock($currentSelector)
46
+ @each $element in $elements
47
+ @if containsModifier($currentSelector) or containsPseudo($currentSelector)
48
+ $selectors: append($selectors, #{$currentSelector e-class($block, $element)}, 'comma')
49
+ @else
50
+ $selectors: append($selectors, e-class($block, $element), 'comma')
51
+
67
52
  @at-root
68
53
  #{$selectors}
69
54
  @content
70
55
 
71
56
  =m($modifiers...)
72
57
  $selectors: ()
73
- @each $modifier in $modifiers
74
- $selectors: append($selectors, unquote('#{&}#{$bemModifierSeparator+$modifier}'), 'comma')
58
+ $parentSelector: &
59
+ @each $currentSelector in $parentSelector
60
+ @each $modifier in $modifiers
61
+ $selectors: append($selectors, m-class($currentSelector, $modifier), 'comma')
75
62
  @at-root
76
63
  #{$selectors}
77
64
  @content
@@ -79,7 +66,7 @@ $bemModifierSeparator: '--'
79
66
  =ms($modifiers...)
80
67
  $selectors: null
81
68
  @each $modifier in $modifiers
82
- $selectors: $selectors#{&}#{$bemModifierSeparator+$modifier}
69
+ $selectors: $selectors#{m-class(&, $modifier)}
83
70
  @at-root
84
71
  #{$selectors}
85
72
  @content
@@ -94,7 +81,5 @@ $bemModifierSeparator: '--'
94
81
  background-position: -($i - 1) * $width (-2 * $height)
95
82
 
96
83
  @function block-image-url($level, $image)
97
- $selector: &
98
- $selector: selectorToString($selector)
99
- $block: if(containsModifier($selector) or containsPseudo($selector) or containsElement($selector), getBlock($selector), selectorToString($selector))
84
+ $block: getBlock(nth(&, 1))
100
85
  @return image-url("#{$level}/#{$block}/images/#{$image}")
@@ -1,3 +1,3 @@
1
1
  module RailsBlocks
2
- VERSION = "0.7.9".freeze
2
+ VERSION = "0.7.10".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_blocks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.9
4
+ version: 0.7.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Potetiurin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-09 00:00:00.000000000 Z
11
+ date: 2017-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails