respondsass 1.0 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,179 @@
1
+ RespondSass
2
+ =============
3
+
4
+ What is it?
5
+ -----------
6
+
7
+ Respondsass is a collection of .scss files to help speed up web development. It has been designed to be configurable but lightweight. It's built 320 mobile first and up, using ems in the media queries. Respondsass has 3 objectives.
8
+
9
+ Concise, optimised CSS output
10
+
11
+ The issue I saw with most frameworks was the amount of CSS in the files to created huge grid options where you may only use one or two classes. In Respondsass because you create the classes you determine how much CSS is in the outputed file and only class being used in the grid will be there.
12
+
13
+ Ems for media queries
14
+
15
+ I think this is now the defacto way to create media queries but I still see lots of frameworks using pixel values for media queries. if you want to learn more about the reason why I chose to go with em based media queries read this post by Lyza Gardner
16
+
17
+ Rems for fonts and spacing
18
+
19
+ Using rems with pixel fallbacks is a future friendly way to implement sizing for fonts and spacing. I've also created a configurable baseline grid to create a nice verticle rhythm.
20
+
21
+ Getting started
22
+ ---------------
23
+
24
+ The easiest way to get started is to install as a Ruby gem. First make sure you have Sass and Compass installed, go to the command line (don't freak out at the command line like I used to do) and type:
25
+
26
+ sass -version
27
+
28
+ and
29
+
30
+ compass -v
31
+
32
+ If you get something like:
33
+
34
+ Sass 3.2.5 (Media Mark)
35
+
36
+ and
37
+
38
+ Compass 0.12.2 (Alnilam)
39
+ Copyright (c) 2008-2013 Chris Eppstein
40
+ Released under the MIT License.
41
+ Compass is charityware., Please make a tax deductable donation for a worthy cause: http://umdf.org/compass"
42
+
43
+ then you are all set. If not you'll need to install one or both of them. When you do have them installed getting Respondsass is as simple as this:
44
+
45
+ sudo gem install respondsass
46
+
47
+ This will install the ruby gem, now all we need is to create a project and require the respondsass framework, again this is easy. Navigate to the folder you want your project folder to be created in for example:
48
+
49
+ cd Desktop
50
+
51
+ Then simply put this (where my_project is the name of your project folder)
52
+
53
+ compass create my_project -r respondsass --using respondsass
54
+
55
+ Now your all set either just set compass of watching the folder:
56
+
57
+ compass watch my_project
58
+
59
+ Creating the grid
60
+ -----------------
61
+
62
+ Creating columns is easy and is by default based of a 16 column grid. First set your html. If I wanted to set up a one row grid with 4 columns, each the same with we could do this.
63
+
64
+ <div class="container">
65
+ <div class="row">
66
+ <nav class="span-4"></nav>
67
+ <section class="span-4"></section>
68
+ <section class="span-4"></section>
69
+ <aside class="span-4"></aside>
70
+ </div>
71
+ </div>
72
+
73
+ Simply import the create grid partial
74
+
75
+ @import "respondsass/create-grid";
76
+
77
+ Then include create grid - this will create the default 16 column grid with a 1.25% gutter.
78
+
79
+ @include create-grid();
80
+
81
+ To create something bespoke you just pass in some parameters. If you would like a 3 column layout simple. Simply pass in how many coulmns and what the class name will be.
82
+
83
+ @include create-grid(thirds, 3);
84
+
85
+ This creates 3 column layout with class names third-1 (spans one third of containing element), thirds-2 (spans 2 thirds of containing element) and thirds-3 that is full width
86
+
87
+ We could use this by doing thing like this
88
+
89
+ <div class="container">
90
+ <div class="row">
91
+ <nav class="thirds-1"></nav>
92
+ <section class="thirds-2"></section>
93
+ </div>
94
+ </div>
95
+
96
+ Easy Nav - Navigation
97
+ ---------------------
98
+
99
+ Just some simple styling to help you get navigation up and running. I found I was doing the same things over and over again with navigation. So I have put them in a mixin.
100
+
101
+ To create a horizontal navigation with 4 links, again first create the html
102
+
103
+ <ul id="nav">
104
+ <li><a href="#">Home</a></li>
105
+ <li><a href="#">Blog</a></li>
106
+ <li><a href="#">About Us</a></li>
107
+ <li><a href="#">Contact</a></li>
108
+ </ul>
109
+ Then in your ul declaration in your sass just include:
110
+
111
+ @include horizontal-nav(4);
112
+ This will create a nice equally sized horizontal navigation that you can add extra styles such a font-sizes and colours.
113
+
114
+ For a vertical nav do the same html but include:
115
+
116
+ @include vertical-nav();
117
+
118
+ There's no parameter for this one just the declaration.
119
+
120
+ Rem sizing
121
+ ----------
122
+
123
+ This can be included in any elements css declaration and creates a future friendly rem value with pixel fallback for and declaration passed to it. As with all things you need to import the sass file.
124
+
125
+ @import "respondsass/rem-sizing";
126
+
127
+ Then to set the bottom margin of an element to 1 rem just include the following.
128
+
129
+ @include rem-sizing(margin-bottom, 1);
130
+
131
+ Simple. This can be used for any declaration. Font-size, padding, margin etc.
132
+
133
+ Buttons
134
+ -------
135
+
136
+ Buttons take 4 parameters. Border-radius, background-colour, font-colour and gradient. To use again import the sass file
137
+
138
+ @import "respondsass/buttons";
139
+
140
+ Then simply include the code. The first parameter is for border-radius and takes a pixel value, the second and third are background and font colour respectively. Both take a colour value. The final is gradient and this take either true (if you want a gradient) or false if you don't. If you choose gradient it will use the background colour passed in to create the gradient and the border. This is the order
141
+
142
+ @include button ($radius, $bg-color, $font-color, $gradient);
143
+ And this is the usage
144
+
145
+ @include button ($radius:0, $bg-color: $primaryCol, $font-color: #fff, $gradient:false);
146
+
147
+ Typography Baseline
148
+ -------------------
149
+
150
+ Simple baseline based on the baseline rhythm calculator
151
+
152
+ I tend to create a typography partial in sass in there I would set my standard stuff such as as assigning a font family to a variable and setting basic colours and sizes.
153
+
154
+ $font-face: Open Sans, HelveticaNeue, Calibri, sans-serif;
155
+
156
+ html {
157
+ -webkit-font-smoothing: antialiased;
158
+ font-size: 100%;
159
+ color: #000000;
160
+ }
161
+
162
+ Again then just make sure you have imported the baseline file
163
+
164
+ @import "respondsass/baseline";
165
+
166
+ Then just include the baseline mixin and pass in some parameters in the order below:
167
+
168
+ @include baseline($font-face, $base-line-font, $base-line-height);
169
+
170
+ So actual code would look something like this.
171
+
172
+ @include baseline($font: $font-face, $base-line-font: 14, $base-line-height: 1.5);
173
+
174
+ Get involved
175
+ ------------
176
+
177
+ This is very much an early version of the framework but if you like it please say so.
178
+
179
+ Also, if you have spot any errors or would like to contribute please get in touch matt@my-html-codes.com
data/lib/respondsass.rb CHANGED
@@ -1,30 +1,4 @@
1
- # All gems that are required for this extension to work should go here.
2
- # These are the requires you would normally put in your config.rb file
3
- # By default, you should always included Compass. Do not include your
4
- # extension.
5
1
  require 'compass'
6
-
7
- # This tells Compass what your Compass extension is called, and where to find
8
- # its files
9
- # Replace 'extension' with the name of your extension. Spaces allowed.
10
- extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
11
- Compass::Frameworks.register('respondsass', :path => extension_path)
12
-
13
- # Version and date of version for your Compass extension.
14
- # Replace Extension with the name of your extension
15
- # Letters, numbers, and underscores only
16
- # Version is a number. If a version contains alphas, it will be created as
17
- # a prerelease version
18
- # Date is in the form of YYYY-MM-DD
19
- module Respondsass
20
- VERSION = "1.0"
21
- DATE = "2013-06-01"
22
- end
23
-
24
- # This is where any custom SassScript should be placed. The functions will be
25
- # available on require of your extension without the need for users to import
26
- # any partials. Uncomment below.
27
-
28
- # module Sass::Script::Functions
29
- #
30
- # end
2
+ Compass::Frameworks.register('respondsass',
3
+ :stylesheets_directory => File.join(File.dirname(__FILE__), '..', 'stylesheets'),
4
+ :templates_directory => File.join(File.dirname(__FILE__), '..', 'templates'))
@@ -0,0 +1,8 @@
1
+ // Your Compass Extension's Sass goes here! Run wild!
2
+ @import "respondsass/baseline";
3
+ @import "respondsass/buttons";
4
+ @import "respondsass/col-generator";
5
+ @import "respondsass/create-grid";
6
+ @import "respondsass/easy-nav";
7
+ @import "respondsass/rem-sizing";
8
+ @import "respondsass/respond-to";
@@ -0,0 +1,56 @@
1
+
2
+ $f: HelveticaNeue, Helvetica, Calibri, sans-serif !default;
3
+ $l-h: 1.5 !default;
4
+ $f-s: 16 !default;
5
+
6
+
7
+ @mixin baseline($font:$f, $base-line-font: $f-s, $base-line-height: $l-h){
8
+
9
+ $b-f-s: $base-line-font/16;
10
+
11
+ body {
12
+ @include rem-sizing(font-size, $b-f-s);
13
+ }
14
+
15
+ h1, h2, h3, h4, h5, h6, p, ul, ol, blockquote, a {
16
+ font-family: $font;
17
+ }
18
+
19
+ h1 {
20
+ @include rem-sizing(font-size, $b-f-s*1.75);
21
+ line-height: $base-line-height;
22
+ @include rem-sizing(margin-bottom, $base-line-height/($b-f-s*1.75));
23
+ }
24
+
25
+ h2 {
26
+ @include rem-sizing(font-size, $b-f-s*1.45);
27
+ line-height: $base-line-height;
28
+ @include rem-sizing(margin-bottom, $base-line-height/($b-f-s*1.45));
29
+ }
30
+
31
+ h3 {
32
+ @include rem-sizing(font-size, $b-f-s*1.285);
33
+ line-height: $base-line-height;
34
+ @include rem-sizing(margin-bottom, $base-line-height/($b-f-s*1.285));
35
+ }
36
+
37
+ h4 {
38
+ @include rem-sizing(font-size, $b-f-s*1.142);
39
+ line-height: $base-line-height;
40
+ @include rem-sizing(margin-bottom, $base-line-height/($b-f-s*1.142));
41
+ }
42
+
43
+ p, ul, blockquote, pre, td, th, label {
44
+ @include rem-sizing(font-size, $b-f-s);
45
+ line-height: $base-line-height;
46
+ @include rem-sizing(margin-bottom, $base-line-height);
47
+ }
48
+
49
+ table {
50
+ border-collapse: collapse;
51
+ @include rem-sizing(margin-bottom, $base-line-height);
52
+ }
53
+
54
+ }
55
+
56
+
@@ -0,0 +1,32 @@
1
+ @import "compass/css3";
2
+
3
+ $default-radius: 2px !default;
4
+ $default-bg-color: #ccc !default;
5
+ $default-gradient: false !default;
6
+ $default-font-size: 1 !default;
7
+ $default-font-color: #333 !default;
8
+
9
+
10
+ @mixin button ($radius: $default-radius, $bg-color: $default-bg-color, $font-color: $default-font-color, $font-size: $default-font-size, $gradient: $default-gradient){
11
+ @if $gradient == true {
12
+ @include background-image(linear-gradient(lighten($bg-color, 5%),darken($bg-color, 5%)));
13
+ } @else {
14
+ background: $bg-color;
15
+ }
16
+ display: inline-block;
17
+ *display:inline;
18
+ *zoom:1;
19
+ @include rem-sizing(padding-top, .55);
20
+ @include rem-sizing(padding-bottom, .55);
21
+ @include rem-sizing(padding-right, 1);
22
+ @include rem-sizing(padding-left, 1);
23
+ outline: none;
24
+ cursor: pointer;
25
+ text-align: center;
26
+ text-decoration: none;
27
+ @include rem-sizing(font-size, 0.9);
28
+ color: $font-color;
29
+ @include border-radius($radius);
30
+ // this determines Mozilla to show the padding
31
+ border: solid 1px darken($bg-color, 10%);
32
+ }
@@ -0,0 +1,11 @@
1
+ // Set all variables
2
+
3
+ $totalColumns: 16 !default;
4
+
5
+ // Grid generation mixin
6
+
7
+ @mixin col-generator($num-columns: $col-number, $total-cols: $total-columns) {
8
+ $column-width: 100% / $total-cols; // Finding column width by dividing space left by number of columns
9
+ $width: ($num-columns * $column-width);
10
+ width: $width;
11
+ }
@@ -0,0 +1,40 @@
1
+ @import "col-generator";
2
+ @import "respond-to";
3
+ @import "rem-sizing";
4
+
5
+ .container{
6
+ margin: 0 auto;
7
+ max-width:1200px;
8
+ clear: both;
9
+ }
10
+
11
+ .row {
12
+ overflow: hidden;
13
+ clear:both;
14
+ padding: 0 2%;
15
+ }
16
+
17
+ $class: span !default;
18
+ $cols: 16 !default;
19
+ $gutter: 1.25% !default;
20
+
21
+ @mixin create-grid ($class-name:$class, $columns:$cols, $gutter:$gutter) {
22
+
23
+ %grid-rules-#{$class-name} {
24
+ float:left;
25
+ @include box-sizing(border-box);
26
+ @include col-generator($num-columns:$columns, $total-cols:$columns);
27
+ }
28
+
29
+
30
+ @for $i from 1 through $columns{
31
+ .#{$class-name}-#{$i}{
32
+ @extend %grid-rules-#{$class-name};
33
+ @include respond-to(tablets-and-above) {
34
+ @include col-generator($num-columns:$i, $total-cols:$columns);
35
+ padding-right:0;
36
+ padding-left:$gutter;
37
+ }
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,44 @@
1
+ @import "rem-sizing";
2
+
3
+ @mixin horizontal-nav($num-list-items){
4
+ $list-item-pc: percentage($num-list-items/($num-list-items*$num-list-items));
5
+ text-align: right;
6
+ overflow: auto;
7
+ width: 100%;
8
+ padding:0;
9
+ list-style:none;
10
+ li {
11
+ margin: 0;
12
+ text-align: center;
13
+ overflow: auto;
14
+ float: left;
15
+ width: $list-item-pc;
16
+ padding-left:1%;
17
+ @include box-sizing(border-box);
18
+ a {
19
+ text-decoration: none;
20
+ display: block;
21
+ }
22
+ &:first-child {
23
+ padding-left:0;
24
+ }
25
+ }
26
+ }
27
+
28
+ @mixin vertical-nav(){
29
+ overflow: auto;
30
+ padding:0;
31
+ list-style:none;
32
+ li {
33
+ margin: 0;
34
+ overflow: auto;
35
+ @include box-sizing(border-box);
36
+ a {
37
+ text-decoration: none;
38
+ display: block;
39
+ @include rem-sizing(padding-bottom,.4);
40
+ @include rem-sizing(padding-left,.4);
41
+ @include rem-sizing(padding-top,.4);
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,9 @@
1
+ $default-p: margin-bottom;
2
+ $default-v: 1;
3
+ $px: px;
4
+
5
+ @mixin rem-sizing ($propery: $default-p, $value: $default-v){
6
+ $v: $value*16;
7
+ #{$propery}: #{$v}px;
8
+ #{$propery}: #{$value}rem;
9
+ }
@@ -0,0 +1,14 @@
1
+ @mixin respond-to($media) {
2
+ @if $media == wide-handhelds {
3
+ @media only screen and (min-width: 30em) and (max-width: 45.938em) { @content; }
4
+ }
5
+ @else if $media == tablets-and-above {
6
+ @media only screen and (min-width: 46em) { @content; }
7
+ }
8
+ @else if $media == tablets-landscape-and-above {
9
+ @media only screen and (min-width: 60em) { @content; }
10
+ }
11
+ @else if $media == desktop-and-above {
12
+ @media only screen and (min-width: 70em) { @content; }
13
+ }
14
+ }
@@ -0,0 +1,12 @@
1
+ $primaryColor: #007fac;
2
+ $secondaryColor: #f28411;
3
+ $primaryFontColor: #222222;
4
+ $secondaryFontColor: #ffffff;
5
+ $fontFamily: HelveticaNeue, Calibri, sans-serif;
6
+
7
+ // ---------------------------------------------------------------------------
8
+ // Imports
9
+
10
+ @import "respondsass";
11
+
12
+ // ---------------------------------------------------------------------------