UNPKG

5.03 kBSCSSView Raw
1:global {
2 @function str-replace($string, $search, $replace) {
3 $index: str-index($string, $search);
4
5 @if $index {
6 @return str-slice($string, 1, $index - 1) + $replace + str-replace(
7 str-slice($string, $index + str-length($search)), $search, $replace
8 );
9 }
10
11 @return $string;
12 }
13
14 @function clean-url($url) {
15 $fixed-url: str-replace(str-replace($url, "http:/", "http://"), "http:///", "http://");
16 @return $fixed-url;
17 }
18
19 /**
20 * setting box sizes is annoying - do it all at once with a mixin
21 *
22 * @example use:
23 * div {
24 * @include box-sizing(border-box);
25 * }
26 */
27 @mixin box-sizing($type) {
28 -webkit-box-sizing:$type;
29 -moz-box-sizing:$type;
30 box-sizing:$type;
31 }
32
33 /**
34 * @example use:
35 * div {
36 * @include circle();
37 * }
38 */
39 @mixin circle {
40 @include border-radius(100%);
41 }
42
43 /**
44 * Create 4-sided elements with exactly equal width and length. In other words...squares.
45 *
46 * @example use:
47 * div {
48 * @include square(100px);
49 * }
50 */
51 @mixin square($size) {
52 width: $size;
53 height: $size;
54 }
55
56
57 /**
58 * It sort of works. Good starting point either way.
59 * @example use:
60 * div {
61 * @include verticale-align();
62 * }
63 * ...and all divs are v-aligned
64 */
65 @mixin vertical-align {
66 position: relative;
67 top: 50%;
68 -webkit-transform: translateY(-50%);
69 -ms-transform: translateY(-50%);
70 transform: translateY(-50%);
71 }
72
73 /**
74 * Put gradients in all the places.
75 * @param {color} $start-color - e.g. #ffffff
76 * @param {color} $end-color e.g. #000000
77 * @param {horizontal | vertical | radial} $orientation - determines what type of gradient
78 *
79 * @EXAMPLE
80 * div {
81 * @include gradient(#ffffff, #000000, horizontal);
82 * }
83 */
84 @mixin gradient($start-color, $end-color, $orientation) {
85 background: $start-color;
86
87 /** vertical */
88 @if $orientation == vertical {
89 background: -moz-linear-gradient(top, $start-color 0%, $end-color 100%);
90 background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,$start-color), color-stop(100%,$end-color));
91 background: -webkit-linear-gradient(top, $start-color 0%,$end-color 100%);
92 background: -o-linear-gradient(top, $start-color 0%,$end-color 100%);
93 background: -ms-linear-gradient(top, $start-color 0%,$end-color 100%);
94 background: linear-gradient(to bottom, $start-color 0%,$end-color 100%);
95 filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='$start-color', endColorstr='$end-color',GradientType=0 );
96
97 /** horizontal */
98 } @else if $orientation == horizontal {
99 background: -moz-linear-gradient(left, $start-color 0%, $end-color 100%);
100 background: -webkit-gradient(linear, left top, right top, color-stop(0%,$start-color), color-stop(100%,$end-color));
101 background: -webkit-linear-gradient(left, $start-color 0%,$end-color 100%);
102 background: -o-linear-gradient(left, $start-color 0%,$end-color 100%);
103 background: -ms-linear-gradient(left, $start-color 0%,$end-color 100%);
104 background: linear-gradient(to right, $start-color 0%,$end-color 100%);
105 filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='$start-color', endColorstr='$end-color',GradientType=1 );
106
107 /** radial */
108 } @else {
109 background: -moz-radial-gradient(center, ellipse cover, $start-color 0%, $end-color 100%);
110 background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,$start-color), color-stop(100%,$end-color));
111 background: -webkit-radial-gradient(center, ellipse cover, $start-color 0%,$end-color 100%);
112 background: -o-radial-gradient(center, ellipse cover, $start-color 0%,$end-color 100%);
113 background: -ms-radial-gradient(center, ellipse cover, $start-color 0%,$end-color 100%);
114 background: radial-gradient(ellipse at center, $start-color 0%,$end-color 100%);
115 filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='$start-color', endColorstr='$end-color',GradientType=1 );
116 }
117 }
118
119 /**
120 * @example usage:
121 * .container-with-floated-children {
122 * @extend %clearfix;
123 * }
124 */
125 %clearfix {
126 *zoom: 1;
127 &:before, &:after {
128 content: " ";
129 display: table;
130 }
131 &:after {
132 clear: both;
133 }
134 }
135}
136
137@mixin height($height) {
138 height: $height;
139 min-height: $height;
140 max-height: $height;
141}
142
143@mixin width($width) {
144 width: $width;
145 min-width: $width;
146 max-width: $width;
147}