modernizr-mixin 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +87 -0
- data/lib/modernizr-mixin.rb +8 -0
- data/stylesheets/_modernizr.scss +109 -0
- metadata +75 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9f946ac711102f5abe64c440ef41d7426b47db0a
|
4
|
+
data.tar.gz: 79b99ea7dcbaed4911bd28bf01f29bdc232cd450
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 42b0f6f4a19777e8f4e9fd721453e11475468a8d55d83028165c7368e50be0312456bb6d46a196eb2a1414b6f0a6d427d3e20491d490c7a2189910f5860cdf8a
|
7
|
+
data.tar.gz: 5ffd4f797553dd00a99fb220918c9252feb33355142106bd7bd884f8a307c94a6871b9358d7e0695d484c2bafa6eeabea2cb1c0ddad5f53ae18106043e9f6852
|
data/README.md
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# Modernizr mixin
|
2
|
+
|
3
|
+
A simple way for DRYier, faster and cleaner Modernizr tests in Sass.
|
4
|
+
|
5
|
+
|
6
|
+
## Install
|
7
|
+
|
8
|
+
Requires Sass 3.3
|
9
|
+
|
10
|
+
There are 3 ways of installing the Modernizr mixin:
|
11
|
+
|
12
|
+
### Download
|
13
|
+
|
14
|
+
Download `_modernizr.scss` which is located in the `stylesheets` folder and place it in your Sass directory.
|
15
|
+
|
16
|
+
### Bower
|
17
|
+
|
18
|
+
To install the package using Bower simply run the following command:
|
19
|
+
|
20
|
+
bower install --save-dev modernizr-mixin
|
21
|
+
|
22
|
+
### Compass extension
|
23
|
+
|
24
|
+
Modernizr is also available as a Compass extension:
|
25
|
+
|
26
|
+
gem install modernizr-mixin
|
27
|
+
|
28
|
+
Then add the following line to your `config.rb`:
|
29
|
+
|
30
|
+
require 'modernizr-mixin'
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
Import it into your main stylesheet:
|
35
|
+
|
36
|
+
@import 'modernizr';
|
37
|
+
|
38
|
+
The Modernizr helper includes two mixins: `yep` and `nope`. Simply pass a comma-separeted list (`argList`) of features as argument and the rules you need to print.
|
39
|
+
|
40
|
+
### yep
|
41
|
+
|
42
|
+
Prints classes for supported features.
|
43
|
+
|
44
|
+
@include yep($features...) { ... }
|
45
|
+
|
46
|
+
### nope
|
47
|
+
|
48
|
+
Prints classes for unsupported features and unavailable Javascript.
|
49
|
+
|
50
|
+
@include nope($features...) { ... }
|
51
|
+
|
52
|
+
### Example
|
53
|
+
|
54
|
+
Sass input:
|
55
|
+
|
56
|
+
```scss
|
57
|
+
.my-selector {
|
58
|
+
@include yep(translate3d, opacity) {
|
59
|
+
transform: translate3d(0, 100px, 0);
|
60
|
+
opacity: 0;
|
61
|
+
}
|
62
|
+
@include nope(translate3d, opacity) {
|
63
|
+
top: 100px;
|
64
|
+
display: none;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
```
|
68
|
+
|
69
|
+
CSS output:
|
70
|
+
|
71
|
+
```css
|
72
|
+
.translate3d.opacity .my-selector {
|
73
|
+
transform: translate3d(0, 100px, 0);
|
74
|
+
opacity: 0;
|
75
|
+
}
|
76
|
+
|
77
|
+
.no-js my-selector,
|
78
|
+
.no-translate3d .selector,
|
79
|
+
.no-opacity .selector {
|
80
|
+
top: 100px;
|
81
|
+
display: none;
|
82
|
+
}
|
83
|
+
```
|
84
|
+
|
85
|
+
## Acknowledgements
|
86
|
+
|
87
|
+
Thanks to [Hugo Giraudel](https://github.com/hugogiraudel) for reviewing and tweaking the original code.
|
@@ -0,0 +1,109 @@
|
|
1
|
+
// =============================================================================
|
2
|
+
// Modernizr mixin
|
3
|
+
//
|
4
|
+
// Table of contents:
|
5
|
+
// 1. Modernizr mixin
|
6
|
+
// 1.1 Generate placeholder name and selectors
|
7
|
+
// 1.2 Define placeholder and print @content
|
8
|
+
// 1.3 Define feature selector and extend the placeholder
|
9
|
+
// 2. Aliases
|
10
|
+
// 2.1 Yep alias
|
11
|
+
// 2.2 Nope alias
|
12
|
+
//
|
13
|
+
// Usage:
|
14
|
+
// .my-selector {
|
15
|
+
// @include yep($features...) { ... }
|
16
|
+
// @include nope($features...) { ... {
|
17
|
+
// }
|
18
|
+
//
|
19
|
+
// =============================================================================
|
20
|
+
|
21
|
+
// =============================================================================
|
22
|
+
// 1. Modernizr mixin
|
23
|
+
// =============================================================================
|
24
|
+
|
25
|
+
@mixin modernizr($features, $supports) {
|
26
|
+
|
27
|
+
$everything-okay: true;
|
28
|
+
|
29
|
+
// Use the 'no-' prefix if checking for unsuported features (e.g. `.no-translate3d`)
|
30
|
+
$prefix: if($supports, '', 'no-');
|
31
|
+
|
32
|
+
// Features selector
|
33
|
+
// a) create a string if checking for supported features. We'll concatenate class names later on (e.g. `.translate3d.opacity selector`)
|
34
|
+
// b) create a list if checking for unsuported features. We'll append the class names later on (e.g. `.no-js selector, .no-translate3d selector`)
|
35
|
+
$selector: if($supports, '', (unquote('.no-js')));
|
36
|
+
|
37
|
+
// The placeholder (e.g. `%yep-translate3d` or `%nope-opacity`)
|
38
|
+
$placeholder: if($supports, '%yep', '%nope');
|
39
|
+
|
40
|
+
|
41
|
+
// 1.1 Generate placeholder and selectors
|
42
|
+
// =====================================
|
43
|
+
|
44
|
+
@each $feature in $features {
|
45
|
+
|
46
|
+
// Making sure $feature is a string
|
47
|
+
@if type-of($feature) != string {
|
48
|
+
|
49
|
+
$everything-okay: false;
|
50
|
+
@warn '`#{$feature} is not a string for `modernizr`';
|
51
|
+
|
52
|
+
} @else {
|
53
|
+
|
54
|
+
// Add feature name to the placeholder string (e.g. '%yep' + '-' + 'translate3d' or '%nope' + '-' + 'translate3d')
|
55
|
+
$placeholder: $placeholder + '-' + $feature;
|
56
|
+
|
57
|
+
// Define the new selector string (e.g. `.translate3d` or `.no-translate3d`)
|
58
|
+
$new-selector: #{'.' + $prefix + $feature};
|
59
|
+
|
60
|
+
// Append the new selector
|
61
|
+
// a) to the string if yep (e.g. `.translate3d.opacity`)
|
62
|
+
// b) to the list if nope (e.g. `.no-translate3d, .no-opacity`)
|
63
|
+
$selector: if($supports, $selector + $new-selector, append($selector, $new-selector, comma));
|
64
|
+
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
@if $everything-okay == true {
|
69
|
+
|
70
|
+
// 1.2 Define the placholder and print @content
|
71
|
+
// =====================================
|
72
|
+
|
73
|
+
#{$placeholder} & {
|
74
|
+
@content;
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
// 1.3 Define feature selector(s) and extend the placeholder
|
79
|
+
// =====================================
|
80
|
+
|
81
|
+
@at-root #{$selector} {
|
82
|
+
@extend #{$placeholder};
|
83
|
+
}
|
84
|
+
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
// =============================================================================
|
89
|
+
// 2. Aliases
|
90
|
+
// =============================================================================
|
91
|
+
|
92
|
+
// 2.1 Yep alias
|
93
|
+
// =====================================
|
94
|
+
|
95
|
+
@mixin yep($features...) {
|
96
|
+
@include modernizr($features, $supports: true) {
|
97
|
+
@content;
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
// 2.2 Nope alias
|
103
|
+
// =====================================
|
104
|
+
|
105
|
+
@mixin nope($features...) {
|
106
|
+
@include modernizr($features, $supports: false) {
|
107
|
+
@content;
|
108
|
+
}
|
109
|
+
}
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: modernizr-mixin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Guillan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sass
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: compass
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.0.alpha
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.0.alpha
|
41
|
+
description: A simple way for DRYier, faster and cleaner Modernizr tests in Sass.
|
42
|
+
email:
|
43
|
+
- daniel.guillan@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- README.md
|
49
|
+
- lib/modernizr-mixin.rb
|
50
|
+
- stylesheets/_modernizr.scss
|
51
|
+
homepage: https://github.com/danielguillan/modernizr-mixin
|
52
|
+
licenses:
|
53
|
+
- MIT
|
54
|
+
metadata: {}
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.3.6
|
69
|
+
requirements: []
|
70
|
+
rubyforge_project: modernizr-mixin
|
71
|
+
rubygems_version: 2.2.2
|
72
|
+
signing_key:
|
73
|
+
specification_version: 4
|
74
|
+
summary: Simple and comprehensive mixin for Modernizr tests in Sass
|
75
|
+
test_files: []
|