sass-aleksi 0.1.2

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.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +44 -0
  3. data/lib/sass-aleksi.rb +31 -0
  4. data/stylesheets/_aleksi.scss +23 -0
  5. data/stylesheets/aleksi/_colors.scss +0 -0
  6. data/stylesheets/aleksi/_config.scss +11 -0
  7. data/stylesheets/aleksi/_general.scss +11 -0
  8. data/stylesheets/aleksi/_lengths.scss +8 -0
  9. data/stylesheets/aleksi/_lists.scss +16 -0
  10. data/stylesheets/aleksi/_maps.scss +21 -0
  11. data/stylesheets/aleksi/_math.scss +10 -0
  12. data/stylesheets/aleksi/_sides.scss +11 -0
  13. data/stylesheets/aleksi/config/_constants.scss +73 -0
  14. data/stylesheets/aleksi/general/_apply.scss +42 -0
  15. data/stylesheets/aleksi/general/_css-rule.scss +88 -0
  16. data/stylesheets/aleksi/general/_default-to.scss +35 -0
  17. data/stylesheets/aleksi/general/_is-of-type.scss +72 -0
  18. data/stylesheets/aleksi/general/_throw.scss +125 -0
  19. data/stylesheets/aleksi/lengths/_convert.scss +100 -0
  20. data/stylesheets/aleksi/lengths/_strip-unit.scss +37 -0
  21. data/stylesheets/aleksi/lists/_contained-in.scss +34 -0
  22. data/stylesheets/aleksi/lists/_depth.scss +46 -0
  23. data/stylesheets/aleksi/lists/_get-nth.scss +44 -0
  24. data/stylesheets/aleksi/lists/_is-list.scss +35 -0
  25. data/stylesheets/aleksi/lists/_list-filter.scss +48 -0
  26. data/stylesheets/aleksi/lists/_next.scss +47 -0
  27. data/stylesheets/aleksi/lists/_prepend.scss +40 -0
  28. data/stylesheets/aleksi/lists/_previous.scss +47 -0
  29. data/stylesheets/aleksi/lists/_set-list-separator.scss +173 -0
  30. data/stylesheets/aleksi/lists/_walk.scss +96 -0
  31. data/stylesheets/aleksi/lists/_wrap-in-list.scss +42 -0
  32. data/stylesheets/aleksi/maps/_debug-map.scss +39 -0
  33. data/stylesheets/aleksi/maps/_is-map.scss +31 -0
  34. data/stylesheets/aleksi/maps/_map-clean.scss +45 -0
  35. data/stylesheets/aleksi/maps/_map-depth.scss +46 -0
  36. data/stylesheets/aleksi/maps/_map-extend.scss +50 -0
  37. data/stylesheets/aleksi/maps/_map-filter.scss +84 -0
  38. data/stylesheets/aleksi/maps/_map-find.scss +95 -0
  39. data/stylesheets/aleksi/maps/_map-get-tuple.scss +33 -0
  40. data/stylesheets/aleksi/maps/_map-has-keys.scss +92 -0
  41. data/stylesheets/aleksi/maps/_map-merge-deep.scss +54 -0
  42. data/stylesheets/aleksi/maps/_map-select.scss +56 -0
  43. data/stylesheets/aleksi/maps/_map-sort.scss +125 -0
  44. data/stylesheets/aleksi/maps/_map-unique.scss +46 -0
  45. data/stylesheets/aleksi/maps/_map-walk.scss +79 -0
  46. data/stylesheets/aleksi/maps/_map-zip.scss +64 -0
  47. data/stylesheets/aleksi/math/_add.scss +66 -0
  48. data/stylesheets/aleksi/math/_divide.scss +66 -0
  49. data/stylesheets/aleksi/math/_multiply.scss +66 -0
  50. data/stylesheets/aleksi/math/_subtract.scss +66 -0
  51. data/stylesheets/aleksi/sides/_output-sides.scss +71 -0
  52. data/stylesheets/aleksi/sides/_reduce-sides.scss +74 -0
  53. data/stylesheets/aleksi/sides/_side-name.scss +48 -0
  54. data/stylesheets/aleksi/sides/_side-value.scss +83 -0
  55. data/stylesheets/aleksi/sides/_sides-shorthand.scss +64 -0
  56. data/stylesheets/aleksi/sides/_to-sides-list.scss +63 -0
  57. data/stylesheets/aleksi/sides/_to-sides-map.scss +57 -0
  58. metadata +199 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 893674e8c5f9e9905e811efeb9e46a42f5105ba2
