@@ -182,14 +182,14 @@ const heatmapCells = computed(() =>
182182 ),
183183);
184184
185- const heatColors = [" #ebedf0 " , " #9be9a8 " , " #40c463 " , " #30a14e " , " #216e39 " ] ;
186-
187- function heatColor (chars : number ): string {
188- if (chars === 0 ) return heatColors [ 0 ] ;
189- if (chars < 500 ) return heatColors [ 1 ] ;
190- if (chars < 2000 ) return heatColors [ 2 ] ;
191- if (chars < 5000 ) return heatColors [ 3 ] ;
192- return heatColors [ 4 ] ;
185+ const heatLevels = [0 , 1 , 2 , 3 , 4 ] as const ;
186+
187+ function heatLevel (chars : number ): number {
188+ if (chars === 0 ) return 0 ;
189+ if (chars < 500 ) return 1 ;
190+ if (chars < 2000 ) return 2 ;
191+ if (chars < 5000 ) return 3 ;
192+ return 4 ;
193193}
194194
195195// 今日字符分类细分
@@ -491,8 +491,8 @@ onUnmounted(() => {
491491 v-for =" day in heatmapCells"
492492 :key =" day.date"
493493 class =" heatmap-cell"
494+ :class =" `heat-${heatLevel(day.chars)}`"
494495 :style =" {
495- backgroundColor: heatColor(day.chars),
496496 gridRow: day.weekday + 1,
497497 gridColumn: day.weekIndex + 1,
498498 }"
@@ -504,10 +504,10 @@ onUnmounted(() => {
504504 <div class =" heatmap-legend" >
505505 <span class =" legend-label" >少</span >
506506 <span
507- v-for =" (c, i) in heatColors "
507+ v-for =" i in heatLevels "
508508 :key =" i"
509509 class =" legend-box"
510- :style = " { backgroundColor: c } "
510+ :class = " `heat-${i}` "
511511 ></span >
512512 <span class =" legend-label" >多</span >
513513 </div >
@@ -730,7 +730,7 @@ onUnmounted(() => {
730730.loading-hint {
731731 text-align : center ;
732732 padding : 40px ;
733- color : var (--text-secondary );
733+ color : hsl ( var (--muted-foreground ) );
734734}
735735
736736/* 数字卡片 */
@@ -742,8 +742,8 @@ onUnmounted(() => {
742742}
743743
744744.stat-card {
745- background : var (--card-bg , #fff );
746- border : 1px solid var (--border-color , #e5e7eb );
745+ background : hsl ( var (--card ) );
746+ border : 1px solid hsl ( var (--border ) );
747747 border-radius : 8px ;
748748 padding : 16px ;
749749 text-align : center ;
@@ -752,19 +752,19 @@ onUnmounted(() => {
752752.stat-value {
753753 font-size : 24px ;
754754 font-weight : 700 ;
755- color : var (--text-primary );
755+ color : hsl ( var (--foreground ) );
756756 line-height : 1.2 ;
757757}
758758
759759.stat-label {
760760 font-size : 12px ;
761- color : var (--text-secondary );
761+ color : hsl ( var (--muted-foreground ) );
762762 margin-top : 4px ;
763763}
764764
765765.stat-detail {
766766 font-size : 11px ;
767- color : var (--text-tertiary , #999 );
767+ color : hsl ( var (--muted-foreground ) / 0.8 );
768768 margin-top : 2px ;
769769}
770770
@@ -797,7 +797,7 @@ onUnmounted(() => {
797797.weekday-labels span {
798798 font-size : 10px ;
799799 line-height : 12px ;
800- color : var (--text-tertiary , #8b949e );
800+ color : hsl ( var (--muted-foreground ) );
801801}
802802
803803.heatmap-right {
@@ -824,13 +824,37 @@ onUnmounted(() => {
824824 box-sizing : border-box ;
825825}
826826
827+ /* GitHub-style 热力图色阶(浅色) */
828+ .heatmap-cell.heat-0 ,
829+ .legend-box.heat-0 {
830+ background : #ebedf0 ;
831+ }
832+ .heatmap-cell.heat-1 ,
833+ .legend-box.heat-1 {
834+ background : #9be9a8 ;
835+ }
836+ .heatmap-cell.heat-2 ,
837+ .legend-box.heat-2 {
838+ background : #40c463 ;
839+ }
840+ .heatmap-cell.heat-3 ,
841+ .legend-box.heat-3 {
842+ background : #30a14e ;
843+ }
844+ .heatmap-cell.heat-4 ,
845+ .legend-box.heat-4 {
846+ background : #216e39 ;
847+ }
848+
849+ /* 暗色色阶(GitHub dark) — 用 :deep 父级匹配 .dark 不行,改在下方非 scoped 块定义 */
850+
827851.heatmap-legend {
828852 display : inline-flex ;
829853 align-items : center ;
830854 align-self : flex-end ;
831855 gap : 4px ;
832856 font-size : 11px ;
833- color : var (--text-secondary );
857+ color : hsl ( var (--muted-foreground ) );
834858 white-space : nowrap ;
835859 margin-top : 2px ;
836860}
@@ -857,7 +881,7 @@ onUnmounted(() => {
857881 left : 50% ;
858882 transform : translate (-50% , -50% );
859883 font-size : 13px ;
860- color : var (--text-tertiary , #bbb );
884+ color : hsl ( var (--muted-foreground ) );
861885 pointer-events : none ;
862886 z-index : 1 ;
863887}
@@ -886,7 +910,7 @@ onUnmounted(() => {
886910}
887911
888912.hour-bar-zero {
889- background : var (--border-color , #e5e7eb );
913+ background : hsl ( var (--border ) );
890914 opacity : 0.5 ;
891915}
892916
@@ -898,14 +922,14 @@ onUnmounted(() => {
898922
899923.hour-label {
900924 font-size : 10px ;
901- color : var (--text-secondary );
925+ color : hsl ( var (--muted-foreground ) );
902926 width : calc (100% / 8 );
903927 text-align : left ;
904928}
905929
906930.hour-label {
907931 font-size : 10px ;
908- color : var (--text-secondary );
932+ color : hsl ( var (--muted-foreground ) );
909933 margin-top : 2px ;
910934}
911935
@@ -922,26 +946,26 @@ onUnmounted(() => {
922946 justify-content : space-between ;
923947 align-items : center ;
924948 padding : 6px 8px ;
925- background : var (--bg- secondary , #f9fafb );
949+ background : hsl ( var (--secondary ) );
926950 border-radius : 6px ;
927951}
928952
929953.detail-label {
930954 font-size : 13px ;
931- color : var (--text-secondary );
955+ color : hsl ( var (--muted-foreground ) );
932956}
933957
934958.detail-value {
935959 font-size : 13px ;
936960 font-weight : 600 ;
937- color : var (--text-primary );
961+ color : hsl ( var (--foreground ) );
938962}
939963
940964/* 水平条形图 */
941965.sub-title {
942966 font-size : 13px ;
943967 font-weight : 600 ;
944- color : var (--text-secondary );
968+ color : hsl ( var (--muted-foreground ) );
945969 margin-top : 12px ;
946970 margin-bottom : 6px ;
947971}
@@ -961,15 +985,15 @@ onUnmounted(() => {
961985.bar-label {
962986 width : 64px ;
963987 font-size : 12px ;
964- color : var (--text-secondary );
988+ color : hsl ( var (--muted-foreground ) );
965989 text-align : right ;
966990 flex-shrink : 0 ;
967991}
968992
969993.bar-track {
970994 flex : 1 ;
971995 height : 16px ;
972- background : var (--bg- secondary , #f3f4f6 );
996+ background : hsl ( var (--secondary ) );
973997 border-radius : 4px ;
974998 overflow : hidden ;
975999}
@@ -1001,7 +1025,7 @@ onUnmounted(() => {
10011025.bar-pct {
10021026 width : 36px ;
10031027 font-size : 12px ;
1004- color : var (--text-secondary );
1028+ color : hsl ( var (--muted-foreground ) );
10051029 text-align : right ;
10061030 flex-shrink : 0 ;
10071031}
@@ -1040,3 +1064,32 @@ onUnmounted(() => {
10401064 transform : translateX (-50% ) rotate (45deg );
10411065}
10421066 </style >
1067+
1068+ <style >
1069+ /* 暗色模式下热力图色阶(GitHub Dark)—— 放在非 scoped 块,
1070+ 因为 scoped 编译器会错误折叠 :global(.dark) ... 链式选择器。
1071+ 选择器加 html. 提高特异性,确保稳定覆盖。 */
1072+ html .dark .heatmap-cell {
1073+ border-color : rgba (255 , 255 , 255 , 0.05 );
1074+ }
1075+ html .dark .heatmap-cell.heat-0 ,
1076+ html .dark .legend-box.heat-0 {
1077+ background : #161b22 ;
1078+ }
1079+ html .dark .heatmap-cell.heat-1 ,
1080+ html .dark .legend-box.heat-1 {
1081+ background : #0e4429 ;
1082+ }
1083+ html .dark .heatmap-cell.heat-2 ,
1084+ html .dark .legend-box.heat-2 {
1085+ background : #006d32 ;
1086+ }
1087+ html .dark .heatmap-cell.heat-3 ,
1088+ html .dark .legend-box.heat-3 {
1089+ background : #26a641 ;
1090+ }
1091+ html .dark .heatmap-cell.heat-4 ,
1092+ html .dark .legend-box.heat-4 {
1093+ background : #39d353 ;
1094+ }
1095+ </style >
0 commit comments