22import { ref , computed , shallowRef , watch } from ' vue'
33import type { VueUiXyDatasetItem } from ' vue-data-ui'
44import { VueUiXy } from ' vue-data-ui/vue-ui-xy'
5- import { useDebounceFn } from ' @vueuse/core'
5+ import { useDebounceFn , useElementSize } from ' @vueuse/core'
66
77const {
88 weeklyDownloads,
@@ -18,8 +18,10 @@ const {
1818
1919const { accentColors, selectedAccentColor } = useAccentColor ()
2020const colorMode = useColorMode ()
21-
2221const resolvedMode = ref <' light' | ' dark' >(' light' )
22+ const rootEl = shallowRef <HTMLElement | null >(null )
23+
24+ const { width } = useElementSize (rootEl )
2325
2426onMounted (() => {
2527 resolvedMode .value = colorMode .value === ' dark' ? ' dark' : ' light'
@@ -50,6 +52,16 @@ const accent = computed(() => {
5052 return id ? (oklchToHex (accentColorValueById .value [id ]! ) ?? ' #8A8A8A' ) : ' #8A8A8A'
5153})
5254
55+ const mobileBreakpointWidth = 640
56+
57+ const isMobile = computed (() => {
58+ return width .value > 0 && width .value < mobileBreakpointWidth
59+ })
60+
61+ onMounted (() => {
62+ rootEl .value = document .documentElement
63+ })
64+
5365type ChartTimeGranularity = ' daily' | ' weekly' | ' monthly' | ' yearly'
5466type EvolutionData =
5567 | DailyDownloadPoint []
@@ -417,6 +429,7 @@ const formatter = ({ value }: { value: number }) => formatCompactNumber(value, {
417429const config = computed (() => ({
418430 theme: isDarkMode .value ? ' dark' : ' default' ,
419431 chart: {
432+ height: isMobile .value ? 850 : 600 ,
420433 userOptions: {
421434 buttons: {
422435 pdf: false ,
@@ -474,6 +487,7 @@ const config = computed(() => ({
474487 },
475488 },
476489 zoom: {
490+ maxWidth: 500 ,
477491 highlightColor: isDarkMode .value ? ' #2A2A2A' : ' #E1E5E8' ,
478492 minimap: {
479493 show: true ,
@@ -699,9 +713,4 @@ const config = computed(() => ({
699713 background : var (--bg-elevated ) !important ;
700714 box-shadow : none !important ;
701715}
702-
703- .vue-data-ui-zoom {
704- max-width : 500px ;
705- margin : 0 auto ;
706- }
707716 </style >
0 commit comments