sassmagic 0.1.5 → 0.1.6

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.
data/lib/sassmagic.rb CHANGED
@@ -16,7 +16,7 @@ ENV['SASS_ENV'] ||= 'development'
16
16
  $:.unshift(load_path + '/')
17
17
 
18
18
 
19
- # require 'sass'
19
+ require 'sass'
20
20
 
21
21
  require 'sassmagic/utils'
22
22
  require 'sassmagic/remote'
@@ -1,4 +1,4 @@
1
- ##目录结构
1
+ ## 目录结构
2
2
 
3
3
  sassmagic/
4
4
  |
@@ -47,48 +47,48 @@
47
47
  |
48
48
  `– main.scss # primary Sass file
49
49
 
50
- ###目录结构描述
50
+ ### 目录结构描述
51
51
 
52
52
  目录结构采用的是常见的7-1模式的结构:7个文件夹,1个文件。基本上,你需要将所有的部件放进7个不同的文件夹和一个位于根目录的文件(通常命名为 main.scss)中——这个文件编译时会引用所有文件夹而形成一个CSS样式表。
53
53
 
54
- ####base
54
+ #### base
55
55
 
56
56
  `base/`文件夹存放项目中的模板文件。在这里,可以找到重置文件、排版规范文件或者一个样式表(我通常命名为`_base.scss`)——定义一些HTML元素公认的标准样式。
57
57
 
58
- ####components
58
+ #### components
59
59
 
60
60
  对于小型组件来说,有一个`components/`文件夹来存放。相对于`partials/`的宏观(定义全局线框结构),`components/`更专注于局部组件。该文件夹包含各类具体模块,基本上是所有的独立模块,比如一个滑块、一个加载块、一个部件……由于整个网站或应用程序主要由微型模块构成,`components/`中往往有大量文件。
61
61
 
62
- ####partials
62
+ #### partials
63
63
 
64
64
  `partials/`文件夹存放构建网站或者应用程序使用到的布局部分。该文件夹存放网站主体(头部、尾部、导航栏、侧边栏...)的样式表、栅格系统甚至是所有表单的CSS样式。(备注:常常也命名为`layout/`)。
65
65
 
66
- ####pages
66
+ #### pages
67
67
 
68
68
  如果页面有特定的样式,最好将该样式文件放进`pages/`文件夹并用页面名字。例如,主页通常具有独特的样式,因此可以在`pages/`下包含一个`_home.scss`以实现需求。
69
69
 
70
- ####themes
70
+ #### themes
71
71
 
72
72
  在大型网站和应用程序中,往往有多种主题。虽有多种方式管理这些主题,但是我个人更喜欢把它们存放在`themes/`文件夹中。
73
73
 
74
- ####helpers
74
+ #### helpers
75
75
 
76
76
  `helpers/`文件夹包含了整个项目中使用到的Sass辅助工具,这里存放着每一个全局变量、函数、混合宏和占位符。(备注,常常也命名为`utils/`)
77
77
 
78
78
  该文件夹的经验法则是,编译后这里不应该输出任何CSS,单纯的只是一些Sass辅助工具。
79
79
 
80
- ####vendors
80
+ #### vendors
81
81
 
82
82
  最后但并非最终的,大多数的项目都有一个`vendors/`文件夹,用来存放所有外部库和框架(Normalize, Bootstrap, jQueryUI, FancyCarouselSliderjQueryPowered……)的CSS文件。将这些文件放在同一个文件中是一个很好的说明方式:"嘿,这些不是我的代码,无关我的责任。"
83
83
 
84
84
  如果你重写了任何库或框架的部分,建议设置第8个文件夹`vendors-extensions/`来存放,并使用相同的名字命名。例如,`vendors-extensions/_boostrap.scss`文件存放所有重写Bootstrap默认CSS之后的CSS规则。这是为了避免在原库或者框架文件中进行二次编辑。
85
85
 
86
- ####main.scss
86
+ #### main.scss
87
87
 
88
88
  主文件(通常写作`main.scss`,也常常命名为`style.scss`)应该是整个代码库中唯一开头不用下划线命名的Sass文件。除 `@import`和注释外,该文件不应该包含任何其他代码。
89
89
 
90
90
 
91
- #####main.scss文件引入顺序
91
+ ##### main.scss文件引入顺序
92
92
 
93
93
  文件应该按照存在的位置顺序依次被引用进来:
94
94
 
@@ -0,0 +1,285 @@
1
+ // sanitize.scss: https://github.com/jonathantneal/sanitize.css/blob/master/sanitize.scss
2
+ // normalize.scss: https://github.com/kristerkari/normalize.scss/blob/master/_normalize.scss
3
+
4
+ // Define variables
5
+
6
+ $root-box-sizing: border-box !default;
7
+ $root-cursor: default !default;
8
+ $root-font-family: sans-serif !default;
9
+ $root-font-size: 16px !default;
10
+ $root-line-height: 1.5 !default;
11
+ $root-text-rendering: optimizeLegibility !default;
12
+
13
+ $anchor-text-decoration: none !default;
14
+ $form-element-background-color: transparent !default;
15
+ $form-element-min-height: if(unitless($root-line-height), #{$root-line-height}em, if(unit($root-line-height) != '%', $root-line-height, null)) !default;
16
+ $media-element-vertical-align: middle !default;
17
+ $monospace-font-family: monospace !default;
18
+ $nav-list-style: none !default;
19
+ $small-font-size: 75% !default;
20
+ $table-border-collapse: collapse !default;
21
+ $table-border-spacing: 0 !default;
22
+ $textarea-resize: vertical !default;
23
+
24
+ :root {
25
+ -ms-overflow-style: -ms-autohiding-scrollbar; // IE11+
26
+ overflow-y: scroll; // All browsers without overlaying scrollbars
27
+ text-size-adjust: 100%; // iOS 8+
28
+ }
29
+
30
+ //details: // Firefox 36+, Internet Explorer 11+, Windows Phone 8.1+
31
+ //main: Android 4.3-, Internet Explorer 11+, Windows Phone 8.1+
32
+ //summary: // Firefox 36+, Internet Explorer 11+, Windows Phone 8.1+
33
+
34
+ details,main,summary {
35
+ display: block;
36
+ }
37
+
38
+ //template: Android 4.3-, Internet Explorer 11+, iOS 7-, Safari 7-, Windows Phone 8.1+
39
+ //[hidden]:Internet Explorer 10-
40
+
41
+ template, [hidden] {
42
+ display: none;
43
+ }
44
+ audio:not([controls]){
45
+ display: none; //Chrome 40+, iOS 8+, Safari 8+
46
+ height: 0; //Remove excess height in iOS5 devices
47
+ }
48
+
49
+ input {
50
+ &[type="number"] {
51
+ width: auto; // Firefox 36+
52
+ }
53
+
54
+ &[type="search"] {
55
+ -webkit-appearance: textfield; // Safari 8+
56
+
57
+ &::-webkit-search-cancel-button,
58
+ &::-webkit-search-decoration {
59
+ -webkit-appearance: none; // Safari 8+
60
+ }
61
+ }
62
+ }
63
+
64
+
65
+
66
+ pre {
67
+ overflow: auto; // Internet Explorer 11+
68
+ }
69
+
70
+ progress {
71
+ display: inline-block; // Internet Explorer 11+, Windows Phone 8.1+
72
+ }
73
+
74
+ small {
75
+ font-size: $small-font-size; // All browsers
76
+ }
77
+
78
+
79
+ textarea {
80
+ overflow: auto; // Internet Explorer 11+
81
+ }
82
+
83
+
84
+ [unselectable] {
85
+ user-select: none; // Android 4.4+, Chrome 40+, Firefox 36+, iOS 8+, Safari 8+
86
+ }
87
+
88
+
89
+ /*
90
+ * Universal inheritance
91
+ */
92
+
93
+ *,
94
+ ::before,
95
+ ::after {
96
+ box-sizing: inherit;
97
+ }
98
+
99
+ * {
100
+ font-size: inherit;
101
+ line-height: inherit;
102
+ }
103
+
104
+ ::before,
105
+ ::after {
106
+ text-decoration: inherit;
107
+ vertical-align: inherit;
108
+ }
109
+
110
+
111
+
112
+ //Opinionated defaults
113
+
114
+
115
+ // specify solid border style of all elements
116
+
117
+ *,
118
+ ::before,
119
+ ::after {
120
+ border-style: solid;
121
+ border-width: 0;
122
+ }
123
+
124
+ // remove margin and padding of all elements
125
+
126
+ * {
127
+ margin: 0;
128
+ padding: 0;
129
+ }
130
+
131
+ // specify the root styles of the document
132
+
133
+ :root {
134
+ box-sizing: $root-box-sizing;
135
+ cursor: $root-cursor;
136
+ font: #{$root-font-size}/#{$root-line-height} $root-font-family;
137
+ text-rendering: $root-text-rendering;
138
+ }
139
+
140
+ // specify the text decoration of anchors
141
+
142
+ a {
143
+ text-decoration: $anchor-text-decoration;
144
+ }
145
+
146
+ // specify media element style
147
+
148
+ audio,
149
+ canvas,
150
+ iframe,
151
+ img,
152
+ svg,
153
+ video {
154
+ vertical-align: $media-element-vertical-align;
155
+ }
156
+
157
+ // specify the background color of form elements
158
+
159
+ button,
160
+ input,
161
+ select,
162
+ textarea {
163
+ background-color: $form-element-background-color;
164
+ }
165
+
166
+ // specify inheritance of form elements
167
+
168
+ button,
169
+ input,
170
+ select,
171
+ textarea {
172
+ color: inherit;
173
+ font-family: inherit;
174
+ font-style: inherit;
175
+ font-weight: inherit;
176
+ min-height: $form-element-min-height; // specify the minimum height of form elements
177
+ }
178
+
179
+ // 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
180
+ // and `video` controls
181
+ // 2. Corrects inability to style clickable 'input' types in iOS
182
+ // 3. Improves usability and consistency of cursor style between image-type
183
+ // 'input' and others
184
+ // Known issue: inner spacing remains in IE6
185
+
186
+ button,
187
+ html input[type="button"], // 1
188
+ input[type="reset"],
189
+ input[type="submit"] {
190
+ -webkit-appearance: button; // 2
191
+ cursor: pointer; // 3
192
+ }
193
+
194
+ // Re-set default cursor for disabled elements
195
+
196
+ button[disabled],
197
+ input[disabled] {
198
+ cursor: default;
199
+ }
200
+
201
+ input {
202
+ // 1. Addresses appearance set to searchfield in S5, Chrome
203
+ // 2. Addresses box-sizing set to border-box in S5, Chrome (include -moz to future-proof)
204
+ &[type="search"] {
205
+ -webkit-appearance: textfield; // 1
206
+ -webkit-box-sizing: content-box; // 2
207
+ box-sizing: content-box;
208
+
209
+ // Remove inner padding and search cancel button in Safari 5 and Chrome
210
+ // on OS X.
211
+ &::-webkit-search-cancel-button,
212
+ &::-webkit-search-decoration {
213
+ -webkit-appearance: none;
214
+ }
215
+ }
216
+
217
+ // 1. Address box sizing set to `content-box` in IE 8/9/10.
218
+ // 2. Remove excess padding in IE 8/9/10.
219
+ &[type="checkbox"],
220
+ &[type="radio"] {
221
+ box-sizing: border-box; // 1
222
+ padding: 0; // 2
223
+ }
224
+ }
225
+
226
+ // specify the font family of code elements
227
+
228
+ code,
229
+ kbd,
230
+ pre,
231
+ samp {
232
+ font-family: $monospace-font-family, monospace;
233
+ }
234
+
235
+ // specify the list style of nav lists
236
+
237
+ nav ol,
238
+ nav ul {
239
+ list-style: $nav-list-style;
240
+ }
241
+
242
+ // style select like a standard input
243
+
244
+ select {
245
+ -moz-appearance: none; // Firefox 36+
246
+ -webkit-appearance: none; // Chrome 41+
247
+
248
+ &::-ms-expand {
249
+ display: none; // Internet Explorer 11+
250
+ }
251
+
252
+ &::-ms-value {
253
+ color: currentColor; // Internet Explorer 11+
254
+ }
255
+ }
256
+
257
+ // specify the border styles of tables
258
+
259
+ table {
260
+ border-collapse: $table-border-collapse;
261
+ border-spacing: $table-border-spacing;
262
+ }
263
+
264
+ // specify textarea resizability
265
+
266
+ textarea {
267
+ resize: $textarea-resize;
268
+ }
269
+
270
+ img {
271
+ border: 0;
272
+ }
273
+
274
+ // hide content from screens but not screenreaders
275
+
276
+ @media screen {
277
+ [hidden~="screen"] {
278
+ display: inherit;
279
+ }
280
+
281
+ [hidden~="screen"]:not(:active):not(:focus):not(:target) {
282
+ clip: rect(0 0 0 0) !important;
283
+ position: absolute !important;
284
+ }
285
+ }
@@ -1,24 +1,22 @@
1
1
  //pull-left
2
2
  %pull-left {
3
- @include float(left);
3
+ @include float(left);
4
4
  }
5
5
 
6
6
  //pull-right
7
-
8
7
  %pull-right {
9
- @include float(right);
8
+ @include float(right);
10
9
  }
11
10
 
12
11
  //clearfix
13
-
14
12
  %clearfix {
15
- &:before,
16
- &:after {
17
- content:"";
18
- display: table;
19
- }
20
- &:after {
21
- overflow: hidden;
22
- clear: both;
23
- }
13
+ &:before,
14
+ &:after {
15
+ content:"";
16
+ display: table;
17
+ }
18
+ &:after {
19
+ overflow: hidden;
20
+ clear: both;
21
+ }
24
22
  }
@@ -1,4 +1,5 @@
1
1
  @import "mixins/backgroundTransparent";
2
2
  @import "mixins/ellipsis-overflow";
3
3
  @import "mixins/float";
4
+ @import "mixins/triangle";
4
5
  @import "mixins/px2rem";
@@ -1,28 +1,29 @@
1
- #Mixins使用方法
1
+ # Mixins使用方法
2
2
 
3
3
  Sass中的mixins默认情况下可以不调用任何参数,此时调用的参数为定义mixins是设置的参数;第二种情形是调用是指定参数。Sass调用mixins都是通过`@include`关键词。
4
4
 
5
- ###1. ellipsis-overflow
5
+ ### 1. ellipsis-overflow
6
6
 
7
- ####功能
7
+ #### 功能
8
8
 
9
9
  字符截取,末尾出现三个`...`。
10
10
 
11
- ####参数
11
+ #### 参数
12
12
 
13
- 定义`$substract`参数,默认值为`0`。指定元素需要去掉的宽度。
13
+ - `$line`,行数,默认值为`1`。
14
+ - `$substract`,指定元素需要去掉的宽度,默认值为`0`。
14
15
 
15
- ####调用
16
+ #### 调用
16
17
 
17
- 调用默认参数值,也就是`$substract`值为0;
18
+ 调用默认参数值,也就是`$line`值为1,`$substract`值为0;
18
19
 
19
20
  @include ellipsis-overflow;
20
21
 
21
22
  指定能数值调用:
22
23
 
23
- @include ellipsis-overflow(20);
24
+ @include ellipsis-overflow(2); // 显示两行文字之后加省略号
24
25
 
25
- ####示例
26
+ #### 示例
26
27
 
27
28
  SCSS
28
29
 
@@ -39,18 +40,18 @@ CSS
39
40
  width: 80%;
40
41
  }
41
42
 
42
- ###2. float
43
+ ### 2. float
43
44
 
44
- ####功能
45
+ #### 功能
45
46
 
46
47
  设置元素浮动方向。
47
48
 
48
- ####参数
49
+ #### 参数
49
50
 
50
51
  - `$direction`: 定义浮动方向,默认值为`left`。可选值为`left`、`right`和`none`。
51
52
  - `$support-for-ie`:布尔值,默认值为`true`。可选值为`true`和`flase`。(如果不需要考虑兼容IE6,可以去掉这个参数)。
52
53
 
53
- ####调用
54
+ #### 调用
54
55
 
55
56
  默认调用方法:
56
57
 
@@ -60,7 +61,7 @@ CSS
60
61
 
61
62
  @include float(right, false);
62
63
 
63
- ####示例
64
+ #### 示例
64
65
 
65
66
  SCSS
66
67
 
@@ -83,19 +84,19 @@ CSS
83
84
  float: right;
84
85
  }
85
86
 
86
- ###3.backgroundTransparent
87
+ ### 3.backgroundTransparent
87
88
 
88
- ####功能
89
+ #### 功能
89
90
 
90
91
  设置带有透明度的背景颜色。
91
92
 
92
- ####参数
93
+ #### 参数
93
94
 
94
95
  - `$color`: 背景颜色
95
96
  - `$opacity`: 透明度
96
97
  - `$support-for-ie`: 布尔值,默认`false`,如果需要兼容低版本浏览器,只需要将其设置为`true`
97
98
 
98
- ####调用
99
+ #### 调用
99
100
 
100
101
  默认调用方法:
101
102
 
@@ -105,7 +106,7 @@ CSS
105
106
 
106
107
  @include backgroundTransparent(#000,.5,true);
107
108
 
108
- ####示例
109
+ #### 示例
109
110
 
110
111
  SCSS
111
112
 
@@ -117,4 +118,4 @@ CSS
117
118
 
118
119
  .box {
119
120
  background-color: rgba(0, 0, 0, 0.5);
120
- }
121
+ }
@@ -1,12 +1,13 @@
1
1
  //Author:Janking (https://github.com/Janking)
2
-
3
- //eg: https://gist.github.com/airen/040f6f06bcc8b3176d8a
4
-
2
+ /// 设置背景透明
3
+ /// @param {[string]} $color - 背景颜色
4
+ /// @param {[string]} $opacity - 透明度
5
+ /// @param {[boolen]} $support-for-ie [false] 是否支持IE
6
+ /// @link https://gist.github.com/airen/040f6f06bcc8b3176d8a
5
7
  @mixin backgroundTransparent($color,$opacity,$support-for-ie:false){
6
8
  background-color:rgba($color,$opacity);
7
9
  @if $support-for-ie{
8
10
  filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#{ie-hex-str(rgba($color,$opacity))},endColorstr=#{ie-hex-str(rgba($color,$opacity))});
9
-
10
11
  :root & {
11
12
  filter:none;
12
13
  }
@@ -1,15 +1,18 @@
1
- //eg: https://gist.github.com/08bce58e9af2fa223118
2
- @mixin content($attr,$content:null){
3
- @if $attr {
4
- display: inline-block;
5
- content: $attr;
6
- }
7
- @else if $content != null {
8
- content: quote($content);
9
- display: inline-block;
10
- }
11
- @else {
12
- content: "";
13
- display: table;
14
- }
1
+ /// 设置元素的content内容
2
+ /// @param {[string]} $attr - 元素属性
3
+ /// @param {[string]} $content [null] 内容值
4
+ /// @link https://gist.github.com/08bce58e9af2fa223118
5
+ @mixin content($attr, $content:null) {
6
+ @if $attr {
7
+ display: inline-block;
8
+ content: $attr;
9
+ }
10
+ @else if $content ! null {
11
+ content: quote($content);
12
+ display: inline-block;
13
+ }
14
+ @else {
15
+ content: "";
16
+ display: table;
17
+ }
15
18
  }
@@ -1,9 +1,9 @@
1
- //eg:https://gist.github.com/airen/caf49ca5c5e7743f9996
2
-
1
+ /// 文字溢出省略号
2
+ /// @param {[string]} $substract [0] 预留区域百分比%
3
+ /// @link https://gist.github.com/airen/caf49ca5c5e7743f9996
3
4
  @mixin ellipsis-overflow($substract:0) {
4
- overflow: hidden;
5
- text-overflow: ellipsis;
6
- white-space: nowrap;
7
- width: 100% - $substract;
8
- }
9
-
5
+ overflow: hidden;
6
+ text-overflow: ellipsis;
7
+ white-space: nowrap;
8
+ width: 100% - $substract;
9
+ }
@@ -1,9 +1,10 @@
1
- //https://gist.github.com/airen/d7f8ad25c982750dcb86
2
-
3
- @mixin float($direction: left,$support-for-ie:true){
4
-
5
- float: unquote($direction);
6
- @if $support-for-ie{
7
- _display: inline;
8
- }
1
+ /// 设置元素的float属性
2
+ /// @param {[string]} $direction [left] float方向
3
+ /// @param {[boolen]} $support-for-ie [true] 是否支持IE
4
+ /// @link https://gist.github.com/airen/d7f8ad25c982750dcb86
5
+ @mixin float($direction: left, $support-for-ie:true) {
6
+ float: unquote($direction);
7
+ @if $support-for-ie {
8
+ _display: inline;
9
+ }
9
10
  }
@@ -1,6 +1,11 @@
1
1
  //Thanks: https://github.com/bitmanic/rem/blob/master/stylesheets/_rem.scss by @benfrain (https://github.com/benfrain)
2
2
 
3
- //eg: https://gist.github.com/airen/cdf85f2a704fbca00dec
3
+ /// px转rem,需要sass>=3.4,libsass推荐用pxToremCalc
4
+ /// @param {[string]} $property - 属性值
5
+ /// @param {[string]} $px-values - 像素值 如10px
6
+ /// @param {[string]} $px-values [16px] 基础字号像素值
7
+ /// @param {[boolen]} $support-for-ie [true] 是否支持IE
8
+ /// @link https://gist.github.com/airen/cdf85f2a704fbca00dec
4
9
 
5
10
  @mixin px2rem($property,$px-values,$baseline-px:16px,$support-for-ie:false){
6
11
  //Conver the baseline into rems
@@ -25,4 +30,41 @@
25
30
  // Return the property and its list of converted values
26
31
  #{$property}: $rem-values;
27
32
  }
33
+ }
34
+
35
+
36
+
37
+
38
+ /// 去掉单位,比如100px => 100
39
+ /// @param {[string]} $number - 带单位或者不带单位的数值
40
+ @function strip-units($number) {
41
+ @return $number / ($number * 0 + 1);
42
+ }
43
+
44
+ /// px转rem 默认字号16px,可以全局设置$browser-default-font-size,eg: @include pxToremCalc(padding,10,20,10);
45
+ /// @param {[string]} $property - 属性值
46
+ /// @param {[string]} $values... - 像素值 如10px,支持传入多值
47
+ @mixin remCalc($property, $values...) {
48
+ $browser-default-font-size:16px !default;
49
+ $max: length($values);//返回$values列表的长度值
50
+ $pxValues: '';
51
+ $remValues: '';
52
+ @for $i from 1 through $max {
53
+ $value: strip-units(nth($values, $i));//返回$values列表中的第$i个值,并将单位值去掉
54
+ $browser-default-font-size: strip-units($browser-default-font-size);
55
+ $remValues: #{$remValues + $value / $browser-default-font-size}rem;
56
+ @if $i < $max {
57
+ $remValues: #{$remValues + " "};
58
+ }
59
+ }
60
+ @for $i from 1 through $max {
61
+ $value: strip-units(nth($values, $i));
62
+ $pxValues: #{$pxValues + $value}px;
63
+ @if $i < $max {
64
+ $pxValues: #{$pxValues + " "};
65
+ }
66
+ }
67
+
68
+ // #{$property}: $pxValues; //不支持rem的输出px
69
+ #{$property}: $remValues;
28
70
  }
@@ -0,0 +1,212 @@
1
+ // 教程:http://alistapart.com/article/quantity-queries-for-css
2
+ // quantity-queries SCSS:https://github.com/danielguillan/quantity-queries/blob/master/stylesheets/_quantity-queries.scss
3
+ // Demo: http://codepen.io/danielguillan/pen/GgBOxm
4
+
5
+ // -----------------------------------------------------------------------------
6
+ // Quantity queries
7
+ // -----------------------------------------------------------------------------
8
+ // Table of contents:
9
+ // 1. Last Simple Selector
10
+ // 2. Build Quantity Selector
11
+ // 3. At least
12
+ // 4. At most
13
+ // 5. Between
14
+ // 6. Exactly
15
+
16
+
17
+ // -----------------------------------------------------------------------------
18
+ // 1. Last Simple Selector
19
+ // -----------------------------------------------------------------------------
20
+
21
+ /// Find the last simple selector in a given selector
22
+ /// @access private
23
+ /// @param {list | string} $selector - A single selector
24
+ /// @return {string} - The last simple selector in $selector
25
+ /// @example scss
26
+ /// $result: _last-simple-selector(ul > li); // li
27
+
28
+ @function _last-simple-selector($selector) {
29
+ $parsed: selector-parse($selector);
30
+
31
+ @if length($parsed) > 1 {
32
+ @error '`#{$selector}` contains #{length($parsed)} selectors and the `_last-simple-selector()`function accepts only 1.';
33
+ }
34
+ $last-simple-selector: nth(nth($parsed, 1), -1);
35
+
36
+ @return $last-simple-selector;
37
+ }
38
+
39
+
40
+ // -----------------------------------------------------------------------------
41
+ // 2. Build Quantity Selector
42
+ // -----------------------------------------------------------------------------
43
+
44
+ /// Builds the selector for the quantity query
45
+ /// @access private
46
+ /// @param {string} $selector-append - The selector to be appended
47
+ /// @param {string} $last-selector - The item's selector
48
+ /// @return {list} - The final quantity query selector
49
+
50
+ @function _build-quantity-selector($selector-append, $last-selector) {
51
+ $quantity-selector: ();
52
+
53
+ @each $s in & {
54
+ $last-simple-selector: '~' + if($last-selector, $last-selector, _last-simple-selector($s));
55
+ $sel: selector-append($s, $selector-append);
56
+ $sel2: selector-nest($sel, $last-simple-selector);
57
+ $quantity-selector: append($quantity-selector, $sel, 'comma');
58
+ $quantity-selector: append($quantity-selector, $sel2 , 'comma');
59
+ }
60
+
61
+ @return $quantity-selector;
62
+ }
63
+
64
+
65
+ // -----------------------------------------------------------------------------
66
+ // 3. At least
67
+ // -----------------------------------------------------------------------------
68
+
69
+ /// Query when total items is at least N items
70
+ /// @param {number} $count - Quantity to match (equal or more)
71
+ /// @example scss - Make the items color red when there are 4 items or more
72
+ /// ul li {
73
+ /// @include at-least(4) { color: red; }
74
+ /// }
75
+ /// @example scss - Make the items color blue when there are 6 items or more and use '*' (element agnostic) as the item selector
76
+ /// ul li {
77
+ /// @include at-least(6, '*') { color: blue; }
78
+ /// }
79
+
80
+ @mixin at-least($count, $selector: null) {
81
+ $selector-append: ':nth-last-child(n+#{$count})';
82
+
83
+ @if type-of($count) != 'number' or not unitless($count) or $count < 1 {
84
+ @error '`#{$count}` is not a valid number for `at-least`';
85
+ }
86
+
87
+ @if $selector != null and (type-of($selector) != 'string' or length($selector) > 1) {
88
+ @error '`#{$selector}` is not a valid selector for `at-least`';
89
+ }
90
+
91
+ $at-least-selector: _build-quantity-selector($selector-append, $selector);
92
+
93
+
94
+ @at-root #{$at-least-selector} {
95
+ @content;
96
+ }
97
+ }
98
+
99
+
100
+ // -----------------------------------------------------------------------------
101
+ // 4. At most
102
+ // -----------------------------------------------------------------------------
103
+
104
+ /// Query when total items is at most N items
105
+ /// @param {number} $count - Quantity to match (equal or less)
106
+ /// @example scss - Make the items color red when there are 4 items or less
107
+ /// ul li {
108
+ /// @include at-most(4) { color: red; }
109
+ /// }
110
+ /// @example scss - Make the items color blue when there are 6 items or less and use '*' (element agnostic) as the item selector
111
+ /// ul li {
112
+ /// @include at-most(6, '*') { color: blue; }
113
+ /// }
114
+
115
+ @mixin at-most($count, $selector: null) {
116
+ $selector-append: ':nth-last-child(-n+#{$count}):first-child';
117
+
118
+ @if type-of($count) != 'number' or not unitless($count) or $count < 1 {
119
+ @error '`#{$count}` is not a valid number for `at-most`.';
120
+ }
121
+
122
+ @if $selector != null and (type-of($selector) != 'string' or length($selector) > 1) {
123
+ @error '`#{$selector}` is not a valid selector for `at-most`';
124
+ }
125
+
126
+ $at-most-selector: _build-quantity-selector($selector-append, $selector);
127
+
128
+
129
+ @at-root #{$at-most-selector} {
130
+ @content;
131
+ }
132
+ }
133
+
134
+
135
+ // -----------------------------------------------------------------------------
136
+ // 5. Between
137
+ // -----------------------------------------------------------------------------
138
+
139
+ /// Query when total items is at least X items and at most Y items
140
+ /// @param {number} $at-least - Lower quantity of items to match
141
+ /// @param {number} $at-most - Higher quantity of items to match
142
+ /// @example scss - Make the items color red when there are at least 2 and at most 4 items
143
+ /// ul li {
144
+ /// @include between(4, 8) { color: red; }
145
+ /// }
146
+ /// @example scss - Make the items color blue when there are at least 6 items and at most 10 items and use '*' (element agnostic) as the item selector
147
+ /// ul li {
148
+ /// @include between(6, 10, '*') { color: blue; }
149
+ /// }
150
+
151
+
152
+ @mixin between($first, $last, $selector: null) {
153
+ $selector-append: ':nth-last-child(n+#{$first}):nth-last-child(-n+#{$last}):first-child';
154
+
155
+ @if type-of($first) != 'number' or not unitless($first) or $first < 1 {
156
+ @error '`#{$first}` is not a valid number for `between`';
157
+ }
158
+
159
+ @if type-of($last) != 'number' or not unitless($last) or $last < 1 {
160
+ @error '`#{$last}` is not a valid number for `between`';
161
+ }
162
+
163
+ @if $first > $last {
164
+ @error '#{$first} can´t be larger that #{$last} for `between`';
165
+ }
166
+
167
+ @if $selector != null and (type-of($selector) != 'string' or length($selector) > 1) {
168
+ @error '`#{$selector}` is not a valid selector for `between`';
169
+ }
170
+
171
+ $between-selector: _build-quantity-selector($selector-append, $selector);
172
+
173
+
174
+ @at-root #{$between-selector} {
175
+ @content;
176
+ }
177
+ }
178
+
179
+
180
+ // -----------------------------------------------------------------------------
181
+ // 6. Exactly
182
+ // -----------------------------------------------------------------------------
183
+
184
+ /// Query when total items is exactly N items
185
+ /// @param {number} $count - Quantity to match (equal)
186
+ /// @example scss - Make the items color red when there are exactly 4 items
187
+ /// ul li {
188
+ /// @include exactly(4) { color: red; }
189
+ /// }
190
+ /// @example scss - Make the items color blue when there are exactly 6 items and use '*' (element agnostic) as the item selector
191
+ /// ul li {
192
+ /// @include exactly(6, '*') { color: blue; }
193
+ /// }
194
+
195
+ @mixin exactly($count, $selector: null) {
196
+ $selector-append: ':nth-last-child(#{$count}):first-child';
197
+
198
+ @if type-of($count) != 'number' or not unitless($count) or $count < 1 {
199
+ @error '`#{$count}` is not a valid number for `exactly`';
200
+ }
201
+
202
+ @if $selector != null and (type-of($selector) != 'string' or length($selector) > 1) {
203
+ @error '`#{$selector}` is not a valid selector for `exactly`';
204
+ }
205
+
206
+ $exactly-selector: _build-quantity-selector($selector-append, $selector);
207
+
208
+
209
+ @at-root #{$exactly-selector} {
210
+ @content;
211
+ }
212
+ }
@@ -1,4 +1,6 @@
1
+ /// 设置元素是否可以resize
2
+ /// @param {[string]} $direction - 方向 horizontal, vertical, both
1
3
  @mixin resizable($direction) {
2
- resize: $direction; // Options: horizontal, vertical, both
3
- overflow: auto; // Per CSS3 UI, `resize` only applies when `overflow` isn't `visible`
4
+ resize: $direction; // Options: horizontal, vertical, both
5
+ overflow: auto; // Per CSS3 UI, `resize` only applies when `overflow` isn't `visible`
4
6
  }
