Spaces:
Sleeping
Sleeping
Keldos
commited on
Commit
•
0546163
1
Parent(s):
1f13df7
feat: 重绘参数滑块样式
Browse files太难了,这个东西太难了……而且我放弃了Firefox的兼容性
- assets/custom.css +34 -0
- assets/custom.js +22 -0
assets/custom.css
CHANGED
@@ -170,6 +170,40 @@ input:checked + .apSlider::before {
|
|
170 |
content:"🌚";
|
171 |
}
|
172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
#submit_btn, #cancel_btn {
|
174 |
height: 42px !important;
|
175 |
}
|
|
|
170 |
content:"🌚";
|
171 |
}
|
172 |
|
173 |
+
/* Override Slider Styles (for webkit browsers like Safari and Chrome)
|
174 |
+
* 好希望这份提案能早日实现 https://github.com/w3c/csswg-drafts/issues/4410
|
175 |
+
* 进度滑块在各个平台还是太不统一了
|
176 |
+
*/
|
177 |
+
input[type="range"] {
|
178 |
+
-webkit-appearance: none;
|
179 |
+
height: 4px;
|
180 |
+
background: var(--input-background-fill);
|
181 |
+
border-radius: 5px;
|
182 |
+
background-image: linear-gradient(var(--primary-500),var(--primary-500));
|
183 |
+
background-size: 0% 100%;
|
184 |
+
background-repeat: no-repeat;
|
185 |
+
}
|
186 |
+
input[type="range"]::-webkit-slider-thumb {
|
187 |
+
-webkit-appearance: none;
|
188 |
+
height: 20px;
|
189 |
+
width: 20px;
|
190 |
+
border-radius: 50%;
|
191 |
+
border: solid 0.5px #ddd;
|
192 |
+
background-color: white;
|
193 |
+
cursor: ew-resize;
|
194 |
+
box-shadow: var(--input-shadow);
|
195 |
+
transition: background-color .1s ease;
|
196 |
+
}
|
197 |
+
input[type="range"]::-webkit-slider-thumb:hover {
|
198 |
+
background: var(--neutral-50);
|
199 |
+
}
|
200 |
+
input[type=range]::-webkit-slider-runnable-track {
|
201 |
+
-webkit-appearance: none;
|
202 |
+
box-shadow: none;
|
203 |
+
border: none;
|
204 |
+
background: transparent;
|
205 |
+
}
|
206 |
+
|
207 |
#submit_btn, #cancel_btn {
|
208 |
height: 42px !important;
|
209 |
}
|
assets/custom.js
CHANGED
@@ -296,6 +296,25 @@ function setChatbotScroll() {
|
|
296 |
var scrollHeight = chatbotWrap.scrollHeight;
|
297 |
chatbotWrap.scrollTo(0,scrollHeight)
|
298 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
|
300 |
function addChuanhuButton(botElement) {
|
301 |
var rawMessage = null;
|
@@ -475,6 +494,9 @@ var mObserver = new MutationObserver(function (mutationsList) {
|
|
475 |
document.querySelectorAll('#chuanhu_chatbot>.wrap>.message-wrap .message.bot').forEach(addChuanhuButton);
|
476 |
document.querySelectorAll('#chuanhu_chatbot>.wrap>.message-wrap .message.bot pre').forEach(addCopyCodeButton);
|
477 |
}
|
|
|
|
|
|
|
478 |
}
|
479 |
for (var node of mmutation.removedNodes) {
|
480 |
if (node.nodeType === 1 && node.classList.contains('message') && node.getAttribute('data-testid') === 'bot') {
|
|
|
296 |
var scrollHeight = chatbotWrap.scrollHeight;
|
297 |
chatbotWrap.scrollTo(0,scrollHeight)
|
298 |
}
|
299 |
+
var rangeInputs = null;
|
300 |
+
var numberInputs = null;
|
301 |
+
function setSlider() {
|
302 |
+
rangeInputs = document.querySelectorAll('input[type="range"]');
|
303 |
+
numberInputs = document.querySelectorAll('input[type="number"]')
|
304 |
+
setSliderRange();
|
305 |
+
rangeInputs.forEach(rangeInput => {
|
306 |
+
rangeInput.addEventListener('input', setSliderRange);
|
307 |
+
});
|
308 |
+
numberInputs.forEach(numberInput => {
|
309 |
+
numberInput.addEventListener('input', setSliderRange);
|
310 |
+
})
|
311 |
+
}
|
312 |
+
function setSliderRange() {
|
313 |
+
var range = document.querySelectorAll('input[type="range"]');
|
314 |
+
range.forEach(range => {
|
315 |
+
range.style.backgroundSize = (range.value - range.min) / (range.max - range.min) * 100 + '% 100%';
|
316 |
+
});
|
317 |
+
}
|
318 |
|
319 |
function addChuanhuButton(botElement) {
|
320 |
var rawMessage = null;
|
|
|
494 |
document.querySelectorAll('#chuanhu_chatbot>.wrap>.message-wrap .message.bot').forEach(addChuanhuButton);
|
495 |
document.querySelectorAll('#chuanhu_chatbot>.wrap>.message-wrap .message.bot pre').forEach(addCopyCodeButton);
|
496 |
}
|
497 |
+
if (node.tagName === 'INPUT' && node.getAttribute('type') === 'range') {
|
498 |
+
setSlider();
|
499 |
+
}
|
500 |
}
|
501 |
for (var node of mmutation.removedNodes) {
|
502 |
if (node.nodeType === 1 && node.classList.contains('message') && node.getAttribute('data-testid') === 'bot') {
|