@@ -16,8 +16,12 @@ const props = defineProps<{
1616const colorMode = useColorMode ()
1717const resolvedMode = shallowRef <' light' | ' dark' >(' light' )
1818const rootEl = shallowRef <HTMLElement | null >(null )
19+ const { width } = useElementSize (rootEl )
1920const { copy, copied } = useClipboard ()
2021
22+ const mobileBreakpointWidth = 640
23+ const isMobile = computed (() => width .value > 0 && width .value < mobileBreakpointWidth )
24+
2125const { colors } = useCssVariables (
2226 [
2327 ' --bg' ,
@@ -277,6 +281,13 @@ const highlightedAxis = shallowRef<AxisHighlight>(null)
277281function toggleAxisHighlight(state : AxisHighlight ) {
278282 highlightedAxis .value = state
279283}
284+
285+ const readyTeleport = shallowRef (false )
286+
287+ onMounted (async () => {
288+ await nextTick ()
289+ readyTeleport .value = true
290+ })
280291 </script >
281292
282293<template >
@@ -296,9 +307,7 @@ function toggleAxisHighlight(state: AxisHighlight) {
296307 </div >
297308
298309 <div class =" flex flex-col sm:flex-row gap-4 items-start" >
299- <div
300- class =" w-full sm:w-fit order-1 sm:order-2 flex flex-row sm:flex-col gap-2 sm:self-end sm:mb-17"
301- >
310+ <div class =" w-full sm:w-fit order-1 sm:order-2 flex flex-row sm:flex-col gap-2" >
302311 <SelectField
303312 class =" w-full"
304313 id =" select-facet-scatter-x"
@@ -327,6 +336,22 @@ function toggleAxisHighlight(state: AxisHighlight) {
327336 @focusin =" toggleAxisHighlight('y')"
328337 @focusout =" toggleAxisHighlight(null)"
329338 />
339+
340+ <h3
341+ id =" scatter-chart-legend-packages"
342+ :class =" [
343+ 'mb-1 font-mono text-fg-subtle tracking-wide uppercase mt-4 text-2xs',
344+ isMobile ? 'sr-only' : 'block',
345+ ]"
346+ >
347+ {{ $t('compare.packages.section_packages') }}
348+ </h3 >
349+
350+ <div
351+ id =" compare-scatter-legend"
352+ role =" group"
353+ aria-labelledby =" scatter-chart-legend-packages"
354+ ></div >
330355 </div >
331356
332357 <ClientOnly >
@@ -344,34 +369,43 @@ function toggleAxisHighlight(state: AxisHighlight) {
344369 </template >
345370
346371 <!-- Custom legend -->
347- <template #legend =" { legend } " >
348- <div
349- class =" flex flex-row flex-wrap gap-x-6 justify-center gap-y-2 px-6 sm:px-10 text-xs"
372+ <template #legend =" { legend } " v-if =" readyTeleport " >
373+ <div id =" compare-scatter-legend-inner" ></div >
374+ <Teleport
375+ :to =" isMobile ? '#compare-scatter-legend-inner' : '#compare-scatter-legend'"
350376 >
351- <button
352- v-for =" datapoint in legend"
353- :key =" datapoint.name"
354- :aria-pressed =" datapoint.isSegregated"
355- :aria-label =" datapoint.name"
356- type =" button"
357- class =" flex gap-1 place-items-center"
358- @click =" datapoint.segregate()"
377+ <ul
378+ :class ="
379+ isMobile
380+ ? 'flex flex-row flex-wrap gap-x-6 justify-center gap-y-2 px-6 sm:px-10 text-xs'
381+ : 'text-sm leading-6'
382+ "
359383 >
360- <div class =" h-3 w-3" >
361- <svg viewBox =" 0 0 2 2" class =" w-full" >
362- <circle cx =" 1" cy =" 1" r =" 1" :fill =" datapoint.color" />
363- </svg >
364- </div >
365- <span
366- class =" text-fg"
367- :style =" {
368- textDecoration: datapoint.isSegregated ? 'line-through' : undefined,
369- }"
370- >
371- {{ datapoint.name }}
372- </span >
373- </button >
374- </div >
384+ <li v-for =" datapoint in legend" :key =" datapoint.name" >
385+ <button
386+ :aria-pressed =" datapoint.isSegregated"
387+ :aria-label =" datapoint.name"
388+ type =" button"
389+ class =" flex gap-1.5 place-items-center"
390+ @click =" datapoint.segregate()"
391+ >
392+ <div class =" h-3 w-3" aria-hidden =" true" >
393+ <svg viewBox =" 0 0 2 2" class =" w-full" >
394+ <circle cx =" 1" cy =" 1" r =" 1" :fill =" datapoint.color" />
395+ </svg >
396+ </div >
397+ <span
398+ class =" text-fg"
399+ :style =" {
400+ textDecoration: datapoint.isSegregated ? 'line-through' : undefined,
401+ }"
402+ >
403+ {{ datapoint.name }}
404+ </span >
405+ </button >
406+ </li >
407+ </ul >
408+ </Teleport >
375409 </template >
376410
377411 <!-- Custom svg content -->
0 commit comments