base.sass 1.0.1 → 1.1.0
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 +4 -4
- data/Changelog.md +55 -0
- data/Readme.md +206 -0
- data/lib/base.sass.rb +1 -0
- data/lib/base.sass/env.rb +1 -1
- data/lib/base.sass/map.rb +126 -0
- data/lib/base.sass/sass-to-ruby.rb +2 -2
- data/lib/base.sass/selector.rb +2 -4
- data/lib/base.sass/support.rb +0 -16
- data/stylesheets/base.sass/_*.scss +0 -1
- data/stylesheets/base.sass/mixins/_placeholder-wrapper.scss +3 -3
- metadata +7 -5
- data/stylesheets/base.sass/functions/_map.scss +0 -55
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5196ecc5e76b30bedc2a493397fb4cd871ca6d68
|
4
|
+
data.tar.gz: 95d0e1bb92cd0a25682d61fb397336368e6d29d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5018bd64cc72ef5ec0238edd5deca2e7aa7a0d2ebb5c4cf8d8af0b0ce5ba00e2e628a140b1738b03ef5f724bea42282827591e503bb4fae22590d03709df8d72
|
7
|
+
data.tar.gz: 6a5fb1eee707df5b80c9eac2a7a2a48da5aa24a7ae7009bc3704c1f6fc3f086b880f33d5e326c9dd6904039ea458e6ad17cd41df1db6807166fa36399d0a7895
|
data/Changelog.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## v1.1.0
|
4
|
+
|
5
|
+
### Overrides official map functions to support nest keys
|
6
|
+
|
7
|
+
- map-get($map, $key-router...)
|
8
|
+
- map-remove($map, $key-router...)
|
9
|
+
- map-has-key($map, $key-router...)
|
10
|
+
- map-merge($map1, $map2, $deep: false)
|
11
|
+
|
12
|
+
### Removes legacy functions
|
13
|
+
|
14
|
+
- map-deep-merge($map1, $map2)
|
15
|
+
- map-find($map, $keys)
|
16
|
+
|
17
|
+
## v1.0.1
|
18
|
+
|
19
|
+
- Fix font url in `font-face()` for ie9
|
20
|
+
|
21
|
+
## v1.0.0
|
22
|
+
|
23
|
+
**Milestone Release**
|
24
|
+
|
25
|
+
### Extensions
|
26
|
+
|
27
|
+
- env($name)
|
28
|
+
- app-config($name)
|
29
|
+
- parse-json($path)
|
30
|
+
- strftime([$format])
|
31
|
+
- parse-rules($rules...)
|
32
|
+
- browsers()
|
33
|
+
- browser-versions($browser, [$include-future])
|
34
|
+
- url($paths...)
|
35
|
+
- nest($selectors...)
|
36
|
+
- append-selector($selector, $to-append)
|
37
|
+
- enumerate($prefix, $from, $through, [$separator])
|
38
|
+
- headings([$from], [$to])
|
39
|
+
|
40
|
+
### Functions
|
41
|
+
|
42
|
+
- comma-list([$list])
|
43
|
+
- slice($list, [$min], [$max])
|
44
|
+
- map-deep-merge($map1, $map2)
|
45
|
+
- map-find($map, $keys)
|
46
|
+
- support-browser($browser [$version])
|
47
|
+
|
48
|
+
### Mixins
|
49
|
+
|
50
|
+
- placeholder-wrapper($name)
|
51
|
+
- clearfix
|
52
|
+
- ellipsis-overflow
|
53
|
+
- inline-block
|
54
|
+
- float($side, [$important])
|
55
|
+
- font-face($font-family, $paths...)
|
data/Readme.md
ADDED
@@ -0,0 +1,206 @@
|
|
1
|
+
# Awesome Extensions For Sass :kiss:
|
2
|
+
|
3
|
+
[](https://travis-ci.org/jsw0528/base.sass)
|
4
|
+
[](http://badge.fury.io/rb/base.sass)
|
5
|
+
|
6
|
+
> Requires Sass >= 3.3
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
In your [`Gemfile`](http://bundler.io/v1.6/gemfile.html):
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'base.sass', '~> 1.1'
|
14
|
+
```
|
15
|
+
|
16
|
+
Or in command line:
|
17
|
+
|
18
|
+
```sh
|
19
|
+
$ gem install base.sass
|
20
|
+
```
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
In your Sass file:
|
25
|
+
|
26
|
+
```scss
|
27
|
+
@import 'base.sass/*';
|
28
|
+
```
|
29
|
+
|
30
|
+
And then in command line:
|
31
|
+
|
32
|
+
```sh
|
33
|
+
$ sass -r base.sass --watch src:dist
|
34
|
+
```
|
35
|
+
|
36
|
+
Or in `config.rb`:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
require 'base.sass'
|
40
|
+
```
|
41
|
+
|
42
|
+
## Features
|
43
|
+
|
44
|
+
### Read environment variable (case insensitive)
|
45
|
+
|
46
|
+
When you run:
|
47
|
+
|
48
|
+
```sh
|
49
|
+
$ SASS_ENV=production sass -r base.sass --update src:dist
|
50
|
+
```
|
51
|
+
|
52
|
+
Then you can use `env()` in a Sass file to get the value:
|
53
|
+
|
54
|
+
```scss
|
55
|
+
env(SASS_ENV) //=> production
|
56
|
+
env(sass_env) //=> production
|
57
|
+
env(sass-env) //=> production
|
58
|
+
```
|
59
|
+
|
60
|
+
You can use any `KEY=value` if you want.
|
61
|
+
|
62
|
+
### Parse local json file
|
63
|
+
|
64
|
+
Returns a map, and the result will be cached per process.
|
65
|
+
|
66
|
+
```scss
|
67
|
+
$map: parse-json('~/Desktop/example.json');
|
68
|
+
$pkg: parse-json('package.json');
|
69
|
+
|
70
|
+
// Then, you can:
|
71
|
+
map-keys($map)
|
72
|
+
map-get($pkg, 'sass')
|
73
|
+
```
|
74
|
+
|
75
|
+
Now you can use the same configurations both in js and css.
|
76
|
+
|
77
|
+
### Parse browser supports (case insensitive)
|
78
|
+
|
79
|
+
All supported browsers: `chrome`, `firefox`, `safari`, `ie`, `opera`, `ios`, `android`.
|
80
|
+
|
81
|
+
> Rules data are from [Can I Use](http://beta.caniuse.com/).
|
82
|
+
|
83
|
+
**Rules:**
|
84
|
+
|
85
|
+
- `last 1 version` is last versions for each browser.
|
86
|
+
- `last 2 Chrome versions` is last versions of the specified browser.
|
87
|
+
- `IE > 8` is IE versions newer than 8.
|
88
|
+
- `IE >= 8` is IE version 8 or newer.
|
89
|
+
- `iOS 7` to set browser version directly.
|
90
|
+
|
91
|
+
```scss
|
92
|
+
// You can use one param
|
93
|
+
parse-rules('last 1 version')
|
94
|
+
|
95
|
+
// Or multi params
|
96
|
+
parse-rules('last 1 version', 'IE >= 8')
|
97
|
+
|
98
|
+
// Or a list
|
99
|
+
$rules: 'last 1 version', 'IE >= 8';
|
100
|
+
parse-rules($rules)
|
101
|
+
```
|
102
|
+
|
103
|
+
[See example](https://github.com/jsw0528/base.sass/wiki/Parse-browser-supports).
|
104
|
+
|
105
|
+
### Enhanced `url()`
|
106
|
+
|
107
|
+
If you want to activate the enhanced `url()`, you should wrap paths with quotes.
|
108
|
+
|
109
|
+
```scss
|
110
|
+
url(http://a.com/b.png)
|
111
|
+
//=> url(http://a.com/b.png) # Did nothing
|
112
|
+
|
113
|
+
url('http://a.com/b.png')
|
114
|
+
//=> url(http://a.com/b.png?1399394203)
|
115
|
+
|
116
|
+
url('a.png', 'b.png')
|
117
|
+
//=> url(a.png?1399394203), url(b.png?1399394203)
|
118
|
+
|
119
|
+
url('a.eot#iefix', 'b.woff')
|
120
|
+
//=> url(a.eot?1399394203#iefix) format('embedded-opentype'), url(b.woff?1399394203) format('woff')
|
121
|
+
```
|
122
|
+
|
123
|
+
The timestamp be added automatically by default, but you can remove it, or change it to whatever string you wanted.
|
124
|
+
|
125
|
+
```scss
|
126
|
+
url('a.png', $timestamp: false)
|
127
|
+
//=> url(a.png)
|
128
|
+
|
129
|
+
url('a.png', $timestamp: '1.0.0')
|
130
|
+
//=> url(a.png?1.0.0)
|
131
|
+
```
|
132
|
+
|
133
|
+
Also, you can defined timestamp as a global setting in `app-config` namespace:
|
134
|
+
|
135
|
+
```scss
|
136
|
+
$app-config: (timestamp: '1.0.0');
|
137
|
+
|
138
|
+
url('a.png')
|
139
|
+
//=> url(a.png?1.0.0)
|
140
|
+
```
|
141
|
+
|
142
|
+
The data uri is also be supported. Must be! :blush:
|
143
|
+
|
144
|
+
```scss
|
145
|
+
url('a.png', $base64: true)
|
146
|
+
//=> url(data:image/png;base64,iVBORw...)
|
147
|
+
|
148
|
+
url('a.eot', 'b.woff', $base64: true)
|
149
|
+
//=> url(data:application/vnd.ms-fontobject;base64,HAcAA...), url(data:application/font-woff;base64,d09GR...)
|
150
|
+
```
|
151
|
+
|
152
|
+
### Enhanced map functions
|
153
|
+
|
154
|
+
**Overrides official map functions to support nest keys.**
|
155
|
+
|
156
|
+
```scss
|
157
|
+
map-get($map, a)
|
158
|
+
map-get($map, a, b, c)
|
159
|
+
|
160
|
+
map-remove($map, a)
|
161
|
+
map-remove($map, a, b, c)
|
162
|
+
|
163
|
+
map-has-key($map, a)
|
164
|
+
map-has-key($map, a, b, c)
|
165
|
+
|
166
|
+
map-merge($map1, $map2)
|
167
|
+
map-merge($map1, $map2, true) // deep merge
|
168
|
+
```
|
169
|
+
|
170
|
+
### Placeholder-style mixins
|
171
|
+
|
172
|
+
If you want to let css contents appear in the place where it used first time, this is yours! :sunglasses:
|
173
|
+
|
174
|
+
Please refer to [ellipsis-overflow](stylesheets/base.sass/mixins/_ellipsis-overflow.scss) mixin.
|
175
|
+
|
176
|
+
```scss
|
177
|
+
.foo {
|
178
|
+
@include ellipsis-overflow;
|
179
|
+
}
|
180
|
+
|
181
|
+
.bar {
|
182
|
+
@include ellipsis-overflow;
|
183
|
+
}
|
184
|
+
```
|
185
|
+
|
186
|
+
Compiles to:
|
187
|
+
|
188
|
+
```css
|
189
|
+
.foo, .bar {
|
190
|
+
overflow: hidden;
|
191
|
+
text-overflow: ellipsis;
|
192
|
+
white-space: nowrap;
|
193
|
+
}
|
194
|
+
```
|
195
|
+
|
196
|
+
### [Read more in Wiki](https://github.com/jsw0528/base.sass/wiki)
|
197
|
+
|
198
|
+
## Test
|
199
|
+
|
200
|
+
```sh
|
201
|
+
$ git clone https://github.com/jsw0528/base.sass && cd base.sass && rake
|
202
|
+
```
|
203
|
+
|
204
|
+
## License
|
205
|
+
|
206
|
+
Licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
|
data/lib/base.sass.rb
CHANGED
data/lib/base.sass/env.rb
CHANGED
@@ -21,7 +21,7 @@ module Sass::Script::Functions
|
|
21
21
|
def app_config(name)
|
22
22
|
assert_type name, :String
|
23
23
|
config = environment.global_env.var('app-config')
|
24
|
-
config.is_a?(Sass::Script::Value::Map) && config.
|
24
|
+
config.is_a?(Sass::Script::Value::Map) && config.to_h[name] || null
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# Overrides official map functions to support nest keys.
|
2
|
+
module Sass::Script::Functions
|
3
|
+
|
4
|
+
# Returns the value in a map associated with the given keys.
|
5
|
+
#
|
6
|
+
# Examples:
|
7
|
+
# $map: (a: (b: (c: 1)));
|
8
|
+
# map-get($map, a) => (b: (c: 1))
|
9
|
+
# map-get($map, a, b) => (c: 1)
|
10
|
+
# map-get($map, a, b, c) => 1
|
11
|
+
# map-get($map, x) => null
|
12
|
+
# map-get($map, a, x, c) => null
|
13
|
+
# map-get($map, a, b, c, x) => null
|
14
|
+
# map-get((), x) => null
|
15
|
+
def map_get(map, *keys)
|
16
|
+
assert_type map, :Map
|
17
|
+
assert_args_number(keys)
|
18
|
+
|
19
|
+
hash, target = map.to_h, keys.pop
|
20
|
+
|
21
|
+
keys.each do |key|
|
22
|
+
# Each parent node must be a map
|
23
|
+
unless hash[key].is_a? Sass::Script::Value::Map
|
24
|
+
hash = {}
|
25
|
+
break
|
26
|
+
end
|
27
|
+
hash = hash[key].value
|
28
|
+
end
|
29
|
+
|
30
|
+
hash[target] || null
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns a new map with keys removed.
|
34
|
+
#
|
35
|
+
# Examples:
|
36
|
+
# $map: (a: (b: (c: 1)));
|
37
|
+
# map-remove($map, a) => ()
|
38
|
+
# map-remove($map, a, b) => (a: ())
|
39
|
+
# map-remove($map, a, b, c) => (a: (b: ()))
|
40
|
+
# map-remove($map, x) => (a: (b: (c: 1)))
|
41
|
+
# map-remove($map, a, x, c) => (a: (b: (c: 1)))
|
42
|
+
# map-remove($map, a, b, c, x) => (a: (b: (c: 1)))
|
43
|
+
def map_remove(map, *keys)
|
44
|
+
return map unless map_has_key(map, *keys).to_bool
|
45
|
+
|
46
|
+
target, hash = keys.pop, get_hash(map, keys)
|
47
|
+
hash.delete target
|
48
|
+
|
49
|
+
while keys.size > 0
|
50
|
+
target = keys.pop
|
51
|
+
_hash, hash = map(hash), get_hash(map, keys)
|
52
|
+
hash[target] = _hash
|
53
|
+
end
|
54
|
+
|
55
|
+
map(hash)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Returns whether a map has a value associated with a given keys.
|
59
|
+
#
|
60
|
+
# Examples:
|
61
|
+
# $map: (a: (b: (c: 1)));
|
62
|
+
# map-has-key($map, a) => true
|
63
|
+
# map-has-key($map, a, b) => true
|
64
|
+
# map-has-key($map, a, c) => false
|
65
|
+
# map-has-key($map, a, b, c) => true
|
66
|
+
# map-has-key($map, a, x, c) => false
|
67
|
+
# map-has-key($map, a, b, c, x) => false
|
68
|
+
def map_has_key(map, *keys)
|
69
|
+
assert_type map, :Map
|
70
|
+
assert_args_number(keys)
|
71
|
+
|
72
|
+
hash = map.to_h
|
73
|
+
|
74
|
+
keys.each do |key|
|
75
|
+
# Each parent node must be a map
|
76
|
+
return bool(false) unless hash.is_a?(Hash) && hash.key?(key)
|
77
|
+
hash = hash[key].value
|
78
|
+
end
|
79
|
+
|
80
|
+
bool(true)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Merges two maps together into a new map recursively.
|
84
|
+
#
|
85
|
+
# Examples:
|
86
|
+
# $map1: (a: (b: (c: 1 2, d: foo, e: baz)));
|
87
|
+
# $map2: (a: (b: (c: 3 4, d: bar)));
|
88
|
+
# map-merge($map1, $map2) => (a: (b: (c: 3 4, d: bar)))
|
89
|
+
# map-merge($map1, $map2, true) => (a: (b: (c: 1 2 3 4, d: bar, e: baz)))
|
90
|
+
def map_merge(map1, map2, deep = bool(false))
|
91
|
+
assert_type map1, :Map
|
92
|
+
assert_type map2, :Map
|
93
|
+
|
94
|
+
map1, map2 = map1.to_h.dup, map2.to_h
|
95
|
+
return map(map1.merge(map2)) unless deep.to_bool
|
96
|
+
|
97
|
+
map2.each do |k, v|
|
98
|
+
orig = map1[k]
|
99
|
+
map1[k] = get_value(orig, v)
|
100
|
+
end
|
101
|
+
|
102
|
+
map(map1)
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
private
|
107
|
+
|
108
|
+
def assert_args_number(keys)
|
109
|
+
raise ArgumentError.new('wrong number of arguments (1 for 2+)') if keys.empty?
|
110
|
+
end
|
111
|
+
|
112
|
+
def get_hash(map, keys)
|
113
|
+
(keys.empty? ? map : map_get(map, *keys)).to_h.dup
|
114
|
+
end
|
115
|
+
|
116
|
+
def get_value(oldVal, newVal)
|
117
|
+
if oldVal.is_a?(Sass::Script::Value::Map) && newVal.is_a?(Sass::Script::Value::Map)
|
118
|
+
map_merge(oldVal, newVal, bool(true))
|
119
|
+
elsif oldVal.is_a?(Sass::Script::Value::List) && newVal.is_a?(Sass::Script::Value::List)
|
120
|
+
join(oldVal, newVal)
|
121
|
+
else
|
122
|
+
newVal
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
@@ -10,14 +10,14 @@ module Sass::Script::Functions
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def to_ruby_hash(sass_map)
|
13
|
-
sass_map.
|
13
|
+
sass_map.to_h.inject({}) do |memo, (k, v)|
|
14
14
|
memo[k.to_s] = sass_to_ruby(v)
|
15
15
|
memo
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
def to_ruby_array(sass_list)
|
20
|
-
sass_list.
|
20
|
+
sass_list.to_a.map do |item|
|
21
21
|
sass_to_ruby(item)
|
22
22
|
end
|
23
23
|
end
|
data/lib/base.sass/selector.rb
CHANGED
@@ -42,11 +42,9 @@ module Sass::Script::Functions
|
|
42
42
|
def headers(from = nil, to = nil)
|
43
43
|
if from && !to
|
44
44
|
if from.is_a?(Sass::Script::Value::String) && from.value == 'all'
|
45
|
-
from = number(1)
|
46
|
-
to = number(6)
|
45
|
+
to, from = number(6), number(1)
|
47
46
|
else
|
48
|
-
to = from
|
49
|
-
from = number(1)
|
47
|
+
to, from = from, number(1)
|
50
48
|
end
|
51
49
|
else
|
52
50
|
from ||= number(1)
|
data/lib/base.sass/support.rb
CHANGED
@@ -44,22 +44,6 @@ module Sass::Script::Functions
|
|
44
44
|
ruby_to_sass(versions)
|
45
45
|
end
|
46
46
|
|
47
|
-
# Grep feature names according to caniuse by regex.
|
48
|
-
#
|
49
|
-
# Examples:
|
50
|
-
# grep-features('^css3?') => /^css3?/
|
51
|
-
# grep-features('box sizing') => /box|sizing/
|
52
|
-
# grep-features('box-sizing') => /box|sizing/
|
53
|
-
# def grep_features(regex)
|
54
|
-
# assert_type regex, :String
|
55
|
-
|
56
|
-
# regex = regex.value.strip.sub(/^-+|-+$/, '')
|
57
|
-
# regex = regex.gsub(/\s+|-+/, '|') if regex =~ /^[\w\s-]+$/
|
58
|
-
# regex = Regexp.new(regex, Regexp::IGNORECASE)
|
59
|
-
|
60
|
-
# ruby_to_sass(CanIUse.instance.supports.keys.select { |k| k =~ regex }.sort)
|
61
|
-
# end
|
62
|
-
|
63
47
|
|
64
48
|
private
|
65
49
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
|
1
|
+
$anonymous-placeholders: ();
|
2
2
|
|
3
3
|
@mixin placeholder-wrapper($name) {
|
4
|
-
$times: map-get(
|
4
|
+
$times: map-get($anonymous-placeholders, $name) or 0;
|
5
5
|
|
6
6
|
@if $times == 0 {
|
7
7
|
@at-root %-#{$name} {
|
@@ -10,5 +10,5 @@ $-registered-placeholders: ();
|
|
10
10
|
}
|
11
11
|
|
12
12
|
@extend %-#{$name};
|
13
|
-
|
13
|
+
$anonymous-placeholders: map-merge($anonymous-placeholders, ($name: $times + 1)) !global;
|
14
14
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: base.sass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- junjun.zhang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sass
|
@@ -30,16 +30,19 @@ dependencies:
|
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '3.5'
|
33
|
-
description:
|
33
|
+
description: Awesome features that you wanted
|
34
34
|
email: i@mrzhang.me
|
35
35
|
executables: []
|
36
36
|
extensions: []
|
37
37
|
extra_rdoc_files: []
|
38
38
|
files:
|
39
|
+
- Changelog.md
|
40
|
+
- Readme.md
|
39
41
|
- data/browsers.json
|
40
42
|
- lib/base.sass.rb
|
41
43
|
- lib/base.sass/caniuse.rb
|
42
44
|
- lib/base.sass/env.rb
|
45
|
+
- lib/base.sass/map.rb
|
43
46
|
- lib/base.sass/parse-json.rb
|
44
47
|
- lib/base.sass/ruby-to-sass.rb
|
45
48
|
- lib/base.sass/sass-to-ruby.rb
|
@@ -49,7 +52,6 @@ files:
|
|
49
52
|
- lib/base.sass/url.rb
|
50
53
|
- stylesheets/base.sass/_*.scss
|
51
54
|
- stylesheets/base.sass/functions/_list.scss
|
52
|
-
- stylesheets/base.sass/functions/_map.scss
|
53
55
|
- stylesheets/base.sass/functions/_support.scss
|
54
56
|
- stylesheets/base.sass/mixins/_clearfix.scss
|
55
57
|
- stylesheets/base.sass/mixins/_ellipsis-overflow.scss
|
@@ -80,5 +82,5 @@ rubyforge_project:
|
|
80
82
|
rubygems_version: 2.2.0
|
81
83
|
signing_key:
|
82
84
|
specification_version: 4
|
83
|
-
summary:
|
85
|
+
summary: Awesome Extensions For Sass
|
84
86
|
test_files: []
|
@@ -1,55 +0,0 @@
|
|
1
|
-
// Example:
|
2
|
-
//
|
3
|
-
// $map1: ( a: (x: 'x') );
|
4
|
-
// $map2: ( a: (y: 'y') );
|
5
|
-
//
|
6
|
-
// map-deep-merge($map1, $map2)
|
7
|
-
// => ( a: (x: 'x', y: 'y') )
|
8
|
-
@function map-deep-merge($map, $sub-map) {
|
9
|
-
@if type-of($map) != map or type-of($sub-map) != map {
|
10
|
-
@warn 'Params for `map-deep-merge` require map data';
|
11
|
-
@return null;
|
12
|
-
}
|
13
|
-
|
14
|
-
@each $key, $value in $sub-map {
|
15
|
-
$original: map-get($map, $key);
|
16
|
-
|
17
|
-
@if type-of($original) == map and type-of($value) == map {
|
18
|
-
$value: map-deep-merge($original, $value);
|
19
|
-
}
|
20
|
-
|
21
|
-
$map: map-merge($map, ($key: $value));
|
22
|
-
}
|
23
|
-
|
24
|
-
@return $map;
|
25
|
-
}
|
26
|
-
|
27
|
-
|
28
|
-
// Example:
|
29
|
-
//
|
30
|
-
// $map: (
|
31
|
-
// a: (
|
32
|
-
// b: (
|
33
|
-
// c: 'Good job!'
|
34
|
-
// )
|
35
|
-
// )
|
36
|
-
// );
|
37
|
-
//
|
38
|
-
// Before: map-get(map-get(map-get($map, a), b), c)
|
39
|
-
// After: map-find($map, 'a.b.c')
|
40
|
-
@function map-find($map, $keys) {
|
41
|
-
@while str-index($keys, '.') {
|
42
|
-
$index: str-index($keys, '.');
|
43
|
-
|
44
|
-
// Child elements
|
45
|
-
$map: map-get($map, str-slice($keys, 0, $index - 1));
|
46
|
-
@if type-of($map) != map {
|
47
|
-
@return null;
|
48
|
-
}
|
49
|
-
|
50
|
-
// Rest keys
|
51
|
-
$keys: str-slice($keys, $index + 1);
|
52
|
-
}
|
53
|
-
|
54
|
-
@return map-get($map, $keys);
|
55
|
-
}
|