dvl-color 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7c2cd87354cf56ced0b0e053b069083e13e35b5b
4
+ data.tar.gz: d92487e19d66c3d41846b73e53b694cd51264ca0
5
+ SHA512:
6
+ metadata.gz: b3187e6e01363291bde8e785d10d824024c6ef7b3ec22fbd944ebc7c39dbd902f6f88dd1d34ed53ecdd10ed0973fe6f43db5591837020517d05f3d2f360c32ed
7
+ data.tar.gz: dc36d86106c02bcb7095029241d651fb640f67ebed9c9362d13d5c3e858f071388fcd3d8df76c2406f787045f013a0c18b6e20b4a9077cb7e3944446b80a3233
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ spec/dummy/config/database.yml
5
+ spec/dummy/log/*.log
6
+ spec/dummy/tmp/
7
+ spec/dummy/.sass-cache
8
+ spec/dummy/public/uploads/*
9
+ tmp/*
10
+ coverage/*
11
+ *.gem
12
+ Gemfile.lock
13
+ spec/dummy/db/test.sqlite3
14
+ gemfiles/*.lock
15
+ .ruby-gemset
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.0
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 Department of Better Technology
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ dvl-color
2
+ =======
3
+
4
+ [![RubyGem][gem]](http://rubygems.org/gems/dvl-color)
5
+
6
+ Generate beautiful, accessible color schemes.
7
+
8
+ [View some examples →](dobtco.github.io/dvl-color)
9
+
10
+ ## Usage
11
+
12
+ #### 1. Install the gem
13
+ ```ruby
14
+ gem 'dvl-color'
15
+ ```
16
+
17
+ #### 2. Generate a color scheme
18
+ ```ruby
19
+ generator = Dvl::Color::Generator.new('#fff') # white background
20
+ generator.to_h # prints a bunch of variables
21
+ ```
22
+
23
+ [gem]: https://img.shields.io/gem/v/dvl-color.svg
data/Rakefile ADDED
@@ -0,0 +1,127 @@
1
+ require 'bundler/setup'
2
+ require 'dvl/color'
3
+ require_relative './spec/spec_helper'
4
+
5
+ task :generate_preview do
6
+ require 'fortitude'
7
+
8
+ class PreviewView < Fortitude::Widget
9
+ doctype :html5
10
+ use_instance_variables_for_assigns true
11
+ format_output false
12
+ start_and_end_comments false
13
+ extra_assigns :use
14
+
15
+ def content
16
+ rawtext "<!doctype html>"
17
+
18
+ html {
19
+ head {
20
+ title 'Color Test'
21
+ script(src: 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js')
22
+ script %{
23
+ $(document).on('keydown', function(e){
24
+ if (e.keyCode == 192) $('.debug').toggle();
25
+ if (e.keyCode == 70) $('.input').toggle();
26
+ });
27
+ }.html_safe
28
+
29
+ style %{
30
+ body {
31
+ margin: 0;
32
+ font-size: 1.125rem;
33
+ line-height: 2rem;
34
+ font-family: sans-serif;
35
+ font-weight: 400;
36
+ -webkit-font-smoothing: antialiased;
37
+ -moz-osx-font-smoothing: grayscale;
38
+ }
39
+
40
+ h2 {
41
+ margin: 5px 0;
42
+ font-size: 4.29rem;
43
+ line-height: 5rem;
44
+ font-family: serif;
45
+ font-weight: 100;
46
+ }
47
+
48
+ * {
49
+ box-sizing: border-box;
50
+ }
51
+
52
+ .color_test_section {
53
+ width: 25%;
54
+ padding: 25px;
55
+ display: inline-block;
56
+ }
57
+
58
+ .input {
59
+ margin: 0 0 1rem;
60
+ padding: 0.5rem 1rem;
61
+ width: 100%;
62
+ border-radius: 4px;
63
+ border-style: solid;
64
+ border-width: 1px;
65
+ }
66
+
67
+ .error_bubble {
68
+ margin-top: 0.5rem;
69
+ padding: 0.5rem 1rem;
70
+ border-radius: 4px;
71
+ }
72
+
73
+ .debug {
74
+ margin-top: 10px;
75
+ font-size: 13px;
76
+ }
77
+ }.squish.html_safe
78
+ }
79
+
80
+ body {
81
+ test_color_array.each do |color|
82
+ render_section(color)
83
+ end
84
+ }
85
+ }
86
+ end
87
+
88
+ def render_section(color)
89
+ generator = Dvl::Color::Generator.new(color)
90
+
91
+ div(class: 'color_test_section', style: "background-color: #{generator.background_color.to_hex}") {
92
+ h2('Header', style: "color: #{generator.base_color.to_hex}")
93
+ label {
94
+ span 'Text ', style: "color: #{generator.base_color.to_hex}"
95
+ abbr '*', style: "color: #{generator.error_color.to_hex}"
96
+ }
97
+ div(
98
+ 'This is my input', class: 'input',
99
+ style: "border-color: rgba(#{generator.base_color.to_hex},0.6);
100
+ background-color: #{generator.input_background.to_hex};
101
+ color: #{generator.input_color.to_hex};"
102
+ )
103
+ div(
104
+ 'This is my input', class: 'input error_input error_input_focus',
105
+ style: "display: none;
106
+ border-color: #{generator.error_color.to_hex};
107
+ background-color: #{generator.input_background_focus.to_hex};
108
+ color: #{generator.input_color.to_hex};"
109
+ )
110
+ div(
111
+ 'Error!', class: 'error_bubble',
112
+ style: "background-color: #{generator.error_bubble_background.to_hex};
113
+ color: #{generator.error_bubble_color.to_hex};"
114
+ )
115
+
116
+ div(
117
+ generator.to_debug_s.html_safe, class: 'debug',
118
+ style: "color: #{generator.base_color.to_hex}; display: none;"
119
+ )
120
+ }
121
+ end
122
+ end
123
+
124
+ html = PreviewView.new.to_html
125
+
126
+ File.write('./index.html', html)
127
+ end
data/circle.yml ADDED
@@ -0,0 +1,11 @@
1
+ test:
2
+ override:
3
+ - script/cibuild
4
+
5
+ deployment:
6
+ github:
7
+ branch: master
8
+ commands:
9
+ - git config --global user.email "ops@dobt.co"
10
+ - git config --global user.name "CircleCI"
11
+ - script/deploy
data/dvl-color.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require "dvl/color/version"
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = "dvl-color"
9
+ s.version = Dvl::Color::VERSION
10
+
11
+ s.required_ruby_version = Gem::Requirement.new('>= 2.0.0')
12
+ s.authors = ['Adam Becker']
13
+ s.summary = 'Generate beautiful, accessible color schemes.'
14
+ s.email = 'adam@dobt.co'
15
+ s.license = 'MIT'
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {features,spec}/*`.split("\n")
19
+
20
+ s.homepage = 'http://github.com/dobtco/dvl-color'
21
+
22
+ s.add_dependency 'chroma', '~> 0.0.1'
23
+ s.add_dependency 'chroma_wcag_contrast', '~> 0.0.1'
24
+
25
+ s.add_development_dependency 'fortitude'
26
+ s.add_development_dependency 'rspec'
27
+ end
@@ -0,0 +1,12 @@
1
+ class Dvl::Color::FakeRgba
2
+ def self.calculate(background, foreground, alpha)
3
+ bg = background.rgb
4
+ fg = foreground.rgb
5
+
6
+ r = (fg.r * alpha) + (bg.r * (1 - alpha))
7
+ g = (fg.g * alpha) + (bg.g * (1 - alpha))
8
+ b = (fg.b * alpha) + (bg.b * (1 - alpha))
9
+
10
+ Chroma::Color.new(Chroma::ColorModes::Rgb.new(r, g, b), :hex)
11
+ end
12
+ end
@@ -0,0 +1,236 @@
1
+ class Dvl::Color::Generator
2
+ DARK_BACKGROUND_CUTOFF = 120
3
+
4
+ attr_accessor :background_color,
5
+ :input_color,
6
+ :input_background,
7
+ :input_background_focus,
8
+ :dropdown_background,
9
+ :dropdown_color
10
+
11
+ # @param background_color [Chroma::Color or String]
12
+ def initialize(background_color)
13
+ self.background_color = background_color
14
+
15
+ unless background_color.is_a?(Chroma::Color)
16
+ self.background_color = Chroma.paint(background_color)
17
+ end
18
+
19
+ self.input_background, self.input_background_focus, self.input_color = generate_input_colors
20
+ self.dropdown_background, self.dropdown_color = generate_dropdown_colors
21
+ end
22
+
23
+ def to_h
24
+ {
25
+ backgroundColor: background_color.to_hex,
26
+ baseColor: base_color.to_hex,
27
+ errorColor: error_color.to_hex,
28
+ errorBubbleBackground: error_bubble_background.to_hex,
29
+ errorBubbleColor: error_bubble_color.to_hex,
30
+ inputBackground: input_background.to_hex,
31
+ inputBackgroundFocus: input_background_focus.to_hex,
32
+ inputColor: input_color.to_hex,
33
+ dropdownBackground: dropdown_background.to_hex,
34
+ dropdownColor: dropdown_color.to_hex
35
+ }
36
+ end
37
+
38
+ def to_scss
39
+ ''.tap do |str|
40
+ to_h.each do |k, v|
41
+ str << "$#{k}:#{v};"
42
+ end
43
+ end
44
+ end
45
+
46
+ def to_debug_s
47
+ str = []
48
+
49
+ to_h.each do |k, v|
50
+ str << "#{k}: #{v}"
51
+ end
52
+
53
+ str << "Background brightness: #{background_color.brightness}"
54
+
55
+ str << "Ratio: #{contrast(background_color, base_color).round(2)}"
56
+ str << "Error Ratio: #{contrast(background_color, error_color).round(2)}"
57
+ str << "Error Bubble Ratio: #{contrast(error_bubble_background, error_bubble_color).round(2)}"
58
+ str << "Input ratio: #{contrast(input_background, input_color).round(2)}"
59
+ str << "Error satur: #{error_color.hsl.s.round(2)}"
60
+ str << "Conservative light: #{conservative_background_light?}"
61
+ str << "Conservative dark: #{conservative_background_dark?}"
62
+
63
+ str.join("<br>")
64
+ end
65
+
66
+ def conservative_background_dark?
67
+ background_color.brightness < 52
68
+ end
69
+
70
+ def conservative_background_light?
71
+ background_color.brightness > 229
72
+ end
73
+
74
+ def target_contrast_ratio
75
+ if conservative_background_dark?
76
+ 13
77
+ elsif conservative_background_light?
78
+ 10
79
+ else
80
+ 7
81
+ end
82
+ end
83
+
84
+ def base_color
85
+ @base_color ||= begin
86
+ text = background_color.dup
87
+
88
+ # If the background is dark, we lighten it.
89
+ # If the background is light, we darken it.
90
+ amt = if background_color.brightness < DARK_BACKGROUND_CUTOFF # Dark
91
+ 1
92
+ else
93
+ -1
94
+ end
95
+
96
+ target = target_contrast_ratio
97
+
98
+ while contrast(background_color, text) < target
99
+ new_text = text.lighten(amt)
100
+
101
+ # prevent infinite loop
102
+ break if text == new_text
103
+
104
+ text = new_text
105
+ end
106
+
107
+ # If the background is a conservative color, use a conservative
108
+ # (desaturated) text color.
109
+
110
+ if conservative_background_dark? || conservative_background_light?
111
+ hsl = text.hsl
112
+ hsl.s = hsl.s * 0.15
113
+ text = Chroma.paint(hsl)
114
+ end
115
+
116
+ text
117
+ end
118
+ end
119
+
120
+ def error_color
121
+ @error_color ||= begin
122
+ error = background_color.dup
123
+
124
+ # Spin the color wheel until we land on "red"
125
+ amt = if error.hsl.h > 180
126
+ 15
127
+ else
128
+ -15
129
+ end
130
+
131
+ while !red?(error)
132
+ error = error.spin(amt)
133
+ end
134
+
135
+ # White
136
+ if background_color == white
137
+ error = Chroma.paint('d95b76')
138
+ # Black
139
+ elsif background_color == black
140
+ error = Chroma.paint('d95b76')
141
+ # Grayscale
142
+ elsif error.hsl.s == 0
143
+ error = error.saturate(100)
144
+ # Otherwise, ensure saturation is at least 0.4, or else it's not really red...
145
+ elsif error.hsl.s < 0.4
146
+ hsl = error.hsl
147
+ hsl.s = 0.4
148
+ error = Chroma.paint(hsl)
149
+ elsif conservative_background_light?
150
+ hsl = error.hsl
151
+ hsl.l = hsl.l - 0.4
152
+ error = Chroma.paint(hsl)
153
+ end
154
+
155
+ amt = if background_color.brightness < 100
156
+ 2
157
+ else
158
+ -2
159
+ end
160
+
161
+ while contrast(error, background_color) < 2.5
162
+ new_error = error.lighten(amt)
163
+ break if error == new_error
164
+ error = new_error
165
+ end
166
+
167
+ error
168
+ end
169
+ end
170
+
171
+ def error_bubble_background
172
+ if error_color.brightness > 200
173
+ white
174
+ else
175
+ error_color
176
+ end
177
+ end
178
+
179
+ def error_bubble_color
180
+ if error_bubble_background == white
181
+ background_color
182
+ else
183
+ white
184
+ end
185
+ end
186
+
187
+ def generate_dropdown_colors
188
+ if background_color.brightness < DARK_BACKGROUND_CUTOFF
189
+ [base_color, background_color]
190
+ else
191
+ [background_color, base_color]
192
+ end
193
+ end
194
+
195
+ def black
196
+ Chroma.paint('#000')
197
+ end
198
+
199
+ def white
200
+ Chroma.paint('#fff')
201
+ end
202
+
203
+ private
204
+
205
+ def generate_input_colors
206
+ input_background = Dvl::Color::FakeRgba.calculate(background_color, white, 0.4)
207
+ input_background_focus = Dvl::Color::FakeRgba.calculate(background_color, white, 0.7)
208
+ input_color = base_color
209
+
210
+ if contrast(input_background, input_color) > 6
211
+ [input_background, input_background_focus, input_color]
212
+ else
213
+ alpha = 0.2
214
+ input_background = Dvl::Color::FakeRgba.calculate(background_color, black, alpha)
215
+ input_background_focus = Dvl::Color::FakeRgba.calculate(background_color, black, alpha + 0.4)
216
+
217
+ while contrast(input_background, input_color) < 6
218
+ alpha += 0.01
219
+ break if alpha == 1
220
+ input_background = Dvl::Color::FakeRgba.calculate(background_color, black, alpha)
221
+ input_background_focus = Dvl::Color::FakeRgba.calculate(background_color, black, alpha + 0.4)
222
+ end
223
+
224
+ [input_background, input_background_focus, input_color]
225
+ end
226
+ end
227
+
228
+ def red?(color)
229
+ color.hsl.h > 355 ||
230
+ color.hsl.h < 10
231
+ end
232
+
233
+ def contrast(c1, c2)
234
+ ChromaWcagContrast.ratio(c1, c2)
235
+ end
236
+ end
@@ -0,0 +1,5 @@
1
+ module Dvl
2
+ module Color
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
data/lib/dvl/color.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'chroma'
2
+ require 'chroma_wcag_contrast'
3
+
4
+ require 'dvl/color/fake_rgba'
5
+ require 'dvl/color/generator'
data/script/cibuild ADDED
@@ -0,0 +1,3 @@
1
+ #! /bin/sh
2
+
3
+ bundle exec rspec
data/script/deploy ADDED
@@ -0,0 +1,16 @@
1
+ #! /bin/sh
2
+
3
+ set -e
4
+
5
+ (git branch | grep -q '* master') || {
6
+ echo "Only release from the master branch."
7
+ exit 1
8
+ }
9
+
10
+ init_branch=`git rev-parse --abbrev-ref HEAD`
11
+ git branch -D gh-pages
12
+ git checkout -b gh-pages
13
+ rake generate_preview
14
+ git commit -am 'deploy preview'
15
+ git push origin gh-pages --force
16
+ git checkout $init_branch
data/script/release ADDED
@@ -0,0 +1,38 @@
1
+ #!/bin/sh
2
+ # Tag and push a release.
3
+
4
+ set -e
5
+
6
+ # Make sure we're in the project root.
7
+
8
+ cd $(dirname "$0")/..
9
+
10
+ # Build a new gem archive.
11
+
12
+ rm -rf dvl-color-*.gem
13
+ gem build -q dvl-color.gemspec
14
+
15
+ # Make sure we're on the master branch.
16
+
17
+ (git branch | grep -q '* master') || {
18
+ echo "Only release from the master branch."
19
+ exit 1
20
+ }
21
+
22
+ # Figure out what version we're releasing.
23
+
24
+ tag=v`ls dvl-color-*.gem | sed 's/^dvl-color-\(.*\)\.gem$/\1/'`
25
+
26
+ # Make sure we haven't released this version before.
27
+
28
+ git fetch -t origin
29
+
30
+ (git tag -l | grep -q "$tag") && {
31
+ echo "Whoops, there's already a '${tag}' tag."
32
+ exit 1
33
+ }
34
+
35
+ # Tag it and bag it.
36
+
37
+ gem push dvl-color-*.gem && git tag "$tag" &&
38
+ git push origin master && git push origin "$tag"
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe Dvl::Color::Generator do
4
+ expected_output = <<-RESULT
5
+ f7f7f7: $backgroundColor:#f7f7f7;$baseColor:#3d3d3d;$errorColor:#ff6a6a;$errorBubbleBackground:#ff6a6a;$errorBubbleColor:#ffffff;$inputBackground:#fafafa;$inputBackgroundFocus:#fdfdfd;$inputColor:#3d3d3d;$dropdownBackground:#f7f7f7;$dropdownColor:#3d3d3d;
6
+ c4c4c4: $backgroundColor:#c4c4c4;$baseColor:#353535;$errorColor:#ef0000;$errorBubbleBackground:#ef0000;$errorBubbleColor:#ffffff;$inputBackground:#dcdcdc;$inputBackgroundFocus:#ededed;$inputColor:#353535;$dropdownBackground:#c4c4c4;$dropdownColor:#353535;
7
+ 949494: $backgroundColor:#949494;$baseColor:#000000;$errorColor:#a30000;$errorBubbleBackground:#a30000;$errorBubbleColor:#ffffff;$inputBackground:#bfbfbf;$inputBackgroundFocus:#dfdfdf;$inputColor:#000000;$dropdownBackground:#949494;$dropdownColor:#000000;
8
+ 6e6e6e: $backgroundColor:#6e6e6e;$baseColor:#ffffff;$errorColor:#6c0000;$errorBubbleBackground:#6c0000;$errorBubbleColor:#ffffff;$inputBackground:#585858;$inputBackgroundFocus:#2c2c2c;$inputColor:#ffffff;$dropdownBackground:#ffffff;$dropdownColor:#6e6e6e;
9
+ 444444: $backgroundColor:#444444;$baseColor:#dddddd;$errorColor:#ff1818;$errorBubbleBackground:#ff1818;$errorBubbleColor:#ffffff;$inputBackground:#363636;$inputBackgroundFocus:#1b1b1b;$inputColor:#dddddd;$dropdownBackground:#dddddd;$dropdownColor:#444444;
10
+ 47141D: $backgroundColor:#47141d;$baseColor:#f3f1f1;$errorColor:#b63c33;$errorBubbleBackground:#b63c33;$errorBubbleColor:#ffffff;$inputBackground:#391017;$inputBackgroundFocus:#1c080c;$inputColor:#f3f1f1;$dropdownBackground:#f3f1f1;$dropdownColor:#47141d;
11
+ 333022: $backgroundColor:#333022;$baseColor:#fefefe;$errorColor:#ae514a;$errorBubbleBackground:#ae514a;$errorBubbleColor:#ffffff;$inputBackground:#29261b;$inputBackgroundFocus:#14130e;$inputColor:#fefefe;$dropdownBackground:#fefefe;$dropdownColor:#333022;
12
+ 073329: $backgroundColor:#073329;$baseColor:#f2f4f4;$errorColor:#d4201d;$errorBubbleBackground:#d4201d;$errorBubbleColor:#ffffff;$inputBackground:#062921;$inputBackgroundFocus:#031410;$inputColor:#f2f4f4;$dropdownBackground:#f2f4f4;$dropdownColor:#073329;
13
+ 072333: $backgroundColor:#072333;$baseColor:#e4e7e9;$errorColor:#b92c1a;$errorBubbleBackground:#b92c1a;$errorBubbleColor:#ffffff;$inputBackground:#061c29;$inputBackgroundFocus:#030e14;$inputColor:#e4e7e9;$dropdownBackground:#e4e7e9;$dropdownColor:#072333;
14
+ 2E0D33: $backgroundColor:#2e0d33;$baseColor:#e8e5e9;$errorColor:#a5382a;$errorBubbleBackground:#a5382a;$errorBubbleColor:#ffffff;$inputBackground:#250a29;$inputBackgroundFocus:#120514;$inputColor:#e8e5e9;$dropdownBackground:#e8e5e9;$dropdownColor:#2e0d33;
15
+ D12A6D: $backgroundColor:#d12a6d;$baseColor:#ffffff;$errorColor:#edaea7;$errorBubbleBackground:#edaea7;$errorBubbleColor:#ffffff;$inputBackground:#a72257;$inputBackgroundFocus:#54112c;$inputColor:#ffffff;$dropdownBackground:#ffffff;$dropdownColor:#d12a6d;
16
+ FF7F4C: $backgroundColor:#ff7f4c;$baseColor:#2d0d00;$errorColor:#bc0600;$errorBubbleBackground:#bc0600;$errorBubbleColor:#ffffff;$inputBackground:#ffb294;$inputBackgroundFocus:#ffd9c9;$inputColor:#2d0d00;$dropdownBackground:#ff7f4c;$dropdownColor:#2d0d00;
17
+ 1BC7A2: $backgroundColor:#1bc7a2;$baseColor:#062922;$errorColor:#c7211b;$errorBubbleBackground:#c7211b;$errorBubbleColor:#ffffff;$inputBackground:#76ddc7;$inputBackgroundFocus:#bbeee3;$inputColor:#062922;$dropdownBackground:#1bc7a2;$dropdownColor:#062922;
18
+ 37A6E6: $backgroundColor:#37a6e6;$baseColor:#03121a;$errorColor:#ac2715;$errorBubbleBackground:#ac2715;$errorBubbleColor:#ffffff;$inputBackground:#87caf0;$inputBackgroundFocus:#c3e4f8;$inputColor:#03121a;$dropdownBackground:#37a6e6;$dropdownColor:#03121a;
19
+ AF45BF: $backgroundColor:#af45bf;$baseColor:#ffffff;$errorColor:#57251e;$errorBubbleBackground:#57251e;$errorBubbleColor:#ffffff;$inputBackground:#8c3799;$inputBackgroundFocus:#461c4c;$inputColor:#ffffff;$dropdownBackground:#ffffff;$dropdownColor:#af45bf;
20
+ FFF7F5: $backgroundColor:#fff7f5;$baseColor:#463834;$errorColor:#ff2934;$errorBubbleBackground:#ff2934;$errorBubbleColor:#ffffff;$inputBackground:#fffaf9;$inputBackgroundFocus:#fffdfc;$inputColor:#463834;$dropdownBackground:#fff7f5;$dropdownColor:#463834;
21
+ FCF9F2: $backgroundColor:#fcf9f2;$baseColor:#34322c;$errorColor:#d64c53;$errorBubbleBackground:#d64c53;$errorBubbleColor:#ffffff;$inputBackground:#fdfbf7;$inputBackgroundFocus:#fefdfb;$inputColor:#34322c;$dropdownBackground:#fcf9f2;$dropdownColor:#34322c;
22
+ F8FFF5: $backgroundColor:#f8fff5;$baseColor:#21291e;$errorColor:#ff2934;$errorBubbleBackground:#ff2934;$errorBubbleColor:#ffffff;$inputBackground:#fbfff9;$inputBackgroundFocus:#fdfffc;$inputColor:#21291e;$dropdownBackground:#f8fff5;$dropdownColor:#21291e;
23
+ F5FDFF: $backgroundColor:#f5fdff;$baseColor:#252f32;$errorColor:#ff2934;$errorBubbleBackground:#ff2934;$errorBubbleColor:#ffffff;$inputBackground:#f9feff;$inputBackgroundFocus:#fcfeff;$inputColor:#252f32;$dropdownBackground:#f5fdff;$dropdownColor:#252f32;
24
+ F7E6FF: $backgroundColor:#f7e6ff;$baseColor:#433649;$errorColor:#ff1a29;$errorBubbleBackground:#ff1a29;$errorBubbleColor:#ffffff;$inputBackground:#faf0ff;$inputBackgroundFocus:#fdf8ff;$inputColor:#433649;$dropdownBackground:#f7e6ff;$dropdownColor:#433649;
25
+ RESULT
26
+
27
+ it 'calculates properly' do
28
+ calculations = test_color_array.map do |x|
29
+ "#{x}: #{described_class.new(x).to_scss}"
30
+ end.join("\n")
31
+
32
+ expect(calculations.strip).to eq(expected_output.strip)
33
+ end
34
+ end
@@ -0,0 +1,26 @@
1
+ require 'dvl/color'
2
+
3
+ def test_color_array
4
+ %w(
5
+ f7f7f7
6
+ c4c4c4
7
+ 949494
8
+ 6e6e6e
9
+ 444444
10
+ 47141D
11
+ 333022
12
+ 073329
13
+ 072333
14
+ 2E0D33
15
+ D12A6D
16
+ FF7F4C
17
+ 1BC7A2
18
+ 37A6E6
19
+ AF45BF
20
+ FFF7F5
21
+ FCF9F2
22
+ F8FFF5
23
+ F5FDFF
24
+ F7E6FF
25
+ )
26
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dvl-color
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Adam Becker
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: chroma
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: chroma_wcag_contrast
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: fortitude
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email: adam@dobt.co
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - ".gitignore"
76
+ - ".ruby-version"
77
+ - Gemfile
78
+ - LICENSE.md
79
+ - README.md
80
+ - Rakefile
81
+ - circle.yml
82
+ - dvl-color.gemspec
83
+ - lib/dvl/color.rb
84
+ - lib/dvl/color/fake_rgba.rb
85
+ - lib/dvl/color/generator.rb
86
+ - lib/dvl/color/version.rb
87
+ - script/cibuild
88
+ - script/deploy
89
+ - script/release
90
+ - spec/dvl/color/generator_spec.rb
91
+ - spec/spec_helper.rb
92
+ homepage: http://github.com/dobtco/dvl-color
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: 2.0.0
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.5.1
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Generate beautiful, accessible color schemes.
116
+ test_files:
117
+ - spec/dvl/color/generator_spec.rb
118
+ - spec/spec_helper.rb
119
+ has_rdoc: