respond-to 2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/respond-to.rb +5 -0
- data/stylesheets/_respond-to.scss +64 -0
- metadata +89 -0
data/lib/respond-to.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
////////////////////////
|
2
|
+
// Import the Breakpoint partial
|
3
|
+
////////////////////////
|
4
|
+
@import 'breakpoint';
|
5
|
+
|
6
|
+
////////////////////////
|
7
|
+
// Default the Breakpoints variable
|
8
|
+
////////////////////////
|
9
|
+
$breakpoints: false !default;
|
10
|
+
|
11
|
+
////////////////////////
|
12
|
+
// Respond-to API Mixin
|
13
|
+
////////////////////////
|
14
|
+
@mixin respond-to($context, $media: "screen") {
|
15
|
+
@if $breakpoints != false {
|
16
|
+
// Check to see if the 2nd item is a number. If it is, we've got a single query
|
17
|
+
@if type-of(nth($breakpoints, 2)) == 'number' {
|
18
|
+
// Check to see if the context matches the breakpoint namespace
|
19
|
+
@if $context == nth($breakpoints, 1) {
|
20
|
+
// Call Media Query Generator
|
21
|
+
@include media-query-gen($breakpoints, $media) {
|
22
|
+
@content;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
// Else, loop over all of them
|
27
|
+
@else {
|
28
|
+
// Loop over each breakpoint and check context
|
29
|
+
@each $bkpt in $breakpoints {
|
30
|
+
// If context is correct…
|
31
|
+
@if $context == nth($bkpt, 1) {
|
32
|
+
// Call the generator!
|
33
|
+
@include media-query-gen($bkpt, $media) {
|
34
|
+
@content;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
////////////////////////
|
43
|
+
// Helper Mixin ebcause this stuff gets used twice
|
44
|
+
////////////////////////
|
45
|
+
@mixin media-query-gen($bpt, $media) {
|
46
|
+
// Get length of breakpoint variable, minus the namespace
|
47
|
+
$length: length($bpt);
|
48
|
+
// Go through all of the breakpoint items, starting at the second, and add them to a variable to be passed into the media query mixin
|
49
|
+
$mq: false !default;
|
50
|
+
@for $i from 2 through $length {
|
51
|
+
// If it's the first item, override $mq
|
52
|
+
@if $i == 2 {
|
53
|
+
$mq: nth($bpt, $i);
|
54
|
+
}
|
55
|
+
// Else, join $mq
|
56
|
+
@else {
|
57
|
+
$mq: join($mq, nth($bpt, $i));
|
58
|
+
}
|
59
|
+
}
|
60
|
+
// Call Media Query mixin
|
61
|
+
@include breakpoint($mq, $media) {
|
62
|
+
@content;
|
63
|
+
}
|
64
|
+
}
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: respond-to
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 2
|
7
|
+
- 0
|
8
|
+
version: "2.0"
|
9
|
+
platform: ruby
|
10
|
+
authors:
|
11
|
+
- Sam Richard
|
12
|
+
autorequire:
|
13
|
+
bindir: bin
|
14
|
+
cert_chain: []
|
15
|
+
|
16
|
+
date: 2011-06-18 00:00:00 -04:00
|
17
|
+
default_executable:
|
18
|
+
dependencies:
|
19
|
+
- !ruby/object:Gem::Dependency
|
20
|
+
name: sass
|
21
|
+
prerelease: false
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
segments:
|
27
|
+
- 3
|
28
|
+
- 1
|
29
|
+
version: "3.1"
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: breakpoint
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
41
|
+
- 2
|
42
|
+
version: "0.2"
|
43
|
+
type: :runtime
|
44
|
+
version_requirements: *id002
|
45
|
+
description: Easy Media Query Handling
|
46
|
+
email:
|
47
|
+
- snugug@gmail.com
|
48
|
+
executables: []
|
49
|
+
|
50
|
+
extensions: []
|
51
|
+
|
52
|
+
extra_rdoc_files: []
|
53
|
+
|
54
|
+
files:
|
55
|
+
- lib/respond-to.rb
|
56
|
+
- stylesheets/_respond-to.scss
|
57
|
+
has_rdoc: true
|
58
|
+
homepage: https://github.com/Snugug/respond-to
|
59
|
+
licenses: []
|
60
|
+
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
segments:
|
78
|
+
- 1
|
79
|
+
- 2
|
80
|
+
version: "1.2"
|
81
|
+
requirements: []
|
82
|
+
|
83
|
+
rubyforge_project: respond-to
|
84
|
+
rubygems_version: 1.3.6
|
85
|
+
signing_key:
|
86
|
+
specification_version: 3
|
87
|
+
summary: Use the Variable Driven Respond-to Mixin (https://gist.github.com/2493551) in your project today!
|
88
|
+
test_files: []
|
89
|
+
|