jacket 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/jacket.rb +1 -1
- data/readme.md +98 -53
- data/stylesheets/_jacket.scss +7 -8
- metadata +1 -1
data/lib/jacket.rb
CHANGED
data/readme.md
CHANGED
@@ -1,26 +1,28 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# Jacket
|
2
|
+
|
3
|
+
**Dress your css appropriately.**
|
3
4
|
|
4
5
|
Jacket is a Sass/Compass component that helps you orgainze stylesheets for a
|
5
6
|
multi-context build process. Write and maintain a master stylesheet, then
|
6
|
-
output custom tailored stylesheets for specific browsers, mobile/desktop sites,
|
7
|
-
and app builds.
|
8
|
-
|
9
|
-
### Installation
|
7
|
+
output custom tailored stylesheets for specific browsers, mobile/desktop sites, and app builds.
|
10
8
|
|
11
|
-
|
9
|
+
## Installation
|
12
10
|
|
13
|
-
|
11
|
+
**With Ruby**
|
14
12
|
|
15
|
-
|
13
|
+
1. In Terminal: `gem install jacket`
|
14
|
+
2. Require the gem in your config.rb
|
15
|
+
3. Import 'jacket' in your stylesheet.
|
16
16
|
|
17
|
-
|
17
|
+
**With Bower**
|
18
18
|
|
19
|
-
|
19
|
+
1. In Terminal: `bower install jacket`
|
20
|
+
2. Add `extensions_dir: "[your Bower component directory]"` to config.rb
|
21
|
+
3. Import 'jacket' in your stylesheet.
|
20
22
|
|
21
|
-
|
23
|
+
## Basic Usage
|
22
24
|
|
23
|
-
Write
|
25
|
+
Write your code in a master stylesheet.
|
24
26
|
|
25
27
|
**style.scss**
|
26
28
|
|
@@ -28,7 +30,6 @@ Write all code in a canonical stylesheet.
|
|
28
30
|
.rainy {
|
29
31
|
// Universal rules
|
30
32
|
font-size: 1rem;
|
31
|
-
width: 90%;
|
32
33
|
|
33
34
|
// Styles for iOS only
|
34
35
|
@include jacket(ios) {
|
@@ -36,7 +37,7 @@ Write all code in a canonical stylesheet.
|
|
36
37
|
content: 'Double ristretto cortado, stat.';
|
37
38
|
}
|
38
39
|
// Styles for Android 2.x only
|
39
|
-
@include jacket(
|
40
|
+
@include jacket(android-2x) {
|
40
41
|
background-color: #baddad;
|
41
42
|
content: 'I should get a new phone.';
|
42
43
|
}
|
@@ -48,7 +49,7 @@ Write all code in a canonical stylesheet.
|
|
48
49
|
}
|
49
50
|
```
|
50
51
|
|
51
|
-
Then create
|
52
|
+
Then create a stylesheet for each build context, and tell Jacket what the weather is.
|
52
53
|
|
53
54
|
**style.ios.scss**
|
54
55
|
|
@@ -57,10 +58,9 @@ Then create stylesheets for each build, and tell Jacket what the weather is.
|
|
57
58
|
$jacket: ios;
|
58
59
|
@import 'style';
|
59
60
|
|
60
|
-
//
|
61
|
+
// Compiles to
|
61
62
|
.rainy {
|
62
63
|
font-size: 1rem;
|
63
|
-
width: 90%;
|
64
64
|
background-color: #c0ffee;
|
65
65
|
content: 'Double ristretto cortado, stat.';
|
66
66
|
}
|
@@ -70,13 +70,12 @@ $jacket: ios;
|
|
70
70
|
|
71
71
|
```scss
|
72
72
|
// Set the weather
|
73
|
-
$jacket:
|
73
|
+
$jacket: android-2x;
|
74
74
|
@import 'style';
|
75
75
|
|
76
|
-
//
|
76
|
+
// Compiles to
|
77
77
|
.rainy {
|
78
78
|
font-size: 1rem;
|
79
|
-
width: 90%;
|
80
79
|
background-color: #baddad;
|
81
80
|
content: 'I should get a new phone.';
|
82
81
|
}
|
@@ -89,65 +88,111 @@ $jacket: andr-2x;
|
|
89
88
|
$jacket: ie8;
|
90
89
|
@import 'style';
|
91
90
|
|
92
|
-
//
|
91
|
+
//Compiles to:
|
93
92
|
.rainy {
|
94
93
|
font-size: 1rem;
|
95
|
-
width: 90%;
|
96
94
|
background-color: #000;
|
97
95
|
content: 'Round three. FIGHT!';
|
98
96
|
}
|
99
97
|
```
|
100
98
|
|
101
|
-
|
99
|
+
Now use an automated build process, conditional comments, or some fancy scripting to give each of your chosen environments a stylesheet made just for them. Not too much, not too little. Those stylesheets are lookin' good.
|
102
100
|
|
103
|
-
|
101
|
+
## Advanced Usage
|
102
|
+
|
103
|
+
You want to take it to the next level? Yeah, we have another level you can take it to.
|
104
|
+
|
105
|
+
#### Wrapping selector
|
106
|
+
|
107
|
+
Add a wrapping selector to a jacket context. Make sure to surround the selector with quotes.
|
104
108
|
|
105
109
|
```scss
|
106
|
-
|
107
|
-
|
110
|
+
.drizzle {
|
111
|
+
// universal styles
|
112
|
+
@include jacket(mackintosh) {
|
113
|
+
// macintosh styles
|
114
|
+
}
|
115
|
+
}
|
116
|
+
```
|
117
|
+
|
118
|
+
**style.mackintosh.scss**
|
119
|
+
|
120
|
+
```scss
|
121
|
+
$jacket: mackintosh '.mack';
|
108
122
|
@import 'style';
|
109
123
|
|
110
|
-
//
|
111
|
-
.
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
background-color: #baddad;
|
117
|
-
content: 'I should get a new phone.';
|
124
|
+
// Compiles to
|
125
|
+
.drizzle {
|
126
|
+
// universal styles
|
127
|
+
}
|
128
|
+
.mack .drizzle {
|
129
|
+
// mackintosh styles
|
118
130
|
}
|
119
131
|
```
|
120
132
|
|
121
|
-
|
133
|
+
#### Multiple contexts in one stylesheet
|
122
134
|
|
123
|
-
|
135
|
+
Set multiple comma separated contexts in `$jacket`. If any context matches a value that jacket will be output.
|
124
136
|
|
125
137
|
```scss
|
126
|
-
|
127
|
-
|
138
|
+
.thunderstorm {
|
139
|
+
// universal styles
|
140
|
+
@include jacket(anorak) {
|
141
|
+
// anorak styles
|
142
|
+
}
|
143
|
+
@include jacket(windbreaker) {
|
144
|
+
// windbreaker styles
|
145
|
+
}
|
146
|
+
}
|
147
|
+
```
|
148
|
+
|
149
|
+
**style.wetandcold.scss**
|
150
|
+
|
151
|
+
```scss
|
152
|
+
$jacket: anorak, windbreaker;
|
128
153
|
@import 'style';
|
129
154
|
|
130
|
-
//
|
131
|
-
.
|
132
|
-
|
133
|
-
|
155
|
+
// Compiles to
|
156
|
+
.thunderstorm {
|
157
|
+
// universal styles
|
158
|
+
// anorak styles
|
159
|
+
// windbreaker styles
|
134
160
|
}
|
161
|
+
```
|
135
162
|
|
136
|
-
|
137
|
-
|
138
|
-
|
163
|
+
#### Jackets that match multiple contexts
|
164
|
+
|
165
|
+
Set multiple values for a single jacket mixin. If a context matches any value, the jacket will be output.
|
166
|
+
|
167
|
+
```scss
|
168
|
+
.soiree {
|
169
|
+
// universal styles
|
170
|
+
@include jacket(suit, coat, tie) {
|
171
|
+
// styles that should be used with any suit, coat, or tie
|
172
|
+
}
|
139
173
|
}
|
140
174
|
```
|
175
|
+
**style.tie.scss**
|
141
176
|
|
142
|
-
|
177
|
+
```scss
|
178
|
+
$jacket: tie;
|
179
|
+
@import 'style';
|
180
|
+
|
181
|
+
// Compiled result
|
182
|
+
.soiree {
|
183
|
+
// universal styles
|
184
|
+
// styles that should be used with any suit, coat, or tie
|
185
|
+
}
|
186
|
+
```
|
143
187
|
|
144
|
-
|
188
|
+
#### And more...
|
145
189
|
|
146
|
-
|
190
|
+
Check out the [tests](https://github.com/Team-Sass/jacket/tree/master/test) for more examples, including condtional logic with nested jackets and a simple media query fallback mixin.
|
147
191
|
|
148
|
-
|
192
|
+
## Todo
|
149
193
|
|
150
|
-
1.
|
151
|
-
2.
|
194
|
+
1. Document `jacket-context()` function.
|
195
|
+
2. Set up automated testing framework.
|
196
|
+
4. Remove `lib` and Compass dependencies when `list-separator()` lands in Sass.
|
152
197
|
|
153
|
-
<small>*Thanks to [Breakpoint](https://github.com/Team-Sass/breakpoint), who's no-query functionality inspired this project.*</small>
|
198
|
+
<small>*Thanks to [Breakpoint](https://github.com/Team-Sass/breakpoint), who's no-query functionality inspired this project.*</small>
|
data/stylesheets/_jacket.scss
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
// Settings variables
|
13
13
|
///////////////////////////////////////////////////////////
|
14
14
|
|
15
|
-
// A list of
|
15
|
+
// A list of jacket contexts to print in the stylesheet.
|
16
16
|
$jacket: null !default;
|
17
17
|
|
18
18
|
// A private variable used by jacket-context().
|
@@ -29,16 +29,15 @@ $jckt-context: null;
|
|
29
29
|
$filtered: ();
|
30
30
|
$selector-string: '';
|
31
31
|
|
32
|
-
// Set the global
|
32
|
+
// Set the global context variable.
|
33
33
|
$jckt-context: $args;
|
34
34
|
|
35
|
-
// If jacket is a single
|
36
|
-
// sent through the next function in one piece.
|
35
|
+
// If jacket is a single context and selector list, encapsulate.
|
37
36
|
@if list-separator($jacket) == 'space' {
|
38
37
|
$jacket: $jacket, null;
|
39
38
|
}
|
40
39
|
|
41
|
-
// Test if
|
40
|
+
// Test if a jacket context and jacket value match.
|
42
41
|
@each $item in $jacket {
|
43
42
|
@if index($args, nth($item, 1)) {
|
44
43
|
|
@@ -52,15 +51,15 @@ $jckt-context: null;
|
|
52
51
|
}
|
53
52
|
}
|
54
53
|
|
55
|
-
// Filter out duplicate selectors.
|
56
|
-
// Sass.
|
54
|
+
// Filter out duplicate selectors.
|
55
|
+
// If reject() is added to Sass we can remove the $filtered holder variable.
|
57
56
|
@each $selector in $selectors {
|
58
57
|
@if index($filtered, $selector) == false {
|
59
58
|
$filtered: append($filtered, $selector);
|
60
59
|
}
|
61
60
|
}
|
62
61
|
|
63
|
-
// Build the selector string
|
62
|
+
// Build the selector string.
|
64
63
|
@each $selector in $filtered {
|
65
64
|
@if $selector-string != '' {
|
66
65
|
$selector-string: $selector-string + ", ";
|