-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
192 lines (172 loc) · 6.19 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
<title>Color Picker</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@simonwep/pickr/dist/themes/classic.min.css"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<style>
body {
background-color: #f0f4f8;
padding-top: 30px;
margin: 0;
font-family: 'Arial', sans-serif;
}
.pickr {
display: none;
}
.color-container {
max-width: 600px;
margin: auto;
text-align: center;
position: relative;
}
h1 {
font-size: 2rem;
margin-bottom: 20px;
color: #333;
}
#selectedColorPanel {
margin-top: 20px;
height: 90px;
display: flex;
align-items: center;
justify-content: space-between;
border-radius: 12px;
font-size: 22px;
font-weight: bold;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
transition: background-color 0.3s ease-in-out;
padding: 0 20px;
position: relative;
overflow: hidden;
}
#colorPickerContainer {
display: none !important;
}
#colorCode {
background-color: rgba(0, 0, 0, 0.5);
padding: 4px 10px;
border-radius: 6px;
color: white;
transition: color 0.3s ease-in-out;
}
.icon-container {
display: flex;
align-items: center;
gap: 10px;
}
.paint-palette, .copy-icon {
background-color: rgba(0, 0, 0, 0.5);
padding: 8px;
border-radius: 50%;
font-size: 28px;
color: white;
transition: color 0.3s ease-in-out;
}
.toast {
position: fixed;
top: 10px;
right: 10px;
z-index: 1050;
}
@media (max-width: 576px) {
h1 {
font-size: 1.5rem;
}
#selectedColorPanel {
height: 80px;
font-size: 18px;
}
.paint-palette, .copy-icon {
font-size: 24px;
padding: 6px;
}
}
</style>
</head>
<body>
<div class="container color-container">
<h1>Color Picker</h1>
<div class="mt-4 p-3 rounded shadow-sm" id="selectedColorPanel" style="background-color: #4F46E5;">
<div class="icon-container">
<i class="fas fa-palette paint-palette"></i>
<span id="colorCode">#4F46E5</span>
</div>
<i class="fas fa-copy copy-icon" id="copyIcon" data-clipboard-target="#colorCode"></i>
</div>
<!-- Контейнер для пикера -->
<div id="colorPickerContainer"></div>
<div class="toast align-items-center text-white bg-success border-0" id="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="d-flex">
<div class="toast-body">
Color copied to clipboard!
</div>
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/@simonwep/pickr/dist/pickr.es5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script>
const pickr = Pickr.create({
el: '#colorPickerContainer', // Изменено для размещения пикера в контейнере
theme: 'classic',
swatches: [
'rgba(244, 67, 54, 1)',
'rgba(233, 30, 99, 0.95)',
'rgba(156, 39, 176, 0.9)',
'rgba(103, 58, 183, 0.85)',
'rgba(63, 81, 181, 0.8)',
'rgba(33, 150, 243, 0.75)',
'rgba(3, 169, 244, 0.7)',
'rgba(0, 188, 212, 0.7)',
'rgba(0, 150, 136, 0.75)',
'rgba(76, 175, 80, 0.8)',
'rgba(139, 195, 74, 0.85)',
'rgba(205, 220, 57, 0.9)',
'rgba(255, 235, 59, 0.95)',
'rgba(255, 193, 7, 1)'
],
showAlways: true,
components: {
preview: true,
opacity: true,
hue: true,
interaction: {
hex: true,
input: true,
clear: true,
save: true
}
}
});
const colorCode = document.getElementById('colorCode');
const selectedColorPanel = document.getElementById('selectedColorPanel');
const toast = new bootstrap.Toast(document.getElementById('toast'));
pickr.on('change', (color) => {
const hexColor = color.toHEXA().toString();
colorCode.textContent = hexColor;
selectedColorPanel.style.backgroundColor = hexColor;
if (hexColor.toLowerCase() === '#ffffff') {
colorCode.style.color = '#000';
document.querySelectorAll('.paint-palette, .copy-icon').forEach(icon => {
icon.style.color = '#000';
});
} else {
colorCode.style.color = 'white';
document.querySelectorAll('.paint-palette, .copy-icon').forEach(icon => {
icon.style.color = 'white';
});
}
});
new ClipboardJS('#copyIcon').on('success', () => {
toast.show();
});
pickr.show();
</script>
</body>
</html>