-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMake-GitHub-Great-Again.js
More file actions
3222 lines (2831 loc) · 115 KB
/
Copy pathMake-GitHub-Great-Again.js
File metadata and controls
3222 lines (2831 loc) · 115 KB
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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name Make-GitHub-Great-Again
// @name:en Make-GitHub-Great-Again
// @namespace https://github.com
// @version 5.3.0
// @description 为 Release 的项目添加背景色,识别文件系统平台类型,以及高亮自定义关键词
// @description:en Add background colors to each Release Asset, identify the file system platform type and custom keywords highlighter.
// @author https://github.com/HumanMus1c
// @match https://github.com/*/releases*
// @grant GM_addStyle
// @grant GM_registerMenuCommand
// @grant GM_getValue
// @grant GM_setValue
// @grant unsafeWindow
// @license MIT
// ==/UserScript==
(function () {
// 国际化配置
const i18n = {
isCN: navigator.language.startsWith("zh"),
t: function (key) {
const texts = {
settingsTitle: { zh: "MGGA", en: "MGGA" },
close: { zh: "关闭", en: "Close" },
oddRow: { zh: "设置奇数行颜色", en: "Set Odd Row Color" },
evenRow: { zh: "设置偶数行颜色", en: "Set Even Row Color" },
hoverRow: { zh: "设置悬停颜色", en: "Set Hover Color" },
svgIdentify: { zh: "识别系统平台", en: "Platform Identification" },
highlightTitle: { zh: "自定义高亮关键词", en: "Custom Highlight Keywords" },
newKeywordPlaceholder: { zh: "输入新关键词", en: "Enter new keyword" },
add: { zh: "添加", en: "Add" },
reset: { zh: "重置", en: "Reset" },
cancel: { zh: "取消", en: "Cancel" },
confirm: { zh: "确认", en: "Confirm" },
resetTitle: { zh: "重置为当前主题默认颜色", en: "Reset to theme default colors" },
enabledTitle: { zh: "已启用,点击禁用", en: "Enabled, click to disable" },
disabledTitle: { zh: "已禁用,点击启用", en: "Disabled, click to enable" },
promptOdd: { zh: "请输入奇数行背景色(HEX格式,如#f8f9fa):", en: "Enter odd row background color (HEX, e.g., #f8f9fa):" },
promptEven: { zh: "请输入偶数行背景色(HEX格式,如#ffffff):", en: "Enter even row background color (HEX, e.g., #ffffff):" },
promptHover: { zh: "请输入鼠标悬停颜色(HEX格式,如#e9ecef):", en: "Enter hover color (HEX, e.g., #e9ecef):" },
confirmReset: { zh: "确定要重置 {theme} 主题的自定义颜色吗?", en: "Are you sure you want to reset the custom colors for {theme} theme?" },
darkTheme: { zh: "暗色", en: "Dark" },
lightTheme: { zh: "亮色", en: "Light" },
menuSettings: { zh: "⚙️ 设置", en: "⚙️ Settings" },
menuOdd: { zh: "⚙️ 设置奇数行颜色", en: "⚙️ Set Odd Row Color" },
menuEven: { zh: "⚙️ 设置偶数行颜色", en: "⚙️ Set Even Row Color" },
menuHover: { zh: "⚙️ 设置悬停行颜色", en: "⚙️ Set Hover Row Color" },
menuReset: { zh: "🔄 重置为默认颜色", en: "🔄 Reset to Default Colors" },
keywordColor: { zh: "关键词颜色", en: "Keyword Color" },
builtinPicker: { zh: "初始化内置颜色选择器...", en: "Initializing built-in color picker..." },
formatToggle: { zh: "点击切换颜色格式(HEX ↔ RGB ↔ HSL)", en: "Click to toggle format (HEX ↔ RGB ↔ HSL)" },
clear: { zh: "清除", en: "Clear" },
noKeywords: { zh: "暂无自定义关键词", en: "No custom keywords" },
defaultTag: { zh: "默认", en: "Default" },
restore: { zh: "恢复", en: "Restore" },
deleteRule: { zh: "删除", en: "Delete" }
};
return texts[key] ? (this.isCN ? texts[key].zh : texts[key].en) : key;
}
};
// 更可靠的主题检测函数
function getCurrentTheme() {
// 检测GitHub的显式主题设置
const explicitTheme =
document.documentElement.getAttribute("data-color-mode");
if (explicitTheme === "light" || explicitTheme === "dark") {
return explicitTheme;
}
// 检测GitHub的类名主题设置
if (document.documentElement.classList.contains("dark")) {
return "dark";
}
// 检测系统级主题设置
return window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light";
}
// 默认颜色配置(亮色主题)
const defaultColorsLight = {
oddRowColor: "#f8f9fa",
evenRowColor: "#ffffff",
hoverColor: "#e9ecef",
};
// 默认颜色配置(暗色主题)
const defaultColorsDark = {
oddRowColor: "#161b22",
evenRowColor: "#0d1117",
hoverColor: "#30363d",
};
// 获取当前主题的默认颜色
function getDefaultColors() {
return getCurrentTheme() === "dark"
? defaultColorsDark
: defaultColorsLight;
}
// 创建样式元素并添加到文档头部
const styleElement = document.createElement("style");
styleElement.id = "Make-GitHub-Great-Again-style";
document.head.appendChild(styleElement);
// 应用颜色的函数 - 根据当前主题动态更新样式
function applyColors(overrides = null) {
const theme = getCurrentTheme();
const themeKey = `customColors${theme.charAt(0).toUpperCase() + theme.slice(1)}`;
const customColors = GM_getValue(themeKey, null);
const colors = (overrides && overrides.colors) || customColors || getDefaultColors();
// 获取切换状态
const isOddEnabled = overrides && overrides.toggles ? overrides.toggles.odd : GM_getValue("colorToggleOdd", true);
const isEvenEnabled = overrides && overrides.toggles ? overrides.toggles.even : GM_getValue("colorToggleEven", true);
const isHoverEnabled = overrides && overrides.toggles ? overrides.toggles.hover : GM_getValue("colorToggleHover", true);
// 动态更新样式
styleElement.textContent = `
.Box.Box--condensed li.Box-row:nth-child(odd) {
background-color: ${isOddEnabled ? colors.oddRowColor : "transparent"} !important;
}
.Box.Box--condensed li.Box-row:nth-child(even) {
background-color: ${isEvenEnabled ? colors.evenRowColor : "transparent"} !important;
}
.Box.Box--condensed li.Box-row:hover {
background-color: ${isHoverEnabled ? colors.hoverColor : "transparent"} !important;
}
`;
// 如果对话框是打开的,更新对话框中的颜色 (仅在非预览模式下更新,防止实时调整被重置)
const dialog = document.querySelector(".color-picker-dialog.visible");
if (dialog && !overrides) {
updateDialogColors();
}
}
// 更新对话框中的颜色显示
function updateDialogColors() {
const dialog = document.querySelector(".color-picker-dialog");
if (!dialog) return;
const currentTheme = getCurrentTheme();
const themeKey = `customColors${currentTheme.charAt(0).toUpperCase() + currentTheme.slice(1)}`;
const customColors = GM_getValue(themeKey, null);
const colors =
customColors ||
(currentTheme === "dark" ? defaultColorsDark : defaultColorsLight);
// 更新标题
const title = dialog.querySelector(".color-picker-title");
const versionStr =
typeof GM_info !== "undefined" ? GM_info.script.version : "4.1";
if (title) {
const themeLabel = currentTheme === "dark" ? i18n.t("darkTheme") : i18n.t("lightTheme");
title.innerHTML = `<svg viewBox="0 0 16 16" width="1.1em" height="1.1em" fill="currentColor" style="vertical-align:-0.15em"><path d="M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"/></svg> ${i18n.t("settingsTitle")} <span style="font-size: 0.8em; font-weight: normal; opacity: 0.7;">v${versionStr}</span> <span style="font-size: 0.6em; font-weight: normal; opacity: 0.5;">(${themeLabel})</span>`;
}
// 更新颜色按钮
const oddRowColorBtn = dialog.querySelector("#oddRowColorBtn");
const evenRowColorBtn = dialog.querySelector("#evenRowColorBtn");
const hoverColorBtn = dialog.querySelector("#hoverColorBtn");
if (oddRowColorBtn)
oddRowColorBtn.style.backgroundColor = colors.oddRowColor;
if (evenRowColorBtn)
evenRowColorBtn.style.backgroundColor = colors.evenRowColor;
if (hoverColorBtn) hoverColorBtn.style.backgroundColor = colors.hoverColor;
}
// 初始应用颜色
applyColors();
// 监听主题变化并动态更新样式
function setupThemeObserver() {
// 监听HTML元素的属性变化
const observer = new MutationObserver((mutations) => {
for (const mutation of mutations) {
if (
mutation.attributeName === "data-color-mode" ||
mutation.attributeName === "class"
) {
applyColors();
break;
}
}
});
// 监听系统主题变化
const systemThemeMedia = window.matchMedia("(prefers-color-scheme: dark)");
systemThemeMedia.addEventListener("change", applyColors);
// 开始观察文档元素
observer.observe(document.documentElement, {
attributes: true,
attributeFilter: ["data-color-mode", "class"],
});
}
// 设置主题观察器
setupThemeObserver();
// 添加CSS样式 - 对话框样式(固定不变)
GM_addStyle(`
:root {
--mgga-text-scale: 1.0em;
--mgga-btn-scale: 0.8em;
}
/* 对话框样式 - 修复主题跟随问题 */
.color-picker-dialog {
position: fixed;
top: 50%; /* 垂直居中 */
left: 1em; /* 距离左侧缩进跟随缩放 */
transform: translateY(-50%) translateX(-100%);
border-radius: 0.5em;
padding: 1.25em;
box-shadow: 0 0.15em 1.5em rgba(0,0,0,0.2);
z-index: 10000;
min-width: 0 !important; max-width: min(20em, 90vw);
font-family: inherit; /* 继承页面字体 */
font-size: var(--mgga-text-scale); /* 文本字体总体缩放 */
/* 初始状态 - 不可见 */
opacity: 0;
visibility: hidden;
pointer-events: none;
/* 过渡动画设置 */
transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
}
/* 明亮主题样式 */
@media (prefers-color-scheme: light) {
.color-picker-dialog {
background: #ffffff;
border: 1px solid #d0d7de;
color: #24292f;
}
.color-picker-header {
border-bottom: 1px solid #d8dee4;
}
.color-picker-title {
color: #24292f;
}
.color-picker-close {
color: #57606a;
}
.color-picker-close:hover {
color: #24292f;
}
.menu-command {
color: #24292f;
}
.color-button {
border: 1px solid #d0d7de;
background: #f6f8fa;
}
}
/* 暗色主题样式 */
@media (prefers-color-scheme: dark) {
.color-picker-dialog {
background: #0d1117;
border: 1px solid #30363d;
color: #c9d1d9;
}
.color-picker-header {
border-bottom: 1px solid #21262d;
}
.color-picker-title {
color: #c9d1d9;
}
.color-picker-close {
color: #8b949e;
}
.color-picker-close:hover {
color: #c9d1d9;
}
.menu-command {
color: #c9d1d9;
}
.color-button {
border: 1px solid #30363d;
background: #161b22;
}
}
/* 对话框可见状态 */
.color-picker-dialog.visible {
opacity: 1;
visibility: visible;
pointer-events: auto;
transform: translateY(-50%) translateX(0);
}
.color-picker-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1em;
padding-bottom: 0.5em;
}
.color-picker-title {
font-weight: bold;
margin: 0;
font-size: 1.25em;
}
.color-picker-close {
cursor: pointer;
padding: 0.3em 0.6em;
font-size: 1.5em;
transition: all 0.3s ease;
}
.color-picker-close:hover {
transform: scale(1.1);
}
.color-picker-content {
display: flex;
flex-direction: column;
gap: 0.75em;
}
.color-picker-row {
display: flex;
align-items: center;
gap: 0.75em;
justify-content: space-between;
}
.menu-command {
font-size: 1em;
font-weight: 500;
min-width: 8em;
display: inline-flex;
align-items: center;
gap: 0.3em;
flex-wrap: nowrap;
}
.button-row {
display: flex;
justify-content: flex-end;
gap: 0.75em;
margin-top: 0.75em;
}
.dialog-button {
padding: 0.5em 1em;
border: none;
border-radius: 0.4em;
cursor: pointer;
font-weight: bold;
font-size: var(--mgga-btn-scale);
transition: all 0.3s ease;
font-family: inherit;
}
/* 按钮颜色保持不变 */
.cancel-button {
background-color: #007bff; /* 蓝色背景 */
color: white;
}
.cancel-button:hover {
background-color: #0069d9;
transform: translateY(-2px);
}
.confirm-button {
background-color: #ffa500; /* 橙黄色背景 */
color: black;
}
.confirm-button:hover {
background-color: #e69500;
transform: translateY(-2px);
}
/* 新添加的重置按钮样式 */
.reset-button {
background-color: #ff6b6b; /* 浅红色背景 */
color: white;
}
.reset-button:hover {
background-color: #ff5252; /* 悬停时加深红色 */
transform: translateY(-2px);
}
.color-button {
font-size: var(--mgga-btn-scale);
width: 2em;
height: 2em;
border-radius: 0.4em;
cursor: pointer;
transition: all 0.3s ease;
}
.color-button:hover {
transform: scale(1.1);
box-shadow: 0 0 5px rgba(0,0,0,0.1);
}
#svgToggleBtn:hover, #highlightToggleBtn:hover {
transform: none !important;
box-shadow: none !important;
}
.color-picker-container {
position: relative;
display: inline-flex;
align-items: center;
gap: 0.2em;
}
.color-picker-container input[type="color"] {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
opacity: 0;
cursor: pointer;
}
.color-picker-container .color-button {
position: relative;
}
/* 悬浮设置按钮样式 */
#mgga-float-btn {
position: fixed;
left: 1em;
top: 50%;
/* 保证居中显示,拖动时我们会修改top实现位移 */
transform: translateY(-50%);
width: 2.8em;
height: 2.8em;
background: rgba(255, 255, 255, 0.85);
border: 1px solid #d0d7de;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: var(--mgga-btn-scale); /* 按钮控件缩放 */
cursor: pointer;
z-index: 9999;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
user-select: none;
transition: opacity 0.4s ease, margin-left 0.4s ease, background 0.2s ease;
}
#mgga-float-btn:hover {
background: rgba(255, 255, 255, 1);
box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}
#mgga-float-btn:active {
cursor: grabbing;
}
@media (prefers-color-scheme: dark) {
#mgga-float-btn {
background: rgba(30, 30, 30, 0.85);
border-color: #30363d;
}
#mgga-float-btn:hover {
background: rgba(50, 50, 50, 1);
}
}
/* 悬浮按钮动画隐藏状态 (向右隐藏) */
#mgga-float-btn.hidden-to-right {
opacity: 0;
pointer-events: none;
/* 向右位移 */
margin-left: 2em;
}
/* 拖拽时的强制禁用动画类 */
#mgga-float-btn.is-dragging {
transition: none !important;
}
/* 自定义关键词高亮样式 */
#customKeywordsContainer {
display: flex;
flex-wrap: wrap;
gap: 0.4em;
align-content: flex-start;
}
.custom-keyword-item {
display: inline-flex;
align-items: center;
gap: 0.35em;
padding: 0.25em 0.45em;
background: rgba(125, 125, 125, 0.1);
border-radius: 0.3em;
font-size: 0.9em;
width: fit-content;
max-width: 100%;
}
.custom-keyword-item .keyword-text {
font-weight: bold;
white-space: nowrap;
}
.custom-keyword-item .keyword-color-swatch {
width: 1.1em;
height: 1.1em;
min-width: 1.1em;
border-radius: 0.3em;
border: 1px solid rgba(125, 125, 125, 0.3);
flex-shrink: 0;
cursor: pointer;
padding: 0;
margin: 0;
box-shadow: none;
display: inline-block;
}
.custom-keyword-item .keyword-action-btn {
cursor: pointer;
font-weight: bold;
font-size: 1em;
line-height: 1;
padding: 0 0.25em;
border-radius: 0.2em;
flex-shrink: 0;
user-select: none;
}
.custom-keyword-item .keyword-remove {
color: #d73a49;
}
.custom-keyword-item .keyword-remove:hover {
color: #cb2431;
}
.custom-keyword-item .keyword-restore {
color: #2da44e;
}
.custom-keyword-item .keyword-restore:hover {
color: #218838;
}
.custom-keyword-item.pending-delete {
background: rgba(215, 58, 73, 0.1);
opacity: 0.65;
}
.custom-keyword-item.pending-delete .keyword-text {
text-decoration: line-through;
font-weight: normal;
}
.custom-keyword-item.default-keyword-item {
background: rgba(125, 125, 125, 0.04);
}
.custom-keyword-item .keyword-default-tag {
font-size: 0.68em;
font-weight: bold;
padding: 0.1em 0.45em;
border-radius: 0.3em;
background: #0969da;
color: #fff;
flex-shrink: 0;
letter-spacing: 0.02em;
white-space: nowrap;
}
#customKeywordsContainer .keyword-empty-hint {
width: 100%;
color: gray;
font-size: 0.9em;
text-align: center;
padding: 0.5em 0;
}
#newKeywordInput { min-width: 0; } #newKeywordColorBtn { flex-shrink: 0; } #addKeywordBtn { white-space: nowrap; flex-shrink: 0; } .color-toggle-btn {
font-size: var(--mgga-btn-scale);
width: 1.8em;
height: 1.8em;
padding: 0;
border-radius: 0.3em;
cursor: pointer;
transition: all 0.2s ease;
background-color: transparent;
border: 1px solid rgba(125, 125, 125, 0.3);
color: inherit;
margin-right: 0.5em;
display: flex;
align-items: center;
justify-content: center;
}
.color-toggle-btn:hover {
background-color: rgba(100, 150, 255, 0.1);
border-color: #0969da;
color: #0969da;
transform: scale(1.05);
}
.color-toggle-btn.disabled {
opacity: 0.5;
background-color: rgba(125, 125, 125, 0.1);
border-color: rgba(125, 125, 125, 0.3);
color: rgba(125, 125, 125, 0.6);
}
/* 自定义color picker子面板样式 */
.custom-color-picker-panel {
position: fixed;
background: inherit;
border: 1px solid rgba(125, 125, 125, 0.3);
border-radius: 0.4em;
padding: 0.8em;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
z-index: 10001;
min-width: fit-content;
display: flex;
flex-direction: column;
gap: 0.6em;
max-width: 90vw;
}
.custom-color-picker-panel input[type="text"] {
padding: 0.3em 0.4em;
border: 1px solid rgba(125, 125, 125, 0.3);
border-radius: 0.3em;
background: transparent;
color: inherit;
font-family: monospace;
font-size: 0.9em;
width: 100%;
box-sizing: border-box;
}
.custom-color-picker-panel input[type="text"]:focus {
outline: none;
border-color: #0969da;
box-shadow: 0 0 0 2px rgba(9, 105, 218, 0.1);
}
.color-picker-controls {
display: flex;
gap: 0.3em;
align-items: center;
}
.color-picker-preview {
width: 2em;
height: 2em;
border: 1px solid rgba(125, 125, 125, 0.3);
border-radius: 0.3em;
cursor: pointer;
flex-shrink: 0;
}
.color-picker-preview:hover {
transform: scale(1.05);
}
.color-picker-clear-btn {
padding: 0.3em 0.6em;
border: 1px solid rgba(125, 125, 125, 0.3);
border-radius: 0.3em;
background: transparent;
color: #d73a49;
cursor: pointer;
font-weight: bold;
transition: all 0.2s ease;
font-size: 0.85em;
}
.color-picker-clear-btn:hover {
background-color: rgba(255, 0, 0, 0.1);
border-color: #d73a49;
}
/* 三库并排容器 */
.color-picker-libraries-container {
display: flex;
gap: 1em;
flex-wrap: wrap;
align-items: flex-start;
}
.color-picker-library-item {
flex: 0 1 auto;
min-width: fit-content;
padding: 0.6em;
border: 1px solid rgba(125, 125, 125, 0.2);
border-radius: 0.3em;
background: rgba(125, 125, 125, 0.05);
}
.color-picker-library-label {
font-size: 0.8em;
font-weight: bold;
margin-bottom: 0.4em;
opacity: 0.7;
display: block;
}
/* 内置颜色选择器样式 */
.builtin-color-picker-container {
display: flex;
flex-direction: column;
gap: 0.8em;
padding: 0.8em;
background: rgba(125, 125, 125, 0.05);
border-radius: 0.3em;
width: 250px; /* 固定宽度,防止切换模式时抖动 */
box-sizing: border-box;
}
.builtin-picker-top-section {
display: flex;
gap: 0.6em;
align-items: stretch;
}
.builtin-color-area-section {
flex: 1;
display: flex;
flex-direction: column;
}
.builtin-color-area-main {
position: relative;
width: 100%;
height: 150px;
border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: 0.2em;
cursor: crosshair;
overflow: hidden;
}
#color-area-canvas {
width: 100%;
height: 100%;
display: block;
}
.builtin-color-picker-point {
position: absolute;
width: 10px;
height: 10px;
border: 2px solid white;
border-radius: 50%;
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3),
inset 0 0 0 1px rgba(0, 0, 0, 0.3);
pointer-events: none;
top: 0;
left: 0;
transform: translate(-50%, -50%);
}
.builtin-hue-alpha-section {
display: flex;
flex-direction: column;
gap: 0.4em;
width: 20px;
}
.builtin-hue-slider-container {
position: relative;
width: 100%;
height: 150px;
border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: 0.2em;
cursor: pointer;
overflow: hidden;
}
.builtin-hue-strip {
width: 100%;
height: 100%;
background: linear-gradient(to bottom,
hsl(0, 100%, 50%),
hsl(30, 100%, 50%),
hsl(60, 100%, 50%),
hsl(90, 100%, 50%),
hsl(120, 100%, 50%),
hsl(150, 100%, 50%),
hsl(180, 100%, 50%),
hsl(210, 100%, 50%),
hsl(240, 100%, 50%),
hsl(270, 100%, 50%),
hsl(300, 100%, 50%),
hsl(330, 100%, 50%),
hsl(360, 100%, 50%)
);
}
.builtin-hue-picker {
position: absolute;
left: 0;
width: 100%;
height: 2px;
background: white;
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3);
top: 0;
pointer-events: none;
transform: translateY(-50%);
}
.builtin-picker-bottom-section {
display: flex;
flex-direction: column;
gap: 0.6em;
}
.builtin-input-group {
display: flex;
align-items: center;
gap: 0.4em;
width: 100%;
box-sizing: border-box;
}
.builtin-input-group label {
font-size: 0.8em;
font-weight: 600;
min-width: 3em;
opacity: 0.7;
}
.builtin-format-toggle-btn {
font-size: 0.8em;
font-weight: 600;
min-width: 3.5em;
padding: 0.3em 0.4em;
border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: 0.2em;
background: rgba(255, 255, 255, 0.3);
cursor: pointer;
transition: all 0.2s ease;
color: inherit;
text-align: center;
flex-shrink: 0;
}
.builtin-format-toggle-btn:hover {
background: rgba(255, 255, 255, 0.5);
border-color: #0969da;
color: #0969da;
}
.builtin-format-toggle-btn:active {
transform: scale(0.95);
}
@media (prefers-color-scheme: dark) {
.builtin-format-toggle-btn {
background: rgba(100, 100, 100, 0.2);
border-color: rgba(100, 100, 100, 0.3);
}
.builtin-format-toggle-btn:hover {
background: rgba(100, 100, 100, 0.4);
border-color: #58a6ff;
color: #58a6ff;
}
}
.builtin-color-hex-input {
flex: 1;
min-width: 0;
padding: 0.3em 0.5em;
border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: 0.2em;
font-size: 0.85em;
font-family: 'Courier New', monospace;
background: rgba(255, 255, 255, 0.5);
box-sizing: border-box;
}
.builtin-color-hex-input:focus {
outline: none;
border-color: #0969da;
background: white;
}
/* RGB/HSL三输入框容器样式 */
.builtin-multi-input-container {
display: flex;
gap: 0.3em;
align-items: center;
flex: 1;
min-width: 0;
box-sizing: border-box;
}
.builtin-color-value-input {
flex: 1;
width: 0;
min-width: 0;
padding: 0.3em 0.2em;
border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: 0.2em;
font-size: 0.85em;
font-family: 'Courier New', monospace;
background: rgba(255, 255, 255, 0.5);
text-align: center;
box-sizing: border-box;
}
.builtin-color-value-input:focus {
outline: none;
border-color: #0969da;
background: white;
}
@media (prefers-color-scheme: dark) {
.builtin-color-hex-input {
background: rgba(100, 100, 100, 0.2);
border-color: rgba(100, 100, 100, 0.3);
color: inherit;
}
.builtin-color-hex-input:focus {
background: rgba(100, 100, 100, 0.3);
border-color: #58a6ff;
}
.builtin-color-value-input {
background: rgba(100, 100, 100, 0.2);
border-color: rgba(100, 100, 100, 0.3);
color: inherit;
}
.builtin-color-value-input:focus {
background: rgba(100, 100, 100, 0.3);
border-color: #58a6ff;
}
}
.builtin-clear-btn {
padding: 0.3em 0.6em;
border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: 0.2em;
background: rgba(255, 255, 255, 0.3);
color: #d73a49;
cursor: pointer;
font-weight: bold;
font-size: 0.85em;
transition: all 0.2s ease;
flex-shrink: 0;
}
.builtin-clear-btn:hover {
background: rgba(255, 0, 0, 0.15);
border-color: #d73a49;
color: #cb2431;
}
.builtin-clear-btn:active {
transform: scale(0.95);
}
.builtin-preset-colors-row {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(1.5em, 1fr));
gap: 0.3em;
}
.builtin-preset-color-swatch {
width: 100%;
aspect-ratio: 1;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 0.15em;
cursor: pointer;
transition: all 0.15s ease;