Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Artemov committed Sep 5, 2014
0 parents commit bcac268
Show file tree
Hide file tree
Showing 49 changed files with 3,903 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/
.sass-cache/
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 Dmitry Artemov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SCSS mixins

## Usage

1. `git clone https://github.com/beliarh/scss-mixins.git`
2. `@import 'scss-mixins/all';`

## Required Sass version

Sass 3.4.0+
24 changes: 24 additions & 0 deletions _all.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@import "mixins/align";
@import "mixins/animation";
@import "mixins/backface";
@import "mixins/background";
@import "mixins/border";
@import "mixins/box";
@import "mixins/clearfix";
@import "mixins/column";
@import "mixins/filter";
@import "mixins/flex";
@import "mixins/fullscreen";
@import "mixins/gradient";
@import "mixins/justify";
@import "mixins/keyframes";
@import "mixins/order";
@import "mixins/perspective";
@import "mixins/placeholder";
@import "mixins/reset";
@import "mixins/selection";
@import "mixins/tab";
@import "mixins/transform";
@import "mixins/transition";
@import "mixins/triangle";
@import "mixins/user";
120 changes: 120 additions & 0 deletions functions/_base-functions.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
@function is-string($value) {
@return type-of($value) == string;
}

@function is-number($value) {
@return type-of($value) == number;
}

@function is-color($value) {
@return type-of($value) == color or (is-string($value) and to-lower-case($value) == currentcolor);
}

@function is-list($value) {
@return type-of($value) == list;
}

@function is-arglist($value) {
@return type-of($value) == arglist;
}

@function is-list-like($value) {
@return is-list($value) or is-arglist($value);
}

@function is-comma-separated($value) {
@return list-separator($value) == comma;
}

@function is-space-separated($value) {
@return list-separator($value) == space;
}

@function is-comma-list($value) {
@return is-list($value) and is-comma-separated($value);
}

@function is-space-list($value) {
@return is-list($value) and is-space-separated($value);
}

@function is-map($value) {
@return type-of($value) == map;
}

@function is-percentage($value) {
@return is-number($value) and unit($value) == '%';
}

@function is-length($value) {
@return is-number($value) and not not index(em ex ch rem vh vw vmin vmax px mm cm in pt pc, unit($value));
}

@function is-angle($value) {
@if is-number($value) and index(deg grad rad turn, unit($value)) {
@return true;
}
@return false;
}

@function is-width($value) {
@return $value == auto or is-length($value) or is-percentage($value);
}

@function is-side-or-corner($value) {
@if is-space-separated($value) {
$length: length($value);
$arg1: nth($value, 1);
@if $length == 1 {
@return not not index(left right top bottom, $arg1);
}
@if $length == 2 {
@if index(left right, $arg1) {
@return not not index(top bottom, nth($value, 2));
}
@if index(top bottom, $arg1) {
@return not not index(left right, nth($value, 2));
}
}
}
@return false;
}

@function is-extent-keyword($value) {
@return not not index(closest-corner closest-side farthest-corner farthest-side, $value);
}

@function is-time($value) {
@return is-number($value) and not not index(ms s, unit($value));
}

@function is-timing-function($value) {
@if is-string($value) {
@if index(ease linear ease-in ease-out ease-in-out step-start step-end, $value) {
@return true;
}
@if str-slice($value, 1, 6) == 'steps(' and str-slice($value, -1) == ')' {
@return true;
}
@if str-slice($value, 1, 13) == 'cubic-bezier(' and str-slice($value, -1) == ')' {
@return true;
}
}
@return false;
}

@function slice-list($list, $from: 1, $to: length($list)) {
$slice: join((), (), list-separator($list));
@for $i from $from through $to {
$slice: append($slice, nth($list, $i));
}
@return $slice;
}

@function unwrap-list($list, $arglist-only: false) {
$list-types: if($arglist-only, arglist, list arglist);
@while index($list-types, type-of($list)) and length($list) == 1 {
$list: nth($list, 1);
}
@return $list;
}
147 changes: 147 additions & 0 deletions functions/_helpers.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
@import "base-functions";

@function __angle-to-webkit-gradient-direction($angle) {
$angle: $angle % 360deg;
$one-sixteenth: 360deg / 16;
@if $angle >= $one-sixteenth * 15 or $angle < $one-sixteenth * 1 {
@return (center bottom, center top);
}
@if $angle >= $one-sixteenth * 1 and $angle < $one-sixteenth * 3 {
@return (left bottom, right top);
}
@if $angle >= $one-sixteenth * 3 and $angle < $one-sixteenth * 5 {
@return (left center, right center);
}
@if $angle >= $one-sixteenth * 5 and $angle < $one-sixteenth * 7 {
@return (left top, right bottom);
}
@if $angle >= $one-sixteenth * 7 and $angle < $one-sixteenth * 9 {
@return (center top, center bottom);
}
@if $angle >= $one-sixteenth * 9 and $angle < $one-sixteenth * 11 {
@return (right top, left bottom);
}
@if $angle >= $one-sixteenth * 11 and $angle < $one-sixteenth * 13 {
@return (right center, left center);
}
@if $angle >= $one-sixteenth * 13 and $angle < $one-sixteenth * 15 {
@return (right bottom, left top);
}
}

@function __parsed-color-stops-to-list($parsed-color-stops) {
$color-stops: ();
@each $parsed-color-stop in $parsed-color-stops {
$color: map-get($parsed-color-stop, 'color');
$position: map-get($parsed-color-stop, 'position');
$color-stop: if($position, $color $position, $color);
$color-stops: append($color-stops, $color-stop, comma);
}
@return $color-stops;
}