@@ -1,7 +1,6 @@
1
1
  //From: http://compass-style.org/reference/compass/layout/sticky_footer/
2
2
 
3
- //html
4
-
3
+ // html
5
4
  // <body>
6
5
  // <div id="wrapper">
7
6
  // <div id="wrapper-inner"></div>
@@ -12,8 +11,12 @@
12
11
  // </div>
13
12
  // </body>
14
13
 
15
-
16
- //eg: https://gist.github.com/airen/2f7211d7819dddaf6003
14
+ /// 设置底部元素sticky
15
+ /// @param {[string]} $footer-height - 底部元素高度
16
+ /// @param {[string]} $root-selector [unquote("#wrapper")] 页面root主元素选择器
17
+ /// @param {[string]} $root-footer-selector [unquote("#push")] 页面root底部元素选择器
18
+ /// @param {[string]} $footer-selector [unquote("#footer")] 底部元素选择器
19
+ /// @link https://gist.github.com/airen/2f7211d7819dddaf6003
17
20
 
18
21
  @mixin stickyFooter($footer-height, $root-selector: unquote("#wrapper"), $root-footer-selector: unquote("#push"), $footer-selector: unquote("#footer")) {
19
22
  html, body {
@@ -0,0 +1,25 @@
1
+ //http://www.w3cplus.com/preprocessor/sass-triangle-mixin.html
2
+ @mixin triangle($width, $height, $color, $direction) {
3
+ $width: $width/2;
4
+ $color-border-style: $height solid $color;
5
+ $transparent-border-style: $width solid transparent;
6
+ height: 0;
7
+ width: 0;
8
+ @if $direction == up {
9
+ border-bottom: $color-border-style;
10
+ border-left: $transparent-border-style;
11
+ border-right: $transparent-border-style;
12
+ } @else if $direction == right {
13
+ border-left: $color-border-style;
14
+ border-top: $transparent-border-style;
15
+ border-bottom: $transparent-border-style;
16
+ } @else if $direction == down {
17
+ border-top: $color-border-style;
18
+ border-left: $transparent-border-style;
19
+ border-right: $transparent-border-style;
20
+ } @else if $direction == left {
21
+ border-right: $color-border-style;
22
+ border-top: $transparent-border-style;
23
+ border-bottom: $transparent-border-style;
24
+ }
25
+ }
@@ -1,25 +1,25 @@
1
1
  //@include visuallyHidden;
2
-
2
+ /// 设置元素隐藏,最常用来隐藏一个元素的方法是使用display:none,可这并不是一个完美的方法,这样会让屏幕阅读器无法读到这个元素。为了解决这个问题,使用另外一种方法来实现元素的隐藏,而这种方法仅在浏览器中隐藏了元素,而屏幕阅读器却能读到这个元素。
3
+ /// @param {[boolen]} $support-for-ie [true] 是否支持IE
4
+ /// @link http://www.w3cplus.com/preprocessor/ten-best-common-mixins.html
3
5
  @mixin visuallyHidden($support-for-ie:true) {
4
- @if $support-for-ie {
5
- clip: rect(0,0,0,0);
6
- }
7
- border: 0;
8
- clip: rect(0 0 0 0);
9
- height: 1px;
10
- margin: -1px;
11
- overflow: hidden;
12
- padding: 0;
13
- position: absolute;
14
- width: 1px;
15
-
16
- &.focusable:active,
17
- &.focusable:focus {
18
- clip: auto;
19
- height: auto;
20
- margin: 0;
21
- overflow: visible;
22
- position: static;
23
- width: auto;
24
- }
6
+ @if $support-for-ie {
7
+ clip: rect(0, 0, 0, 0);
8
+ }
9
+ border: 0;
10
+ clip: rect(0 0 0 0);
11
+ height: 1px;
12
+ margin: -1px;
13
+ overflow: hidden;
14
+ padding: 0;
15
+ position: absolute;
16
+ width: 1px;
17
+ &.focusable:active, &.focusable:focus {
18
+ clip: auto;
19
+ height: auto;
20
+ margin: 0;
21
+ overflow: visible;
22
+ position: static;
23
+ width: auto;
24
+ }
25
25
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sassmagic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-31 00:00:00.000000000 Z
12
+ date: 2015-04-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sass
@@ -48,6 +48,7 @@ files:
48
48
  - lib/sassmagic/reset.rb
49
49
  - lib/sassmagic/utils.rb
50
50
  - lib/sassmagic.rb
51
+ - stylesheets/sassmagic/base/_reset.scss
51
52
  - stylesheets/sassmagic/helpers/_helpers.scss
52
53
  - stylesheets/sassmagic/helpers/_mixins.scss
53
54
  - stylesheets/sassmagic/helpers/_variables.scss
@@ -56,8 +57,10 @@ files:
56
57
  - stylesheets/sassmagic/helpers/mixins/_ellipsis-overflow.scss
57
58
  - stylesheets/sassmagic/helpers/mixins/_float.scss
58
59
  - stylesheets/sassmagic/helpers/mixins/_px2rem.scss
60
+ - stylesheets/sassmagic/helpers/mixins/_quantity-queries.scss
59
61
  - stylesheets/sassmagic/helpers/mixins/_resizable.scss
60
62
  - stylesheets/sassmagic/helpers/mixins/_stickyFooter.scss
63
+ - stylesheets/sassmagic/helpers/mixins/_triangle.scss
61
64
  - stylesheets/sassmagic/helpers/mixins/_visuallyHidden.scss
62
65
  - stylesheets/sassmagic/helpers/mixins/README.md
63
66
  - stylesheets/sassmagic/main.scss