bem-constructor 0.3.0 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bem-constructor.rb +1 -1
- data/stylesheets/_block.scss +11 -2
- data/stylesheets/_element.scss +7 -2
- data/stylesheets/_error-checks.scss +9 -22
- data/stylesheets/_hack.scss +4 -1
- data/stylesheets/_modifier.scss +5 -0
- data/stylesheets/_modifies-element.scss +6 -2
- data/stylesheets/logger/_block-logger.scss +4 -1
- data/stylesheets/logger/_element-logger.scss +5 -1
- data/stylesheets/logger/_modifier-logger.scss +5 -1
- data/stylesheets/logger/_scope-logger.scss +5 -1
- 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: 7b9f377ac2844b2e29439656b8ea795caee5e925
|
4
|
+
data.tar.gz: 6522e754bab2703329555864d0edee404cb3e330
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 338df5a582de055c92b5bb917d6673614da3b9708f8781f0b6ddd680db2a1b563abade48e1f2306fb16bdf9ae48e756f318d553c34b95bede1873c9e49bd180e
|
7
|
+
data.tar.gz: 347ebc42e58d0a8b9da81cfeb1a5e27fd0b8261a9ff89cff97d3a5bf3e196bda1c2dc467520509d1662d19f9cf4e0051071e8fbcff7627569e4233523e235c66
|
data/lib/bem-constructor.rb
CHANGED
data/stylesheets/_block.scss
CHANGED
@@ -23,14 +23,23 @@ $bem-block-namespaces: (
|
|
23
23
|
$new-block: _bem-log-block($name);
|
24
24
|
|
25
25
|
// Error check
|
26
|
-
$outside-check:
|
26
|
+
$outside-check: _should-not-be-called-within('scope', 'block');
|
27
|
+
|
28
|
+
// Return false in case error throwing is disabled
|
29
|
+
@if $outside-check == false {
|
30
|
+
@return false;
|
31
|
+
}
|
27
32
|
|
28
33
|
// Set namespace
|
29
34
|
$namespace: '';
|
30
35
|
|
31
36
|
@if $bem-use-namespaces {
|
32
37
|
@if not map-has-key($bem-block-namespaces, $type) {
|
33
|
-
@
|
38
|
+
@if $bem-throw-errors {
|
39
|
+
@error '`#{$type}` is not a valid `$type` for `block()`';
|
40
|
+
}
|
41
|
+
|
42
|
+
@return false;
|
34
43
|
}
|
35
44
|
$namespace: map-get($bem-block-namespaces, $type) + '-';
|
36
45
|
}
|
data/stylesheets/_element.scss
CHANGED
@@ -13,8 +13,13 @@
|
|
13
13
|
$new-element: _bem-log-element($elements...);
|
14
14
|
|
15
15
|
// Error checks
|
16
|
-
$inside-check:
|
17
|
-
$outside-check:
|
16
|
+
$inside-check: _should-be-called-within('block');
|
17
|
+
$outside-check: _should-not-be-called-within('modifier', 'state', 'element');
|
18
|
+
|
19
|
+
// Return false in case error throwing is disabled
|
20
|
+
@if $inside-check == false or $outside-check == false {
|
21
|
+
@return false;
|
22
|
+
}
|
18
23
|
|
19
24
|
$selector: ();
|
20
25
|
|
@@ -12,20 +12,13 @@
|
|
12
12
|
/// Checks that it's being created within all of the passed $objs...
|
13
13
|
@function _should-be-called-within($objs...) {
|
14
14
|
|
15
|
-
$found: false;
|
16
|
-
|
17
15
|
@each $obj in $objs {
|
18
|
-
@if map-get($_bem-current-context, $obj)
|
19
|
-
$
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
@if not $found {
|
24
|
-
@if ($bem-throw-error) {
|
25
|
-
@error 'It should be called within #{inspect($objs)}';
|
16
|
+
@if map-get($_bem-current-context, $obj) == null {
|
17
|
+
@if $bem-throw-errors {
|
18
|
+
@error 'It should be called within #{inspect($objs)}';
|
19
|
+
}
|
20
|
+
@return false;
|
26
21
|
}
|
27
|
-
|
28
|
-
@return false;
|
29
22
|
}
|
30
23
|
|
31
24
|
@return true;
|
@@ -39,19 +32,13 @@
|
|
39
32
|
/// Checks that it's being created outside all of the passed $objs...
|
40
33
|
@function _should-not-be-called-within($objs...) {
|
41
34
|
|
42
|
-
$found: false;
|
43
|
-
|
44
35
|
@each $obj in $objs {
|
45
36
|
@if map-get($_bem-current-context, $obj) != null {
|
46
|
-
$
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
@if $found {
|
51
|
-
@if ($bem-throw-error) {
|
52
|
-
@error 'It should not be called within #{inspect($objs)}';
|
37
|
+
@if $bem-throw-errors {
|
38
|
+
@error 'It should not be called within #{inspect($objs)}';
|
39
|
+
}
|
40
|
+
@return false;
|
53
41
|
}
|
54
|
-
@return false;
|
55
42
|
}
|
56
43
|
|
57
44
|
@return true;
|
data/stylesheets/_hack.scss
CHANGED
@@ -10,7 +10,10 @@ $hack-namespace: '_' !default;
|
|
10
10
|
$parsed: selector-parse($selector);
|
11
11
|
|
12
12
|
@if length($parsed) > 1 {
|
13
|
-
|
13
|
+
@if $bem-throw-errors {
|
14
|
+
@error '`#{$selector}` contains #{length($parsed)} selectors and the `_last-simple-selector()`function accepts only 1.';
|
15
|
+
}
|
16
|
+
@return false;
|
14
17
|
}
|
15
18
|
$last-simple-selector: nth(nth($parsed, 1), -1);
|
16
19
|
|
data/stylesheets/_modifier.scss
CHANGED
@@ -17,6 +17,11 @@
|
|
17
17
|
$inside-check: _should-be-called-within('block');
|
18
18
|
$outside-check: _should-not-be-called-within('modifier');
|
19
19
|
|
20
|
+
// Return false in case error throwing is disabled
|
21
|
+
@if $inside-check == false or $outside-check == false {
|
22
|
+
@return false;
|
23
|
+
}
|
24
|
+
|
20
25
|
$selector: ();
|
21
26
|
|
22
27
|
@each $modifier in $modifiers {
|
@@ -9,8 +9,12 @@
|
|
9
9
|
|
10
10
|
@function _modifies-element($modified-elements...) {
|
11
11
|
|
12
|
-
$inside-check:
|
13
|
-
$outside-check:
|
12
|
+
$inside-check: _should-be-called-within('modifier', 'state');
|
13
|
+
$outside-check: _should-not-be-called-within('element');
|
14
|
+
|
15
|
+
@if $inside-check == 'false' or $outside-check == false {
|
16
|
+
@return false;
|
17
|
+
}
|
14
18
|
|
15
19
|
$selectors: ();
|
16
20
|
|
@@ -16,7 +16,10 @@
|
|
16
16
|
|
17
17
|
// Check if the block has already been created
|
18
18
|
@if block-exists($block) {
|
19
|
-
@
|
19
|
+
@if $bem-throw-errors {
|
20
|
+
@error '`#{$block}` block has already been created';
|
21
|
+
}
|
22
|
+
@return false;
|
20
23
|
}
|
21
24
|
|
22
25
|
// Initialize a new block map
|
@@ -31,7 +31,11 @@
|
|
31
31
|
|
32
32
|
// Check any $elements has already been defined for the current block
|
33
33
|
@if element-exists($elements...) {
|
34
|
-
@
|
34
|
+
@if $bem-throw-errors {
|
35
|
+
@error 'One or more elements from `#{inspect($elements)}` have already been created';
|
36
|
+
}
|
37
|
+
|
38
|
+
@return false;
|
35
39
|
}
|
36
40
|
|
37
41
|
// Find the current block name
|
@@ -31,7 +31,11 @@
|
|
31
31
|
|
32
32
|
// Check if the modifier has already been defined for the current block or element
|
33
33
|
@if modifier-exists($modifiers...) {
|
34
|
-
@
|
34
|
+
@if $bem-throw-errors {
|
35
|
+
@error 'One or more elements from `#{inspect($modifiers)}` have already been created';
|
36
|
+
}
|
37
|
+
|
38
|
+
@return false;
|
35
39
|
}
|
36
40
|
|
37
41
|
// Find the current block name
|
@@ -16,7 +16,11 @@
|
|
16
16
|
|
17
17
|
// Check if the scope has already been created
|
18
18
|
@if scope-exists($scope) {
|
19
|
-
@
|
19
|
+
@if $bem-throw-errors {
|
20
|
+
@error '`#{$scope}` scope has already been created';
|
21
|
+
}
|
22
|
+
|
23
|
+
@return false;
|
20
24
|
}
|
21
25
|
|
22
26
|
// Initialize a new scope map
|