doggystyle 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.hound.yml +5 -0
- data/.npmignore +18 -0
- data/.ruby-version +1 -0
- data/.scss-lint.yml +243 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +40 -0
- data/RELEASING.md +1 -0
- data/Rakefile +9 -0
- data/bin/doggystyle +5 -0
- data/bower.json +38 -0
- data/circle.yml +13 -0
- data/core/_imports.scss +229 -0
- data/core/animations/_jump.scss +7 -0
- data/core/animations/_shake.scss +24 -0
- data/core/animations/_wobble.scss +8 -0
- data/core/functions/_mobile-first.scss +3 -0
- data/core/functions/_opposite-direction.scss +45 -0
- data/core/functions/casts/_to-bool.scss +19 -0
- data/core/functions/casts/_to-color.scss +74 -0
- data/core/functions/casts/_to-list.scss +38 -0
- data/core/functions/casts/_to-map.scss +27 -0
- data/core/functions/casts/_to-null.scss +15 -0
- data/core/functions/casts/_to-number.scss +66 -0
- data/core/functions/casts/_to-string.scss +15 -0
- data/core/functions/colours/_colour-contrast.scss +61 -0
- data/core/functions/colours/_colour.scss +69 -0
- data/core/functions/colours/_random-colour.scss +78 -0
- data/core/functions/lists/_contains.scss +62 -0
- data/core/functions/lists/_first.scss +19 -0
- data/core/functions/lists/_insert-nth.scss +37 -0
- data/core/functions/lists/_last.scss +11 -0
- data/core/functions/lists/_merge.scss +30 -0
- data/core/functions/lists/_prepend.scss +11 -0
- data/core/functions/lists/_remove-nth.scss +53 -0
- data/core/functions/lists/_remove.scss +30 -0
- data/core/functions/lists/_replace-nth.scss +55 -0
- data/core/functions/lists/_replace.scss +36 -0
- data/core/functions/lists/_reverse.scss +31 -0
- data/core/functions/lists/_second.scss +19 -0
- data/core/functions/lists/_shift.scss +24 -0
- data/core/functions/lists/_slice.scss +52 -0
- data/core/functions/lists/_sort.scss +51 -0
- data/core/functions/maps/_map-deep-get.scss +51 -0
- data/core/functions/maps/_map-deep-set.scss +34 -0
- data/core/functions/maps/_map-depth.scss +23 -0
- data/core/functions/maps/_map-extend.scss +47 -0
- data/core/functions/maps/_map-has-keys.scss +23 -0
- data/core/functions/maps/_map-has-nested-keys.scss +24 -0
- data/core/functions/maps/_map-set.scss +4 -0
- data/core/functions/maps/_map-zip.scss +50 -0
- data/core/functions/numbers/_add-unit.scss +54 -0
- data/core/functions/numbers/_pad.scss +16 -0
- data/core/functions/numbers/_spacer.scss +16 -0
- data/core/functions/numbers/_strip.scss +29 -0
- data/core/functions/numbers/_units.scss +17 -0
- data/core/functions/svg/_dots.scss +84 -0
- data/core/functions/svg/_fake-radius.scss +131 -0
- data/core/functions/svg/_lines.scss +76 -0
- data/core/functions/svg/_svg.scss +12 -0
- data/core/functions/text/_smart-lineheight.scss +13 -0
- data/core/functions/text/_string-explode.scss +45 -0
- data/core/functions/text/_string-replace.scss +38 -0
- data/core/helpers/_custom-elements.scss +114 -0
- data/core/helpers/_eases.scss +44 -0
- data/core/helpers/_reset.scss +282 -0
- data/core/helpers/_show-breakpoints.scss +25 -0
- data/core/helpers/_strings.scss +648 -0
- data/core/helpers/_warnings.scss +3 -0
- data/core/helpers/checks/_check.scss +69 -0
- data/core/helpers/checks/_is-absolute-length.scss +25 -0
- data/core/helpers/checks/_is-angel.scss +25 -0
- data/core/helpers/checks/_is-arglist.scss +11 -0
- data/core/helpers/checks/_is-bool.scss +23 -0
- data/core/helpers/checks/_is-calc.scss +11 -0
- data/core/helpers/checks/_is-colour.scss +23 -0
- data/core/helpers/checks/_is-dark.scss +14 -0
- data/core/helpers/checks/_is-duration.scss +15 -0
- data/core/helpers/checks/_is-false.scss +13 -0
- data/core/helpers/checks/_is-first-character.scss +11 -0
- data/core/helpers/checks/_is-frequency.scss +15 -0
- data/core/helpers/checks/_is-function.scss +44 -0
- data/core/helpers/checks/_is-integer.scss +15 -0
- data/core/helpers/checks/_is-length.scss +16 -0
- data/core/helpers/checks/_is-light.scss +14 -0
- data/core/helpers/checks/_is-list.scss +11 -0
- data/core/helpers/checks/_is-map.scss +11 -0
- data/core/helpers/checks/_is-null.scss +11 -0
- data/core/helpers/checks/_is-number.scss +19 -0
- data/core/helpers/checks/_is-percentage.scss +13 -0
- data/core/helpers/checks/_is-position.scss +16 -0
- data/core/helpers/checks/_is-pseudo.scss +24 -0
- data/core/helpers/checks/_is-relative-length.scss +25 -0
- data/core/helpers/checks/_is-resolution.scss +15 -0
- data/core/helpers/checks/_is-selector.scss +3 -0
- data/core/helpers/checks/_is-string.scss +11 -0
- data/core/helpers/checks/_is-time.scss +15 -0
- data/core/helpers/checks/_is-unit.scss +16 -0
- data/core/helpers/private/_arglist-to-list.scss +36 -0
- data/core/helpers/private/_brightness.scss +13 -0
- data/core/helpers/private/_find-digits.scss +41 -0
- data/core/helpers/private/_find-integer.scss +40 -0
- data/core/helpers/private/_from-hex.scss +48 -0
- data/core/helpers/private/_from-hsl.scss +55 -0
- data/core/helpers/private/_from-rgb.scss +55 -0
- data/core/helpers/private/_get-color-value.scss +26 -0
- data/core/helpers/private/_hash-fix.scss +15 -0
- data/core/helpers/private/_hex-to-dec.scss +28 -0
- data/core/helpers/private/_length.scss +26 -0
- data/core/helpers/private/_lightness.scss +15 -0
- data/core/helpers/private/_list-items-to-strings.scss +8 -0
- data/core/helpers/private/_min-max-number.scss +12 -0
- data/core/helpers/private/_pow.scss +29 -0
- data/core/helpers/private/_string-compare.scss +38 -0
- data/core/helpers/private/_string-explode.scss +43 -0
- data/core/helpers/private/_sudo.scss +23 -0
- data/core/helpers/symbols/_arrows.scss +337 -0
- data/core/helpers/symbols/_block.scss +97 -0
- data/core/helpers/symbols/_box.scss +385 -0
- data/core/helpers/symbols/_common.scss +101 -0
- data/core/helpers/symbols/_currency.scss +82 -0
- data/core/helpers/symbols/_dingbats.scss +565 -0
- data/core/helpers/symbols/_geometric.scss +289 -0
- data/core/helpers/symbols/_letterlike.scss +235 -0
- data/core/helpers/symbols/_misc.scss +568 -0
- data/core/helpers/symbols/_operators.scss +766 -0
- data/core/helpers/symbols/_punctuation.scss +214 -0
- data/core/mixins/_align.scss +15 -0
- data/core/mixins/_animate.scss +16 -0
- data/core/mixins/_aspect-ratio.scss +86 -0
- data/core/mixins/_backface-visibility.scss +7 -0
- data/core/mixins/_background-image.scss +13 -0
- data/core/mixins/_blend.scss +10 -0
- data/core/mixins/_blendmodes.scss +24 -0
- data/core/mixins/_border-radius.scss +105 -0
- data/core/mixins/_browsers.scss +155 -0
- data/core/mixins/_bulletpoint.scss +12 -0
- data/core/mixins/_center.scss +3 -0
- data/core/mixins/_clearfix.scss +7 -0
- data/core/mixins/_columns.scss +22 -0
- data/core/mixins/_custom-property.scss +15 -0
- data/core/mixins/_devices.scss +97 -0
- data/core/mixins/_dropdown.scss +38 -0
- data/core/mixins/_fake-radius.scss +99 -0
- data/core/mixins/_filters.scss +163 -0
- data/core/mixins/_flip.scss +11 -0
- data/core/mixins/_font-face.scss +11 -0
- data/core/mixins/_fontsize.scss +126 -0
- data/core/mixins/_gallery.scss +134 -0
- data/core/mixins/_gradient.scss +72 -0
- data/core/mixins/_image-size.scss +18 -0
- data/core/mixins/_image.scss +12 -0
- data/core/mixins/_inputs.scss +18 -0
- data/core/mixins/_keyframes.scss +8 -0
- data/core/mixins/_last.scss +5 -0
- data/core/mixins/_nth-last.scss +7 -0
- data/core/mixins/_nth.scss +10 -0
- data/core/mixins/_placeholder.scss +15 -0
- data/core/mixins/_prefixer.scss +55 -0
- data/core/mixins/_selection.scss +15 -0
- data/core/mixins/_shadow.scss +7 -0
- data/core/mixins/_size.scss +13 -0
- data/core/mixins/_smart-horizontal.scss +21 -0
- data/core/mixins/_sudo-image.scss +12 -0
- data/core/mixins/_text-shadow.scss +30 -0
- data/core/mixins/_transforms.scss +264 -0
- data/core/mixins/_transition.scss +189 -0
- data/core/mixins/_triangle-classic.scss +170 -0
- data/core/mixins/_triangle.scss +250 -0
- data/core/mixins/_unwrap.scss +5 -0
- data/core/mixins/_user-select.scss +5 -0
- data/core/mixins/_vertical.scss +10 -0
- data/core/mixins/columns/_columns.scss +92 -0
- data/core/mixins/flexbox/_flex-container.scss +201 -0
- data/core/mixins/flexbox/_flex-grid.scss +235 -0
- data/core/mixins/flexbox/_flex-items.scss +140 -0
- data/core/mixins/flexbox/_flex-remove.scss +12 -0
- data/core/mixins/grid/_break-between.scss +6 -0
- data/core/mixins/grid/_grid.scss +150 -0
- data/core/mixins/svg/_svg-size.scss +4 -0
- data/core/mixins/svg/_svg.scss +9 -0
- data/core/placeholders/_clear.scss +27 -0
- data/core/placeholders/_cursor.scss +35 -0
- data/core/placeholders/_misc.scss +20 -0
- data/core/placeholders/_rendering.scss +21 -0
- data/core/placeholders/_text.scss +41 -0
- data/core/settings/_colours.scss +30 -0
- data/core/settings/_directories.scss +7 -0
- data/core/settings/_global.scss +14 -0
- data/core/settings/_grid.scss +24 -0
- data/core/settings/_padding.scss +8 -0
- data/core/settings/_spacing.scss +8 -0
- data/core/settings/_text.scss +13 -0
- data/doggystyle.gemspec +29 -0
- data/eyeglass-exports.js +7 -0
- data/features/install.feature +29 -0
- data/features/step_definitions/doggystyle_steps.rb +31 -0
- data/features/support/bourbon_support.rb +19 -0
- data/features/support/env.rb +1 -0
- data/features/update.feature +30 -0
- data/features/version.feature +5 -0
- data/index.js +7 -0
- data/lib/doggystyle.rb +7 -0
- data/lib/doggystyle/generator.rb +81 -0
- data/lib/doggystyle/version.rb +3 -0
- data/package.json +33 -0
- data/spec/doggystyle/library/border_color_spec.rb +51 -0
- data/spec/doggystyle/library/border_radius_spec.rb +25 -0
- data/spec/doggystyle/library/border_style_spec.rb +51 -0
- data/spec/doggystyle/library/border_width_spec.rb +51 -0
- data/spec/doggystyle/library/buttons_spec.rb +53 -0
- data/spec/doggystyle/library/clearfix_spec.rb +18 -0
- data/spec/doggystyle/library/contrast_switch_spec.rb +23 -0
- data/spec/doggystyle/library/ellipsis_spec.rb +20 -0
- data/spec/doggystyle/library/font_face_spec_1.rb +16 -0
- data/spec/doggystyle/library/font_face_spec_2.rb +21 -0
- data/spec/doggystyle/library/font_face_spec_3.rb +16 -0
- data/spec/doggystyle/library/font_face_spec_4.rb +17 -0
- data/spec/doggystyle/library/font_stacks_spec.rb +40 -0
- data/spec/doggystyle/library/hide_text_spec.rb +17 -0
- data/spec/doggystyle/library/hide_visually_spec.rb +35 -0
- data/spec/doggystyle/library/margin_spec.rb +51 -0
- data/spec/doggystyle/library/modular_scale_spec.rb +43 -0
- data/spec/doggystyle/library/padding_spec.rb +51 -0
- data/spec/doggystyle/library/position_spec.rb +67 -0
- data/spec/doggystyle/library/prefixer_spec.rb +34 -0
- data/spec/doggystyle/library/shade_spec.rb +31 -0
- data/spec/doggystyle/library/size_spec.rb +31 -0
- data/spec/doggystyle/library/strip_unit_spec.rb +31 -0
- data/spec/doggystyle/library/text_inputs_spec.rb +75 -0
- data/spec/doggystyle/library/tint_spec.rb +31 -0
- data/spec/doggystyle/library/triangle_spec.rb +31 -0
- data/spec/doggystyle/library/word_wrap_spec.rb +29 -0
- data/spec/doggystyle/utilities/assign_inputs_spec.rb +50 -0
- data/spec/doggystyle/utilities/collapse_directionals.rb +25 -0
- data/spec/doggystyle/utilities/directional_values_spec.rb +21 -0
- data/spec/doggystyle/utilities/font_source_declaration_spec.rb +29 -0
- data/spec/doggystyle/utilities/retrieve_bourbon_setting_spec.rb +31 -0
- data/spec/doggystyle/utilities/unpack_spec.rb +32 -0
- data/spec/doggystyle/validators/contains_spec.rb +27 -0
- data/spec/doggystyle/validators/is_length_spec.rb +49 -0
- data/spec/doggystyle/validators/is_light_spec.rb +37 -0
- data/spec/doggystyle/validators/is_number_spec.rb +43 -0
- data/spec/doggystyle/validators/is_size_spec.rb +43 -0
- data/spec/fixtures/_setup.scss +1 -0
- data/spec/fixtures/library/border-color.scss +26 -0
- data/spec/fixtures/library/border-radius.scss +17 -0
- data/spec/fixtures/library/border-style.scss +21 -0
- data/spec/fixtures/library/border-width.scss +21 -0
- data/spec/fixtures/library/buttons.scss +17 -0
- data/spec/fixtures/library/clearfix.scss +5 -0
- data/spec/fixtures/library/contrast-switch.scss +9 -0
- data/spec/fixtures/library/ellipsis.scss +5 -0
- data/spec/fixtures/library/font-face-1.scss +6 -0
- data/spec/fixtures/library/font-face-2.scss +10 -0
- data/spec/fixtures/library/font-face-3.scss +8 -0
- data/spec/fixtures/library/font-face-4.scss +7 -0
- data/spec/fixtures/library/font-stacks.scss +41 -0
- data/spec/fixtures/library/hide-text.scss +5 -0
- data/spec/fixtures/library/hide-visually.scss +9 -0
- data/spec/fixtures/library/margin.scss +21 -0
- data/spec/fixtures/library/modular-scale.scss +29 -0
- data/spec/fixtures/library/padding.scss +21 -0
- data/spec/fixtures/library/position.scss +25 -0
- data/spec/fixtures/library/prefixer.scss +13 -0
- data/spec/fixtures/library/shade.scss +17 -0
- data/spec/fixtures/library/size.scss +13 -0
- data/spec/fixtures/library/strip-unit.scss +17 -0
- data/spec/fixtures/library/text-inputs.scss +21 -0
- data/spec/fixtures/library/tint.scss +17 -0
- data/spec/fixtures/library/triangle.scss +9 -0
- data/spec/fixtures/library/word-wrap.scss +9 -0
- data/spec/fixtures/utilities/assign-inputs.scss +19 -0
- data/spec/fixtures/utilities/collapse-directionals.scss +17 -0
- data/spec/fixtures/utilities/directional-values.scss +13 -0
- data/spec/fixtures/utilities/font-source-declaration.scss +11 -0
- data/spec/fixtures/utilities/retrieve-bourbon-setting.scss +16 -0
- data/spec/fixtures/utilities/unpack.scss +17 -0
- data/spec/fixtures/validators/contains.scss +28 -0
- data/spec/fixtures/validators/is-length.scss +35 -0
- data/spec/fixtures/validators/is-light.scss +29 -0
- data/spec/fixtures/validators/is-number.scss +31 -0
- data/spec/fixtures/validators/is-size.scss +31 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/support/matchers/have_rule.rb +35 -0
- data/spec/support/matchers/have_ruleset.rb +20 -0
- data/spec/support/matchers/have_value.rb +17 -0
- data/spec/support/parser_support.rb +16 -0
- data/spec/support/sass_support.rb +10 -0
- metadata +527 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
/// Convert to Map
|
2
|
+
///
|
3
|
+
/// @author Hugo Giraudel
|
4
|
+
///
|
5
|
+
/// @link https://github.com/HugoGiraudel/SassyCast
|
6
|
+
///
|
7
|
+
/// @access public
|
8
|
+
///
|
9
|
+
/// @param {*} $value - Value to cast
|
10
|
+
///
|
11
|
+
/// @return {map}
|
12
|
+
|
13
|
+
@function to-map($value) {
|
14
|
+
@if type-of($value) == "list" {
|
15
|
+
$map: ();
|
16
|
+
|
17
|
+
@if length($value) > 1 {
|
18
|
+
@for $i from 1 through length($value) {
|
19
|
+
$map: map-merge($map, ($i: nth($value, $i)));
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
@return $map;
|
24
|
+
}
|
25
|
+
|
26
|
+
@return if(type-of($value) != map, (1: $value), $value);
|
27
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/// Convert to Null
|
2
|
+
///
|
3
|
+
/// @author Hugo Giraudel
|
4
|
+
///
|
5
|
+
/// @link https://github.com/HugoGiraudel/SassyCast
|
6
|
+
///
|
7
|
+
/// @access public
|
8
|
+
///
|
9
|
+
/// @param {*} $value - Value to cast
|
10
|
+
///
|
11
|
+
/// @return {null}
|
12
|
+
|
13
|
+
@function to-null($value) {
|
14
|
+
@return null;
|
15
|
+
}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
/// Cast a value to a number if possible or return 0
|
2
|
+
///
|
3
|
+
/// @author Hugo Giraudel
|
4
|
+
///
|
5
|
+
/// @link https://github.com/HugoGiraudel/SassyCast
|
6
|
+
///
|
7
|
+
/// @access public
|
8
|
+
///
|
9
|
+
/// @param {string} $value
|
10
|
+
///
|
11
|
+
/// @return {number}
|
12
|
+
|
13
|
+
@function to-number($value) {
|
14
|
+
// In case everything's good
|
15
|
+
@if type-of($value) == "number" {
|
16
|
+
@return $value;
|
17
|
+
}
|
18
|
+
|
19
|
+
// Boolean to number
|
20
|
+
@if $value == true {
|
21
|
+
@return 1;
|
22
|
+
}
|
23
|
+
|
24
|
+
// Fail
|
25
|
+
@if type-of($value) != "string" {
|
26
|
+
@return 0;
|
27
|
+
}
|
28
|
+
|
29
|
+
// Trying to cast
|
30
|
+
$pointer: 1;
|
31
|
+
$result: 0;
|
32
|
+
$allowed: "-" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9"; // Allowed characted to start with
|
33
|
+
$first: str-slice($value, $pointer, $pointer); // First character of the number
|
34
|
+
$minus: $first == "-"; // Is it negative?
|
35
|
+
|
36
|
+
// Early check for errors
|
37
|
+
@if not index($allowed, $first) {
|
38
|
+
// @warn "Could not cast `#{inspect($value)} into number.";
|
39
|
+
@return 0;
|
40
|
+
}
|
41
|
+
|
42
|
+
// Find the integer part
|
43
|
+
$find-integer: helper-find-integer($value, $pointer);
|
44
|
+
$pointer: nth($find-integer, 1);
|
45
|
+
$result: nth($find-integer, 2);
|
46
|
+
|
47
|
+
// Find digits
|
48
|
+
@if str-slice($value, $pointer, $pointer) == "." {
|
49
|
+
$find-digits: helper-find-digits($value, $pointer);
|
50
|
+
$pointer: nth($find-digits, 1);
|
51
|
+
$digits: nth($find-digits, 2);
|
52
|
+
$result: $result + $digits;
|
53
|
+
}
|
54
|
+
|
55
|
+
// In case of negative
|
56
|
+
@if $minus {
|
57
|
+
$result: $result * -1;
|
58
|
+
}
|
59
|
+
|
60
|
+
// In case of possible CSS unit
|
61
|
+
@if $pointer < str-length($value) {
|
62
|
+
$result: helper-length($result, str-slice($value, $pointer));
|
63
|
+
}
|
64
|
+
|
65
|
+
@return $result;
|
66
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/// Convert to string
|
2
|
+
///
|
3
|
+
/// @author Hugo Giraudel
|
4
|
+
///
|
5
|
+
/// @link https://github.com/HugoGiraudel/SassyCast
|
6
|
+
///
|
7
|
+
/// @access public
|
8
|
+
///
|
9
|
+
/// @param {*} $value - value to cast
|
10
|
+
///
|
11
|
+
/// @return {string}
|
12
|
+
|
13
|
+
@function to-string($value) {
|
14
|
+
@return if(type-of($value) != string, inspect($value), $value);
|
15
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
/// Compares contrast of a given colour and returns the most appropriate given colour that contrasts it.
|
2
|
+
///
|
3
|
+
/// @author David Halford
|
4
|
+
///
|
5
|
+
/// @access public
|
6
|
+
///
|
7
|
+
/// @link http://codepen.io/davidhalford/pen/wlDxL?editors=1100
|
8
|
+
///
|
9
|
+
/// @param {color} $colour - Define a colour that you want to check is dark or light
|
10
|
+
///
|
11
|
+
/// @param {list | colour} - Define up to two seperate colours. Each one will be checked for their lightness or darkness
|
12
|
+
/// If one of the colours is not dark enough it will revert to black;
|
13
|
+
/// If the other colour is not light enough it will revert to white;
|
14
|
+
///
|
15
|
+
/// @require {function} is-colour
|
16
|
+
/// @require {function} is-dark
|
17
|
+
/// @require {function} is-light
|
18
|
+
/// @require {function} _brightness
|
19
|
+
/// @require {function} _lightness
|
20
|
+
///
|
21
|
+
/// @return {number}
|
22
|
+
///
|
23
|
+
/// @example {scss} - Usage
|
24
|
+
/// color : colour-contrast(red, purple yellow);
|
25
|
+
///
|
26
|
+
/// @example {scss} - Output
|
27
|
+
/// color : yellow;
|
28
|
+
|
29
|
+
@function colour-contrast($colour, $text-colours:null) {
|
30
|
+
|
31
|
+
$dark-text : black;
|
32
|
+
$light-text : white;
|
33
|
+
|
34
|
+
@each $setting in $text-colours {
|
35
|
+
@if is-colour($setting) {
|
36
|
+
@if $dark-text == black {
|
37
|
+
$dark-text: $setting;
|
38
|
+
}
|
39
|
+
@elseif $light-text == white {
|
40
|
+
$light-text: $setting;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
$dark-text : if(is-dark($dark-text), $dark-text, black);
|
46
|
+
$light-text : if(is-light($light-text), $light-text, white);
|
47
|
+
|
48
|
+
@return if(_brightness($colour) < _lightness(), $light-text, $dark-text);
|
49
|
+
}
|
50
|
+
|
51
|
+
/// @alias contrasting-colour
|
52
|
+
///
|
53
|
+
/// @access public
|
54
|
+
///
|
55
|
+
/// @require {function} contrasting-colour
|
56
|
+
///
|
57
|
+
/// @return {color}
|
58
|
+
|
59
|
+
@function color-contrast($colour, $light:white, $dark:dark) {
|
60
|
+
@return colour-contrast($colour, $light, $dark);
|
61
|
+
}
|
@@ -0,0 +1,69 @@
|
|
1
|
+
/// An alternative to the native rgba function. With a few extra checks.
|
2
|
+
///
|
3
|
+
/// @author Mark Notton
|
4
|
+
///
|
5
|
+
/// @access public
|
6
|
+
///
|
7
|
+
/// @param {list} $settings
|
8
|
+
/// In any order and without comma delimination, add any of the follwing settings
|
9
|
+
/// {color} - The first instance of a colour will be used
|
10
|
+
/// {opacity} - The first instance of a number will be used as the opacity
|
11
|
+
///
|
12
|
+
/// @param {opacity} $opacity
|
13
|
+
/// Perhaps a little over engineered, but if you mistype the function and set the opacity as a seperate
|
14
|
+
/// parameter rather than part of the settings list. This function will still work.
|
15
|
+
///
|
16
|
+
/// @return {color}
|
17
|
+
|
18
|
+
@function colour($settings:null, $opacity:null) {
|
19
|
+
|
20
|
+
// Deafult settings
|
21
|
+
$colour : random-colour();
|
22
|
+
$new-opacity : if($opacity == null, 1, $opacity);
|
23
|
+
|
24
|
+
// Check Settings
|
25
|
+
@each $setting in $settings {
|
26
|
+
@if is-colour($setting) {
|
27
|
+
$colour : $setting;
|
28
|
+
}
|
29
|
+
@elseif is-number($setting) {
|
30
|
+
@if $opacity == null {
|
31
|
+
$new-opacity : strip($setting);
|
32
|
+
} @else {
|
33
|
+
$new-opacity : $opacity;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
@if str-index(#{$colour}, 'rgba') {
|
39
|
+
@return $colour;
|
40
|
+
}
|
41
|
+
@else {
|
42
|
+
@return rgba($colour, $new-opacity);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
/// @alias colour
|
47
|
+
///
|
48
|
+
/// @access public
|
49
|
+
///
|
50
|
+
/// @require {function} colour
|
51
|
+
///
|
52
|
+
/// @return {bool}
|
53
|
+
|
54
|
+
@function color($settings:null, $opacity:null) {
|
55
|
+
@return colour($settings, $opacity);
|
56
|
+
}
|
57
|
+
|
58
|
+
|
59
|
+
/// @alias colour
|
60
|
+
///
|
61
|
+
/// @access public
|
62
|
+
///
|
63
|
+
/// @require {function} colour
|
64
|
+
///
|
65
|
+
/// @return {bool}
|
66
|
+
|
67
|
+
@function col($settings:null, $opacity:null) {
|
68
|
+
@return colour($settings, $opacity);
|
69
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
/// Random colour.
|
2
|
+
///
|
3
|
+
/// @author Pankaj Parashar
|
4
|
+
///
|
5
|
+
/// @access public
|
6
|
+
///
|
7
|
+
/// @author https://pankajparashar.com/posts/random-colors-sass/
|
8
|
+
///
|
9
|
+
/// @param {number} $opacity - Amend the opacity of the colour that is returned. Default is 1
|
10
|
+
///
|
11
|
+
/// @example scss - Usage
|
12
|
+
/// random-colour(0.5);
|
13
|
+
///
|
14
|
+
/// @example css - Output
|
15
|
+
/// rgba(38, 153, 180, 0.5);
|
16
|
+
///
|
17
|
+
/// @return {color}
|
18
|
+
|
19
|
+
@function random-colour($opacity:1) {
|
20
|
+
@return rgba(random(256) - 1, random(256) - 1, random(256) - 1, $opacity);
|
21
|
+
}
|
22
|
+
|
23
|
+
|
24
|
+
/// @alias random-colour
|
25
|
+
///
|
26
|
+
/// @access public
|
27
|
+
///
|
28
|
+
/// @require {function} random-colour
|
29
|
+
///
|
30
|
+
/// @return {color}
|
31
|
+
|
32
|
+
@function random-color($opacity:0.3) {
|
33
|
+
@return random-colour($opacity);
|
34
|
+
}
|
35
|
+
|
36
|
+
|
37
|
+
/// @alias random-colour
|
38
|
+
///
|
39
|
+
/// @access public
|
40
|
+
///
|
41
|
+
/// @require {function} random-colour
|
42
|
+
///
|
43
|
+
/// @return {color}
|
44
|
+
|
45
|
+
@function rc($opacity:0.3) {
|
46
|
+
@return random-colour($opacity);
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
/// Random colours on a range of elements. Ideal for developers wanting to visually see elements quickly
|
51
|
+
///
|
52
|
+
/// @author Mark Notton
|
53
|
+
///
|
54
|
+
/// @access public
|
55
|
+
///
|
56
|
+
/// @param {number} $amount - How many items are there. Default is 10
|
57
|
+
///
|
58
|
+
/// @param {string} $target - Add any children elements you want to target
|
59
|
+
///
|
60
|
+
/// @param {number} $opacity - The opacity strength. Default is 0.5
|
61
|
+
///
|
62
|
+
/// @example scss - Usage
|
63
|
+
/// li { random-colours(5, '.link'); }
|
64
|
+
///
|
65
|
+
/// @example css - Output
|
66
|
+
/// li:nth-of-type(1) .link { background-color: rgba(166, 213, 186, 0.5); }
|
67
|
+
/// li:nth-of-type(2) .link { background-color: rgba(118, 134, 177, 0.5); }
|
68
|
+
/// li:nth-of-type(3) .link { background-color: rgba(223, 47, 35, 0.5); }
|
69
|
+
/// li:nth-of-type(4) .link { background-color: rgba(175, 255, 1, 0.5); }
|
70
|
+
/// li:nth-of-type(5) .link { background-color: rgba(100, 108, 80, 0.5); }
|
71
|
+
///
|
72
|
+
/// @return {*}
|
73
|
+
|
74
|
+
@mixin random-colours($amount:10, $target:null, $opacity:0.5) {
|
75
|
+
@for $i from 1 through $amount {
|
76
|
+
&:nth-of-type(#{$i}) #{$target} { background-color:random-colour($opacity); }
|
77
|
+
}
|
78
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
/// Checks to see if a given value exists within a list
|
2
|
+
///
|
3
|
+
/// @author Mark Notton
|
4
|
+
///
|
5
|
+
/// @access public
|
6
|
+
///
|
7
|
+
/// @param {list} $list - List to be crossed referenced to
|
8
|
+
///
|
9
|
+
/// @param {string | number | list} $values - These are the values that will be checked within the list from the first param.
|
10
|
+
/// All list and value items will be cast to strings. Specificially useful is a list of numbers are compared
|
11
|
+
/// to a list of stringed numbers for example.
|
12
|
+
///
|
13
|
+
/// @param {bool} $recursive - If a list is being cross referenced to another list, this function will
|
14
|
+
/// return true if just one of the items are found. If $recursive is true, then this function will
|
15
|
+
/// only return true if ALL the list values are found within the other list.
|
16
|
+
///
|
17
|
+
/// @example scss - Usage
|
18
|
+
/// $list1 : contains(a b c d, a);
|
19
|
+
/// $list2 : contains(a b c d, a b);
|
20
|
+
/// $list3 : contains(a b c d, a b f);
|
21
|
+
/// $list4 : contains(a b c d, a b f, true);
|
22
|
+
///
|
23
|
+
/// @example scss - Output
|
24
|
+
/// $list1 : true;
|
25
|
+
/// $list2 : true;
|
26
|
+
/// $list3 : true;
|
27
|
+
/// $list4 : false;
|
28
|
+
///
|
29
|
+
/// @return {bool}
|
30
|
+
@function contains($list, $values, $recursive:false) {
|
31
|
+
|
32
|
+
@if is-string($values) or is-number($values) or is-list($values) or $recursive {
|
33
|
+
// Convert all list and values items to strings.
|
34
|
+
$temp-list : _list-items-to-strings($list);
|
35
|
+
$temp-values : _list-items-to-strings($values);
|
36
|
+
|
37
|
+
@if $recursive {
|
38
|
+
|
39
|
+
@if length($values) == length($list) {
|
40
|
+
|
41
|
+
@each $value in $temp-values {
|
42
|
+
@if not index($temp-list, $value) {
|
43
|
+
@return false;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
@return true;
|
47
|
+
} @else {
|
48
|
+
@return false;
|
49
|
+
}
|
50
|
+
|
51
|
+
} @else {
|
52
|
+
|
53
|
+
@each $value in $temp-list {
|
54
|
+
@if index($temp-values, $value) {
|
55
|
+
@return true;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
@return false;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/// Simple function for targeting the first list item
|
2
|
+
///
|
3
|
+
/// @author Hugo Giraudel
|
4
|
+
///
|
5
|
+
/// @link http://hugogiraudel.com/2013/08/08/advanced-sass-list-functions/#selecting-values-from-list
|
6
|
+
///
|
7
|
+
/// @access public
|
8
|
+
///
|
9
|
+
/// @param {list}
|
10
|
+
///
|
11
|
+
/// @return {list}
|
12
|
+
|
13
|
+
@function first($list) {
|
14
|
+
@if length($list) >= 1 {
|
15
|
+
@return nth($list, 1);
|
16
|
+
} @else {
|
17
|
+
@return null;
|
18
|
+
}
|
19
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
/// Insert a value at nth index in a list
|
2
|
+
///
|
3
|
+
/// @author Hugo Giraudel
|
4
|
+
///
|
5
|
+
/// @link http://hugogiraudel.com/2013/08/08/advanced-sass-list-functions/#adding-values-to-a-list
|
6
|
+
///
|
7
|
+
/// @access public
|
8
|
+
|
9
|
+
@function insert-nth($list, $index, $value) {
|
10
|
+
$result: null;
|
11
|
+
|
12
|
+
@if type-of($index) != number {
|
13
|
+
@warn "$index: #{quote($index)} is not a number for `insert-nth`.";
|
14
|
+
}
|
15
|
+
|
16
|
+
@else if $index < 1 {
|
17
|
+
@warn "List index 0 must be a non-zero integer for `insert-nth`";
|
18
|
+
}
|
19
|
+
|
20
|
+
@else if $index > length($list) {
|
21
|
+
@warn "List index is #{$index} but list is only #{length($list)} item long for `insert-nth'.";
|
22
|
+
}
|
23
|
+
|
24
|
+
@else {
|
25
|
+
$result: ();
|
26
|
+
|
27
|
+
@for $i from 1 through length($list) {
|
28
|
+
@if $i == $index {
|
29
|
+
$result: append($result, $value);
|
30
|
+
}
|
31
|
+
|
32
|
+
$result: append($result, nth($list, $i));
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
@return $result;
|
37
|
+
}
|