adminforth 4.4.0 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,14 +1,48 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
2
|
+
<span v-bind="restAttrs" :class="rootClasses">
|
|
3
|
+
<!-- a hairline edge keeps white stripes visible on a white page -->
|
|
4
|
+
<img
|
|
5
|
+
v-if="flagUrl"
|
|
6
|
+
:src="flagUrl"
|
|
7
|
+
:alt="countryCode"
|
|
8
|
+
class="block w-full h-full object-cover ring-1 ring-black/10 dark:ring-white/10"
|
|
9
|
+
:class="IMAGE_RADIUS[size]"
|
|
10
|
+
/>
|
|
4
11
|
<span v-else-if="getFlagUrl && countryCode">{{ countryCode }}</span>
|
|
5
|
-
</
|
|
12
|
+
</span>
|
|
6
13
|
</template>
|
|
7
14
|
|
|
8
15
|
<script setup lang="ts">
|
|
9
|
-
import { computed, shallowRef } from 'vue';
|
|
16
|
+
import { computed, shallowRef, useAttrs } from 'vue';
|
|
17
|
+
import { type ClassNameValue } from 'tailwind-merge';
|
|
18
|
+
import { mergeClasses } from './classMerge';
|
|
10
19
|
|
|
11
|
-
|
|
20
|
+
type CountryFlagSize = 'sm' | 'md';
|
|
21
|
+
|
|
22
|
+
defineOptions({ inheritAttrs: false });
|
|
23
|
+
|
|
24
|
+
const props = withDefaults(defineProps<{
|
|
25
|
+
countryCode?: string,
|
|
26
|
+
// sm is 16×12 for menus, lists and selects, md is 32×24
|
|
27
|
+
size?: CountryFlagSize,
|
|
28
|
+
}>(), {
|
|
29
|
+
size: 'md',
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const SIZES: Record<CountryFlagSize, string> = { sm: 'w-4 h-3', md: 'w-8 h-6' };
|
|
33
|
+
const IMAGE_RADIUS: Record<CountryFlagSize, string> = { sm: 'rounded-[2px]', md: 'rounded-[3px]' };
|
|
34
|
+
|
|
35
|
+
const attrs = useAttrs();
|
|
36
|
+
const restAttrs = computed(() => {
|
|
37
|
+
const { class: _class, ...rest } = attrs;
|
|
38
|
+
return rest;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const rootClasses = computed(() => mergeClasses(
|
|
42
|
+
'afcl-country-flag inline-flex shrink-0 items-center justify-center',
|
|
43
|
+
SIZES[props.size],
|
|
44
|
+
attrs.class as ClassNameValue,
|
|
45
|
+
));
|
|
12
46
|
|
|
13
47
|
// the map of flag URLs is loaded when a flag is shown for the first time
|
|
14
48
|
const getFlagUrl = shallowRef<(countryCode: string) => string | undefined>();
|
|
@@ -18,12 +52,3 @@ import('./countryFlagUrls').then((module) => {
|
|
|
18
52
|
|
|
19
53
|
const flagUrl = computed(() => props.countryCode && getFlagUrl.value?.(props.countryCode));
|
|
20
54
|
</script>
|
|
21
|
-
|
|
22
|
-
<style scoped>
|
|
23
|
-
.flag-icon {
|
|
24
|
-
box-shadow: inset -0.3px -0.3px 0.3px 0px rgba(0 0 0 / 0.2),
|
|
25
|
-
inset 0.3px 0.3px 0.3px 0px rgba(255 255 255 / 0.2),
|
|
26
|
-
0px 0px 3px #00000030;
|
|
27
|
-
width: auto;
|
|
28
|
-
}
|
|
29
|
-
</style>
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
>
|
|
13
13
|
<RouterLink
|
|
14
14
|
v-if="foreignResource && foreignResource?.pk"
|
|
15
|
-
class="font-medium
|
|
15
|
+
class="font-medium hover:underline whitespace-nowrap"
|
|
16
16
|
:to="{
|
|
17
17
|
name: 'resource-show',
|
|
18
18
|
params: {
|