SassFunk 0.0.1
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 +15 -0
- data/README.md +123 -0
- data/lib/SassFunk.rb +17 -0
- data/stylesheets/SassFunk/_sfnk-colors-complement.scss +13 -0
- data/stylesheets/SassFunk/_sfnk-colors-darken.scss +18 -0
- data/stylesheets/SassFunk/_sfnk-colors-desaturate.scss +13 -0
- data/stylesheets/SassFunk/_sfnk-colors-grayscale.scss +13 -0
- data/stylesheets/SassFunk/_sfnk-colors-invert.scss +13 -0
- data/stylesheets/SassFunk/_sfnk-colors-lighten.scss +18 -0
- data/stylesheets/SassFunk/_sfnk-colors-mix.scss +17 -0
- data/stylesheets/SassFunk/_sfnk-colors-saturate.scss +13 -0
- data/stylesheets/SassFunk/_sfnk-is-color-list.scss +14 -0
- data/stylesheets/SassFunk/_sfnk-is-grayscale-color.scss +14 -0
- data/stylesheets/SassFunk/_sfnk-is-nested-list.scss +14 -0
- data/stylesheets/SassFunk/_sfnk-is-numeric-list.scss +14 -0
- data/stylesheets/SassFunk/_sfnk-is-type-list.scss +14 -0
- data/stylesheets/SassFunk/_sfnk-is-valid-border.scss +58 -0
- data/stylesheets/SassFunk/_sfnk-list-contains-all.scss +14 -0
- data/stylesheets/SassFunk/_sfnk-list-contains.scss +14 -0
- data/stylesheets/SassFunk/_sfnk-list-mapify.scss +22 -0
- data/stylesheets/SassFunk/_sfnk-list-prepend.scss +14 -0
- data/stylesheets/SassFunk/_sfnk-list-reject-all.scss +15 -0
- data/stylesheets/SassFunk/_sfnk-list-reject-nth.scss +21 -0
- data/stylesheets/SassFunk/_sfnk-list-reject.scss +43 -0
- data/stylesheets/SassFunk/_sfnk-list-reverse.scss +16 -0
- data/stylesheets/SassFunk/_sfnk-map-listify-deep.scss +22 -0
- data/stylesheets/SassFunk/_sfnk-map-listify.scss +24 -0
- data/stylesheets/SassFunk/_sfnk-map-set.scss +9 -0
- data/stylesheets/_SassFunk.scss +25 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MmIwNzRiNjU5YzkyOTJkMzcxNWM4MzYzODNmMDM5ZmEzOTZmMTZlNA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZTM1NTg2ZGFiNGQ4NjdkNjAzOGVjZmYxM2UwMGU2ZjI3ODhkMTYwNw==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YjQ3OGQ1YjA1YTdkYjA3NThmNzU3NzVhMmNmMDI4OTZiYzMwY2I0YjUwYzQz
|
10
|
+
N2IzYjhhMjdiZWUyYzFiNzg2ZDUxNTMyNDUxNzk5NjdiZmIwMTIxZjk4ZWU0
|
11
|
+
ZjhiYTIzNDVjNWZlNmQyYWEwYjFhMmIzYjA1YjI0NWU4YTdkZjA=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
N2JkOWEyNzU5MDYwNGE1N2NjMjgwYzc0ZDA1ODEyNWViZmEyMzNlNzljYTJh
|
14
|
+
MTZjZDI2ZGMwZmNlMDQ3YTk5NjM4OTI2NDBlYjE0MTgzN2Q1NmY2OGY3OTMx
|
15
|
+
ZjFhNTk3NWY2NjNmNmZhMDA4MjBjZDdlYjcxYTg4ZjI0YzVlYjE=
|
data/README.md
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
# SassFunk
|
2
|
+
|
3
|
+
A collection of utility functions for Sass.
|
4
|
+
|
5
|
+
## Install SassFunk
|
6
|
+
|
7
|
+
SassFunk can be installed as a Ruby gem, via [Bower](http://bower.io), or manually.
|
8
|
+
|
9
|
+
When installing as a Ruby Gem, SassFunk will be installed as a Compass extension if Compass is installed on your system:
|
10
|
+
|
11
|
+
$ gem install SassFunk
|
12
|
+
|
13
|
+
|
14
|
+
To install ia bower run:
|
15
|
+
|
16
|
+
$ bower install --save-dev SassFunk
|
17
|
+
|
18
|
+
For a manual install, include `dist/SassFunk.scss` in the appropriate directory of your project.
|
19
|
+
|
20
|
+
SassFunk is also on [Sache](http://sache.in).
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
## Use SassFunk
|
25
|
+
|
26
|
+
### What's inside
|
27
|
+
|
28
|
+
#### sfnk-colors-complement( $colors )
|
29
|
+
Returns the list of complementary colors for a list of colors.
|
30
|
+
|
31
|
+
#### sfnk-colors-darken( $colors, $value )
|
32
|
+
Returns the list of colors darkened by `$value`.
|
33
|
+
|
34
|
+
#### sfnk-colors-desaturate( $colors, $value )
|
35
|
+
Returns the list of colors desatureated by `$value`.
|
36
|
+
|
37
|
+
#### sfnk-colors-grayscale( $colors )
|
38
|
+
Returns the list of equivalent grayscale colors.
|
39
|
+
|
40
|
+
#### sfnk-colors-invert( $colors )
|
41
|
+
Returns the list of inverted colors.
|
42
|
+
|
43
|
+
#### sfnk-colors-lighten( $colors, $value )
|
44
|
+
Returns th elist of colors lightened by `$value`.
|
45
|
+
|
46
|
+
#### sfnk-colors-mix( $colors )
|
47
|
+
Returns a single color that is the mix of `$colors`.
|
48
|
+
|
49
|
+
#### sfnk-colors-saturate( $colors, $value )
|
50
|
+
Returns the list of colors saturated by `$value`.
|
51
|
+
|
52
|
+
#### sfnk-is-color-list( $list )
|
53
|
+
Retruns a bool whether `$list` consists of color values only.
|
54
|
+
|
55
|
+
#### sfnk-is-nested-list( $list )
|
56
|
+
Returns a bool whether `$list` contains any items that are lists.
|
57
|
+
|
58
|
+
#### sfnk-is-numeric-list( $list )
|
59
|
+
Returns a bool whether `$list`consists of numbers only.
|
60
|
+
|
61
|
+
#### sfnk-is-type-list( $list, $type )
|
62
|
+
Returns a bool whether all items of $list are of type `$type` .
|
63
|
+
|
64
|
+
#### sfnk-is-valid-border( $border, [$strict:false] )
|
65
|
+
Returns a bool whether $border is a valid CSS border statement. Pass `strict: true`to check whether $border is a complete shorthand CSS border statement consisting of border-width, border-style, and border-color.
|
66
|
+
|
67
|
+
#### sfnk-list-contains-all( $list1, $list2 )
|
68
|
+
Returns a bool whether `$list1` contains all items in `$list2`.
|
69
|
+
|
70
|
+
#### sfnk-list-contains( $list, $value )
|
71
|
+
Returns a bool whether `$list` contains `$value`.
|
72
|
+
|
73
|
+
#### sfnk-list-mapify( $list )
|
74
|
+
Creates a map from a nested list where the keys are the first items of the items of `$list`, the value the remaining items of each item of `$list`.
|
75
|
+
|
76
|
+
#### sfnk-list-prepend( $list, $value )
|
77
|
+
Returns `$list`prepended with `$value`.
|
78
|
+
|
79
|
+
#### sfnk-list-reject-all( $list, $value )
|
80
|
+
Returns a list where all occurences of `$value`.
|
81
|
+
|
82
|
+
#### sfnk-list-reject-nth( $list, $index, [$pos: 1] )
|
83
|
+
Rejects the item at `$index` from `$list`. Pass `$pos: -1` to reject the item at `$index` from the end of `$list`.
|
84
|
+
|
85
|
+
#### sfnk-list-reject( $list, $value, [$pos: 1])
|
86
|
+
Rejects first occurence of `$value` from `$list`. Pass `$pos: -1`to reject the last occurence.
|
87
|
+
|
88
|
+
#### sfnk-list-reverse( $list )
|
89
|
+
Reverses `$list`.
|
90
|
+
|
91
|
+
#### sfnk-map-listify-deep( $map )
|
92
|
+
Like `sfnk-map-listify()` , but recursive.
|
93
|
+
|
94
|
+
#### sfnk-map-listify( $map )
|
95
|
+
Creates a list of list items from `$map`, where the keys are the first item in each list item of `$list`.
|
96
|
+
|
97
|
+
#### sfnk-map-set( $map, $key, $value )
|
98
|
+
Sets key `$key` in `$map` to `$value`.
|
99
|
+
|
100
|
+
|
101
|
+
The MIT License (MIT)
|
102
|
+
---
|
103
|
+
|
104
|
+
|
105
|
+
Copyright (c) 2015 Franz Heidl
|
106
|
+
|
107
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
108
|
+
of this software and associated documentation files (the "Software"), to deal
|
109
|
+
in the Software without restriction, including without limitation the rights
|
110
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
111
|
+
copies of the Software, and to permit persons to whom the Software is
|
112
|
+
furnished to do so, subject to the following conditions:
|
113
|
+
|
114
|
+
The above copyright notice and this permission notice shall be included in
|
115
|
+
all copies or substantial portions of the Software.
|
116
|
+
|
117
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
118
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
119
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
120
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
121
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
122
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
123
|
+
THE SOFTWARE.
|
data/lib/SassFunk.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
2
|
+
stylesheets_path = File.join(extension_path, 'stylesheets')
|
3
|
+
|
4
|
+
if (defined? Compass)
|
5
|
+
Compass::Frameworks.register('SassFunk', :path => extension_path)
|
6
|
+
else
|
7
|
+
if ENV.has_key?("SASS_PATH")
|
8
|
+
ENV["SASS_PATH"] = ENV["SASS_PATH"] + File::PATH_SEPARATOR + stylesheets_path
|
9
|
+
else
|
10
|
+
ENV["SASS_PATH"] = stylesheets_path
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module SassFunk
|
15
|
+
VERSION = "0.0.1"
|
16
|
+
DATE = "2015-03-24"
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
@function sfnk-colors-complement($colors) {
|
2
|
+
@if sfnk-is-color-list($colors) or type-of($colors) == color {
|
3
|
+
$complement: ();
|
4
|
+
@each $color in $colors {
|
5
|
+
$complement: append($complement, complement($color));
|
6
|
+
}
|
7
|
+
@return $complement;
|
8
|
+
}
|
9
|
+
@else {
|
10
|
+
@warn "SassFunk: #{type-of($colors)} #{$colors} is not a valid argument for sfnk-colors-complement(). Pass multiple colors or a list of colors.";
|
11
|
+
@return null;
|
12
|
+
}
|
13
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
@function sfnk-colors-darken($colors, $value) {
|
2
|
+
@if type-of($colors) == list or type-of($colors) == color {
|
3
|
+
@if type-of($colors) == color {
|
4
|
+
@return darken($colors, $value);
|
5
|
+
}
|
6
|
+
@else {
|
7
|
+
$darkened: ();
|
8
|
+
@each $color in $colors {
|
9
|
+
$darkened: append($darkened, darken($color, $value));
|
10
|
+
}
|
11
|
+
@return $darkened;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
@else {
|
15
|
+
@warn "SassFunk: #{type-of($colors)} #{$colors} is not a valid argument for sfnk-colors-darken(). Pass a list of colors.";
|
16
|
+
@return null;
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
@function sfnk-colors-desaturate($colors, $value) {
|
2
|
+
@if sfnk-is-color-list($colors) or type-of($colors) == color {
|
3
|
+
$desaturated: ();
|
4
|
+
@each $color in $colors {
|
5
|
+
$desaturated: append($desaturated, desaturate($color, $value));
|
6
|
+
}
|
7
|
+
@return $desaturated;
|
8
|
+
}
|
9
|
+
@else {
|
10
|
+
@warn "SassFunk: #{type-of($colors)} #{$colors} is not a valid argument for sfnk-colors-desaturate(). Pass multiple colors or a list of colors.";
|
11
|
+
@return null;
|
12
|
+
}
|
13
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
@function sfnk-colors-grayscale($colors) {
|
2
|
+
@if sfnk-is-color-list($colors) or type-of($colors) == color {
|
3
|
+
$grayscale: ();
|
4
|
+
@each $color in $colors {
|
5
|
+
$grayscale: append($grayscale, grayscale($color));
|
6
|
+
}
|
7
|
+
@return $grayscale;
|
8
|
+
}
|
9
|
+
@else {
|
10
|
+
@warn "SassFunk: #{type-of($colors)} #{$colors} is not a valid argument for sfnk-colors-grayscale(). Pass multiple colors or a list of colors.";
|
11
|
+
@return null;
|
12
|
+
}
|
13
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
@function sfnk-colors-invert($colors) {
|
2
|
+
@if sfnk-is-color-list($colors) or type-of($colors) == color {
|
3
|
+
$invert: ();
|
4
|
+
@each $color in $colors {
|
5
|
+
$invert: append($invert, invert($color));
|
6
|
+
}
|
7
|
+
@return $invert;
|
8
|
+
}
|
9
|
+
@else {
|
10
|
+
@warn "SassFunk: #{type-of($colors)} #{$colors} is not a valid argument for sfnk-colors-invert(). Pass multiple colors or a list of colors.";
|
11
|
+
@return null;
|
12
|
+
}
|
13
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
@function sfnk-colors-lighten($colors, $value) {
|
2
|
+
@if type-of($colors) == list or type-of($colors) == color {
|
3
|
+
@if type-of($colors) == color {
|
4
|
+
@return lighten($colors, $value);
|
5
|
+
}
|
6
|
+
@else {
|
7
|
+
$lightened: ();
|
8
|
+
@each $color in $colors {
|
9
|
+
$lightened: append($lightened, lighten($color, $value));
|
10
|
+
}
|
11
|
+
@return $lightened;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
@else {
|
15
|
+
@warn "SassFunk: #{type-of($colors)} #{$colors} is not a valid argument for sfnk-colors-lighten(). Pass a list of colors.";
|
16
|
+
@return null;
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
@function sfnk-colors-mix($colors...) {
|
2
|
+
@if sfnk-is-color-list($colors) and length($colors) > 1 {
|
3
|
+
$mix: nth($colors, 1);
|
4
|
+
$colors: sfnk-list-reject-nth($colors, 1);
|
5
|
+
$i: 1;
|
6
|
+
@each $item in $colors {
|
7
|
+
$i: $i + 1;
|
8
|
+
$perc: 100% / $i;
|
9
|
+
$mix: mix($mix, $item, $perc);
|
10
|
+
}
|
11
|
+
@return $mix;
|
12
|
+
}
|
13
|
+
@else {
|
14
|
+
@warn "SassFunk: #{type-of($colors)} #{$colors} is not a valid argument for sfnk-colors-mix(). Pass multiple colors or a list of colors.";
|
15
|
+
@return null;
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
@function sfnk-colors-saturate($colors, $value) {
|
2
|
+
@if sfnk-is-color-list($colors) or type-of($colors) == color {
|
3
|
+
$saturated: ();
|
4
|
+
@each $color in $colors {
|
5
|
+
$saturated: append($saturated, saturate($color, $value));
|
6
|
+
}
|
7
|
+
@return $saturated;
|
8
|
+
}
|
9
|
+
@else {
|
10
|
+
@warn "SassFunk: #{type-of($colors)} #{$colors} is not a valid argument for sfnk-colors-saturate(). Pass multiple colors or a list of colors.";
|
11
|
+
@return null;
|
12
|
+
}
|
13
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
@function sfnk-is-color-list($list) {
|
2
|
+
@if type-of($list) == list or type-of($list) == arglist {
|
3
|
+
@each $item in $list {
|
4
|
+
@if type-of($item) != color {
|
5
|
+
@return false;
|
6
|
+
}
|
7
|
+
}
|
8
|
+
@return true;
|
9
|
+
}
|
10
|
+
@else {
|
11
|
+
@warn "SassFunk: #{type-of($list)} #{$list} is not a valid argument for sfnk-is-color-list(). Pass a list or arglist.";
|
12
|
+
@return null;
|
13
|
+
}
|
14
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
@function sfnk-is-grayscale-color($color) {
|
2
|
+
@if type-of($color) == color {
|
3
|
+
@if red($color) == green($color) and green($color) == blue($color) {
|
4
|
+
@return true;
|
5
|
+
}
|
6
|
+
@else {
|
7
|
+
@return false;
|
8
|
+
}
|
9
|
+
}
|
10
|
+
@else {
|
11
|
+
@warn "SassFunk: #{type-of($color)} #{$color} is not a valid argument for sfnk-is-grayscale-color(). Pass a color instead.";
|
12
|
+
@return null;
|
13
|
+
}
|
14
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
@function sfnk-is-nested-list($list) {
|
2
|
+
@if type-of($list) == list or type-of($list) == arglist {
|
3
|
+
@each $item in $list {
|
4
|
+
@if type-of($item) == list {
|
5
|
+
@return true;
|
6
|
+
}
|
7
|
+
}
|
8
|
+
@return false;
|
9
|
+
}
|
10
|
+
@else {
|
11
|
+
@warn "SassFunk: #{type-of($list)} #{$list} is not a valid argument for sfnk-is-nested-list(). Pass a list or arglist.";
|
12
|
+
@return null;
|
13
|
+
}
|
14
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
@function sfnk-is-numeric-list($list) {
|
2
|
+
@if type-of($list) == list or type-of($list) == arglist {
|
3
|
+
@each $item in $list {
|
4
|
+
@if type-of($item) != number {
|
5
|
+
@return false;
|
6
|
+
}
|
7
|
+
}
|
8
|
+
@return true;
|
9
|
+
}
|
10
|
+
@else {
|
11
|
+
@warn "SassFunk: #{type-of($list)} #{$list} is not a valid argument for sfnk-is-numeric-list(). Pass a list or arglist.";
|
12
|
+
@return null;
|
13
|
+
}
|
14
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
@function sfnk-is-type-list($list, $type) {
|
2
|
+
@if type-of($list) == list or type-of($list) == arglist {
|
3
|
+
@each $item in $list {
|
4
|
+
@if type-of($item) != $type {
|
5
|
+
@return false;
|
6
|
+
}
|
7
|
+
}
|
8
|
+
@return true;
|
9
|
+
}
|
10
|
+
@else {
|
11
|
+
@warn "SassFunk: #{type-of($list)} #{$list}, #{$type} is not a valid argument for sfnk-list-items-type(). Pass a list or arglist.";
|
12
|
+
@return null;
|
13
|
+
}
|
14
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
@function sfnk-is-valid-border($border, $strict: false) {
|
2
|
+
$borderTypes: color string number;
|
3
|
+
$borderStyles: solid dotted dashed double none;
|
4
|
+
$validBorder: false;
|
5
|
+
$has: (width: false, style: false, color: false);
|
6
|
+
|
7
|
+
@if $strict == true {
|
8
|
+
@if type-of($border) == list or type-of($border) == arglist {
|
9
|
+
@if length($border) == 3 {
|
10
|
+
@each $item in $border {
|
11
|
+
@if type-of($item) == color {
|
12
|
+
$has: sfnk-map-set($has, color, true);
|
13
|
+
}
|
14
|
+
@else if type-of($item) == number {
|
15
|
+
@if $item == 0 or unit($item) == px {
|
16
|
+
$has: sfnk-map-set($has, width, true);
|
17
|
+
}
|
18
|
+
}
|
19
|
+
@else if type-of($item) == string {
|
20
|
+
@if sfnk-list-contains($borderStyles, $item) {
|
21
|
+
$has: sfnk-map-set($has, style, true);
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
@if map-get($has, width) == true and map-get($has, style) == true and map-get($has, color) == true {
|
26
|
+
@return true;
|
27
|
+
}
|
28
|
+
@else {
|
29
|
+
@return false;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
@else {
|
33
|
+
@return false;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
@else {
|
37
|
+
@return false;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
@else {
|
41
|
+
@each $item in $border {
|
42
|
+
@if type-of($item) == string {
|
43
|
+
@if (sfnk-list-contains($borderStyles, $item)) == false {
|
44
|
+
@return false;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
@else if type-of($item) == number {
|
48
|
+
@if ($item != 0 and unitless($item)) {
|
49
|
+
@return false;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
@else if type-of($item) != color {
|
53
|
+
@return false;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
@return true;
|
57
|
+
}
|
58
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
@function sfnk-list-contains-all($list1, $list2) {
|
2
|
+
@if (type-of($list1) == list) and (type-of($list2) == list) {
|
3
|
+
@each $item in $list2 {
|
4
|
+
@if not index($list1, $item) {
|
5
|
+
@return false;
|
6
|
+
}
|
7
|
+
}
|
8
|
+
@return true;
|
9
|
+
}
|
10
|
+
@else {
|
11
|
+
@warn "SassFunk: #{type-of($list1)} #{$list1} #{type-of($list2)} #{$list2} are not valid arguments for sfnk-list-contains-all(). Pass two lists to compare.";
|
12
|
+
@return null;
|
13
|
+
}
|
14
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
@function sfnk-list-contains($list, $value) {
|
2
|
+
@if type-of($list) == list {
|
3
|
+
@if index($list, $value) {
|
4
|
+
@return true;
|
5
|
+
}
|
6
|
+
@else {
|
7
|
+
@return false;
|
8
|
+
}
|
9
|
+
}
|
10
|
+
@else {
|
11
|
+
@warn "SassFunk: #{type-of($list)} #{$list} is not a valid argument for sfnk-list-contains(). Pass a list or arglist.";
|
12
|
+
@return null;
|
13
|
+
}
|
14
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
@function sfnk-list-mapify($list) {
|
2
|
+
@if type-of($list) == list or type-of($list) == arglist {
|
3
|
+
$map: null;
|
4
|
+
@each $item in $list {
|
5
|
+
@if type-of($item) == list && length($item) > 1 {
|
6
|
+
// (border 1px solid green, hover (color: red, background: yellow)) --> (border: 1px solid green, hover: (color: red, background-yellow))
|
7
|
+
$key: nth($item, 1);
|
8
|
+
$val: sfnk-list-reject-nth($item, 1);
|
9
|
+
$map: sfnk-map-set($map, $key, $val);
|
10
|
+
}
|
11
|
+
@else {
|
12
|
+
@warn "SassFunk: #{type-of($item)} #{$item} is not a list. All items in the list passed to sfnk-list-mapify must be at least 2 items long.";
|
13
|
+
@return null;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
@return $map;
|
17
|
+
}
|
18
|
+
@else {
|
19
|
+
@warn "SassFunk: #{type-of($list)} #{$list} is not a valid argument for sfnk-list-mapify(). Pass a list or arglist.";
|
20
|
+
@return null;
|
21
|
+
}
|
22
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
@function sfnk-list-prepend($list, $value) {
|
2
|
+
@if type-of($list) == list or type-of($list) == arglist {
|
3
|
+
$new-list: ();
|
4
|
+
$new-list: append($new-list, $value);
|
5
|
+
@each $item in $list {
|
6
|
+
$new-list: append($new-list, $item);
|
7
|
+
}
|
8
|
+
@return $new-list;
|
9
|
+
}
|
10
|
+
@else {
|
11
|
+
@warn "SassFunk: #{type-of($list)} #{$list} is not a valid argument for sfnk-list-prepend(). Pass a list or arglist.";
|
12
|
+
@return null;
|
13
|
+
}
|
14
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
@function sfnk-list-reject-all($list, $value) {
|
2
|
+
@if type-of($list) == list {
|
3
|
+
$rejected: ();
|
4
|
+
@for $i from 1 through length($list) {
|
5
|
+
@if nth($list, $i) != $value {
|
6
|
+
$rejected: append($rejected, nth($list, $i));
|
7
|
+
}
|
8
|
+
}
|
9
|
+
@return $rejected;
|
10
|
+
}
|
11
|
+
@else {
|
12
|
+
@warn "SassFunk: #{type-of($list)} #{$list} is not a valid argument for sfnk-list-reject-all(). Pass a list or arglist.";
|
13
|
+
@return null;
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
@function sfnk-list-reject-nth($list, $index, $pos: 1) {
|
2
|
+
@if type-of($list) == list or type-of($list) == arglist {
|
3
|
+
$rejected-list: ();
|
4
|
+
@if $pos == -1 {
|
5
|
+
$list: sfnk-list-reverse($list);
|
6
|
+
}
|
7
|
+
@for $i from 1 through length($list) {
|
8
|
+
@if $i != $index {
|
9
|
+
$rejected-list: append($rejected-list, nth($list, $i));
|
10
|
+
}
|
11
|
+
}
|
12
|
+
@if $pos == -1 {
|
13
|
+
$rejected-list: sfnk-list-reverse($rejected-list);
|
14
|
+
}
|
15
|
+
@return $rejected-list;
|
16
|
+
}
|
17
|
+
@else {
|
18
|
+
@warn "SassFunk: #{type-of($list)} #{$list} is not a valid argument for sfnk-list-reject-nth(). Pass a list or arglist and the index of the item to be removed.";
|
19
|
+
@return null;
|
20
|
+
}
|
21
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
@function sfnk-list-reject($list, $value, $pos: 1) {
|
2
|
+
@if type-of($list) == list or type-of($list) == arglist {
|
3
|
+
@if index($list, $value) {
|
4
|
+
$rejected-list: ();
|
5
|
+
@if $pos == -1 or $pos == 1 {
|
6
|
+
@if $pos == -1 { // index from end of list
|
7
|
+
$list: sfnk-list-reverse($list);
|
8
|
+
}
|
9
|
+
// (1, 2, 3, 4, 3, 5) --> (1, 2, 4, 3, 5)
|
10
|
+
$done: false;
|
11
|
+
@each $item in $list {
|
12
|
+
@if $item != $value {
|
13
|
+
$rejected-list: append($rejected-list, $item);
|
14
|
+
}
|
15
|
+
@else {
|
16
|
+
@if not $done {
|
17
|
+
$done: true;
|
18
|
+
}
|
19
|
+
@else {
|
20
|
+
$rejected-list: append($rejected-list, $item);
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
24
|
+
@if $pos == -1 { // reverse list again if it was reversed in order to remove the last matching element
|
25
|
+
$rejected-list: sfnk-list-reverse($rejected-list);
|
26
|
+
}
|
27
|
+
@return $rejected-list;
|
28
|
+
}
|
29
|
+
@else {
|
30
|
+
@warn "SassUtils: #{$pos} is not a valid position argument for reject-list(). Pass 1, -1, or nothing.";
|
31
|
+
@return null;
|
32
|
+
}
|
33
|
+
@return $list;
|
34
|
+
}
|
35
|
+
@else {
|
36
|
+
@return $list;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
@else {
|
40
|
+
@warn "SassFunk: #{type-of($list)} #{$list} is not a valid argument for sfnk-list-reject(). Pass a list or arglist and a value to be removed.";
|
41
|
+
@return null;
|
42
|
+
}
|
43
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
@function sfnk-list-reverse($list) {
|
2
|
+
@if type-of($list) == list or type-of($list) == arglist {
|
3
|
+
$reversed: ();
|
4
|
+
@for $i from 0 through length($list) {
|
5
|
+
$rev-index: length($list) - $i;
|
6
|
+
@if $rev-index > 0 {
|
7
|
+
$reversed: append($reversed, nth($list, $rev-index));
|
8
|
+
}
|
9
|
+
}
|
10
|
+
@return $reversed;
|
11
|
+
}
|
12
|
+
@else {
|
13
|
+
@warn "SassFunk: #{type-of($list)} #{$list} is not a valid argument for sfnk-list-reverse(). Pass a list or arglist.";
|
14
|
+
@return null;
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
@function sfnk-map-listify-deep($map) {
|
2
|
+
@if type-of($map) == map {
|
3
|
+
$flattened: ();
|
4
|
+
$keys: map-keys($map);
|
5
|
+
@for $i from 1 through length($map) {
|
6
|
+
$list: ();
|
7
|
+
$key: nth($keys, $i);
|
8
|
+
$value: map-get($map, $key);
|
9
|
+
@if type-of($value) == map {
|
10
|
+
$value: sfnk-map-listify-deep($value);
|
11
|
+
}
|
12
|
+
$list: append($list, $key);
|
13
|
+
$list: append($list, $value);
|
14
|
+
$flattened: append($flattened, $list);
|
15
|
+
}
|
16
|
+
@return $flattened;
|
17
|
+
}
|
18
|
+
@else {
|
19
|
+
@warn "SassFunk: #{type-of($map)} #{$map} is not a valid argument for sfnk-map-listify-deep(). Pass a list or arglist.";
|
20
|
+
@return null;
|
21
|
+
}
|
22
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
@function sfnk-map-listify($map, $flatten-lists: false) {
|
2
|
+
@if type-of($map) == map {
|
3
|
+
$flattened: ();
|
4
|
+
$keys: map-keys($map);
|
5
|
+
@for $i from 1 through length($map) {
|
6
|
+
$list: ();
|
7
|
+
$key: nth($keys, $i);
|
8
|
+
$value: map-get($map, $key);
|
9
|
+
@if type-of($value) == list and $flatten-lists == true {
|
10
|
+
$list: sfnk-list-prepend($value, $key);
|
11
|
+
}
|
12
|
+
@else {
|
13
|
+
$list: append($list, $key);
|
14
|
+
$list: append($list, $value);
|
15
|
+
}
|
16
|
+
$flattened: append($flattened, $list);
|
17
|
+
}
|
18
|
+
@return $flattened;
|
19
|
+
}
|
20
|
+
@else {
|
21
|
+
@warn "SassFunk: #{type-of($map)} #{$map} is not a valid argument for sfnk-map-listify(). Pass a list or arglist.";
|
22
|
+
@return null;
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
@function sfnk-map-set($map, $key, $value) {
|
2
|
+
@if type-of($map) == map {
|
3
|
+
@return map-merge($map, ($key: $value));
|
4
|
+
}
|
5
|
+
@else {
|
6
|
+
@warn "SassFunk: #{type-of($map)} #{$map} is not a valid argument for sfnk-map-set(). Pass a map as the first argument.";
|
7
|
+
@return null;
|
8
|
+
}
|
9
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
@import "SassFunk/sfnk-colors-complement";
|
2
|
+
@import "SassFunk/sfnk-colors-darken";
|
3
|
+
@import "SassFunk/sfnk-colors-desaturate";
|
4
|
+
@import "SassFunk/sfnk-colors-grayscale";
|
5
|
+
@import "SassFunk/sfnk-colors-invert";
|
6
|
+
@import "SassFunk/sfnk-colors-lighten";
|
7
|
+
@import "SassFunk/sfnk-colors-mix";
|
8
|
+
@import "SassFunk/sfnk-colors-saturate";
|
9
|
+
@import "SassFunk/sfnk-is-color-list";
|
10
|
+
@import "SassFunk/sfnk-is-grayscale-color";
|
11
|
+
@import "SassFunk/sfnk-is-nested-list";
|
12
|
+
@import "SassFunk/sfnk-is-numeric-list";
|
13
|
+
@import "SassFunk/sfnk-is-type-list";
|
14
|
+
@import "SassFunk/sfnk-is-valid-border";
|
15
|
+
@import "SassFunk/sfnk-list-contains-all";
|
16
|
+
@import "SassFunk/sfnk-list-contains";
|
17
|
+
@import "SassFunk/sfnk-list-mapify";
|
18
|
+
@import "SassFunk/sfnk-list-prepend";
|
19
|
+
@import "SassFunk/sfnk-list-reject-all";
|
20
|
+
@import "SassFunk/sfnk-list-reject-nth";
|
21
|
+
@import "SassFunk/sfnk-list-reject";
|
22
|
+
@import "SassFunk/sfnk-list-reverse";
|
23
|
+
@import "SassFunk/sfnk-map-listify-deep";
|
24
|
+
@import "SassFunk/sfnk-map-listify";
|
25
|
+
@import "SassFunk/sfnk-map-set";
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: SassFunk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Franz Heidl
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sass
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.3'
|
27
|
+
description: Sass utility functions
|
28
|
+
email:
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- README.md
|
34
|
+
- lib/SassFunk.rb
|
35
|
+
- stylesheets/_SassFunk.scss
|
36
|
+
- stylesheets/SassFunk/_sfnk-colors-complement.scss
|
37
|
+
- stylesheets/SassFunk/_sfnk-colors-darken.scss
|
38
|
+
- stylesheets/SassFunk/_sfnk-colors-desaturate.scss
|
39
|
+
- stylesheets/SassFunk/_sfnk-colors-grayscale.scss
|
40
|
+
- stylesheets/SassFunk/_sfnk-colors-invert.scss
|
41
|
+
- stylesheets/SassFunk/_sfnk-colors-lighten.scss
|
42
|
+
- stylesheets/SassFunk/_sfnk-colors-mix.scss
|
43
|
+
- stylesheets/SassFunk/_sfnk-colors-saturate.scss
|
44
|
+
- stylesheets/SassFunk/_sfnk-is-color-list.scss
|
45
|
+
- stylesheets/SassFunk/_sfnk-is-grayscale-color.scss
|
46
|
+
- stylesheets/SassFunk/_sfnk-is-nested-list.scss
|
47
|
+
- stylesheets/SassFunk/_sfnk-is-numeric-list.scss
|
48
|
+
- stylesheets/SassFunk/_sfnk-is-type-list.scss
|
49
|
+
- stylesheets/SassFunk/_sfnk-is-valid-border.scss
|
50
|
+
- stylesheets/SassFunk/_sfnk-list-contains-all.scss
|
51
|
+
- stylesheets/SassFunk/_sfnk-list-contains.scss
|
52
|
+
- stylesheets/SassFunk/_sfnk-list-mapify.scss
|
53
|
+
- stylesheets/SassFunk/_sfnk-list-prepend.scss
|
54
|
+
- stylesheets/SassFunk/_sfnk-list-reject-all.scss
|
55
|
+
- stylesheets/SassFunk/_sfnk-list-reject-nth.scss
|
56
|
+
- stylesheets/SassFunk/_sfnk-list-reject.scss
|
57
|
+
- stylesheets/SassFunk/_sfnk-list-reverse.scss
|
58
|
+
- stylesheets/SassFunk/_sfnk-map-listify-deep.scss
|
59
|
+
- stylesheets/SassFunk/_sfnk-map-listify.scss
|
60
|
+
- stylesheets/SassFunk/_sfnk-map-set.scss
|
61
|
+
homepage: https://github.com/franzheidl/SassFunk
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.3.6
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.0.0.rc.2
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: A collection of Sass utitlity functions mainly dealing with colors, lists,
|
85
|
+
and maps
|
86
|
+
test_files: []
|