oo-loop 1.0.0 → 1.0.3

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Loop changelog
2
2
 
3
+ ## 1.0.3: 2022-04-05
4
+
5
+ ### Feature
6
+ - Set up function to return the alias information
7
+ ### Fixes
8
+ - Return the reference value and send a warning if the alias function cannot be performed
9
+
10
+ ## 1.0.2: 2022-04-04
11
+
12
+ ### Fixes
13
+ - Fix `pointbreak()` on rem unit
14
+ - Fix generating double properties when merging custom map with camelCase `props`
15
+ - Fix the lost of references when merging custom config on `init`
16
+ - Bump dependencies
17
+
18
+ ## 1.0.1 : 2020-07-30
19
+
20
+ - Add missing `states` properties in variants
21
+ - Fix rule to add any pseudo elements, states and pseudo-selectors from `props`
22
+ - Bump lodash from 4.17.15 to 4.17.19
23
+
3
24
  ## 1.0.0
4
25
 
5
26
  ### Changes
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  **Flexible and Expressive CSS**
10
10
 
11
- [Loop](https://oo-loop.github.io/) is a fully customizable Sass framework aiming to create a more maintainable and readable CSS.
11
+ [Loop](https://oo-loop.github.io/) is a fully customizable CSS framework built with Sass aiming to create a more maintainable and readable Code.
12
12
  It gives you complete control on your project to let you create and match your styles with your design needs.
13
13
 
14
14
  ## Installation
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "oo-loop",
3
- "version": "1.0.0",
4
- "description": "Loop framework, flexible and expressive CSS",
3
+ "version": "1.0.3",
4
+ "description": "Loop CSS framework, flexible and expressive CSS",
5
5
  "keywords": [
6
6
  "scss",
7
7
  "sass",
@@ -39,10 +39,10 @@
39
39
  "dev": "node-sass -r --output-style expanded --precision 6 src/index.scss dist/loop.css",
40
40
  "build": "node-sass --output-style compressed --precision 6 src/index.scss dist/loop.css",
41
41
  "watch": "npm run dev && npm run dev -- -w",
42
- "example": "node-sass --output-style expanded --source-comments false --precision 6 -w example/ -o example/build"
42
+ "example": "node-sass --output-style expanded --precision 6 example/src -o example/build"
43
43
  },
44
44
  "devDependencies": {
45
- "node-sass": "^4.13.1"
45
+ "node-sass": "^7.0.0"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">= 6.0.0",
package/scss/_init.scss CHANGED
@@ -15,11 +15,11 @@
15
15
  /// Init ooLoop configs
16
16
 
17
17
  @mixin ooInit($custom:null) {
18
- $map: if(hasRef($ooLoop), ooParse($ooLoop), $ooLoop);
18
+ $map: $ooLoop;
19
19
  @if isMap($custom) and isNotEmpty($custom) {
20
20
  $map: mapMergeDeep($map, $custom);
21
- $map: if(hasRef($map), ooParse($map), $map);
22
21
  }
22
+ $map: if(hasRef($map), ooParse($map), $map);
23
23
  $map: setMapValue($map, 'init', true);
24
24
  $ooLoop: $map !global;
25
25
  }
@@ -21,11 +21,11 @@
21
21
  /// @credit-to https://gist.github.com/pentzzsolt
22
22
  /// @param map $parentMap Map of data to be merged into
23
23
  /// @param map $childMap The set of data
24
- /// @param map $refMap The base map to refer too,
25
- /// usually equivalent to the $ooLoop before going into nested merge
24
+ /// @param map $refMap The base map to refer too, usually equivalent to the $ooLoop before going into nested merge
25
+ /// @param bool $forceKebab force the use of kebab-case property
26
26
  /// @return map
27
27
 
28
- @function mapMergeDeep($parentMap, $childMap, $refMap:null) {
28
+ @function mapMergeDeep($parentMap, $childMap, $refMap:null, $forceKebab: false) {
29
29
  $map: $parentMap;
30
30
  @if not isMap($map) {
31
31
  @return $map;
@@ -34,6 +34,7 @@
34
34
  $refMap: if($refMap == null, $ooLoop, $refMap);
35
35
 
36
36
  @each $key, $value in $childMap {
37
+ $key: if($forceKebab, toKebabCase($key), $key);
37
38
  @if isRef(map-get($map, $key)) {
38
39
  $mapValue: getRefValue(map-get($map, $key), $refMap);
39
40
  $map: map-merge($map, ($key: $mapValue));
@@ -41,7 +42,7 @@
41
42
  @if (not map-has-key($map, $key)) or (type-of(map-get($map, $key) ) != type-of($value)) or (not (isMap(map-get($map, $key)) and isMap($value))) {
42
43
  $map: map-merge($map, ($key: $value));
43
44
  } @else {
44
- $map: map-merge($map, ($key: mapMergeDeep(map-get($map, $key), $value, $refMap)));
45
+ $map: map-merge($map, ($key: mapMergeDeep(map-get($map, $key), $value, $refMap, inList($key, ('props', 'states')))));
45
46
  }
46
47
  }
47
48
  @return $map;
@@ -2,12 +2,12 @@ $ooAlias: (
2
2
  (
3
3
  name: 'ooDarken',
4
4
  function: 'darken',
5
- params: ('color', 'number'),
5
+ paramType: ('color', 'number'),
6
6
  ),
7
7
  (
8
8
  name: 'ooLighten',
9
9
  function: 'lighten',
10
- params: ('color', 'number'),
10
+ paramType: ('color', 'number'),
11
11
  ),
12
12
  );
13
13
 
@@ -48,49 +48,79 @@ $ooAlias: (
48
48
  @return $isAlias;
49
49
  }
50
50
 
51
+ /// getAliasInfo
52
+ /// retrieve the alias information
53
+ /// @param string $aliasFunction The complete alias function
54
+ /// @return map|null
55
+
56
+ @function getAliasInfo($aliasFunction) {
57
+ @each $alias in $ooAlias {
58
+ $aliasName: getMapValue($alias, 'name');
59
+ $aliasLength: str-length($aliasName);
60
+ $aliasFunctionName: stripSpaces(str-slice($aliasFunction, 1, $aliasLength));
61
+
62
+ @if $aliasFunctionName == $aliasName {
63
+ $currentAlias: $alias;
64
+ $functionName: getMapValue($alias, 'function');
65
+
66
+ @return (
67
+ name: $aliasName,
68
+ nameLength: $aliasLength,
69
+ function: if(function-exists('get-function'), get-function($functionName), $functionName),
70
+ functionName: $functionName,
71
+ paramType: getMapValue($alias, 'paramType'),
72
+ );
73
+ }
74
+ }
75
+
76
+ @return null;
77
+ }
51
78
 
52
79
  /// getAliasValue
53
80
  /// retrieve the value of an alias function
54
- /// @param string $string The complete alias function
81
+ /// @param string $aliasFunction The complete alias function
55
82
  /// @param string $value Value of the 1st parameter
56
83
  /// @return bool
57
84
 
58
- /// @todo review, simplify
59
-
60
- @function getAliasValue($string, $param:null) {
61
- $currentAlias: null;
85
+ @function getAliasValue($aliasFunction, $value:null) {
86
+ $name: null;
87
+ $paramType: null;
62
88
  $function: null;
63
- $params: split(',', inspect($string));
64
-
89
+ $params: split(',', inspect($aliasFunction));
65
90
  $param1: nth($params, 1);
66
- @each $alias in $ooAlias {
67
- $aliasName: getMapValue($alias, 'name');
68
- $aliasLength: str-length($aliasName);
69
- @if str-slice($string, 1, $aliasLength) == $aliasName {
70
- $currentAlias: $alias;
71
- $function: getMapValue($alias, 'function');
72
- $param1: stripSpaces(str-slice($param1, $aliasLength + 2, str-length($param1)));
73
- @if function-exists('get-function') {
74
- $function: get-function($function);
75
- }
76
- }
91
+
92
+ $aliasInfo: getAliasInfo($aliasFunction);
93
+
94
+ @if $aliasInfo != null {
95
+ $name: getMapValue($aliasInfo, 'name');
96
+ $function: getMapValue($aliasInfo, 'function');
97
+ $paramType: getMapValue($aliasInfo, 'paramType');
98
+ $param1: stripSpaces(str-slice($param1, getMapValue($aliasInfo, 'nameLength') + 2, str-length($param1)));
77
99
  }
78
100
 
79
- $param1: if($param == null, $param1, $param);
101
+ $param1: if($value==null, $param1, $value);
80
102
 
81
103
  @if length($params) > 1 {
82
- $paramLeft: removeInList($params, 1);
83
- $param2: stripSpaces(str-slice(#{$paramLeft}, 1, -2));
104
+ $param2: stripSpaces(str-slice(#{nth($params, 2)}, 1, -2));
105
+
106
+ $param1Type: null;
107
+ $param2Type: null;
84
108
 
85
- $currentAliasParams: getMapValue($currentAlias, 'params');
86
- $param1: toType(nth($currentAliasParams, 1), $param1);
87
- $param2: toType(nth($currentAliasParams, 2), $param2);
109
+ @if $paramType != null {
110
+ $param1Type: nth($paramType, 1);
111
+ $param2Type: nth($paramType, 2);
112
+ }
88
113
 
89
- @if type-of($param1) != nth($currentAliasParams, 1) or type-of($param2) != nth($currentAliasParams, 2) {
90
- @return $string;
114
+ $param1: toType($param1Type, $param1);
115
+ $param2: toType($param2Type, $param2);
116
+
117
+ @if type-of($param1) != $param1Type or type-of($param2) != $param2Type {
118
+ @warn('The alias `#{$aliasFunction}` is targetting `#{$value}` and therefore cannot be used with the sass function `#{getMapValue($aliasInfo, 'functionName')}`');
119
+ @return $value;
91
120
  }
92
121
 
93
122
  @return call($function, $param1, $param2);
94
123
  }
124
+
95
125
  @return call($function, $param1);
96
- }
126
+ }
@@ -15,7 +15,7 @@
15
15
  @if map-has-key(oo('breakpoints'), $key) {
16
16
  $minWidth: map-get(oo('breakpoints'), $key);
17
17
  $maxWidth: $minWidth - 1;
18
- @if unit($minWidth) == 'em' or unit('rem') {
18
+ @if inList(unit($minWidth), ('em', 'rem')) {
19
19
  $maxWidth: $minWidth - 0.001;
20
20
  }
21
21
  @media (max-width: $maxWidth) {
@@ -36,7 +36,13 @@
36
36
  @if isNotEmpty($variantsMap) {
37
37
  @each $name, $props in $variantsMap {
38
38
  @if isMap($props) {
39
+ $hasStates: if(map-has-key($props, 'states'), map-get($props, 'states'), null);
39
40
  [#{ooPrefix()}-#{$componentName}~="#{toKebabCase($name)}"] {
41
+ @if map-has-key($props, 'states') {
42
+ $states: map-get($props, 'states');
43
+ $props: map-remove($props, 'states');
44
+ @include generateStatesProperties($states);
45
+ }
40
46
  @include generateProperties($props);
41
47
  }
42
48
  }
@@ -7,8 +7,8 @@
7
7
  @each $propertyName, $propertyValue in $propertiesMap {
8
8
  $propertyName: toKebabCase($propertyName);
9
9
 
10
- @if inList($propertyName, ('before', 'after')) {
11
- &::#{$propertyName} {
10
+ @if isString($propertyName) and str-slice($propertyName,1,1) == ':' {
11
+ &#{$propertyName} {
12
12
  @include generateProperties($propertyValue);
13
13
  }
14
14
  } @else if isMap($propertyValue) and areKeysBreakpoints($propertyValue) {