@datagouv/components-next 1.4.1-dev.1373.g379aceb6 → 1.4.1-dev.1374.g4dfe0257

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.
Files changed (53) hide show
  1. package/assets/main.css +4 -0
  2. package/dist/{Datafair.client-Ci2WOgAS.js → Datafair.client-LChXlMI3.js} +1 -1
  3. package/dist/{ImagePreview.client-B4RtxuiJ.js → ImagePreview.client-DWNGZghK.js} +1 -1
  4. package/dist/{JsonPreview.client-r7swv2fp.js → JsonPreview.client-DCklbUyJ.js} +2 -2
  5. package/dist/{MapContainer.client-CxH1a8Tn.js → MapContainer.client-B-aQhH35.js} +6 -6
  6. package/dist/{PdfPreview.client-BjeMcqcy.js → PdfPreview.client-1WFiBcXh.js} +3 -3
  7. package/dist/{PdfSkeleton-CVZxJaeL.js → PdfSkeleton-BvU7ERD1.js} +1 -1
  8. package/dist/{Pmtiles.client-D8idR2l7.js → Pmtiles.client-BlbOlwyy.js} +2 -2
  9. package/dist/{PreviewError-Cx7CItT_.js → PreviewError-BfBCBDEx.js} +6873 -6871
  10. package/dist/{PreviewWrapper-Cd1RSmS-.js → PreviewWrapper-DvycGC7l.js} +1 -1
  11. package/dist/{XmlPreview.client-cSebx8br.js → XmlPreview.client-ClFD8R3a.js} +2 -2
  12. package/dist/components-next.css +1 -1
  13. package/dist/components-next.js +11924 -11677
  14. package/dist/components.css +1 -1
  15. package/dist/{france-DPcdJc84.js → france-JfC0dOuE.js} +1 -1
  16. package/package.json +1 -1
  17. package/src/components/CardMedia.vue +42 -0
  18. package/src/components/ChartCard.vue +53 -59
  19. package/src/components/DataserviceCard.vue +69 -85
  20. package/src/components/DataserviceQualityInline.vue +4 -20
  21. package/src/components/DataserviceQualityTooltipContent.vue +57 -65
  22. package/src/components/DatasetCard.vue +80 -93
  23. package/src/components/DatasetQualityInline.vue +4 -20
  24. package/src/components/DatasetQualityTooltipContent.vue +60 -62
  25. package/src/components/DiscussionMessageCard.vue +19 -22
  26. package/src/components/ObjectCard.vue +89 -18
  27. package/src/components/ObjectCardBadge.vue +27 -16
  28. package/src/components/ObjectCardMeta.vue +15 -0
  29. package/src/components/ObjectCardMetric.vue +23 -0
  30. package/src/components/ObjectCardMetrics.vue +6 -0
  31. package/src/components/ObjectCardOwner.vue +170 -17
  32. package/src/components/ObjectCardQuality.vue +32 -0
  33. package/src/components/ObjectCardShortDescription.vue +1 -1
  34. package/src/components/OrganizationCard.vue +101 -69
  35. package/src/components/OrganizationNameInline.vue +49 -0
  36. package/src/components/OrganizationTypeBadge.vue +21 -0
  37. package/src/components/OwnerType.vue +1 -1
  38. package/src/components/OwnerTypeIcon.vue +7 -3
  39. package/src/components/PostCard.vue +31 -35
  40. package/src/components/ProgressBar.vue +6 -3
  41. package/src/components/QualityItem.vue +9 -18
  42. package/src/components/QualityScore.vue +7 -1
  43. package/src/components/ReuseCard.vue +114 -95
  44. package/src/components/ReuseDetails.vue +19 -29
  45. package/src/components/SchemaCard.vue +30 -27
  46. package/src/components/Search/GlobalSearch.vue +7 -4
  47. package/src/components/Toggletip.vue +24 -12
  48. package/src/components/Tooltip.vue +113 -29
  49. package/src/components/TopicCard.vue +69 -78
  50. package/src/main.ts +0 -4
  51. package/src/components/ObjectCardHeader.vue +0 -42
  52. package/src/components/OrganizationHorizontalCard.vue +0 -87
  53. package/src/components/ReuseHorizontalCard.vue +0 -81
