sass-color-schemes 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 092075af671c7f8422c9d5d4d5958787d5086436
4
- data.tar.gz: 4567e52a8b37a22edeba60bc81a096ea3723491d
3
+ metadata.gz: c45992fb58c248552b0e307edb7bb64adf379a5e
4
+ data.tar.gz: 7c9f0cd191151f4b9da95f454e635ae8b3b8f672
5
5
  SHA512:
6
- metadata.gz: be61f2ba4994195ffb0d0b069e5ff13aa25cbc455026a435d514aaca150a6876199fec0fd68a6baed7826d25a1da6121cf9a4659c1a64e6c4698ef75a626ebb5
7
- data.tar.gz: d4db49a72db0ba1fe0b65552a0faef393b75fc46015fc337fa5b829981f70a1eea07c9a51352bae469ec32596f4792b096cc95aaff9460a81cd7216fb223dfe1
6
+ metadata.gz: f8a9be5b1d5e0c47c6a2fdfc80c4e7d6eb98863a1934815464fc5396cc8d1459c05eeb3e1349ce9de9485614c6073f8065b95d6ce36e0c9c87391f8c35f8bc39
7
+ data.tar.gz: 575990604cea78ccd5f9fbb477f6d21a165e98f164c566ee12e7961546b688eea13521701170dfd4d9454c38766b0a015a9fd6fb40b41e3cd3aa638786ff9b78
data/README.md CHANGED
@@ -23,13 +23,13 @@ Or install it yourself as:
23
23
  Import it into your main stylesheet:
24
24
 
25
25
  @import 'sass-color-schemes';
26
-
26
+
27
27
  ### Color functions
28
28
 
