Skip to content

Commit 758e505

Browse files
committed
initial code drop
1 parent 67bbbd2 commit 758e505

18 files changed

+1187
-0
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
_sandbox
2+
.tmp
3+
.electron-cache
4+
node_modules
5+
dist
6+
build
7+
.DS_Store

.scss-lint.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
linters:
2+
Comment:
3+
allowed: '(Copyright)|(\.scss[ */]*$)|(@noflip)'
4+
DeclarationOrder:
5+
enabled: false
6+
DisableLinterReason:
7+
enabled: true
8+
IdSelector:
9+
enabled: false
10+
ImportantRule:
11+
enabled: false
12+
MergeableSelector:
13+
force_nesting: false
14+
NameFormat:
15+
enabled: false
16+
NestingDepth:
17+
max_depth: 6
18+
PropertySortOrder:
19+
enabled: false
20+
QualifyingElement:
21+
enabled: false
22+
SelectorDepth:
23+
enabled: false
24+
max_depth: 6
25+
SelectorFormat:
26+
enabled: false
27+
Shorthand:
28+
allowed_shorthands: [1,2,4]
29+
SpaceAfterPropertyColon:
30+
enabled: false
31+
style: one_space_or_newline
32+
TrailingSemicolon:
33+
enabled: false
34+
TransitionAll:
35+
enabled: true
36+
UnnecessaryMantissa:
37+
enabled: false
38+
UrlFormat:
39+
enabled: false
40+
VendorPrefix:
41+
enabled: false

app/app.js

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/*
2+
* Copyright 2016 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
const $ = require('./jquery.min.js');
20+
const electron = require('electron');
21+
const colors = require('./colors.js');
22+
23+
var $hues;
24+
var $values;
25+
26+
27+
function init() {
28+
buildUi();
29+
$('.close-button').click(() => {
30+
electron.remote.getCurrentWindow().hide();
31+
electron.ipcRenderer.send('update-ui-mode');
32+
});
33+
34+
electron.ipcRenderer.on('update-downloaded', (event, releaseName) => {
35+
$('<div>')
36+
.addClass('update-banner')
37+
.text(`Install v${releaseName}`)
38+
.click(() => electron.ipcRenderer.send('install-update'))
39+
.appendTo('body');
40+
});
41+
}
42+
43+
44+
function displayLabelForHue(hue) {
45+
return hue.split('-')
46+
.map(s => s.charAt(0).toUpperCase() + s.substring(1))
47+
.join(' ');
48+
}
49+
50+
51+
function selectHue(hue) {
52+
$('.hue').removeClass('is-selected');
53+
$(`.hue-${hue}`).addClass('is-selected');
54+
55+
// build values
56+
57+
$values.empty();
58+
59+
$('<div>')
60+
.addClass('value-heading')
61+
.text(displayLabelForHue(hue))
62+
.appendTo($values);
63+
64+
for (let value in colors[hue]) {
65+
let $value = $('<div>')
66+
.addClass('value')
67+
.toggleClass('is-white', !!colors[hue][value].white)
68+
.css({
69+
backgroundColor: colors[hue][value].color
70+
})
71+
.appendTo($values);
72+
73+
$('<div>')
74+
.addClass('value-name')
75+
.text(value.toUpperCase())
76+
.appendTo($value);
77+
78+
$('<div>')
79+
.addClass('value-hex')
80+
.text(colors[hue][value].color.toUpperCase())
81+
.click(() => electron.clipboard.writeText(colors[hue][value].color.toUpperCase()))
82+
.appendTo($value);
83+
}
84+
}
85+
86+
87+
function buildUi() {
88+
$hues = $('<div>')
89+
.addClass('hues')
90+
.appendTo('body');
91+
92+
let firstHue;
93+
for (let hue in colors) {
94+
if (!firstHue) {
95+
firstHue = hue;
96+
}
97+
98+
let $hue = $('<div>')
99+
.addClass('hue')
100+
.addClass('hue-' + hue)
101+
.click(() => selectHue(hue))
102+
.appendTo($hues);
103+
104+
let $hueIcon = $('<div>')
105+
.addClass('hue-icon')
106+
.css({
107+
backgroundColor: colors[hue]['500'].color
108+
})
109+
.appendTo($hue);
110+
111+
$('<div>')
112+
.addClass('hue-icon-selector')
113+
.css({
114+
backgroundColor: colors[hue]['700'].color
115+
})
116+
.appendTo($hueIcon);
117+
118+
$('<div>')
119+
.addClass('hue-label')
120+
.text(displayLabelForHue(hue))
121+
.appendTo($hue);
122+
}
123+
124+
$values = $('<div>')
125+
.addClass('values')
126+
.appendTo('body');
127+
128+
selectHue(firstHue);
129+
}
130+
131+
132+
init();

0 commit comments

Comments
 (0)