-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
305 lines (301 loc) · 10.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<!Doctype HTML>
<html lang="en">
<head>
<meta name="author" content="Brandon Diaz-Abreu">
<meta name="description" content="A tool for visual designers and web developers. Draw inspiration from these hex color codes that have some personality.">
<meta name="keywords" content="Fun HEX color names">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#408CFF">
<meta name="google-site-verification" content="NY1ANoMTcO7X90-hoJus7x5cnj0oAOZjMVvRGcz10t4" />
<title>Cheeky Colors</title>
<style type="text/css">
@font-face {
font-family: 'Mouse Memoirs';
src: url('fonts/Mouse_Memoirs/mousememoirs-regular-webfont.woff2') format('woff2'),
url('fonts/Mouse_Memoirs/mousememoirs-regular-webfont.woff') format('woff');
font-weight: normal;
font-style: normal;
}
body{
background: #408CFF; /* For browsers that do not support gradients */
background: -webkit-linear-gradient(135deg, #408CFF, #DA4BFF);
background: -o-linear-gradient(135deg, #408CFF, #DA4BFF);
background: -moz-linear-gradient(135deg, #408CFF, #DA4BFF);
background: linear-gradient(135deg, #408CFF, #DA4BFF);
min-height: 100vh;
margin: 0;
text-align: center;
font-size: 18px;
}
button{
padding: 1vh 1vh;
background-color: transparent;
border: 2px solid #000000;
border-radius: 0.5em;
font-size: 1.1em;
}
button:hover{
background-color: white;
color: #000000;
cursor: pointer;
}
button a{
text-decoration: none;
color: initial;
}
#main_area{
margin: 1vh 2vw 1vh 2vw;
min-height: 100vh;
}
.legible_background{
background-color: #FFFFFF;
border-radius: 1em;
padding: 1px 10px;
}
.legible_background p{
text-align: initial;
}
#desktop_instructions,
#fork_banner,
.hexcode,
.color_title:hover .plaintext{
display: none;
}
.color_block{
min-width: 100px;
min-height: 120px;
width: 20%;
height: 20vw;
display: inline-block;
background-color: #FFFFFF;
border-radius: 12px;
margin: 25px;
box-shadow: 0px 0px 51px 0px rgba(0, 0, 0, 0.08),
0px 6px 18px 0px rgba(0, 0, 0, 0.05);
transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
transform: translateY(0px);
}
.color_display{
height: 48%;
border-radius: 12px 12px 0px 0px;
margin: 4% 5% -4% 5%;
}
.def_link{
color: #000000;
margin: 0.6vmin 0;
}
.def_link:hover{
opacity: 0.7;
color: blue;
}
.color_title{
background-color: #FFFFFF;
text-align: center;
}
.color_title p{
/*font-size: 30px; Good for desktop*/
margin: 0.8vmin 0;
}
.color_title:hover .hexcode{
font-family: 'Mouse Memoirs', sans-serif;
display: block;
}
.button_container{
margin: 4vh 0;
}
footer{
width: 100%;
background-color: #FFFFFF;
padding: 0.5vh 0;
}
@media only screen and (min-width: 800px){
body{
font-size: 21px;
}
#mobile_instructions{
display: none;
}
#desktop_instructions{
display: initial;
}
#fork_banner{
display: inline;
position: absolute;
top: 0;
right: 0;
border: 0;
}
.color_display{
height: 65%;
}
}
</style>
</head>
<body>
<div id="main_area">
<div class="legible_background">
<p style="display:none;">A tool for visual designers and web developers. Draw inspiration from these HEX colors that have some personality.</p>
<h1>Cheeky Colors</h1>
<p>A collection of over 14,000 words from various languages that can be spelled using the hexadecimal digits. See what colors they produce when used as a hex color code and check their definiton on Wiktionary. Visit the <a href="gallery.html">full gallery</a> to search and filter through all the words, or check out the sample below.
<span id="desktop_instructions">Hover over a color name to view its hex code.</span>
<span id="mobile_instructions">Tap on the name of a color to view its hex code.</span>
</p>
</div>
<a href="https://github.com/brandon8000/Cheeky-Colors"><img id="fork_banner" src="images/fork_me.png" alt="Fork this project on GitHub"></a>
<div id="display_area"></div>
<div class="button_container">
<button id="loader">Load More</button>
<button id="redirect"><a href="gallery.html">View All</a></button>
</div>
<noscript>
<div class="color_block">
<div class="color_display" style="background-color: #BADA55;">
</div>
<div class="color_title">
<p class="plaintext">BADASS</p>
<p class="hexcode">#BADA55</p>
</div>
<a class="def_link" href="https://en.wiktionary.org/wiki/badass" target="_blank">Definition</a>
</div>
<div class="color_block">
<div class="color_display" style="background-color: #CA7;">
</div>
<div class="color_title">
<p class="plaintext">CAT</p>
<p class="hexcode">#CA7</p>
</div>
<a class="def_link" href="https://en.wiktionary.org/wiki/cat" target="_blank">Definition</a>
</div>
<div class="color_block">
<div class="color_display" style="background-color: #2EA;">
</div>
<div class="color_title">
<p class="plaintext">SEA</p>
<p class="hexcode">#5EA</p>
</div>
<a class="def_link" href="https://en.wiktionary.org/wiki/sea" target="_blank">Definition</a>
</div>
<div class="color_block">
<div class="color_display" style="background-color: #BAE;">
</div>
<div class="color_title">
<p class="plaintext">BAE</p>
<p class="hexcode">#BAE</p>
</div>
<a class="def_link" href="https://en.wiktionary.org/wiki/bae" target="_blank">Definition</a>
</div>
<div>Please enable JavaScript to view more!</div>
</noscript>
<script type="text/javascript">
var smallDictionary = ['accept','potpie','access','act','ziptop','add','affect','age','ago','aid','aspect','assess','assist','hissed','attach','safest','bad','bag','zoo','bed','beside','cop','dad','debate','decade','decide','defeat','depict','detect','die','dig','dog','eat','effect','egg','escape','estate','etc','ethics','fat','fee','fit','gap','gas','sadist','get','gifted','hat','height','hip','his','zap','hit','doe','pst','hot','ice','its','odd','off','office','oppose','pet','pie','pop','pot','potato','sad','sag','sea','hog','see','set','she','sit','speech','tactic','tap','tea','pasted','the','tie','bet','big','bit','cap','cat','cheese','passed','choice','ace','choose','potato','coffee','tip','hashes','toe','too','pez','top'];
var hexMapping = {
O:0,
I:1,
Z:2,
H:4,
S:5,
G:6,
T:7,
P:9
};
var referenceSet = new Array(smallDictionary.length);
referenceSet.fill(false);
/*console.log("Look at the reference set: "+referenceSet);*/
if(Object.seal){
Object.seal(referenceSet);
}
else{
console.log("The reference set is not fixed size!");
}
function colorize(name){
let hexVersion = "#";
let index = 0;
while(index < name.length){
/* because the keys of the hexMapping object are single letters,
we can access the values using this simple syntax!
*/
let hexValue = hexMapping[name[index] ];
/* Can't use the default operator because "O" maps to 0.
So if we fail to access an appropriate value in the mapping,
we just use the letter that was given by the name*/
if(hexValue == undefined || hexValue == null ){
hexValue = name[index];
}
hexVersion += hexValue;
++index;
}
return hexVersion;
}
function renderColor(givenColor){
/*is there a clean way to create this once globally and
edit the relevant parts upon function call?*/
let namedColor = givenColor.toUpperCase();
let hexColor = colorize(namedColor);
let container = document.createElement("div");
container.classList.add("color_block");
let colorArea = document.createElement("div");
colorArea.classList.add("color_display");
colorArea.style.backgroundColor = hexColor;
let textArea = document.createElement("div");
textArea.classList.add("color_title");
let plainTitle = document.createElement("p");
plainTitle.classList.add("plaintext");
plainTitle.appendChild(document.createTextNode(namedColor) );
let hexTitle = document.createElement("p");
hexTitle.classList.add("hexcode");
hexTitle.appendChild(document.createTextNode(hexColor) );
let linkPart = document.createElement("a");
linkPart.classList.add("def_link");
let theURL = "https://en.wiktionary.org/wiki/"+givenColor;
linkPart.setAttribute("href", theURL);
linkPart.setAttribute("target", "_blank");
linkPart.appendChild(document.createTextNode("Definition") );
textArea.appendChild(plainTitle);
textArea.appendChild(hexTitle);
container.appendChild(colorArea);
container.appendChild(textArea);
container.appendChild(linkPart);
return container;
}
function loadRandom(){
let targetArea = document.getElementById("display_area");
let count = 0;
while(count < 10){
let currentIndex = Math.floor(Math.random() * smallDictionary.length);
let infinityCounter = 0;
while(referenceSet[currentIndex]){
currentIndex = Math.floor(Math.random() * smallDictionary.length);
++infinityCounter;
if(infinityCounter > smallDictionary.length){
/*console.log("Couldn't find a new random word.");*/
let availableWord = smallDictionary.lastIndexOf(false);
/*console.log("Look at what index was available: "+availableWord);*/
if(availableWord > -1){
currentIndex = availableWord;
}
else{
currentIndex = -1;
/*Destroy the loading button*/
document.getElementById("loader").remove();
}
break;
}
}
/*console.log("We randomly picked this color: "+smallDictionary[currentIndex]+" at index "+currentIndex);*/
if(currentIndex > -1){
targetArea.appendChild(renderColor(smallDictionary[currentIndex]));
referenceSet[currentIndex] = true;
++count;
}
else{
break;
}
}
}
document.getElementById("loader").addEventListener("click", loadRandom);
loadRandom();
</script>
</div>
<footer>Designed with ❤︎ in New Jersey</footer>
</body>
</html>