@function __parsed-color-stops-to-webkit-color-stops($parsed-color-stops) {
$length: length($parsed-color-stops);
@if $length < 2 {
@return null;
}
$color-stops: ();
$color-stop-maps: ();
$colors-buffer: ();
@for $i from 1 through $length {
$parsed-color-stop: nth($parsed-color-stops, $i);
$color: map-get($parsed-color-stop, 'color');
$position: map-get($parsed-color-stop, 'position');
@if $position == null {
@if $i == 1 {
$position: 0%;
} @else if $i == $length {
$position: 100%;
}
}
@if ($i == $length or is-percentage($position)) and length($colors-buffer) > 0 {
$last-index: length($color-stop-maps);
$last-color-stop: nth($color-stop-maps, $last-index);
$last-position: map-get($last-color-stop, 'position');
$increment: ($position - $last-position) / ($i - $last-index);
@each $buffered-color in $colors-buffer {
$last-position: $last-position + $increment;
$color-stop: unquote('color-stop(#{$last-position}, #{$buffered-color})');
$color-stops: append($color-stops, $color-stop, comma);
$color-stop-map: ('color': $buffered-color, 'position': $last-position);
$color-stop-maps: append($color-stop-maps, $color-stop-map);
}
$colors-buffer: ();
}
@if $position == null {
$colors-buffer: append($colors-buffer, $color);
} @else if is-percentage($position) {
$color-stop: unquote('color-stop(#{$position}, #{$color})');
$color-stops: append($color-stops, $color-stop, comma);
$color-stop-map: ('color': $color, 'position': $position);
$color-stop-maps: append($color-stop-maps, $color-stop-map);
} @else {
@return null;
}
}
@return $color-stops;
}

@function __prefix-transition-properties($properties...) {
$properties: unwrap-list($properties);
$webkit-properties: ();
$moz-properties: ();
$o-properties: ();
@each $property in $properties {
$webkit-property: $property;
$moz-property: $property;
$o-property: $property;
$prefixes: map-get((
'transform': -webkit -moz -o,
'transform-origin': -webkit -moz -o,
'perspective': -webkit -moz,
'perspective-origin': -webkit -moz,
'column-width': -webkit -moz,
'column-count': -webkit -moz,
'column-gap': -webkit -moz,
'column-rule': -webkit -moz,
'column-rule-color': -webkit -moz,
'column-rule-width': -webkit -moz,
'flex': -webkit,
'flex-basis': -webkit,
'background-size': -webkit -moz -o,
'border-radius': -webkit -moz,
'box-shadow': -webkit -moz,
), $property);
@if $prefixes {
@if index($prefixes, -webkit) {
$webkit-property: -webkit-#{$property};
}
@if index($prefixes, -moz) {
$moz-property: -moz-#{$property};
}
@if index($prefixes, -o) {
$o-property: -o-#{$property};
}
} @else {
$moz-single-border-radius: map-get((
'border-top-left-radius': -moz-border-radius-topleft,
'border-top-right-radius': -moz-border-radius-topright,
'border-bottom-left-radius': -moz-border-radius-bottomleft,
'border-bottom-right-radius': -moz-border-radius-bottomright,
), $property);
@if $moz-single-border-radius {
$webkit-property: -webkit-#{$property};
$moz-property: $moz-single-border-radius;
}
}
$webkit-properties: append($webkit-properties, $webkit-property, comma);
$moz-properties: append($moz-properties, $moz-property, comma);
$o-properties: append($o-properties, $o-property, comma);
}
@return (
'-webkit': $webkit-properties,
'-moz': $moz-properties,
'-o': $o-properties,
);
}
49 changes: 49 additions & 0 deletions functions/_parse-background-position.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
@import "base-functions";

@function __parse-background-position($background-position) {
@if is-comma-separated($background-position) {
// <COMMA-LIST>
@return null;
}
$length: length($background-position);
@if not ($length >= 1 and $length <= 2) {
// Incorrect arguments count
@return null;
}
$arg1: unquote(nth($background-position, 1));
@if is-length($arg1) or is-percentage($arg1) or index(left center right, $arg1) {
// [<length> | <percentage> | left | center | right] ...
@if $length == 1 {
// [<length> | <percentage> | left | center | right]
@return ('x': $arg1, 'y': center);
}
$arg2: unquote(nth($background-position, 2));
@if is-length($arg2) or is-percentage($arg2) or index(top center bottom, $arg2) {
// [<length> | <percentage> | left | center | right] [<length> | <percentage> | top | center | bottom]
@return ('x': $arg1, 'y': $arg2);
} @else if $arg1 == center and index(left right, $arg2) {
// center [left | right]
@return ('x': $arg2, 'y': $arg1);
} @else {
// [<length> | <percentage> | left | center | right] <UNEXPECTED-VALUE>
@return null;
}
} @else if index(top center bottom, $arg1) {
// [top | center | bottom] ...
@if $length == 1 {
// [top | center | bottom]
@return ('x': center, 'y': $arg1);
}
$arg2: unquote(nth($background-position, 2));
@if index(left center right, $arg2) {
// [top | center | bottom] [left | center | right]
@return ('x': $arg2, 'y': $arg1);
} @else {
// [top | center | bottom] <UNEXPECTED-VALUE>
@return null;
}
} @else {
// <UNEXPECTED-VALUE>
@return null;
}
}
Loading

0 comments on commit bcac268

Please sign in to comment.