@@ -8,7 +8,7 @@ const props = withDefaults(
88 theme? : ' light' | ' dark'
99 color? : string
1010 }>(),
11- { theme: ' dark ' },
11+ { theme: ' light ' },
1212)
1313
1414const t = computed (() => SHARE_CARD_THEMES [props .theme ])
@@ -20,41 +20,8 @@ const primaryColor = computed(() => {
2020 return ACCENT_COLOR_TOKENS .sky [props .theme ].hex
2121})
2222
23- function withAlpha(color : string , alpha : number ): string {
24- if (color .startsWith (' oklch(' )) return color .replace (' )' , ` / ${alpha }) ` )
25- if (color .startsWith (' #' ))
26- return (
27- color +
28- Math .round (alpha * 255 )
29- .toString (16 )
30- .padStart (2 , ' 0' )
31- )
32- return color
33- }
34-
35- function formatNum(n : number ) {
36- return Intl .NumberFormat (' en' , { notation: ' compact' , maximumFractionDigits: 1 }).format (n )
37- }
38-
39- function formatBytes(bytes : number ) {
40- if (! + bytes ) return ' —'
41- const k = 1024
42- const sizes = [' B' , ' KB' , ' MB' , ' GB' ] as const
43- const i = Math .floor (Math .log (bytes ) / Math .log (k ))
44- return ` ${parseFloat ((bytes / k ** i ).toFixed (1 ))} ${sizes [i ]} `
45- }
46-
47- function formatDate(iso : string ) {
48- return new Date (iso ).toLocaleDateString (' en-US' , {
49- month: ' short' ,
50- day: ' numeric' ,
51- year: ' numeric' ,
52- })
53- }
54-
55- function truncate(s : string , n : number ) {
56- return s .length > n ? s .slice (0 , n - 1 ) + ' …' : s
57- }
23+ const compactFormatter = useCompactNumberFormatter ()
24+ const bytesFormatter = useBytesFormatter ()
5825
5926const { data : resolvedVersion } = await useResolvedVersion (
6027 computed (() => props .name ),
@@ -151,7 +118,7 @@ const fontMono = "'Geist Mono', ui-monospace, monospace"
151118 class =" text-[40px] font-medium leading-none tracking-[-1.5px]"
152119 :style =" { color: t.text, fontFamily: fontMono }"
153120 >
154- {{ formatNum (weeklyDownloads) }}
121+ {{ compactFormatter.format (weeklyDownloads) }}
155122 </span >
156123 <span class =" text-[22px] font-light" :style =" { color: t.textMuted }" >weekly</span >
157124 </div >
@@ -171,15 +138,15 @@ const fontMono = "'Geist Mono', ui-monospace, monospace"
171138 v-if =" hasTypes"
172139 class =" flex items-center text-[20px] font-light py-1 px-[14px] rounded-[6px] leading-[1.6]"
173140 :style =" {
174- border: `1px solid ${withAlpha(t.border, 0.6) }`,
141+ border: `1px solid ${t.borderMuted }`,
175142 color: t.textSubtle,
176143 }"
177144 >Types</span
178145 >
179146 <span
180147 class =" flex items-center text-[20px] font-light py-1 px-[14px] rounded-[6px] leading-[1.6]"
181148 :style =" {
182- border: `1px solid ${withAlpha(t.border, 0.6) }`,
149+ border: `1px solid ${t.borderMuted }`,
183150 color: t.textSubtle,
184151 }"
185152 >{{ moduleFormat }}</span
@@ -188,7 +155,7 @@ const fontMono = "'Geist Mono', ui-monospace, monospace"
188155 v-if =" license"
189156 class =" flex items-center text-[20px] font-light py-1 px-[14px] rounded-[6px] leading-[1.6]"
190157 :style =" {
191- border: `1px solid ${withAlpha(t.border, 0.6) }`,
158+ border: `1px solid ${t.borderMuted }`,
192159 color: t.textSubtle,
193160 }"
194161 >{{ license }}</span
@@ -197,8 +164,8 @@ const fontMono = "'Geist Mono', ui-monospace, monospace"
197164 v-if =" repoSlug"
198165 class =" flex items-center text-[20px] font-light py-1 px-[14px] rounded-[6px] leading-[1.6]"
199166 :style =" {
200- border: `1px solid ${withAlpha(t.border, 0.5) }`,
201- color: withAlpha(t.textSubtle, 0.8) ,
167+ border: `1px solid ${t.borderFaint }`,
168+ color: t.textFaint ,
202169 fontFamily: fontMono,
203170 }"
204171 >{{ repoSlug }}</span
@@ -228,7 +195,7 @@ const fontMono = "'Geist Mono', ui-monospace, monospace"
228195 <span
229196 class =" text-[24px] font-normal leading-none tracking-[-0.3px]"
230197 :style =" { color: t.textMuted }"
231- >{{ formatNum (stars) }}</span
198+ >{{ compactFormatter.format (stars) }}</span
232199 >
233200 </div >
234201
@@ -252,7 +219,7 @@ const fontMono = "'Geist Mono', ui-monospace, monospace"
252219 <span
253220 class =" text-[24px] font-normal leading-none tracking-[-0.3px]"
254221 :style =" { color: t.textMuted }"
255- >{{ formatNum (forks) }}</span
222+ >{{ compactFormatter.format (forks) }}</span
256223 >
257224 </div >
258225
@@ -276,7 +243,7 @@ const fontMono = "'Geist Mono', ui-monospace, monospace"
276243 <span
277244 class =" text-[24px] font-normal leading-none tracking-[-0.3px]"
278245 :style =" { color: t.textMuted }"
279- >{{ formatBytes (unpackedSize) }}</span
246+ >{{ bytesFormatter.format (unpackedSize) }}</span
280247 >
281248 </div >
282249
0 commit comments