@@ -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 =" isMobile ? undefined : 'group'"
353+ :aria-labelledby =" isMobile ? undefined : 'scatter-chart-legend-packages'"
354+ ></div >
330355 </div >
331356
332357 <ClientOnly >
@@ -346,32 +371,46 @@ function toggleAxisHighlight(state: AxisHighlight) {
346371 <!-- Custom legend -->
347372 <template #legend =" { legend } " >
348373 <div
349- class =" flex flex-row flex-wrap gap-x-6 justify-center gap-y-2 px-6 sm:px-10 text-xs"
374+ id =" compare-scatter-legend-inner"
375+ :role =" isMobile ? 'group' : undefined"
376+ :aria-labelledby =" isMobile ? 'scatter-chart-legend-packages' : undefined"
377+ ></div >
378+ <Teleport
379+ v-if =" readyTeleport"
380+ :to =" isMobile ? '#compare-scatter-legend-inner' : '#compare-scatter-legend'"
350381 >
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()"
382+ <ul
383+ :class ="
384+ isMobile
385+ ? 'flex flex-row flex-wrap gap-x-6 justify-center gap-y-2 px-6 sm:px-10 text-xs'
386+ : 'text-sm leading-6'
387+ "
359388 >
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 >
389+ <li v-for =" datapoint in legend" :key =" datapoint.name" >
390+ <button
391+ :aria-pressed =" datapoint.isSegregated"
392+ :aria-label =" datapoint.name"
393+ type =" button"
394+ class =" flex gap-1.5 place-items-center"
395+ @click =" datapoint.segregate()"
396+ >
397+ <div class =" h-3 w-3" aria-hidden =" true" >
398+ <svg viewBox =" 0 0 2 2" class =" w-full" >
399+ <circle cx =" 1" cy =" 1" r =" 1" :fill =" datapoint.color" />
400+ </svg >
401+ </div >
402+ <span
403+ class =" text-fg"
404+ :style =" {
405+ textDecoration: datapoint.isSegregated ? 'line-through' : undefined,
406+ }"
407+ >
408+ {{ datapoint.name }}
409+ </span >
410+ </button >
411+ </li >
412+ </ul >
413+ </Teleport >
375414 </template >
376415
377416 <!-- Custom svg content -->
0 commit comments