All checks were successful
Build Docker Image / build (push) Successful in 5m8s
- Remove all Storybook files and configuration - Add type declarations for @vueuse/core, @formkit/core, vue3-apexcharts - Fix TypeScript configuration (typeRoots, include paths) - Fix Sentry config - move settings to plugin - Fix nullable prop assignments with ?? operator - Fix type narrowing issues with explicit type assertions - Fix Card component linkable computed properties - Update codegen with operationResultSuffix - Fix GraphQL operation type definitions
86 lines
2.7 KiB
Vue
86 lines
2.7 KiB
Vue
<template>
|
|
<component
|
|
:is="linkable ? NuxtLink : 'div'"
|
|
:to="linkable ? resolvedLink : undefined"
|
|
class="block"
|
|
:class="{ 'cursor-pointer': selectable }"
|
|
@click="selectable && $emit('select')"
|
|
@mouseenter="$emit('hover', true)"
|
|
@mouseleave="$emit('hover', false)"
|
|
>
|
|
<Card
|
|
padding="small"
|
|
:interactive="linkable || selectable"
|
|
:class="[
|
|
isSelected && 'ring-2 ring-primary ring-offset-2'
|
|
]"
|
|
>
|
|
<div class="flex flex-col gap-1">
|
|
<!-- Title -->
|
|
<Text size="base" weight="semibold" class="truncate">{{ hub.name }}</Text>
|
|
<!-- Country left, distance right -->
|
|
<div class="flex items-center justify-between">
|
|
<Text tone="muted" size="sm">
|
|
{{ countryFlag }} {{ hub.country || t('catalogMap.labels.country_unknown') }}
|
|
</Text>
|
|
<span v-if="hub.distance" class="badge badge-neutral badge-dash text-xs">
|
|
{{ hub.distance }}
|
|
</span>
|
|
</div>
|
|
<!-- Transport icons bottom -->
|
|
<div v-if="hub.transportTypes?.length" class="flex items-center gap-1 pt-1">
|
|
<Icon v-if="hasTransport('auto')" name="lucide:truck" size="14" class="text-base-content/50" />
|
|
<Icon v-if="hasTransport('rail')" name="lucide:train-front" size="14" class="text-base-content/50" />
|
|
<Icon v-if="hasTransport('sea')" name="lucide:ship" size="14" class="text-base-content/50" />
|
|
<Icon v-if="hasTransport('air')" name="lucide:plane" size="14" class="text-base-content/50" />
|
|
</div>
|
|
</div>
|
|
</Card>
|
|
</component>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { NuxtLink } from '#components'
|
|
|
|
interface Hub {
|
|
uuid?: string | null
|
|
name?: string | null
|
|
country?: string | null
|
|
countryCode?: string | null
|
|
distance?: string
|
|
transportTypes?: string[] | null
|
|
}
|
|
|
|
const props = defineProps<{
|
|
hub: Hub
|
|
selectable?: boolean
|
|
isSelected?: boolean
|
|
linkTo?: string
|
|
}>()
|
|
|
|
defineEmits<{
|
|
(e: 'select'): void
|
|
(e: 'hover', hovered: boolean): void
|
|
}>()
|
|
|
|
const localePath = useLocalePath()
|
|
const { t } = useI18n()
|
|
|
|
const linkable = computed(() => !props.selectable && !!(props.linkTo || props.hub.uuid))
|
|
const resolvedLink = computed(() => props.linkTo || localePath(`/catalog/hubs/${props.hub.uuid}`))
|
|
|
|
// ISO code to emoji flag
|
|
const isoToEmoji = (code: string): string => {
|
|
return code.toUpperCase().split('').map(char => String.fromCodePoint(0x1F1E6 - 65 + char.charCodeAt(0))).join('')
|
|
}
|
|
|
|
const countryFlag = computed(() => {
|
|
if (props.hub.countryCode) {
|
|
return isoToEmoji(props.hub.countryCode)
|
|
}
|
|
return '🌍'
|
|
})
|
|
|
|
const hasTransport = (type: string) => props.hub.transportTypes?.includes(type)
|
|
</script>
|