4
+ data.tar.gz: f03afa65e82e3b4e5aaad93dcc1b7c760e1e96c9
5
+ SHA512:
6
+ metadata.gz: 31591aa865f29353917dcd9a22cf487a381175cd7b2a6104fb8dffe856876d0becb031cfaf2f91566987f38ca52b6af60c7d91887bb6bbb98e5b2f78526ae8eb
7
+ data.tar.gz: e8e0941ecede6e1231dcd420e8dd588bdbb2999cd34c30b8ee65254521a76cb87880391ae426cdd9b090579e116ec2407a3d6823aa8aa135e9488a58c8e96c3c
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # Aleksi
2
+
3
+ Aleksi is a collection of Sass helper functions and mixins. It bundles other libraries and provides its own functions and mixins on top.
4
+
5
+ The russian firstname *Aleksi* means *helper of man*.
6
+
7
+ ## Installation
8
+
9
+ ### RubyGem & Compass
10
+
11
+ Open the Terminal and install the ruby gem:
12
+
13
+ gem install sass-aleksi
14
+
15
+ Require gem in your compass project configuration file
16
+
17
+ require sass-aleksi;
18
+
19
+ Import files in your project's stylesheets
20
+
21
+ @import "aleksi";
22
+
23
+ ### Bower
24
+
25
+ Open the Terminal, `cd` to your project folder and enter the following command:
26
+
27
+ bower install sass-aleksi --save
28
+
29
+ Import files in your project's stylesheets
30
+
31
+ @import "path/to/bower_components/sass-aleksi/aleksi";
32
+
33
+ ## Dependencies and Bundling
34
+
35
+ Aleski requires Compass and will import only the needed parts from compass. Additionally, it depends on the following Sass/Compass extensions:
36
+
37
+ + [Sass (~> 3.3)](https://github.com/sass/sass)
38
+ + [SassyCast (~> 1.1.1)](https://github.com/HugoGiraudel/SassyCast)
39
+ + [SassyMath (~> 1.5)](https://github.com/at-import/sassy-math)
40
+ + [SassyStrings (~> 1.1.4)](https://github.com/at-import/Sassy-Strings)
41
+ + [SassyLists (~> 2.2)](https://github.com/at-import/SassyLists)
42
+ + [Sassy-Maps (0.4.0)](https://github.com/at-import/Sassy-Maps/)
43
+
44
+ These extensions are bundled with Aleksi, adding `@import "aleksi";` to your stylesheet will give you access to all their functionalities. Be sure to check out their respective documentations to take the most out of Aleksi.
@@ -0,0 +1,31 @@
1
+ require 'compass/import-once/activate'
2
+ # Require additional compass plugins here
3
+ require 'SassyCast'
4
+ require 'sassy-math'
5
+ require 'SassyStrings'
6
+ require 'SassyLists'
7
+ require 'sassy-maps'
8
+
9
+ # Extension Paths
10
+ extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
11
+ stylesheets_path = File.join(extension_path, 'stylesheets')
12
+
13
+ # Register Extension
14
+ if (defined? Compass)
15
+ # Register as a Compass extension
16
+ Compass::Frameworks.register('sass-aleksi', :path => extension_path)
17
+ else
18
+ # Compass not found, register on the Sass path via the environment.
19
+ if ENV.has_key?("SASS_PATH")
20
+ ENV["SASS_PATH"] = ENV["SASS_PATH"] + File::PATH_SEPARATOR + stylesheets_path
21
+ else
22
+ ENV["SASS_PATH"] = stylesheets_path
23
+ end
24
+ end
25
+
26
+ # Version is a number. If a version contains alphas, it will be created as a prerelease version
27
+ # Date is in the form of YYYY-MM-DD
28
+ module SassAleksi
29
+ VERSION = "0.1.2"
30
+ DATE = "2015-08-25"
31
+ end
@@ -0,0 +1,23 @@
1
+ // =============================================================================
2
+ // =Aleksi
3
+ // =============================================================================
4
+ //// Aleksi is a collection of useful Sass functions and mixins. It bundles
5
+ //// other libraries and provides its own functions and mixins on top.
6
+ ////
7
+ //// @author [Yoannis Jamar](http://yoannis.me)
8
+
9
+ // LIBRARIES/FRAMEWORKS
10
+ @import "SassyCast";
11
+ @import "SassyStrings";
12
+ @import "SassyLists";
13
+ @import "sassy-maps";
14
+
15
+ // PARTIALS
16
+ @import "aleksi/config";
17
+ @import "aleksi/general";
18
+ @import "aleksi/math";
19
+ @import "aleksi/lengths";
20
+ @import "aleksi/colors";
21
+ @import "aleksi/lists";
22
+ @import "aleksi/maps";
23
+ @import "aleksi/sides";
File without changes
@@ -0,0 +1,11 @@
1
+ // =============================================================================
2
+ // =ALEKSI - CONFIG
3
+ // =============================================================================
4
+
5
+ @import "aleksi/config/constants";
6
+
7
+ // =sass constants
8
+ // =============================================================================
9
+
10
+ @include const('CSS_SIDES', 'top' 'right' 'bottom' 'left');
11
+ @include const('CSS_POSITIONS', 'top' 'right' 'bottom' 'left' 'center');
@@ -0,0 +1,11 @@
1
+ // =============================================================================
2
+ // =ALEKSI - GENERAL
3
+ // =============================================================================
4
+ //// Imports all general tools.
5
+ //// @author [Yoannis Jamar](http://yoannis.me)
6
+
7
+ @import "aleksi/general/throw";
8
+ @import "aleksi/general/is-of-type";
9
+ @import "aleksi/general/default-to";
10
+ @import "aleksi/general/apply";
11
+ @import "aleksi/general/css-rule";
@@ -0,0 +1,8 @@
1
+ // =============================================================================
2
+ // =ALEKSI - UNIT
3
+ // =============================================================================
4
+ ////
5
+ //// @group aleksi-units
6
+ //// @author [Yoannis Jamar](http://yoannis.me)
7
+
8
+ @import "aleksi/lengths/strip-unit";
@@ -0,0 +1,16 @@
1
+ // =============================================================================
2
+ // =ALEKSI - LISTS
3
+ // =============================================================================
4
+ //// Tools to work with lists.
5
+ //// @author [Yoannis Jamar](http://yoannis.me)
6
+
7
+ @import "aleksi/lists/is-list";
8
+ @import "aleksi/lists/set-list-separator";
9
+ @import "aleksi/lists/prepend";
10
+ @import "aleksi/lists/next";
11
+ @import "aleksi/lists/previous";
12
+ @import "aleksi/lists/get-nth";
13
+ @import "aleksi/lists/contained-in";
14
+ @import "aleksi/lists/walk";
15
+ @import "aleksi/lists/list-filter";
16
+ @import "aleksi/lists/depth";
@@ -0,0 +1,21 @@
1
+ // =============================================================================
2
+ // =ALEKSI - MAPS
3
+ // =============================================================================
4
+ //// Tools to work with maps.
5
+ //// @author [Yoannis Jamar](http://yoannis.me)
6
+
7
+ @import "aleksi/maps/is-map";
8
+ @import "aleksi/maps/debug-map";
9
+ @import "aleksi/maps/map-get-tuple";
10
+ @import "aleksi/maps/map-find";
11
+ @import "aleksi/maps/map-depth";
12
+ @import "aleksi/maps/map-has-keys";
13
+ @import "aleksi/maps/map-walk";
14
+ @import "aleksi/maps/map-unique";
15
+ @import "aleksi/maps/map-clean";
16
+ @import "aleksi/maps/map-filter";
17
+ @import "aleksi/maps/map-select";
18
+ @import "aleksi/maps/map-sort";
19
+ @import "aleksi/maps/map-zip";
20
+ @import "aleksi/maps/map-merge-deep";
21
+ @import "aleksi/maps/map-extend";
@@ -0,0 +1,10 @@
1
+ // =============================================================================
2
+ // =ALEKSI - MATH
3
+ // =============================================================================
4
+ //// Tools to work with mathemacitcal operations.
5
+ //// @author [Yoannis Jamar](http://yoannis.me)
6
+
7
+ @import "aleksi/math/add";
8
+ @import "aleksi/math/subtract";
9
+ @import "aleksi/math/multiply";
10
+ @import "aleksi/math/divide";
@@ -0,0 +1,11 @@
1
+ // =============================================================================
2
+ // =ALEKSI - SIDES
3
+ // =============================================================================
4
+
5
+ @import "sides/sides-shorthand";
6
+ @import "sides/side-name";
7
+ @import "sides/to-sides-map";
8
+ @import "sides/to-sides-list";
9
+ @import "sides/reduce-sides";
10
+ @import "sides/output-sides";
11
+ @import "sides/side-value";
@@ -0,0 +1,73 @@
1
+ // =============================================================================
2
+ // =ALEKSI - CONSTANTS
3
+ // =============================================================================
4
+
5
+ @import "sassy-maps";
6
+
7
+ $CONSTANTS: () !default;
8
+
9
+ // =const( $name )
10
+ // -----------------------------------------------------------------------------
11
+ /// Constant getter. Safely retrieves the value of a constant.
12
+ /// @author [Hugo Giraudel](http://hugogiraudel.com)
13
+ ///
14
+ /// @param {string} $name - Name of the constant to retrieve.
15
+ ///
16
+ /// @return {any} - The value of the constant.
17
+ /// @throw Error if constant doesn't exist.
18
+ ///
19
+ /// @example scss
20
+ /// $foo: const('CSS_SIDES');
21
+ /// // => 'top' 'right' 'bottom' 'left'
22
+ ///
23
+ /// @access public
24
+ /// @since 0.1.0
25
+
26
+ @function const( $name )
27
+ {
28
+ @if type-of($name) != string {
29
+ @return throw-error("const():: $name must be a string. Was #{inspect($name)}.");
30
+ }
31
+
32
+ @if not map-has-key($CONSTANTS, $name) {
33
+ @return throw-error("Unknown constant #{$name}");
34
+ }
35
+
36
+ @return map-get($CONSTANTS, $name);
37
+ }
38
+
39
+ // =const( $name, $value )
40
+ // -----------------------------------------------------------------------------
41
+ /// Constant setter. Stores the given value in a constant and prevents existing
42
+ /// constants to be modified.
43
+ /// @author [Hugo Giraudel](http://hugogiraudel.com)
44
+ ///
45
+ /// @param {string} $name - The name of the constant tp store.
46
+ /// @param {any} $value - The stored constant's value.
47
+ ///
48
+ /// @throw Error if $name is not a string.
49
+ /// @throw Error if $name is not a full-caps name or contains hyphens.
50
+ /// @throw Error if $name is already a defined constant.
51
+ ///
52
+ /// @example scss
53
+ /// @include const('HOURS_IN_DAY', 24);
54
+ ///
55
+ /// @access public
56
+ /// @since 0.1.0
57
+
58
+ @mixin const( $name, $value )
59
+ {
60
+ @if type-of($name) != string {
61
+ @include throw-error('const():: $name must be string. Was #{inspect($name)}.');
62
+ }
63
+
64
+ @else if to-upper-case($name) != $name or str-index($name, '-') {
65
+ @include throw-error('const():: Constant name #{inspect($name)} is not valid. Must be upper-case and without hyphens.');
66
+ }
67
+
68
+ @else if map-has-key($CONSTANTS, $name) {
69
+ @include throw-error('Constant #{inspect($name)} already defined.');
70
+ }
71
+
72
+ $CONSTANTS: map-set($CONSTANTS, $name, $value) !global;
73
+ }
@@ -0,0 +1,42 @@
1
+ // =============================================================================
2
+ // =ALEKSI - APPLY
3
+ // =============================================================================
4
+ ////
5
+ //// @group aleksi-general
6
+ //// @author [Yoannis Jamar](http://yoannis.me)
7
+
8
+ @import "aleksi/lists/walk";
9
+ @import "aleksi/maps/map-walk";
10
+
11
+ // =apply( $value, $func[, $args... ])
12
+ // -----------------------------------------------------------------------------
13
+ /// Applies the given function to a value. Delegates to `walk()` if `$value is
14
+ /// a list, arglist or map. On any other value types, it acts like an alias to
15
+ /// `call()` (with `$name` and `$value` arguments inverted). That means that,
16
+ /// contrary to how `call()` behaves, simple values won't be returned as a
17
+ /// single item list.
18
+ ///
19
+ /// @param {any} $value - The value to modify.
20
+ /// @param {string} $func - The name of the function to apply to `$value`.
21
+ /// @param {argList} $args... - Additional arguments to pass to `$func`.
22
+ ///
23
+ /// @return {any} - The modified value for `$value`.
24
+ /// @throw Can not apply function '#{$func}' because it doesn't exist.
25
+ ///
26
+ /// @example scss
27
+ /// $foo: apply(rgb(120,70,20), 'hue');
28
+ /// // => 18.75deg
29
+ /// $bar: apply('lots' 'of' 'laugh', 'str-slice', 1, 2);
30
+ /// // => 'l' 'o' 'l'
31
+ ///
32
+ /// @access public
33
+ /// @since 0.1.0
34
+
35
+ @function apply( $value, $func, $args... )
36
+ {
37
+ @if is-of-type($value, 'list' 'map') {
38
+ @return walk($value, $func, $args...);
39
+ }
40
+
41
+ @return call($func, $value, $args...);
42
+ }
@@ -0,0 +1,88 @@
1
+ // =============================================================================
2
+ // =ALEKSI - CSS-RULE
3
+ // =============================================================================
4
+
5
+ // =css-value( $value[, $important ])
6
+ // -----------------------------------------------------------------------------
7
+ /// Optionally appends the !important flag to a css-value. Can also run the
8
+ /// value through a function before if needed.
9
+ ///
10
+ /// @param {any} $value - The value of the css rule to modify
11
+ /// @param {bool} $important - Whether to append the `!important` flag
12
+ /// @param {string} $func - The name of a function to run $value through
13
+ /// @param {arglist} $args... - Additional arguments for $func
14
+ ///
15
+ /// @example scss - SCSS stylesheet
16
+ /// .foo {
17
+ /// color: css-value(aqua);
18
+ /// font-size: css-value(2em, true);
19
+ /// content: css-value('hello world', false, 'to-upper-case');
20
+ /// }
21
+ ///
22
+ /// @example css - CSS output
23
+ /// .foo {
24
+ /// color: aqua;
25
+ /// font-size: 2em !important;
26
+ /// content: 'HELLO WORLD';
27
+ /// }
28
+ ///
29
+ /// @access public
30
+ /// @since 0.1.0
31
+
32
+ @function css-value( $value, $important: false, $func: null, $args... )
33
+ {
34
+ // optionally apply a given funtion to modify the value
35
+ $value: if($func, call($func, $value, $args...), $value);
36
+
37
+ // don't append the '!important' flag to `null` because that will make SASS
38
+ // output it in the final CSS, when `null` alone will be left out.
39
+ @return if( $important and ($value != null), $value !important, $value );
40
+ }
41
+
42
+ // =css-rule( $property, $value[, $important, $func, $args... ])
43
+ // -----------------------------------------------------------------------------
44
+ /// Outputs a css rule dynamically. Optionally modifies the value with a
45
+ /// function and/or appending the '!important' flag. Delegates to the
46
+ /// 'css-value()' function.
47
+ ///
48
+ /// @param {string} $name - The property of the css rule to output
49
+ /// @param {any} $value - The value of the css rule to output
50
+ /// @param {bool} $important - Whether to append the `!important` flag
51
+ /// @param {string} $func - The name of a function to run $value through
52
+ /// @param {arglist} $args... - Additional arguments for $func
53
+ ///
54
+ /// @see {function} css-value
55
+ ///
56
+ /// @example scss - SCSS stylesheet
57
+ /// .foo {
58
+ /// @include css-rule('color', aqua);
59
+ /// @include css-rule(font-size, 2em, true);
60
+ /// @include css-rule(content, 'hello world', false, 'to-upper-case');
61
+ /// }
62
+ ///
63
+ /// @example css - CSS output
64
+ /// .foo {
65
+ /// color: aqua;
66
+ /// font-size: 2em !important;
67
+ /// content: 'HELLO WORLD';
68
+ /// }
69
+ ///
70
+ /// @access public
71
+ /// @since 0.1.0
72
+
73
+ @mixin css-rule( $property, $value, $important: false, $func: null, $args... )
74
+ {
75
+ #{$property}: css-value( $value, $important, $func, $args... );
76
+ }
77
+
78
+ // =css( $property, $value[, $important, $func, $args... ])
79
+ // -----------------------------------------------------------------------------
80
+ /// @alias css-rule
81
+ ///
82
+ /// @access public
83
+ /// @since 0.1.0
84
+
85
+ @mixin css( $property, $value, $important: false, $func: null, $args... )
86
+ {
87
+ @include css-rule($property, $value, $important, $func, $args...);
88
+ }
@@ -0,0 +1,35 @@
1
+ // =============================================================================
2
+ // =ALEKSI - DEFAULT-TO
3
+ // =============================================================================
4
+ ////
5
+ //// @group aleksi-general
6
+ //// @author [Yoannis Jamar](http://yoannis.me)
7
+
8
+ // =default-to( $values... )
9
+ // -----------------------------------------------------------------------------
10
+ /// Returns the first truethy value in the given argument's list. You'll usually
11
+ /// want to provide a raw, truethy value as last argument to serve as default.
12
+ ///
13
+ /// @param {argList} $values... - The ordered list of values to
14
+ /// @return {any} - The first truethy value in `$values` or `null` if none was found.
15
+ ///
16
+ /// @example scss
17
+ /// $foo: default-to(null, false, 'bar');
18
+ /// // => 'bar'
19
+ /// $bar: default-to(false, 'wiz', 'baz');
20
+ /// // => 'wiz'
21
+ /// $baz: default-to( 10, 'foo', null, true);
22
+ /// // => 10
23
+ ///
24
+ /// @access public
25
+
26
+ @function default-to( $values... )
27
+ {
28
+ @each $value in $values {
29
+ @if $value {
30
+ @return $value;
31
+ }
32
+ }
33
+
34
+ @return null;
35
+ }
@@ -0,0 +1,72 @@
1
+ // =============================================================================
2
+ // =ALEKSI - IS-OF-TYPE
3
+ // =============================================================================
4
+ ////
5
+ //// @group aleksi-general
6
+ //// @author [Yoannis Jamar](http://yoannis.me)
7
+
8
+ @import "SassyLists";
9
+ @import "aleksi/general/throw";
10
+ @import "aleksi/lists/is-list";
11
+ @import "aleksi/maps/is-map";
12
+
13
+ // =is-of-type( $value, $type )
14
+ // -----------------------------------------------------------------------------
15
+ /// Checks if a value is of the given type. Also accepts a list of types to
16
+ /// allow multiple types.
17
+ /// **Note**: delegates to `is-list()` so arglists are also considered to be of
18
+ /// type `list`.
19
+ /// **Note**: delegates to `is-map()` so the empty map `()` is also considered
20
+ /// to be of type `map`.
21
+ ///
22
+ /// @param {any} $value - The value to analyze.
23
+ /// @param {any} $type - The type(s) to check `$value` against.
24
+ ///
25
+ /// @return {bool} - Whether the value's type corresponds to `$type`.
26
+ ///
27
+ /// @example scss
28
+ /// $foo: is-of-type('hello', 'string');
29
+ /// // => true
30
+ /// $bar: is-of-type('hello', number string null);
31
+ /// // => true
32
+ /// $baz: is-of-type(10, string bool null);
33
+ /// // => false
34
+ /// $wiz: is-of-type((), map);
35
+ /// // => true
36
+ ///
37
+ /// @access public
38
+ /// @since 0.1.0
39
+
40
+ @function is-of-type( $value, $type )
41
+ {
42
+ // accept a list of multiple types to test against
43
+ @if is-list($type) {
44
+ @each $t in $type {
45
+ @if is-of-type($value, $t) {
46
+ @return true;
47
+ }
48
+ }
49
+ // stop if none of the types in $type correspond
50
+ @return false;
51
+ }
52
+
53
+ // accept the unquoted `null` as a data-type
54
+ @if $type == null {
55
+ @return if( $value == null, true, false );
56
+ }
57
+
58
+ // only test against valid type names
59
+ @else if type-of($type) != string {
60
+ $e: throw-error('$type must be a string or a list of strings, was #{inspect($type)}.');
61
+ }
62
+
63
+ @else if $type == list {
64
+ @return is-list($value);
65
+ }
66
+
67
+ @else if $type == map {
68
+ @return is-map($value);
69
+ }
70
+
71
+ @return (type-of($value) == $type);
72
+ }
@@ -0,0 +1,125 @@
1
+ // =============================================================================
2
+ // =ALEKSI - THROW
3
+ // =============================================================================
4
+ //// Tools to throw errors and warnings.
5
+ ////
6
+ //// @group aleksi-general
7
+ //// @author [Yoannis Jamar](http://yoannis.me)
8
+ ////
9
+ //// @todo Fork SassyLogger to add support inside of functions and implement it.
10
+
11
+ // =_throw( $type, $message )
12
+ // -----------------------------------------------------------------------------
13
+ /// Throws a warning or an error to the console with the given `$message`.
14
+ ///
15
+ /// @param {string} $type - The type of log message you want to throw (either 'warn' or 'error')
16
+ /// @param {string} $message - The message to print in the Sass console.
17
+ ///
18
+ /// @return {null} - Always returns null
19
+ /// @throw `$type` is not a valid Sass logging directive.
20
+ /// @throw `$message` must be a string.
21
+ ///
22
+ /// @access private
23
+ /// @since 0.1.0
24
+
25
+ @function _throw( $type, $message )
26
+ {
27
+ @if not index('warn' 'error', $type) {
28
+ @return _throw('error', '#{inspect($type)} is not a valid directive for Sass\'s console.');
29
+ }
30
+
31
+ @if type-of($message) != string {
32
+ @return _throw('error', '$message must be a string, was #{inspect($message)}.');
33
+ }
34
+
35
+ @if $type == 'warn' {
36
+ @warn #{$message};
37
+ }
38
+
39
+ @else if $type == 'error' {
40
+ @error #{$message};
41
+ }
42
+
43
+ @return null;
44
+ }
45
+
46
+ // =throw-warning( $message )
47
+ // -----------------------------------------------------------------------------
48
+ /// Throws a warning to the console with the given `$message`.
49
+ ///
50
+ /// @param {string} $message - The message to print in the Sass console.
51
+ ///
52
+ /// @return {null} - Always returns `null`.
53
+ ///
54
+ /// @access public
55
+ /// @since 0.1.0
56
+
57
+ @function throw-warning( $message )
58
+ {
59
+ @return _throw('warn', $message);
60
+ }
61
+
62
+ // =throw-error( $message )
63
+ // -----------------------------------------------------------------------------
64
+ /// Throws an error to the console with the given `$message`.
65
+ ///
66
+ /// @param {string} $message - The message to print in the Sass console.
67
+ ///
68
+ /// @return {null} - Always returns `null`.
69
+ ///
70
+ /// @access public
71
+ /// @since 0.1.0
72
+
73
+ @function throw-error( $message )
74
+ {
75
+ @return _throw('error', $message);
76
+ }
77
+
78
+ // =MIXINS
79
+ // =============================================================================
80
+
81
+ // =_throw( $type, $message )
82
+ // -----------------------------------------------------------------------------
83
+ /// Throws a warning or an error to the console with the given `$message`.
84
+ ///
85
+ /// @param {string} $type - The type of log message you want to throw (either 'warn' or 'error')
86
+ /// @param {string} $message - The message to print in the Sass console.
87
+ ///
88
+ /// @throw `$type` is not a valid Sass logging directive.
89
+ /// @throw `$message` must be a string.
90
+ ///
91
+ /// @access private
92
+ /// @since 0.1.0
93
+
94
+ @mixin _throw( $type, $message )
95
+ {
96
+ $exception: _throw($type, $message);
97
+ }
98
+
99
+ // =throw-warning( $message )
100
+ // -----------------------------------------------------------------------------
101
+ /// Throws a warning to the console with the given `$message`.
102
+ ///
103
+ /// @param {string} $message - The message to print in the Sass console.
104
+ ///
105
+ /// @access public
106
+ /// @since 0.1.0
107
+
108
+ @mixin throw-warning( $message )
109
+ {
110
+ @include _throw('warn', $message);
111
+ }
112
+
113
+ // =throw-error( $message )
114
+ // -----------------------------------------------------------------------------
115
+ /// Throws an error to the console with the given `$message`.
116
+ ///
117
+ /// @param {string} $message - The message to print in the Sass console.
118
+ ///
119
+ /// @access public
120
+ /// @since 0.1.0
121
+
122
+ @mixin throw-error( $message )
123
+ {
124
+ @include _throw('error', $message );
125
+ }