compass-responsive 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +57 -0
- data/lib/responsive.rb +1 -0
- data/stylesheets/_responsive.scss +3 -0
- data/stylesheets/responsive/_breakpoint.scss +11 -0
- data/stylesheets/responsive/_font-size.scss +38 -0
- data/stylesheets/responsive/_unit.scss +12 -0
- data/templates/project/manifest.rb +11 -0
- data/templates/project/screen.scss +4 -0
- metadata +53 -0
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
#Compass responsive
|
2
|
+
|
3
|
+
**A responsive compass extension to simplify configuring
|
4
|
+
responsive breakpoints and sizing, that allows you to think in
|
5
|
+
pixels but compile in ems or rems.**
|
6
|
+
|
7
|
+
See [my compass-responsive blog post](http://blog.colinmeinke.com/a-responsive-extension-for-compass) for a full usage tutorial.
|
8
|
+
|
9
|
+
##What can I use it for?
|
10
|
+
|
11
|
+
1. `-responsive-unit($size: 50px)`: a function that converts
|
12
|
+
pixels to ems/rems.
|
13
|
+
2. `@include -responsive-breakpoint(500px) { }`: a mixin that
|
14
|
+
generates min-width media queries in ems.
|
15
|
+
3. `@include -font-size($size: 20px, $breakpoints: (500px, 960px), $scale: (2, 4));`:
|
16
|
+
a mixin that allows you to define a font-size suitable for
|
17
|
+
small screens, and then scale the font-size up at defined
|
18
|
+
breakpoints relative to the original definition.
|
19
|
+
|
20
|
+
##How do I use it?
|
21
|
+
|
22
|
+
###-responsive-unit()
|
23
|
+
|
24
|
+
Takes the following params:
|
25
|
+
|
26
|
+
* $base (string): base font-size in pixels
|
27
|
+
* $unit (string): unit to convert to [em, rem]
|
28
|
+
* $size (string): pixel value to convert
|
29
|
+
|
30
|
+
###-responsive-breakpoint()
|
31
|
+
|
32
|
+
Takes the following params:
|
33
|
+
|
34
|
+
* $size (string): size in pixels
|
35
|
+
|
36
|
+
###-responsive-font-size()
|
37
|
+
|
38
|
+
Takes the following params:
|
39
|
+
|
40
|
+
* $base (string): base font-size in pixels
|
41
|
+
* $unit (string): unit to convert font-size to [em, rem]
|
42
|
+
* $size (string): font-size in pixels
|
43
|
+
* $breakpoints (list): list of breakpoints in pixels
|
44
|
+
* $scale (list): list of font-size scale values for
|
45
|
+
corresponding breakpoints
|
46
|
+
|
47
|
+
### Installation
|
48
|
+
|
49
|
+
To install compass-responsive:
|
50
|
+
|
51
|
+
1. Install the gem with bundler `gem 'compass-responsive'`.
|
52
|
+
2. Initialise a new compass project with `compass install .
|
53
|
+
-r responsive --using responsive`.
|
54
|
+
|
55
|
+
##License
|
56
|
+
|
57
|
+
Licensed under MIT by Colin Meinke, 2012.
|
data/lib/responsive.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Compass::Frameworks.register("responsive", :path => "#{File.dirname(__FILE__)}/..")
|
@@ -0,0 +1,11 @@
|
|
1
|
+
// Generate a min-width media query defined
|
2
|
+
// in pixels but output in ems.
|
3
|
+
//
|
4
|
+
// $size (string): size in pixels
|
5
|
+
@mixin -responsive-breakpoint($size) {
|
6
|
+
@media screen and (min-width: -responsive-unit(
|
7
|
+
$unit: em,
|
8
|
+
$size: $size)) {
|
9
|
+
@content;
|
10
|
+
}
|
11
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
// Define a font-size suitable for small screens, and
|
2
|
+
// then scale the font-size up at defined breakpoints
|
3
|
+
// relative to the original definition.
|
4
|
+
//
|
5
|
+
// $base (string): base font-size in pixels
|
6
|
+
// $unit (string): unit to convert font-size to [em, rem]
|
7
|
+
// $size (string): font-size in pixels
|
8
|
+
// $breakpoints (list): list of breakpoints in pixels
|
9
|
+
// $scale (list): list of font-size scale values
|
10
|
+
// for corresponding breakpoints
|
11
|
+
@mixin -responsive-font-size(
|
12
|
+
$base: $-responsive-default-base,
|
13
|
+
$unit: $-responsive-default-unit,
|
14
|
+
$size: 16px,
|
15
|
+
$breakpoints: (500px, 960px),
|
16
|
+
$scale: (1.2, 1.4)
|
17
|
+
) {
|
18
|
+
// Define base font-size for small screens
|
19
|
+
font-size: -responsive-unit(
|
20
|
+
$base: $base,
|
21
|
+
$unit: $unit,
|
22
|
+
$size: $size
|
23
|
+
);
|
24
|
+
|
25
|
+
// Iterate up through breakpoints and calculate
|
26
|
+
// font-size for each
|
27
|
+
$i: 1;
|
28
|
+
@each $breakpoint in $breakpoints {
|
29
|
+
@include -responsive-breakpoint($breakpoint) {
|
30
|
+
font-size: -responsive-unit(
|
31
|
+
$base: $base,
|
32
|
+
$unit: $unit,
|
33
|
+
$size: $size * nth($scale, $i)
|
34
|
+
);
|
35
|
+
}
|
36
|
+
$i: $i + 1;
|
37
|
+
}
|
38
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
// Convert pixel value to em/rem value.
|
2
|
+
//
|
3
|
+
// $base (string): base font-size in pixels
|
4
|
+
// $unit (string): unit to convert to [em, rem]
|
5
|
+
// $size (string): pixel value to convert
|
6
|
+
@function -responsive-unit(
|
7
|
+
$base: $-responsive-default-base,
|
8
|
+
$unit: $-responsive-default-unit,
|
9
|
+
$size: 16px
|
10
|
+
) {
|
11
|
+
@return #{$size / $base}#{$unit};
|
12
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
discover :all
|
2
|
+
|
3
|
+
description "A responsive compass extension."
|
4
|
+
|
5
|
+
help %Q{
|
6
|
+
See http://blog.colinmeinke.com/a-responsive-extension-for-compass for a full usage tutorial.
|
7
|
+
}
|
8
|
+
|
9
|
+
welcome_message %Q{
|
10
|
+
See http://blog.colinmeinke.com/a-responsive-extension-for-compass for a full usage tutorial.
|
11
|
+
}
|
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: compass-responsive
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Colin Meinke
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-11 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: A responsive compass extension to simplify configuring responsive breakpoints
|
15
|
+
and sizing, that allows you to think in pixels but compile in ems or rems.
|
16
|
+
email: hello@colinmeinke.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- README.md
|
22
|
+
- lib/responsive.rb
|
23
|
+
- stylesheets/_responsive.scss
|
24
|
+
- stylesheets/responsive/_font-size.scss
|
25
|
+
- stylesheets/responsive/_breakpoint.scss
|
26
|
+
- stylesheets/responsive/_unit.scss
|
27
|
+
- templates/project/manifest.rb
|
28
|
+
- templates/project/screen.scss
|
29
|
+
homepage: http://rubygems.org/gems/compass-responsive
|
30
|
+
licenses: []
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
requirements: []
|
48
|
+
rubyforge_project:
|
49
|
+
rubygems_version: 1.8.23
|
50
|
+
signing_key:
|
51
|
+
specification_version: 3
|
52
|
+
summary: A responsive compass extension
|
53
|
+
test_files: []
|