Skip to content

Commit bb3e29c

Browse files
committed
feat(ui): support RTL layout for weekly downloads sparkline
Reverse the dataset order when the page direction is RTL so the sparkline reads right-to-left (newest data on the left). Add dir="ltr" on the chart container to prevent CSS logical properties from affecting SVG layout. Fixes #428
1 parent 6b5b847 commit bb3e29c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

app/components/Chart/SplitSparkline.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,20 @@ const { colors } = useCssVariables(
6666
)
6767
6868
const isDarkMode = computed(() => resolvedMode.value === 'dark')
69+
const isRtl = computed(() => {
70+
if (import.meta.server) return false
71+
return document.documentElement.dir === 'rtl'
72+
})
6973
7074
const datasets = computed<VueUiSparklineDatasetItem[][]>(() => {
7175
return (props.dataset ?? []).map(unit => {
72-
return props.dates.map((period, i) => {
76+
const items = props.dates.map((period, i) => {
7377
return {
7478
period,
7579
value: unit.series[i] ?? 0,
7680
}
7781
})
82+
return isRtl.value ? items.toReversed() : items
7883
})
7984
})
8085
@@ -192,7 +197,12 @@ const configs = computed(() => {
192197
<template>
193198
<div class="grid gap-8 sm:grid-cols-2">
194199
<ClientOnly v-for="(config, i) in configs" :key="`config_${i}`">
195-
<div @mouseleave="resetHover" @keydown.esc="resetHover" class="w-full max-w-[400px] mx-auto">
200+
<div
201+
@mouseleave="resetHover"
202+
@keydown.esc="resetHover"
203+
class="w-full max-w-[400px] mx-auto"
204+
dir="ltr"
205+
>
196206
<div class="flex gap-2 place-items-center">
197207
<div class="h-3 w-3">
198208
<svg viewBox="0 0 2 2" class="w-full">

0 commit comments

Comments
 (0)