@@ -1,25 +1,15 @@
1
1
  <template>
2
- <ObjectCard>
3
- <template #badge>
4
- <ObjectCardBadge
5
- v-if="dataset.private"
6
- :icon="RiLockLine"
7
- >
8
- {{ t('Brouillon') }}
9
- </ObjectCardBadge>
10
- <ObjectCardBadge
11
- v-else-if="dataset.archived"
12
- :icon="RiArchiveLine"
13
- >
14
- {{ t('Archivé') }}
15
- </ObjectCardBadge>
16
- </template>
17
-
2
+ <ObjectCard
3
+ :url="datasetUrl || dataset.page"
4
+ :target="datasetUrlInNewTab ? '_blank' : undefined"
5
+ :icon="RiDatabase2Line"
6
+ :title-tag
7
+ >
18
8
  <template #media>
19
9
  <OrganizationLogo
20
10
  v-if="dataset.organization"
21
11
  :organization="dataset.organization"
22
- size-class="size-12"
12
+ size-class="size-12 p-1"
23
13
  />
24
14
  <Avatar
25
15
  v-else-if="dataset.owner"
@@ -32,33 +22,41 @@
32
22
  class="size-12"
33
23
  />
34
24
  </template>
35
- <ObjectCardHeader
36
- :icon="RiDatabase2Line"
37
- :url="datasetUrl || dataset.page"
38
- :target="datasetUrlInNewTab ? '_blank' : undefined"
39
- :title-tag="titleTag"
40
- >
41
- {{ dataset.title }}
42
- <template
25
+ <template #title>
26
+ {{ dataset.title }}<small
43
27
  v-if="dataset.acronym"
44
- #extra
28
+ class="ml-2"
29
+ >{{ dataset.acronym }}</small>
30
+ </template>
31
+ <template
32
+ v-if="dataset.private || dataset.archived"
33
+ #badge
34
+ >
35
+ <ObjectCardBadge
36
+ v-if="dataset.private"
37
+ :icon="RiLockLine"
45
38
  >
46
- <small class="flex-1 ml-2">{{ dataset.acronym }}</small>
47
- </template>
48
- </ObjectCardHeader>
49
- <div
39
+ {{ t('Brouillon') }}
40
+ </ObjectCardBadge>
41
+ <ObjectCardBadge
42
+ v-else
43
+ :icon="RiArchiveLine"
44
+ >
45
+ {{ t('Archivé') }}
46
+ </ObjectCardBadge>
47
+ </template>
48
+
49
+ <ObjectCardOwner
50
50
  v-if="dataset.organization || dataset.owner"
51
- class="text-sm flex flex-wrap md:flex-nowrap gap-y-1 items-center truncate"
52
- >
53
- <ObjectCardOwner
54
- :organization="dataset.organization"
55
- :owner="dataset.owner"
56
- :organization-url="organizationUrl"
57
- />
58
- <RiSubtractLine class="hidden md:block size-4 flex-none fill-gray-medium" />
51
+ show-details
52
+ :organization="dataset.organization"
53
+ :owner="dataset.owner"
54
+ :organization-url="organizationUrl"
55
+ />
56
+ <ObjectCardMeta>
59
57
  <TranslationT
60
- tag="div"
61
- class="w-full md:w-auto text-gray-medium whitespace-nowrap"
58
+ tag="span"
59
+ class="tabular-nums"
62
60
  keypath="Mis à jour {date}"
63
61
  >
64
62
  <template #date>
@@ -69,58 +67,38 @@
69
67
  />
70
68
  </template>
71
69
  </TranslationT>
72
- </div>
73
- <div class="mx-0 -mb-1 flex flex-wrap items-center text-sm text-gray-medium">
74
- <div class="hidden sm:flex text-gray-medium">
75
- <DatasetQualityInline :quality="dataset.quality" />
76
- </div>
77
- <RiSubtractLine
78
- aria-hidden="true"
79
- class="hidden sm:block size-3"
70
+ <DatasetQualityInline
71
+ :quality="dataset.quality"
72
+ class="max-[480px]:hidden"
80
73
  />