29
29
  Sass-color-schemes has 4 functions that all return an array of 5 color values (of 5 `null`'s). Each function uses variables, such as `$base-color`, `$variation`, etc. for calculating the proper values.
30
30
 
31
- See **variables** for a description of the different kinds.
32
-
31
+ See [`$sass-color-schemes` variable](#sass-color-schemes-variable) for a description of the different types.
32
+
33
33
  #### primary-colors
34
34
 
35
35
  Returns an array of 5 colors, in which the first element is the base color and the rest are different shades of the base color. You need the Sass' `nth` function to access a specific color:
@@ -47,7 +47,7 @@ $color-primary-1: nth(primary-colors(), 2);
47
47
  color: $color-primary-1;
48
48
  }
49
49
 
50
- ```
50
+ ```
51
51
 
52
52
  #### complement-colors
53
53
 
@@ -83,24 +83,50 @@ $color-secondary-2-1: nth(secondary-2-colors(), 2);
83
83
  ```
84
84
  **Note:** The `secondary-1-colors` and `secondary-2-colors` functions only returns an array of colors when the `$scheme` variable is set to `adjacent`, `tetrad` or `triad`. Otherwise an array with 5 `null`'s is returned.
85
85
 
86
- ### Variables
86
+ ### `$sass-color-schemes` variable
87
+
88
+ You can (and might want to) configure sass-color-schemes to customize the color scheme. For this you need to define the `$sass-color-schemes` map variable, which contains one or more of the following keys:
87
89
 
88
- You can (and might want to) define several variables to customize the color scheme.
90
+ * [base-color](#base-color-key)
91
+ * [scheme](#scheme-key)
92
+ * [complement](#complement-key)
93
+ * [angle](#angle-key)
94
+ * [variation](#variation-key)
95
+ * [mode](#mode-key)
89
96
 
90
- #### $base-color
97
+ ```
98
+ $sass-color-schemes: (
99
+ base-color: red,
100
+ scheme: 'monochromatic',
101
+ // ... etc.
102
+ );
103
+
104
+ ```
91
105
 
92
- The color used as a base color to calculate the shades and all other colors. This can be any Sass color.
106
+ #### `base-color` key
107
+
108
+ The color used as a base color to calculate the shades and all other colors. This can be any [Sass color](http://sass-lang.com/documentation/Sass/Script/Value/Color.html).
93
109
 
94
110
  Defaults to `#ff0000` (red).
95
111
 
96
112
  ```
97
- $base-color: red;
98
- $base-color: hsl(0deg, 100%, 50%);
99
- $base-color: #ff0000;
100
- // ... etc.
113
+ $sass-color-schemes: (
114
+ base-color: red,
115
+ // ... etc.
116
+ );
117
+
118
+ $sass-color-schemes: (
119
+ base-color: hsl(0deg, 100%, 50%),
120
+ // ... etc.
121
+ );
122
+
123
+ $sass-color-schemes: (
124
+ base-color: #ff0000,
125
+ // ... etc.
126
+ );
101
127
  ```
102
128
 
103
- #### $scheme
129
+ #### `scheme` key
104
130
 
105
131
  Sass-color-schemes supports 4 different color schemes:
106
132
 
@@ -112,37 +138,55 @@ Sass-color-schemes supports 4 different color schemes:
112
138
  Defaults to `'monochromatic'`.
113
139
 
114
140
  ```
115
- $scheme: 'monochromatic';
116
- $scheme: 'tetrad';
117
- // ... etc.
118
-
141
+ $sass-color-schemes: (
142
+ scheme: 'monochromatic',
143
+ // ... etc.
144
+ );
145
+
146
+ $sass-color-schemes: (
147
+ scheme: 'tetrad',
148
+ // ... etc.
149
+ );
119
150
  ```
120
151
 
121
- #### $complement
152
+ #### `complement` key
122
153
 
123
154
  If set to `true`, the `complement-colors` function returns shades of the complementary color of the `$base-color`.
124
155
 
125
- Defaults to `false`.
156
+ Defaults to `true`.
126
157
 
127
158
  ```
128
- $complement: true;
129
- $complement: false;
159
+ $sass-color-schemes: (
160
+ complement: false,
161
+ // ... etc.
162
+ );
130
163
 
131
164
  ```
132
165
 
133
- #### $angle
166
+ #### `angle` key
134
167
 
135
168
  The angle applied to the `$base-color` to calculate other colors in all schemes, expect `monochromatic`. This can be any value and can be set in degrees (deg) or radian (rad) units as well.
136
169
 
137
170
  Defaults to `30deg`.
138
171
 
139
172
  ```
140
- $angle: 30;
141
- $angle: 30deg;
142
- $angle: 0.5236rad;
173
+ $sass-color-schemes: (
174
+ angle: 30,
175
+ // ... etc.
176
+ );
177
+
178
+ $sass-color-schemes: (
179
+ angle: 30deg,
180
+ // ... etc.
181
+ );
182
+
183
+ $sass-color-schemes: (
184
+ angle: 0.5236rad,
185
+ // ... etc.
186
+ );
143
187
  ```
144
188
 
145
- #### $variation
189
+ #### `variation` key
146
190
 
147
191
  This will vary the tints, tones and shades of the colors returned by all functions. Currently Sass-color-schemes supports 24 variations:
148
192
 
@@ -171,40 +215,49 @@ This will vary the tints, tones and shades of the colors returned by all functio
171
215
  * greyish medium dark
172
216
  * greyish lightest
173
217
 
174
- Defaults to `full colors`.
218
+ Defaults to `default`.
175
219
 
176
220
  ```
177
- $variation: 'darker pale pastel';
178
- $variation: 'shiny';
179
- // ... etc.
221
+ $sass-color-schemes: (
222
+ variation: 'darker pale pastel',
223
+ // ... etc.
224
+ );
225
+
226
+ $sass-color-schemes: (
227
+ variation: 'shiny',
228
+ // ... etc.
229
+ );
180
230
 
181
231
  ```
182
232
 
183
- #### $mode
233
+ #### `mode` key
184
234
 
185
235
  You can choose between:
186
236
 
187
237
  * [RGB](http://en.wikipedia.org/wiki/RGB_color_model) (a.k.a. the light model)
188
238
  * [RYB](http://en.wikipedia.org/wiki/RYB_color_model)
189
239
 
190
- These modes are internally used when calculating colors. RYB is primarily used in art and design education.
240
+ These modes are used internally when calculating colors. RYB is primarily used in art and design education.
191
241
 
192
242
  Defaults to `ryb`.
193
243
 
194
244
  ```
195
- $mode: 'rgb';
196
- $mode: 'ryb';
245
+ $sass-color-schemes: (
246
+ mode: 'rgb',
247
+ // ... etc.
248
+ );
197
249
 
198
250
  ```
199
251
 
200
252
  ### Full example
201
253
 
202
254
  ```
203
- $base-color: #6893A6;
204
- $variation: 'shiny';
205
- $scheme: 'adjacent';
206
- $angle: 25;
207
- $complement: true;
255
+ $sass-color-schemes: (
256
+ base-color: #6893A6,
257
+ variation: 'shiny',
258
+ scheme: 'adjacent',
259
+ angle: 25
260
+ );
208
261
 
209
262
  $color-primary-0: nth(primary-colors(), 1);
210
263
  $color-primary-1: nth(primary-colors(), 2);
@@ -1,9 +1,9 @@
1
1
  @function primary-colors() {
2
- @return _compose-shades($base-color);
2
+ @return _compose-shades(_base-color());
3
3
  }
4
4
 
5
5
  @function complement-colors() {
6
- @if ($complement == false) and ($scheme != 'tetrad') {
6
+ @if (_complement() == false) and (_scheme() != 'tetrad') {
7
7
  @return _empty-array();
8
8
  }
9
9
 
@@ -11,20 +11,20 @@
11
11
  }
12
12
 
13
13
  @function secondary-1-colors() {
14
- @if ($scheme == 'triad') {
15
- @return _compose-color(180 - $angle);
16
- } @else if ($scheme == 'adjacent') or ($scheme == 'tetrad') {
17
- @return _compose-color($angle);
14
+ @if (_scheme() == 'triad') {
15
+ @return _compose-color(180 - _angle());
16
+ } @else if (_scheme() == 'adjacent') or (_scheme() == 'tetrad') {
17
+ @return _compose-color(_angle());
18
18
  } @else {
19
19
  @return _empty-array();
20
20
  }
21
21
  }
22
22
 
23
23
  @function secondary-2-colors() {
24
- @if ($scheme == 'triad') or ($scheme == 'tetrad') {
25
- @return _compose-color(180 + $angle);
26
- } @else if ($scheme == 'adjacent') {
27
- @return _compose-color(-$angle);
24
+ @if (_scheme() == 'triad') or (_scheme() == 'tetrad') {
25
+ @return _compose-color(180 + _angle());
26
+ } @else if (_scheme() == 'adjacent') {
27
+ @return _compose-color(-_angle());
28
28
  } @else {
29
29
  @return _empty-array();
30
30
  }
@@ -36,11 +36,11 @@
36
36
  }
37
37
 
38
38
  @function _adjust-hue($angle) {
39
- @return if($mode == 'ryb', ryb-adjust-hue($base-color, $angle), adjust-hue($base-color, $angle));
39
+ @return if(_mode() == 'ryb', ryb-adjust-hue(_base-color(), $angle), adjust-hue(_base-color(), $angle));
40
40
  }
41
41
 
42
42
  @function _compose-shades($color) {
43
- $shades: map-get($variations, $variation);
43
+ $shades: map-get($_scs-variations, _variation());
44
44
 
45
45
  $colors: ();
46
46
  @for $i from 1 through 5 {
@@ -64,3 +64,31 @@
64
64
  }
65
65
  @return $arr;
66
66
  }
67
+
68
+ @function _base-color() {
69
+ @return _fetch('base-color', $_scs-base-color);
70
+ }
71
+
72
+ @function _variation() {
73
+ @return _fetch('variation', $_scs-variation);
74
+ }
75
+
76
+ @function _scheme() {
77
+ @return _fetch('scheme', $_scs-scheme);
78
+ }
79
+
80
+ @function _mode() {
81
+ @return _fetch('mode', $_scs-mode);
82
+ }
83
+
84
+ @function _angle() {
85
+ @return _fetch('angle', $_scs-angle);
86
+ }
87
+
88
+ @function _complement() {
89
+ @return _fetch('complement', $_scs-complement);
90
+ }
91
+
92
+ @function _fetch($key, $default) {
93
+ @return if(map-has-key($sass-color-schemes, $key), map-get($sass-color-schemes, $key), $default);
94
+ }
@@ -1,11 +1,14 @@
1
- $base-color: #ff0000 !default;
2
- $variation: 'full colors' !default;
3
- $scheme: 'monochromatic' !default; // monochromatic, adjacent, triad, tetrad
4
- $mode: 'ryb' !default; // rgb, ryb
5
- $angle: 30deg !default;
6
- $complement: false !default;
1
+ $sass-color-schemes: () !default;
7
2
 
8
- $variations: (
3
+ $_scs-base-color: green !default;
4
+ $_scs-variation: 'default' !default;
5
+ $_scs-scheme: 'monochromatic' !default; // monochromatic, adjacent, triad, tetrad
6
+ $_scs-mode: 'ryb' !default; // rgb, ryb
7
+ $_scs-angle: 30deg !default;
8
+ $_scs-complement: true !default;
9
+
10
+ $_scs-variations: (
11
+ 'default': (0 0) (16 68) (9 36) (12 -24) (32 -44),
9
12
  'lightest pale pastel': (0 77) (0 90) (0 82) (0 68) (0 60),
10
13
  'very light pale pastel': (0 65) (0 86) (0 77) (-26 42) (-44 15),
11
14
  'lighter pale pastel': (-36 48) (0 83) (0 75) (-49 22) (-52 -5),
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass-color-schemes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Baselier