jacket 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/jacket.rb +2 -2
- data/readme.md +80 -122
- data/stylesheets/_jacket.scss +38 -16
- metadata +2 -2
data/lib/jacket.rb
CHANGED
@@ -4,8 +4,8 @@ extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
|
4
4
|
Compass::Frameworks.register('jacket', :path => extension_path)
|
5
5
|
|
6
6
|
module Jacket
|
7
|
-
VERSION = "0.1.
|
8
|
-
DATE = "2013-
|
7
|
+
VERSION = "0.1.4"
|
8
|
+
DATE = "2013-07-07"
|
9
9
|
end
|
10
10
|
|
11
11
|
module Sass::Script::Functions
|
data/readme.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# Jacket
|
2
2
|
|
3
|
-
**Dress
|
3
|
+
**Conditional Styles with Sass. Dress you CSS appropriately.**
|
4
4
|
|
5
|
-
Jacket is a
|
6
|
-
multi-context build process. Write and maintain a master stylesheet, then
|
7
|
-
output custom tailored stylesheets for specific browsers, mobile/desktop sites, and app builds.
|
5
|
+
Jacket is a Compass component that prints and hides styles based on context variables you set in your stylesheet. Write and maintain a master stylesheet, then output custom tailored stylesheets for modern and legacy browsers, site and app builds, or any other context you can think of.
|
8
6
|
|
9
7
|
## Installation
|
10
8
|
|
9
|
+
Until Sass 3.3 is released Jacket requires Compass.
|
10
|
+
|
11
11
|
**With Ruby**
|
12
12
|
|
13
13
|
1. In Terminal: `gem install jacket`
|
@@ -17,182 +17,140 @@ output custom tailored stylesheets for specific browsers, mobile/desktop sites,
|
|
17
17
|
**With Bower**
|
18
18
|
|
19
19
|
1. In Terminal: `bower install jacket`
|
20
|
-
2. Add `extensions_dir
|
20
|
+
2. Add `extensions_dir = "[your Bower component directory]"` to config.rb
|
21
21
|
3. Import 'jacket' in your stylesheet.
|
22
22
|
|
23
23
|
## Basic Usage
|
24
24
|
|
25
|
-
|
25
|
+
### The jacket() mixin
|
26
26
|
|
27
|
-
|
27
|
+
Use the jacket mixin to conditionally output blocks of code. If any context matches a context in the `$jacket` variable, your conditional code will be output. If the context has a wrapping selector associated with it, the code block will be wrapped in the wrapping selector.
|
28
28
|
|
29
29
|
```scss
|
30
|
-
|
31
|
-
//
|
32
|
-
font-size: 1rem;
|
33
|
-
|
34
|
-
// Styles for iOS only
|
35
|
-
@include jacket(ios) {
|
36
|
-
background-color: #c0ffee;
|
37
|
-
content: 'Double ristretto cortado, stat.';
|
38
|
-
}
|
39
|
-
// Styles for Android 2.x only
|
40
|
-
@include jacket(android-2x) {
|
41
|
-
background-color: #baddad;
|
42
|
-
content: 'I should get a new phone.';
|
43
|
-
}
|
44
|
-
// Styles for ie8 only
|
45
|
-
@include jacket(ie8) {
|
46
|
-
background-color: #000;
|
47
|
-
content: 'Round three. FIGHT!';
|
48
|
-
}
|
30
|
+
jacket($contexts...) {
|
31
|
+
// Conditional code
|
49
32
|
}
|
50
33
|
```
|
51
34
|
|
52
|
-
|
35
|
+
### The jacket() function
|
53
36
|
|
54
|
-
|
37
|
+
Use the jacket function to conditionally output values. If any context matches a context in the `$jacket` variable, the value will be output.
|
55
38
|
|
56
39
|
```scss
|
57
|
-
|
58
|
-
$jacket: ios;
|
59
|
-
@import 'style';
|
60
|
-
|
61
|
-
// Compiles to
|
62
|
-
.rainy {
|
63
|
-
font-size: 1rem;
|
64
|
-
background-color: #c0ffee;
|
65
|
-
content: 'Double ristretto cortado, stat.';
|
66
|
-
}
|
40
|
+
property: jacket($value, $contexts...);
|
67
41
|
```
|
68
42
|
|
69
|
-
|
43
|
+
### The $jacket variable
|
70
44
|
|
71
|
-
|
72
|
-
// Set the weather
|
73
|
-
$jacket: android-2x;
|
74
|
-
@import 'style';
|
45
|
+
Use the `$jacket` variable to set a stylesheet's context. Each context can have an optional wrapping selector.
|
75
46
|
|
76
|
-
// Compiles to
|
77
|
-
.rainy {
|
78
|
-
font-size: 1rem;
|
79
|
-
background-color: #baddad;
|
80
|
-
content: 'I should get a new phone.';
|
81
|
-
}
|
82
47
|
```
|
83
|
-
|
84
|
-
**style.ie.scss**
|
85
|
-
|
86
|
-
```scss
|
87
|
-
// Set the weather
|
88
|
-
$jacket: ie8;
|
89
|
-
@import 'style';
|
90
|
-
|
91
|
-
//Compiles to:
|
92
|
-
.rainy {
|
93
|
-
font-size: 1rem;
|
94
|
-
background-color: #000;
|
95
|
-
content: 'Round three. FIGHT!';
|
96
|
-
}
|
48
|
+
$jacket: context, context '.wrapping-selector', context;
|
97
49
|
```
|
98
50
|
|
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.
|
100
51
|
|
101
|
-
|
102
|
-
|
103
|
-
You want to take it to the next level? Yeah, we have another level you can take it to.
|
52
|
+
### Examples
|
104
53
|
|
105
|
-
|
54
|
+
Write your code in a master stylesheet.
|
106
55
|
|
107
|
-
|
56
|
+
**style.scss**
|
108
57
|
|
109
58
|
```scss
|
110
|
-
.
|
111
|
-
//
|
112
|
-
|
113
|
-
|
114
|
-
}
|
59
|
+
.example {
|
60
|
+
// Universal rules
|
61
|
+
font-size: 1rem;
|
62
|
+
padding:0 20px;
|
115
63
|
}
|
116
64
|
```
|
117
65
|
|
118
|
-
|
66
|
+
Add context specific code wrapped in the jacket mixin or the jacket function. If any jacket mixin context matches a value in the `$jacket` variable, the code will be output.
|
119
67
|
|
120
68
|
```scss
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
.drizzle {
|
126
|
-
// universal styles
|
127
|
-
}
|
128
|
-
.mack .drizzle {
|
129
|
-
// mackintosh styles
|
130
|
-
}
|
131
|
-
```
|
132
|
-
|
133
|
-
#### Multiple contexts in one stylesheet
|
134
|
-
|
135
|
-
Set multiple comma separated contexts in `$jacket`. If any context matches a value that jacket will be output.
|
69
|
+
.example {
|
70
|
+
// Universal rules
|
71
|
+
font-size: 1rem;
|
72
|
+
padding:0 20px;
|
136
73
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
@include jacket(anorak) {
|
141
|
-
// anorak styles
|
74
|
+
// Conditional styles for an ie8 stylesheet
|
75
|
+
@include jacket(ie8) {
|
76
|
+
float: left;
|
142
77
|
}
|
143
|
-
|
144
|
-
|
78
|
+
|
79
|
+
// Conditional styles for an iOS and android app build of the stylesheet
|
80
|
+
@include jacket(ios, android) {
|
81
|
+
background-color: #c0ffee;
|
145
82
|
}
|
83
|
+
|
84
|
+
line-height: jacket(1.5, ios, site) jacket(1.3, android);
|
146
85
|
}
|
147
86
|
```
|
148
87
|
|
149
|
-
|
88
|
+
Then create a stylesheet for each build context, and tell Jacket what the weather is.
|
89
|
+
|
90
|
+
**style.ios.scss**
|
150
91
|
|
151
92
|
```scss
|
152
|
-
$jacket:
|
93
|
+
$jacket: ios;
|
153
94
|
@import 'style';
|
154
95
|
|
155
96
|
// Compiles to
|
156
|
-
.
|
157
|
-
|
158
|
-
|
159
|
-
|
97
|
+
.example {
|
98
|
+
font-size: 1rem;
|
99
|
+
padding: 0 20px;
|
100
|
+
background-color: #c0ffee;
|
101
|
+
line-height: 1.5;
|
160
102
|
}
|
161
103
|
```
|
162
104
|
|
163
|
-
|
164
|
-
|
165
|
-
Set multiple values for a single jacket mixin. If a context matches any value, the jacket will be output.
|
105
|
+
**style.android.scss**
|
166
106
|
|
167
107
|
```scss
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
108
|
+
// Set the weather
|
109
|
+
$jacket: android;
|
110
|
+
@import 'style';
|
111
|
+
|
112
|
+
// Compiles to
|
113
|
+
.example {
|
114
|
+
font-size: 1rem;
|
115
|
+
padding: 0 20px;
|
116
|
+
background-color: #c0ffee;
|
117
|
+
line-height: 1.3;
|
173
118
|
}
|
174
119
|
```
|
175
|
-
|
120
|
+
|
121
|
+
**style.ie8.scss**
|
176
122
|
|
177
123
|
```scss
|
178
|
-
$jacket:
|
124
|
+
$jacket: ie8 '.ie8';
|
179
125
|
@import 'style';
|
180
126
|
|
181
|
-
//
|
182
|
-
.
|
183
|
-
|
184
|
-
|
127
|
+
//Compiles to:
|
128
|
+
.example {
|
129
|
+
font-size: 1rem;
|
130
|
+
padding: 0 20px;
|
131
|
+
}
|
132
|
+
.ie8 .example {
|
133
|
+
float: left;
|
185
134
|
}
|
186
135
|
```
|
187
136
|
|
188
|
-
|
137
|
+
Now you can serve these custom tailored stylesheets to the correct context with conditional comments, an automated build process, or some javascript. Not too much, not too little. Those stylesheets are lookin' good.
|
138
|
+
|
139
|
+
## Advanced Usage
|
189
140
|
|
190
141
|
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.
|
191
142
|
|
192
|
-
##
|
143
|
+
## Contribute
|
144
|
+
|
145
|
+
Report bugs and feature proposals in the [Github issue tracker](https://github.com/Team-Sass/jacket/issues). In lieu of a formal styleguide, take care to maintain the existing coding style.
|
146
|
+
|
147
|
+
## Release History
|
148
|
+
|
149
|
+
0.1.4, July 7, 2013: Add jacket() function, rewrite docs and tests.
|
150
|
+
0.1.0, April 21, 2013: Initial release.
|
151
|
+
|
152
|
+
## License
|
193
153
|
|
194
|
-
|
195
|
-
2. Set up automated testing framework.
|
196
|
-
4. Remove `lib` and Compass dependencies when `list-separator()` lands in Sass.
|
154
|
+
[BSD-NEW](http://en.wikipedia.org/wiki/BSD_License)
|
197
155
|
|
198
156
|
<small>*Thanks to [Breakpoint](https://github.com/Team-Sass/breakpoint), who's no-query functionality inspired this project.*</small>
|
data/stylesheets/_jacket.scss
CHANGED
@@ -1,28 +1,29 @@
|
|
1
1
|
///////////////////////////////////////////////////////////
|
2
2
|
// Jacket
|
3
|
-
// Dress appropriately
|
3
|
+
// Conditional Styles with Sass. Dress you CSS appropriately.
|
4
4
|
///////////////////////////////////////////////////////////
|
5
5
|
|
6
|
-
// Jacket is a
|
7
|
-
//
|
8
|
-
// output custom tailored stylesheets for
|
9
|
-
//
|
6
|
+
// Jacket is a Compass component that prints and hides styles based on
|
7
|
+
// context variables you set in your stylesheet. Write and maintain a master
|
8
|
+
// stylesheet, then output custom tailored stylesheets for modern and legacy
|
9
|
+
// browsers, site and app builds, or any other context you can think of.
|
10
10
|
|
11
11
|
///////////////////////////////////////////////////////////
|
12
12
|
// Settings variables
|
13
13
|
///////////////////////////////////////////////////////////
|
14
14
|
|
15
|
-
//
|
15
|
+
// Default list of jacket contexts.
|
16
16
|
$jacket: null !default;
|
17
17
|
|
18
|
-
//
|
18
|
+
// Private variable used by jacket-context().
|
19
19
|
$jckt-context: null;
|
20
20
|
|
21
21
|
///////////////////////////////////////////////////////////
|
22
22
|
// Jacket mixin
|
23
|
-
// Takes a list of jacket
|
23
|
+
// Takes a list of jacket contexts.
|
24
|
+
// Outputs a block of styles if a context is set.
|
24
25
|
///////////////////////////////////////////////////////////
|
25
|
-
@mixin jacket($
|
26
|
+
@mixin jacket($contexts...) {
|
26
27
|
|
27
28
|
$naked: false;
|
28
29
|
$selectors: ();
|
@@ -30,7 +31,7 @@ $jckt-context: null;
|
|
30
31
|
$selector-string: '';
|
31
32
|
|
32
33
|
// Set the global context variable.
|
33
|
-
$jckt-context: $
|
34
|
+
$jckt-context: $contexts;
|
34
35
|
|
35
36
|
// If jacket is a single context and selector list, encapsulate.
|
36
37
|
@if list-separator($jacket) == 'space' {
|
@@ -39,8 +40,8 @@ $jckt-context: null;
|
|
39
40
|
|
40
41
|
// Test if a jacket context and jacket value match.
|
41
42
|
@each $item in $jacket {
|
42
|
-
@each $
|
43
|
-
@if index($
|
43
|
+
@each $context in $contexts {
|
44
|
+
@if index($context, nth($item, 1)) {
|
44
45
|
|
45
46
|
// Gather wrapping selectors.
|
46
47
|
@if length($item) == 1 {
|
@@ -80,11 +81,32 @@ $jckt-context: null;
|
|
80
81
|
}
|
81
82
|
}
|
82
83
|
|
84
|
+
///////////////////////////////////////////////////////////
|
85
|
+
// Jacket function
|
86
|
+
// Takes a list of jacket contexts.
|
87
|
+
// Outputs a value if a context is set.
|
88
|
+
///////////////////////////////////////////////////////////
|
89
|
+
@function jacket($value, $contexts...) {
|
90
|
+
|
91
|
+
@each $item in $jacket {
|
92
|
+
@each $context in $contexts {
|
93
|
+
@if index($context, nth($item, 1)) {
|
94
|
+
// If the weather is right, return the value!
|
95
|
+
@return $value;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
// Else return null. If null is the only value for a selector, the selector
|
101
|
+
// will not be printed.
|
102
|
+
@return null;
|
103
|
+
}
|
104
|
+
|
83
105
|
///////////////////////////////////////////////////////////
|
84
106
|
// Jacket Context function
|
85
|
-
// Takes a jacket value. Use when code inside a jacket
|
86
|
-
// needs to know if a specific jacket
|
107
|
+
// Takes a jacket context value. Use when code inside a jacket
|
108
|
+
// needs to know if a specific jacket context is set.
|
87
109
|
///////////////////////////////////////////////////////////
|
88
|
-
@function jacket-context($
|
89
|
-
@return if(index($jckt-context, $
|
110
|
+
@function jacket-context($context) {
|
111
|
+
@return if(index($jckt-context, $context), true, false);
|
90
112
|
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jacket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sass
|