81
- <div class="flex flex-wrap items-center gap-1">
82
- <p
83
- class="text-sm mb-0 flex items-center gap-0.5"
84
- :aria-label="t('{n} vues | {n} vue | {n} vues', dataset.metrics.views)"
85
- >
86
- <RiEyeLine
87
- aria-hidden="true"
88
- class="size-3.5"
89
- />{{ summarize(dataset.metrics.views) }}
90
- </p>
91
- <p
92
- class="text-sm mb-0 flex items-center gap-0.5"
93
- :aria-label="t('{n} téléchargements des ressources | {n} téléchargement des ressources | {n} téléchargements des ressources', dataset.metrics.resources_downloads)"
94
- >
95
- <RiDownloadLine
96
- aria-hidden="true"
97
- class="size-3.5"
98
- />{{ summarize(dataset.metrics.resources_downloads) }}
99
- </p>
100
- <p
101
- class="text-sm mb-0 flex items-center gap-0.5"
102
- :aria-label="t('{n} réutilisations | {n} réutilisation | {n} réutilisations', dataset.metrics.reuses)"
103
- >
104
- <RiLineChartLine
105
- aria-hidden="true"
106
- class="size-3.5"
107
- />{{ summarize(dataset.metrics.reuses) }}
108
- </p>
109
- <p
110
- class="text-sm mb-0 flex items-center gap-0.5"
111
- :aria-label="t('{n} abonnés | {n} abonné | {n} abonnés', dataset.metrics.followers)"
112
- >
113
- <RiStarLine
114
- aria-hidden="true"
115
- class="size-3.5"
116
- />{{ summarize(dataset.metrics.followers) }}
117
- </p>
118
- </div>
119
- </div>
74
+ <ObjectCardMetrics class="max-[480px]:hidden">
75
+ <ObjectCardMetric
76
+ :icon="RiEyeLine"
77
+ :value="dataset.metrics.views"
78
+ :label="t('{n} vues | {n} vue | {n} vues', dataset.metrics.views)"
79
+ />
80
+ <ObjectCardMetric
81
+ :icon="RiDownloadLine"
82
+ :value="dataset.metrics.resources_downloads"
83
+ :label="t('{n} téléchargements des ressources | {n} téléchargement des ressources | {n} téléchargements des ressources', dataset.metrics.resources_downloads)"
84
+ />
85
+ <ObjectCardMetric
86
+ :icon="RiLineChartLine"
87
+ :value="dataset.metrics.reuses"
88
+ :label="t('{n} réutilisations | {n} réutilisation | {n} réutilisations', dataset.metrics.reuses)"
89
+ />
90
+ <ObjectCardMetric
91
+ :icon="RiStarLine"
92
+ :value="dataset.metrics.followers"
93
+ :label="t('{n} abonnés | {n} abonné | {n} abonnés', dataset.metrics.followers)"
94
+ />
95
+ </ObjectCardMetrics>
96
+ </ObjectCardMeta>
120
97
  <slot>
121
98
  <ObjectCardShortDescription
122
99
  v-if="showDescriptionShort"
123
- :text="getDescriptionShort(props.dataset)"
100
+ :text="getDescriptionShort(dataset)"
101
+ class="max-md:hidden"
124
102
  />
125
103
  </slot>
126
104
  </ObjectCard>
@@ -128,20 +106,29 @@
128
106
 
129
107
  <script setup lang="ts">
130
108
  import type { RouteLocationRaw } from 'vue-router'
131
- import { RiArchiveLine, RiDatabase2Line, RiDownloadLine, RiEyeLine, RiLineChartLine, RiLockLine, RiStarLine, RiSubtractLine } from '@remixicon/vue'
109
+ import {
110
+ RiArchiveLine,
111
+ RiDatabase2Line,
112
+ RiDownloadLine,
113
+ RiEyeLine,
114
+ RiLineChartLine,
115
+ RiLockLine,
116
+ RiStarLine,
117
+ } from '@remixicon/vue'
132
118
  import type { Dataset, DatasetV2 } from '../types/datasets'
