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,16 @@
|
|
1
|
+
/// Checks to see if value is a direction position
|
2
|
+
///
|
3
|
+
/// @author Hugo Giraudel
|
4
|
+
///
|
5
|
+
/// @link https://css-tricks.com/snippets/sass/advanced-type-checking/
|
6
|
+
///
|
7
|
+
/// @access public
|
8
|
+
///
|
9
|
+
/// @require {function} is-length
|
10
|
+
/// @require {function} is-percentage
|
11
|
+
///
|
12
|
+
/// @return {bool}
|
13
|
+
|
14
|
+
@function is-position($value) {
|
15
|
+
@return is-length($value) or is-percentage($value) or index('top' 'right' 'bottom' 'left' 'center', $value) != null;
|
16
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/// Check to see is a 'before' of 'after' pseudo has been passed
|
2
|
+
///
|
3
|
+
/// @author Mark Notton
|
4
|
+
///
|
5
|
+
/// @access public
|
6
|
+
///
|
7
|
+
/// @return {bool}
|
8
|
+
|
9
|
+
@function is-pseudo($pseudo) {
|
10
|
+
@return index(before after, $pseudo);
|
11
|
+
}
|
12
|
+
|
13
|
+
|
14
|
+
/// @alias is-pseudo
|
15
|
+
///
|
16
|
+
/// @access public
|
17
|
+
///
|
18
|
+
/// @require {function} is-pseudo
|
19
|
+
///
|
20
|
+
/// @return {bool}
|
21
|
+
|
22
|
+
@function is-sudo($pseudo) {
|
23
|
+
@return is-pseudo($pseudo)
|
24
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
/// List of all relative length unit types
|
2
|
+
///
|
3
|
+
/// @link http://www.w3schools.com/cssref/css_units.asp
|
4
|
+
///
|
5
|
+
/// @type list
|
6
|
+
|
7
|
+
$relative-lengths : em ex ch rem vw vh vmin vmax;
|
8
|
+
|
9
|
+
|
10
|
+
/// Checks to see if value is a type of unit that can be manipulated relative to parent elements
|
11
|
+
///
|
12
|
+
/// @author Hugo Giraudel
|
13
|
+
///
|
14
|
+
/// @link https://css-tricks.com/snippets/sass/advanced-type-checking/
|
15
|
+
///
|
16
|
+
/// @access public
|
17
|
+
///
|
18
|
+
/// @require {function} is-number
|
19
|
+
/// @require {variable} relative-lengths
|
20
|
+
///
|
21
|
+
/// @return {bool}
|
22
|
+
|
23
|
+
@function is-relative-length($value) {
|
24
|
+
@return is-number($value) and index($relative-lengths, unit($value)) != null;
|
25
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/// Checks to see if value ends with a type of resolution
|
2
|
+
///
|
3
|
+
/// @author Hugo Giraudel
|
4
|
+
///
|
5
|
+
/// @link https://css-tricks.com/snippets/sass/advanced-type-checking/
|
6
|
+
///
|
7
|
+
/// @access public
|
8
|
+
///
|
9
|
+
/// @require {function} is-number
|
10
|
+
///
|
11
|
+
/// @return {bool}
|
12
|
+
|
13
|
+
@function is-resolution($value) {
|
14
|
+
@return is-number($value) and index('dpi' 'dpcm' 'dppx', unit($value)) != null;
|
15
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/// Checks to see if value ends with 's' or 'ms'
|
2
|
+
///
|
3
|
+
/// @author Hugo Giraudel
|
4
|
+
///
|
5
|
+
/// @link https://css-tricks.com/snippets/sass/advanced-type-checking/
|
6
|
+
///
|
7
|
+
/// @access public
|
8
|
+
///
|
9
|
+
/// @require {function} is-number
|
10
|
+
///
|
11
|
+
/// @return {bool}
|
12
|
+
|
13
|
+
@function is-time($value) {
|
14
|
+
@return is-number($value) and index('ms' 's', unit($value)) != null;
|
15
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/// Checks to see if value ends with any type of unit
|
2
|
+
///
|
3
|
+
/// @author Hugo Giraudel
|
4
|
+
///
|
5
|
+
/// @link https://css-tricks.com/snippets/sass/advanced-type-checking/
|
6
|
+
///
|
7
|
+
/// @access public
|
8
|
+
///
|
9
|
+
/// @require {function} is-relative-length
|
10
|
+
/// @require {function} is-absolute-length
|
11
|
+
///
|
12
|
+
/// @return {bool}
|
13
|
+
|
14
|
+
@function is-unit($value) {
|
15
|
+
@return unit($value) != '';
|
16
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
/// Casts a list of arguments into a single list of lists.
|
2
|
+
///
|
3
|
+
/// @author Mark Notton
|
4
|
+
///
|
5
|
+
/// @access private
|
6
|
+
///
|
7
|
+
/// @argument {arglist} $values
|
8
|
+
///
|
9
|
+
/// @example scss - Usage
|
10
|
+
/// _arglist-to-list((foo bar), lorem ipsum, 1 2 3, red);
|
11
|
+
///
|
12
|
+
/// @example scss - Output
|
13
|
+
/// ((foo bar) (lorem ipsum) (1 2 3) (red));
|
14
|
+
///
|
15
|
+
/// @return {list}
|
16
|
+
|
17
|
+
@function _arglist-to-list($args...) {
|
18
|
+
|
19
|
+
$args: if(length($args) > 0, $args, null);
|
20
|
+
|
21
|
+
$lists : ();
|
22
|
+
|
23
|
+
@for $i from 1 through length($args) {
|
24
|
+
|
25
|
+
$setting : nth($args, $i);
|
26
|
+
@if is-arglist($setting) {
|
27
|
+
@each $set in $setting {
|
28
|
+
$lists : append($lists, $set);
|
29
|
+
}
|
30
|
+
} @else {
|
31
|
+
$lists : append($lists, $setting);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
@return $lists;
|
36
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/// Calculates a colours brightness
|
2
|
+
///
|
3
|
+
/// @author David Halford
|
4
|
+
///
|
5
|
+
/// @access private
|
6
|
+
///
|
7
|
+
/// @link http://codepen.io/davidhalford/pen/wlDxL?editors=1100
|
8
|
+
///
|
9
|
+
/// @return {number}
|
10
|
+
|
11
|
+
@function _brightness($colour) {
|
12
|
+
@return abs(round((red($colour) * 299) + (green($colour) * 587) + (blue($colour) * 114) / 1000));
|
13
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
/// Finding the digits part of a stringified number
|
2
|
+
///
|
3
|
+
/// @author Hugo Giraudel
|
4
|
+
///
|
5
|
+
/// @link https://github.com/HugoGiraudel/SassyCast
|
6
|
+
///
|
7
|
+
/// @access private
|
8
|
+
///
|
9
|
+
/// @param {string} $source - string source
|
10
|
+
///
|
11
|
+
/// @param {number} $pointer - current pointer
|
12
|
+
///
|
13
|
+
/// @return {list} - new pointer, parsed number
|
14
|
+
|
15
|
+
@function helper-find-digits($source, $pointer) {
|
16
|
+
$source: to-lower-case($source);
|
17
|
+
$length: str-length($source);
|
18
|
+
$numbers: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9";
|
19
|
+
$result: 0;
|
20
|
+
$runs: 1;
|
21
|
+
|
22
|
+
@while $pointer <= $length {
|
23
|
+
$token: str-slice($source, $pointer, $pointer);
|
24
|
+
$index: index($numbers, $token);
|
25
|
+
|
26
|
+
@if $token == "." {
|
27
|
+
// @continue;
|
28
|
+
}
|
29
|
+
@else if $index and $index > 0 {
|
30
|
+
$runs: $runs * 10;
|
31
|
+
$result: $result * 10 + ($index - 1);
|
32
|
+
}
|
33
|
+
@else {
|
34
|
+
@return $pointer, $result / $runs;
|
35
|
+
}
|
36
|
+
|
37
|
+
$pointer: $pointer + 1;
|
38
|
+
}
|
39
|
+
|
40
|
+
@return $pointer, $result / $runs;
|
41
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
/// Finding the digits part of a stringified number
|
2
|
+
///
|
3
|
+
/// @author Hugo Giraudel
|
4
|
+
///
|
5
|
+
/// @link https://github.com/HugoGiraudel/SassyCast
|
6
|
+
///
|
7
|
+
/// @access private
|
8
|
+
///
|
9
|
+
/// @param {string} $source - string source
|
10
|
+
///
|
11
|
+
/// @param {number} $pointer - current pointer
|
12
|
+
///
|
13
|
+
/// @return {list} new pointer, parsed number
|
14
|
+
|
15
|
+
@function helper-find-integer($source, $pointer) {
|
16
|
+
$source: to-lower-case($source);
|
17
|
+
$length: str-length($source);
|
18
|
+
$numbers: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9";
|
19
|
+
$result: 0;
|
20
|
+
|
21
|
+
@while $pointer <= $length {
|
22
|
+
$token: str-slice($source, $pointer, $pointer);
|
23
|
+
$index: index($numbers, $token);
|
24
|
+
|
25
|
+
@if $token == "-" {
|
26
|
+
// @continue;
|
27
|
+
}
|
28
|
+
@else if $index {
|
29
|
+
$result: $result * 10 + ($index - 1);
|
30
|
+
}
|
31
|
+
@else {
|
32
|
+
@return $pointer, $result;
|
33
|
+
}
|
34
|
+
|
35
|
+
$pointer: $pointer + 1;
|
36
|
+
}
|
37
|
+
|
38
|
+
@return $pointer, $result;
|
39
|
+
}
|
40
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
/// Cast a string into a hexadecimal color
|
2
|
+
///
|
3
|
+
/// @author Hugo Giraudel
|
4
|
+
///
|
5
|
+
/// @link https://github.com/HugoGiraudel/SassyCast
|
6
|
+
///
|
7
|
+
/// @access private
|
8
|
+
///
|
9
|
+
/// @param {string} $string - string
|
10
|
+
///
|
11
|
+
/// @return {color | String} - string or hex color depending on the match
|
12
|
+
///
|
13
|
+
/// @require {function} _hex-to-dec
|
14
|
+
|
15
|
+
@function helper-from-hex($string) {
|
16
|
+
$string-lower: to-lower-case($string);
|
17
|
+
$r: ""; $g: ""; $b: "";
|
18
|
+
$hex: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f";
|
19
|
+
$length: str-length($string);
|
20
|
+
$max: if($length == 4, 1, 2);
|
21
|
+
|
22
|
+
// Check for length accuracy
|
23
|
+
@if $length != 4 and $length != 7 {
|
24
|
+
@return $string;
|
25
|
+
}
|
26
|
+
|
27
|
+
// Loop from the second character (omitting #)
|
28
|
+
@for $i from 2 through $length {
|
29
|
+
$c: str-slice($string-lower, $i, $i);
|
30
|
+
|
31
|
+
// If wrong character, return
|
32
|
+
@if not index($hex, $c) {
|
33
|
+
@return $string;
|
34
|
+
}
|
35
|
+
|
36
|
+
@if str-length($r) < $max { $r: $r + $c }
|
37
|
+
@else if str-length($g) < $max { $g: $g + $c }
|
38
|
+
@else if str-length($b) < $max { $b: $b + $c }
|
39
|
+
}
|
40
|
+
|
41
|
+
@if $length == 4 {
|
42
|
+
$r: $r + $r;
|
43
|
+
$g: $g + $g;
|
44
|
+
$b: $b + $b;
|
45
|
+
}
|
46
|
+
|
47
|
+
@return rgb(_hex-to-dec($r), _hex-to-dec($g), _hex-to-dec($b));
|
48
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
/// Cast a string into a hsl color
|
2
|
+
///
|
3
|
+
/// @author Hugo Giraudel
|
4
|
+
///
|
5
|
+
/// @link https://github.com/HugoGiraudel/SassyCast
|
6
|
+
///
|
7
|
+
/// @access private
|
8
|
+
///
|
9
|
+
/// @param {string} $string - string
|
10
|
+
///
|
11
|
+
/// @return {color | String} - string or hsl color depending on the match
|
12
|
+
///
|
13
|
+
/// @require {function} _get-color-value
|
14
|
+
|
15
|
+
@function helper-from-hsl($string) {
|
16
|
+
$frags: ();
|
17
|
+
$string-lower: to-lower-case($string);
|
18
|
+
$is-alpha: str-slice($string-lower, 4, 4) == 'a';
|
19
|
+
$length: str-length($string);
|
20
|
+
$start: str-index($string, "(");
|
21
|
+
|
22
|
+
@for $i from $start through $length {
|
23
|
+
$token: str-slice($string-lower, $i, $i);
|
24
|
+
@if $token == ' ' {
|
25
|
+
// @continue;
|
26
|
+
}
|
27
|
+
@else if $token == '(' or $token == ',' {
|
28
|
+
$frags: append($frags, "");
|
29
|
+
}
|
30
|
+
@else if $token == ')' {
|
31
|
+
@if length($frags) != if($is-alpha, 4, 3) { @return $string; } // Parsing error
|
32
|
+
$hue: _get-color-value(nth($frags, 1));
|
33
|
+
$saturation: _get-color-value(nth($frags, 2));
|
34
|
+
$lightness: _get-color-value(nth($frags, 3));
|
35
|
+
|
36
|
+
@if not $hue or not $saturation or not $lightness {
|
37
|
+
@return $string;
|
38
|
+
}
|
39
|
+
|
40
|
+
@if $is-alpha {
|
41
|
+
@if length($frags) != 4 { @return $string; } // No alpha channel found
|
42
|
+
$alpha: _get-color-value(nth($frags, 4));
|
43
|
+
@if not $alpha { @return $string; } // Error parsing alpha channel
|
44
|
+
@return hsla($hue, $saturation, $lightness, $alpha);
|
45
|
+
}
|
46
|
+
|
47
|
+
@return hsl($hue, $saturation, $lightness);
|
48
|
+
}
|
49
|
+
@else {
|
50
|
+
$frags: set-nth($frags, length($frags), nth($frags, length($frags)) + $token);
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
@return $string;
|
55
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
/// Cast a string into a rgb color
|
2
|
+
///
|
3
|
+
/// @author Hugo Giraudel
|
4
|
+
///
|
5
|
+
/// @link https://github.com/HugoGiraudel/SassyCast
|
6
|
+
///
|
7
|
+
/// @access private
|
8
|
+
///
|
9
|
+
/// @param {string} $string - string
|
10
|
+
///
|
11
|
+
/// @return {color | string} - string or rgb color depending on the match
|
12
|
+
///
|
13
|
+
/// @require {function} _get-color-value
|
14
|
+
|
15
|
+
@function helper-from-rgb($string) {
|
16
|
+
$string-lower: to-lower-case($string);
|
17
|
+
$frags: ();
|
18
|
+
$is-alpha: str-slice($string-lower, 4, 4) == 'a';
|
19
|
+
$start: str-index($string, "(");
|
20
|
+
$length: str-length($string);
|
21
|
+
|
22
|
+
@for $i from $start through $length {
|
23
|
+
$token: str-slice($string-lower, $i, $i);
|
24
|
+
@if $token == ' ' {
|
25
|
+
// @continue;
|
26
|
+
}
|
27
|
+
@else if $token == '(' or $token == ',' {
|
28
|
+
$frags: append($frags, "");
|
29
|
+
}
|
30
|
+
@else if $token == ')' {
|
31
|
+
@if length($frags) != if($is-alpha, 4, 3) { @return $string; } // Parsing error
|
32
|
+
$red: _get-color-value(nth($frags, 1));
|
33
|
+
$green: _get-color-value(nth($frags, 2));
|
34
|
+
$blue: _get-color-value(nth($frags, 3));
|
35
|
+
|
36
|
+
@if not $red or not $green or not $blue {
|
37
|
+
@return $string;
|
38
|
+
}
|
39
|
+
|
40
|
+
@if $is-alpha {
|
41
|
+
@if length($frags) != 4 { @return $string; } // No alpha channel found
|
42
|
+
$alpha: _get-color-value(nth($frags, 4));
|
43
|
+
@if not $alpha { @return $string; } // Error parsing alpha channel
|
44
|
+
@return rgba($red, $green, $blue, $alpha);
|
45
|
+
}
|
46
|
+
|
47
|
+
@return rgb($red, $green, $blue);
|
48
|
+
}
|
49
|
+
@else {
|
50
|
+
$frags: set-nth($frags, length($frags), nth($frags, length($frags)) + $token);
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
@return $string;
|
55
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/// Cast a stringified number / stringified percentage into number type
|
2
|
+
///
|
3
|
+
/// @author Hugo Giraudel
|
4
|
+
///
|
5
|
+
/// @link https://github.com/HugoGiraudel/SassyCast
|
6
|
+
///
|
7
|
+
/// @access private
|
8
|
+
///
|
9
|
+
/// @param {string} $string - string
|
10
|
+
///
|
11
|
+
/// @return {number} - unitless number or percentage
|
12
|
+
///
|
13
|
+
/// @require {function} to-number
|
14
|
+
|
15
|
+
@function helper-get-color-value($string) {
|
16
|
+
$first: str-slice($string, 1, 1);
|
17
|
+
|
18
|
+
// Pad <1 values with a leading 0
|
19
|
+
@if $first == '.' {
|
20
|
+
$string: '0' + $string;
|
21
|
+
}
|
22
|
+
|
23
|
+
$last: str-slice($string, -1, -1);
|
24
|
+
|
25
|
+
@return if($last == '%', to-number(str-slice($string, 1, -2), 2) * 1%, to-number($string));
|
26
|
+
}
|