Skip to content

Commit a841c6e

Browse files
committed
fix(ui): update toggle to make it reusable
1 parent 6b8b10c commit a841c6e

2 files changed

Lines changed: 19 additions & 15 deletions

File tree

app/components/Package/VersionDistribution.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ const xAxisLabels = computed(() => {
249249
:tooltip="$t('package.versions.hide_old_versions_tooltip')"
250250
tooltip-position="right"
251251
:tooltip-teleport-to="inModal ? '#chart-modal' : undefined"
252+
justify="start"
252253
:class="{ 'opacity-50 pointer-events-none': pending }"
253254
/>
254255
</div>

app/components/Settings/Toggle.client.vue

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
<script setup lang="ts">
22
import TooltipApp from '~/components/Tooltip/App.vue'
33
4-
defineProps<{
5-
label?: string
6-
description?: string
7-
tooltip?: string
8-
tooltipPosition?: 'top' | 'bottom' | 'left' | 'right'
9-
tooltipTeleportTo?: string
10-
class?: string | Record<string, boolean> | Array<string | Record<string, boolean>>
11-
}>()
4+
withDefaults(
5+
defineProps<{
6+
label?: string
7+
description?: string
8+
class?: string
9+
justify?: 'between' | 'start'
10+
tooltip?: string
11+
tooltipPosition?: 'top' | 'bottom' | 'left' | 'right'
12+
tooltipTeleportTo?: string
13+
}>(),
14+
{
15+
justify: 'between',
16+
},
17+
)
1218
1319
const checked = defineModel<boolean>({
1420
default: false,
@@ -18,26 +24,23 @@ const checked = defineModel<boolean>({
1824
<template>
1925
<button
2026
type="button"
21-
class="w-full flex items-center justify-start gap-3 group focus-visible:outline-none py-1 -my-1"
27+
class="w-full flex items-center gap-4 group focus-visible:outline-none py-1 -my-1"
28+
:class="[justify === 'start' ? 'justify-start' : 'justify-between', $props.class]"
2229
role="switch"
2330
:aria-checked="checked"
2431
@click="checked = !checked"
25-
:class="class"
2632
>
2733
<TooltipApp
2834
v-if="tooltip && label"
2935
:text="tooltip"
3036
:position="tooltipPosition ?? 'top'"
3137
:teleportTo="tooltipTeleportTo"
3238
>
33-
<span class="text-sm font-mono text-fg group-hover:text-fg/80 transition-colors select-none">
39+
<span class="text-sm text-fg font-medium text-start">
3440
{{ label }}
3541
</span>
3642
</TooltipApp>
37-
<span
38-
v-else-if="label"
39-
class="text-sm font-mono text-fg group-hover:text-fg/80 transition-colors select-none"
40-
>
43+
<span v-else-if="label" class="text-sm text-fg font-medium text-start">
4144
{{ label }}
4245
</span>
4346
<span

0 commit comments

Comments
 (0)