133
119
  import type { TitleTag } from '../types/ui'
134
- import { summarize } from '../functions/helpers'
135
120
  import { getDescriptionShort } from '../functions/description'
136
121
  import { useTranslation } from '../composables/useTranslation'
137
122
  import DatasetQualityInline from './DatasetQualityInline.vue'
138
123
  import Avatar from './Avatar.vue'
139
124
  import Placeholder from './Placeholder.vue'
140
125
  import OrganizationLogo from './OrganizationLogo.vue'
141
- import ObjectCardOwner from './ObjectCardOwner.vue'
142
126
  import ObjectCard from './ObjectCard.vue'
143
127
  import ObjectCardBadge from './ObjectCardBadge.vue'
144
- import ObjectCardHeader from './ObjectCardHeader.vue'
128
+ import ObjectCardMeta from './ObjectCardMeta.vue'
129
+ import ObjectCardMetric from './ObjectCardMetric.vue'
130
+ import ObjectCardMetrics from './ObjectCardMetrics.vue'
131
+ import ObjectCardOwner from './ObjectCardOwner.vue'
145
132
  import ObjectCardShortDescription from './ObjectCardShortDescription.vue'
146
133
  import FormattedDate from './FormattedDate.vue'
147
134
  import TranslationT from './TranslationT.vue'
@@ -156,7 +143,7 @@ type Props = {
156
143
  titleTag?: TitleTag
157
144
  }
158
145
 
