-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
161 lines (158 loc) · 5.97 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Primary Meta Tags -->
<title>HTML Color Names</title>
<meta name="title" content="HTML Color Names">
<meta name="description" content="Use HTML reserved colors by name, Hex color code or RGB value.">
<link rel="icon" href="https://avatars.githubusercontent.com/u/39514595?s=32">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://color-names.netlify.app/">
<meta property="og:title" content="HTML Color Names">
<meta property="og:description" content="Use HTML reserved colors by name, Hex color code or RGB value.">
<meta property="og:image" content="https://raw.githubusercontent.com/rayc2045/html-reserved-colors/main/assets/images/cover.png">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://color-names.netlify.app/">
<meta property="twitter:title" content="HTML Color Names">
<meta property="twitter:description" content="Use HTML reserved colors by name, Hex color code or RGB value.">
<meta property="twitter:image" content="https://raw.githubusercontent.com/rayc2045/html-reserved-colors/main/assets/images/cover.png">
<!-- Font Rubik -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Rubik:wght@500;700&display=swap" rel="stylesheet">
<!-- Style -->
<link rel="stylesheet" href="/src/styles/style.css">
<style>
[v-cloak] {
display: none;
}
</style>
</head>
<body
class="grid-center"
v-cloak
@mounted="init"
@mousedown.once="audiosCatch([copySound], 3)"
@dblclick="scrollTo(0, 0)"
@contextmenu.prevent
@selectstart.prevent
@dragstart.prevent
>
<header :class="[{ animate: !isLoading }]">
<h1>Color Names</h1>
<p>
Modern browsers support {{ colors.length === 141 ? 141 : ''}} named colors. Use them by name, Hex color code or RGB value.
</p>
</header>
<p
v-if="marketplaces.length > 1"
:class="['marketplace', { animate: !isLoading }]"
>
Current marketplace:
<span
@click="changeCurrentMarketIndex"
title="Click to change the marketplace"
>
{{ marketplaces[marketIndex] }}
</span>
</p>
<ul :class="['cards', { animate: !isLoading }]">
<li class="card" v-for="color in colors" :key="color.name">
<div
class="color-display pointer"
:style="`background-color: ${color.hex};`"
title="Click to copy color name"
@click="copyColorCode(color, 'name')"
></div>
<h1
class="pointer"
:style="`${
color.name.length >= 19 ? 'font-size: 1.5em; margin: 0.5em;' :
color.name.length >= 17 ? 'font-size: 1.5em; margin: 0.7em;' :
color.name.length >= 15 ? 'font-size: 1.55em; margin: 0.7em;' :
''
}`"
title="Click to copy color name"
@click="copyColorCode(color, 'name')"
>
{{ color.name }}
<a
title="Go to NFT page"
:href="color.url[marketplaces[marketIndex]]"
target="_blank"
rel="noreferrer noopener"
onclick="event.stopPropagation()"
>
<img class="eth" src="/assets/images/ETH.svg" alt="">
</a>
</h1>
<div
class="hex-section pointer"
title="Click to copy HEX code"
@click="copyColorCode(color, 'hex')"
>
<div class="title uppercase">HEX CODE</div>
<div class="hex-value">{{ color.hex }}</div>
</div>
<div
class="rgb-section pointer"
title="Click to copy RGB value"
@click="copyColorCode(color, 'rgb')"
>
<div class="title uppercase">RGB VALUE</div>
<div class="rgb-value">{{ color.rgb }}</div>
</div>
</li>
</ul>
<script type="module">
import { createApp } from '/src/scripts/petite-vue.js';
import {
getQueryParams, getData, copyText, playAudio, audiosCatch
} from '/src/scripts/utils.js';
createApp({
isLoading: true,
marketplaces: [],
marketIndex: 0,
colors: [],
copySound: new Audio('/assets/audios/modern-technology-select.wav'),
async init() {
const colorQueries = getQueryParams().colors?.split(' ') ?? [];
await this.loadColorData(colorQueries);
this.marketplaces = Object.keys(this.colors[0].url);
this.isLoading = false;
// console.log(`${this.colors.length} colors, ${getRepeatedItem(this.colors).length} repeated`);
},
async loadColorData(queries) {
const data = await getData('/src/data/colors.json');
if (!queries.length) return this.colors = data;
const matches = data.filter(color =>
queries.includes(this.getMinifiedColorName(color.name)));
if (!matches.length) return this.colors = data;
this.colors = matches;
},
copyColorCode(color, key) {
playAudio(this.copySound);
if (key === 'name')
return copyText(this.getMinifiedColorName(color.name));
copyText(color[key]);
},
getMinifiedColorName(colorName) {
return colorName.toLowerCase().replaceAll(' ', '');
},
audiosCatch(audios, minute = 1) {
audiosCatch(audios, minute);
},
changeCurrentMarketIndex() {
if (this.marketIndex === this.marketplaces.length - 1)
return this.marketIndex = 0;
this.marketIndex++;
}
}).mount();
</script>
</body>
</html>