159
- const props = withDefaults(defineProps<Props>(), {
146
+ withDefaults(defineProps<Props>(), {
160
147
  showDescriptionShort: true,
161
148
  })
162
149
 
@@ -1,31 +1,15 @@
1
1
  <template>
2
- <div class="m-0 text-sm text-gray-medium">
3
- <Toggletip
4
- :styled-button="false"
5
- button-class="border-transparent -outline-offset-2 inline-flex items-center justify-center hover:bg-gray-lower transition-colors"
6
- :button-props="{ class: 'relative z-2 gap-1 rounded-sm px-1 -mx-1 group/quality', title: t('Qualité des métadonnées') }"
7
- >
8
- <RiInformationLine class="size-3.5 shrink-0" />
9
- <span class="text-gray-medium text-sm group-hover/quality:underline">{{ t('Métadonnées :') }}</span>
10
- <QualityScore :score="quality.score" />
11
- <template #toggletip>
12
- <DatasetQualityTooltipContent :quality />
13
- </template>
14
- </Toggletip>
15
- </div>
2
+ <ObjectCardQuality :score="quality.score">
3
+ <DatasetQualityTooltipContent :quality />
4
+ </ObjectCardQuality>
16
5
  </template>
17
6
 
18
7
  <script setup lang="ts">
19
- import { RiInformationLine } from '@remixicon/vue'
20
8
  import type { Quality } from '../types/datasets'
21
- import QualityScore from './QualityScore.vue'
22
9
  import DatasetQualityTooltipContent from './DatasetQualityTooltipContent.vue'
23
- import Toggletip from './Toggletip.vue'
24
- import { useTranslation } from '../composables/useTranslation'
10
+ import ObjectCardQuality from './ObjectCardQuality.vue'
25
11
 
26
12
  defineProps<{
27
13
  quality: Quality
28
14
  }>()
29
-
30
- const { t } = useTranslation()
31
15
  </script>
@@ -1,67 +1,65 @@
1
1
  <template>
2
- <p class="text-sm text-gray-plain font-bold mb-0">
3
- {{ t("Qualité des métadonnées :") }}
4
- </p>
5
- <ul class="list-none pl-0 space-y-2">
6
- <DatasetQualityItem
7
- :passed="quality.dataset_description_quality"
8
- :message-passed="t('Description des données renseignée')"
9
- :message-failed="t('Description des données non renseignée')"
10
- class="pb-0"
11
- />
12
- <DatasetQualityItem
13
- :passed="quality.resources_documentation"
14
- :message-passed="t('Fichiers documentés')"
15
- :message-failed="t('Documentation des fichiers manquante')"
16
- class="pb-0"
17
- />
18
- <DatasetQualityItem
19
- :passed="quality.license"
20
- :message-passed="t('Licence renseignée')"
21
- :message-failed="t('Licence non renseignée')"
22
- class="pb-0"
23
- />
24
- <DatasetQualityItem
25
- :passed="quality.update_frequency && !!quality.update_fulfilled_in_time"
26
- :message-passed="t('Fréquence de mise à jour respectée')"
27
- :message-failed="quality.update_frequency ? t('Fréquence de mise à jour non respectée') : t('Fréquence de mise à jour non renseignée')"
28
- class="pb-0"
29
- />
30
- <DatasetQualityItem
31
- :passed="quality.has_open_format"
32
- :message-passed="t('Formats de fichiers standards')"
33
- :message-failed="t('Formats de fichiers non standards')"
34
- class="pb-0"
35
- />
36
- <DatasetQualityItem
37
- :passed="quality.temporal_coverage"
38
- :message-passed="t('Couverture temporelle renseignée')"
39
- :message-failed="t('Couverture temporelle non renseignée')"
40
- class="pb-0"
41
- />
42
- <DatasetQualityItem
43
- :passed="quality.spatial"
44
- :message-passed="t('Couverture spatiale renseignée')"
45
- :message-failed="t('Couverture spatiale non renseignée')"
46
- class="pb-0"
47
- />
48
- <DatasetQualityItem
49
- :passed="quality.all_resources_available"
50
- :message-passed="t('Tous les fichiers sont disponibles')"
51
- :message-failed="t('Certains fichiers ne sont pas disponibles')"
52
- class="pb-0"
53
- />
54
- </ul>
55
- <div class="fr-grid-row fr-grid-row--right">
56
- <a
57
- :href="config.datasetQualityGuideUrl"
58
- target="_blank"
59
- rel="noopener"
60
- :title="t('En savoir plus sur cet indicateur - ouvre une nouvelle fenêtre')"
2
+ <section class="flex flex-col gap-3">
3
+ <p class="m-0 text-sm/[22px] font-semibold text-gray-title">
4
+ {{ t("Qualité des métadonnées :") }}
5
+ </p>
6
+ <ul class="list-none flex flex-col gap-2 m-0 p-0">
7
+ <DatasetQualityItem
8
+ :passed="quality.dataset_description_quality"
9
+ :message-passed="t('Description des données renseignée')"
10
+ :message-failed="t('Description des données non renseignée')"
11
+ />
12
+ <DatasetQualityItem
13
+ :passed="quality.resources_documentation"
14
+ :message-passed="t('Fichiers documentés')"
15
+ :message-failed="t('Documentation des fichiers manquante')"
16
+ />
17
+ <DatasetQualityItem
18
+ :passed="quality.license"
19
+ :message-passed="t('Licence renseignée')"
20
+ :message-failed="t('Licence non renseignée')"
21
+ />
22
+ <DatasetQualityItem
23
+ :passed="quality.update_frequency && !!quality.update_fulfilled_in_time"
24
+ :message-passed="t('Fréquence de mise à jour respectée')"
25
+ :message-failed="quality.update_frequency ? t('Fréquence de mise à jour non respectée') : t('Fréquence de mise à jour non renseignée')"
26
+ />
27
+ <DatasetQualityItem
28
+ :passed="quality.has_open_format"
29
+ :message-passed="t('Formats de fichiers standards')"
30
+ :message-failed="t('Formats de fichiers non standards')"
31
+ />
32
+ <DatasetQualityItem
33
+ :passed="quality.temporal_coverage"
34
+ :message-passed="t('Couverture temporelle renseignée')"
35
+ :message-failed="t('Couverture temporelle non renseignée')"
36
+ />
37
+ <DatasetQualityItem
38
+ :passed="quality.spatial"
39
+ :message-passed="t('Couverture spatiale renseignée')"
40
+ :message-failed="t('Couverture spatiale non renseignée')"
41
+ />
42
+ <DatasetQualityItem
43
+ :passed="quality.all_resources_available"
44
+ :message-passed="t('Tous les fichiers sont disponibles')"
45
+ :message-failed="t('Certains fichiers ne sont pas disponibles')"
46
+ />
47
+ </ul>
48
+ <p
49
+ v-if="config.datasetQualityGuideUrl"
50
+ class="m-0 text-sm/[22px] font-medium"
61
51
  >
62
- {{ t("En savoir plus sur cet indicateur") }}
63
- </a>
64
- </div>
52
+ <a
53
+ :href="config.datasetQualityGuideUrl"
54
+ target="_blank"
55
+ rel="noopener"
56
+ class="text-gray-title bg-none underline underline-offset-3"
57
+ :title="t('En savoir plus sur cet indicateur - ouvre une nouvelle fenêtre')"
58
+ >
59
+ {{ t("En savoir plus sur cet indicateur") }}
60
+ </a>
61
+ </p>
62
+ </section>
65
63
  </template>
66
64
 
67
65
  <script setup lang="ts">
@@ -1,27 +1,23 @@
1
1
  <template>
2
- <ObjectCard>
3
- <ObjectCardHeader
4
- :icon="RiChat3Line"
5
- :url="discussionUrl || discussion.self_web_url || '#'"
6
- >
2
+ <ObjectCard
3
+ :url="discussionUrl || discussion.self_web_url || '#'"
4
+ :icon="RiChat3Line"
5
+ >
6
+ <template #title>
7
7
  {{ discussion.title }}
8
- </ObjectCardHeader>
8
+ </template>
9
9
 
10
- <div
11
- v-if="discussion.organization || discussion.user"
12
- class="text-sm flex flex-wrap md:flex-nowrap gap-y-1 items-center truncate"
13
- >
10
+ <ObjectCardMeta class="mt-2">
14
11
  <ObjectCardOwner
12
+ v-if="discussion.organization || discussion.user"
13
+ show-details
15
14
  :organization="discussion.organization"
16
15
  :owner="discussion.user"
17
16
  :organization-url="organizationUrl"
18
17
  />
19
- <RiSubtractLine
20
- aria-hidden="true"
21
- class="size-4 flex-none fill-gray-medium"
22
- />
23
18
  <TranslationT
24
- class="text-gray-medium whitespace-nowrap"
19
+ tag="span"
20
+ class="tabular-nums"
25
21
  keypath="Posté {date}"
26
22
  >
27
23
  <template #date>
@@ -32,24 +28,25 @@
32
28
  />
33
29
  </template>
34
30
  </TranslationT>
35
- </div>
36
-
37
- <ObjectCardShortDescription :text="firstMessageContent" />
38
-
31
+ </ObjectCardMeta>
32
+ <ObjectCardShortDescription
33
+ :text="firstMessageContent"
34
+ class="mt-2 max-md:hidden"
35
+ />
39
36
  <slot />
40
37
  </ObjectCard>
41
38
  </template>
42
39
 
43
40
  <script setup lang="ts">
44
- import { RiChat3Line, RiSubtractLine } from '@remixicon/vue'
41
+ import { RiChat3Line } from '@remixicon/vue'
45
42
  import { computed } from 'vue'
46
43
  import type { RouteLocationRaw } from 'vue-router'
47
44
  import type { Thread } from '../types/discussions'
45
+ import FormattedDate from './FormattedDate.vue'
48
46
  import ObjectCard from './ObjectCard.vue'
49
- import ObjectCardHeader from './ObjectCardHeader.vue'
47
+ import ObjectCardMeta from './ObjectCardMeta.vue'
50
48
  import ObjectCardOwner from './ObjectCardOwner.vue'
51
49
  import ObjectCardShortDescription from './ObjectCardShortDescription.vue'
52
- import FormattedDate from './FormattedDate.vue'
53
50
  import TranslationT from './TranslationT.vue'
54
51
 
55
52
  const props = defineProps<{
@@ -1,22 +1,65 @@
1
1
  <template>
2
+ <!--
3
+ The title link covers the whole card through its `before` pseudo-element; interactive elements
4
+ inside the card (owner details, quality, tooltips) sit above it with `relative z-2`.
5
+ -->
2
6
  <article
3
- class="p-4 border bg-white border-gray-default relative hover:bg-gray-some fr-enlarge-link"
4
- :class="articleClass"
7
+ class="@container relative min-w-0 rounded border bg-white text-sm/[22px] text-gray-title
8
+ has-[[data-card-link]:hover]:bg-gray-some has-[[data-card-link]:active]:bg-gray-active
9
+ has-[[data-card-link]:focus-visible]:outline-2 has-[[data-card-link]:focus-visible]:outline-new-focus has-[[data-card-link]:focus-visible]:outline-offset-3"
10
+ :class="highlighted ? 'border-gray-secondary' : 'border-gray-default'"
5
11
  >
6
- <slot name="badge" />
7
- <div class="flex flex-wrap md:flex-nowrap gap-4 items-start">
12
+ <div
13
+ v-if="$slots.cover"
14
+ class="overflow-hidden rounded-t-[3px]"
15
+ >
16
+ <slot name="cover" />
17
+ </div>
18
+ <div
19
+ class="flex items-start p-4"
20
+ :class="layoutClass"
21
+ >
8
22
  <div
9
23
  v-if="$slots.media"
10
- class="flex-none"
24
+ class="flex-none max-w-full"
25
+ :class="mediaClass"
11
26
  >
12
27
  <div
13
- class="flex justify-center items-center border border-gray-lower bg-[#fff] rounded-md overflow-hidden"
14
- :class="mediaContainerClass"
28
+ class="flex justify-center items-center max-w-full overflow-hidden rounded border border-gray-default bg-white"
29
+ :class="frameClass"
15
30
  >
16
31
  <slot name="media" />
17
32
  </div>
18
33
  </div>
19
- <div class="flex-1 overflow-hidden space-y-1">
34
+ <div class="flex flex-col gap-1 flex-1 min-w-0 w-full">
35
+ <div class="flex items-start gap-x-2 gap-y-1 min-w-0 @max-[480px]:flex-col">
36
+ <component
37
+ :is="titleTag"
38
+ class="m-0 flex-1 min-w-0 w-full text-base/6 font-semibold text-gray-title [overflow-wrap:anywhere]"
39
+ >
40
+ <AppLink
41
+ :to="url"
42
+ :target
43
+ data-card-link
44
+ class="line-clamp-2 text-gray-title hover:text-new-primary bg-none no-underline focus-visible:outline-none
45
+ before:absolute before:inset-0 before:z-1 after:hidden"
46
+ >
47
+ <component
48
+ :is="icon"
49
+ v-if="icon"
50
+ class="size-4 inline-block align-[-2px] me-1"
51
+ aria-hidden="true"
52
+ />
53
+ <slot name="title" />
54
+ </AppLink>
55
+ </component>
56
+ <div
57
+ v-if="$slots.badge"
58
+ class="flex-none @max-[480px]:order-first"
59
+ >
60
+ <slot name="badge" />
61
+ </div>
62
+ </div>
20
63
  <slot />
21
64
  </div>
22
65
  </div>
@@ -24,22 +67,50 @@
24
67
  </template>
25
68
 
26
69
  <script setup lang="ts">
27
- import { computed } from 'vue'
70
+ import { computed, type Component } from 'vue'
71
+ import type { RouteLocationRaw } from 'vue-router'
72
+ import type { TitleTag } from '../types/ui'
73
+ import AppLink from './AppLink.vue'
28
74
 
29
75
  const props = withDefaults(defineProps<{
30
- articleClass?: string | string[] | Record<string, boolean>
76
+ url: RouteLocationRaw
77
+ target?: string
78
+ icon?: Component
79
+ titleTag?: TitleTag
80
+ // `sm` is a logo or an avatar, `lg` and `xl` an illustration.
31
81
  mediaSize?: 'sm' | 'lg' | 'xl'
82
+ // Puts the media above the content instead of beside it. Over a cover, the media overlaps it.
83
+ stacked?: boolean
84
+ highlighted?: boolean
32
85
  }>(), {
86
+ titleTag: 'h3',
33
87
  mediaSize: 'sm',
34
88
  })
35
89
 
36
- const mediaContainerClass = computed(() => {
37
- if (props.mediaSize === 'xl') {
38
- return 'w-[250px] h-[190px]'
39
- }
40
- if (props.mediaSize === 'lg') {
41
- return 'w-[225px] h-[120px]'
42
- }
43
- return 'p-2'
90
+ const slots = defineSlots<{
91
+ title(): unknown
92
+ badge?(): unknown
93
+ cover?(): unknown
94
+ media?(): unknown
95
+ default?(): unknown
96
+ }>()
97
+
98
+ // Beside the content, the media moves above it once the card is too narrow for both.
99
+ const layoutClass = computed(() => {
100
+ if (props.stacked) return 'flex-col gap-3'
101
+ if (props.mediaSize === 'sm') return 'gap-4 @max-[280px]:flex-col @max-[280px]:gap-3'
102
+ return 'gap-4 @max-[480px]:flex-col'
103
+ })
104
+
105
+ const mediaClass = computed(() => {
106
+ if (props.stacked && slots.cover) return 'relative -mt-10'
107
+ if (props.mediaSize === 'sm') return ''
108
+ return '@max-[480px]:w-full'
44
109
  })
110
+
111
+ const frameClass = computed(() => ({
112
+ sm: '',
113
+ lg: 'w-48 h-30 @max-[480px]:w-full @max-[480px]:h-auto @max-[480px]:aspect-video',
114
+ xl: 'w-56 h-40 @max-[480px]:w-full @max-[480px]:h-auto @max-[480px]:aspect-video',
115
+ })[props.mediaSize])
45
116
  </script>
@@ -1,22 +1,33 @@
1
1
  <template>
2
- <div class="absolute top-0 left-4 fr-grid-row fr-grid-row--middle fr-mt-n3v">
3
- <p class="fr-badge fr-badge--sm fr-badge--mention-grey text-gray-medium">
4
- <component
5
- :is="icon"
6
- aria-hidden="true"
7
- class="size-4 mr-1"
8
- />
9
- <slot />
10
- </p>
11
- </div>
2
+ <span
3
+ class="inline-flex items-center gap-1 max-w-full min-h-6 px-2 py-0.5 rounded border border-current/20 text-xs/[18px] font-medium"
4
+ :class="toneClass"
5
+ >
6
+ <component
7
+ :is="icon"
8
+ v-if="icon"
9
+ class="size-3.5 flex-none"
10
+ aria-hidden="true"
11
+ />
12
+ <span class="min-w-0 [overflow-wrap:anywhere]"><slot /></span>
13
+ </span>
12
14
  </template>
13
15
 
14
16
  <script setup lang="ts">
15
- // Only one ObjectCardBadge should be rendered at a time (use v-if/v-else-if),
16
- // because the absolute positioning will cause multiple badges to overlap.
17
- import type { Component } from 'vue'
17
+ import { computed, type Component } from 'vue'
18
18
 
19
- defineProps<{
20
- icon: Component
21
- }>()
19
+ const props = withDefaults(defineProps<{
20
+ icon?: Component | null
21
+ tone?: 'neutral' | 'info' | 'warning' | 'yellow' | 'danger'
22
+ }>(), {
23
+ tone: 'neutral',
24
+ })
25
+
26
+ const toneClass = computed(() => ({
27
+ neutral: 'bg-gray-lower text-gray-plain',
28
+ info: 'bg-blue-france-contrast text-new-primary',
29
+ warning: 'bg-new-warning-light text-new-warning',
30
+ yellow: 'bg-warning2-lightest text-warning2-dark',
31
+ danger: 'bg-new-error-light text-new-error',
32
+ })[props.tone])
22
33
  </script>