From af540c312ea4dadb99513aa69c12c827a7430a45 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Tue, 17 Mar 2026 14:59:24 +0100 Subject: [PATCH] FEATURE refactoring presse components to handle datas with the new post type dedicated archives presses --- resources/css/blocks/press-ressources.css | 94 +++++++++++++++---- resources/css/components/post-card.css | 27 ++++++ resources/img/icons/carhop-source-audio.svg | 14 +++ resources/img/icons/carhop-source-ecrits.svg | 16 ++++ resources/img/icons/carhop-source-photo.svg | 13 +++ resources/img/icons/carhop-source-video.svg | 12 +++ .../components/cards/archive-presse-card.php | 30 +++++- .../archives-presse/archives-presse-grid.php | 77 ++++++++++----- 8 files changed, 237 insertions(+), 46 deletions(-) create mode 100644 resources/img/icons/carhop-source-audio.svg create mode 100644 resources/img/icons/carhop-source-ecrits.svg create mode 100644 resources/img/icons/carhop-source-photo.svg create mode 100644 resources/img/icons/carhop-source-video.svg diff --git a/resources/css/blocks/press-ressources.css b/resources/css/blocks/press-ressources.css index 84b4a94..e6169ad 100644 --- a/resources/css/blocks/press-ressources.css +++ b/resources/css/blocks/press-ressources.css @@ -153,21 +153,6 @@ } } -.presse-reviews { - @apply mt-12; - .wp-block-carhop-blocks-content-box { - @apply !w-full !m-0; - .content-box__innerblocks { - @apply p-0; - > * { - @apply w-full max-w-none; - } - } - } - &__list { - @apply grid grid-cols-1 md:grid-cols-2 gap-8; - } -} .ressources-grid-content-wrapper { &[data-active-tab='communiques'] { .ressources-graphiques, @@ -189,9 +174,84 @@ } } +.presse-reviews { + @apply mt-12; + .wp-block-carhop-blocks-content-box { + @apply !w-full !m-0; + .content-box__innerblocks { + @apply p-0; + > * { + @apply w-full max-w-none; + } + } + } + &__inner { + @apply grid gap-8; + grid-template-columns: 250px 3fr; + } + aside { + ul.presse-reviews__years-list { + @apply sticky top-0; + li.presse-reviews__year { + @apply list-none border border-primary border-solid p-6 text-4xl fjalla; + } + li.presse-reviews__year + li.presse-reviews__year { + @apply mt-4; + } + } + } + &__archives-list { + @apply grid grid-cols-1 gap-8; + .archives-year-title-wrapper { + @apply relative mb-6; + &:after { + @apply content-[''] block w-full bg-primary absolute; + top: 50%; + height: 1px; + } + h3 { + @apply bg-white w-fit mx-auto px-8 relative z-10 text-lg nunito !font-bold tracking-wide; + } + } + } + &__archives-decade { + .post-card + .post-card { + @apply mt-8; + } + } + + &__title { + @apply my-12; + } + ul.archives-decade-used-types { + @apply flex items-center gap-10; + + li.archives-decade-used-type { + @apply text-primary flex items-center gap-2; + + &::before { + @apply content-[''] block w-8 h-8 bg-no-repeat bg-center bg-contain bg-red-300; + } + + &--audio::before { + background-image: url('../resources/img/icons/carhop-source-audio.svg'); + } + &--video::before { + background-image: url('../resources/img/icons/carhop-source-video.svg'); + } + &--photo::before { + background-image: url('../resources/img/icons/carhop-source-photo.svg'); + } + &--article::before { + background-image: url('../resources/img/icons/carhop-source-ecrits.svg'); + } + } + } +} +/* .archives-presse-card { - @apply block; + @apply block bg-red-500; &__inner { @apply flex items-start justify-between gap-8; } @@ -208,4 +268,4 @@ .archives-presse-card__file-type { @apply uppercase; } -} \ No newline at end of file +} */ diff --git a/resources/css/components/post-card.css b/resources/css/components/post-card.css index 254478e..7cc0c49 100644 --- a/resources/css/components/post-card.css +++ b/resources/css/components/post-card.css @@ -84,3 +84,30 @@ } } } + +.post-card--archives-presse { + &::after { + @apply !content-none; + } + .media-type-list { + .media-type { + @apply flex items-center gap-2 w-fit; + &::before { + @apply content-[''] block w-8 h-8 bg-no-repeat bg-center bg-contain bg-red-300; + } + + &--audio::before { + background-image: url('../resources/img/icons/carhop-source-audio.svg'); + } + &--video::before { + background-image: url('../resources/img/icons/carhop-source-video.svg'); + } + &--photo::before { + background-image: url('../resources/img/icons/carhop-source-photo.svg'); + } + &--article::before { + background-image: url('../resources/img/icons/carhop-source-ecrits.svg'); + } + } + } +} diff --git a/resources/img/icons/carhop-source-audio.svg b/resources/img/icons/carhop-source-audio.svg new file mode 100644 index 0000000..9bd0d1a --- /dev/null +++ b/resources/img/icons/carhop-source-audio.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/resources/img/icons/carhop-source-ecrits.svg b/resources/img/icons/carhop-source-ecrits.svg new file mode 100644 index 0000000..1c0c0f6 --- /dev/null +++ b/resources/img/icons/carhop-source-ecrits.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/resources/img/icons/carhop-source-photo.svg b/resources/img/icons/carhop-source-photo.svg new file mode 100644 index 0000000..bee09cf --- /dev/null +++ b/resources/img/icons/carhop-source-photo.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/resources/img/icons/carhop-source-video.svg b/resources/img/icons/carhop-source-video.svg new file mode 100644 index 0000000..d811d71 --- /dev/null +++ b/resources/img/icons/carhop-source-video.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/template-parts/components/cards/archive-presse-card.php b/template-parts/components/cards/archive-presse-card.php index 250d32d..5c7e3f3 100644 --- a/template-parts/components/cards/archive-presse-card.php +++ b/template-parts/components/cards/archive-presse-card.php @@ -10,7 +10,7 @@ $link = get_field('source_url', $ID) ?? "#"; $has_post_thumbnail = has_post_thumbnail($ID); $thumbnail_url = get_the_post_thumbnail_url($ID) ?? null; -$date = get_the_date('F Y', $ID); +$year = get_field('year', $ID); $authors = get_field('authors', $ID); $editors = get_field('editors', $ID); @@ -18,9 +18,19 @@ $editors = get_field('editors', $ID); $numerotation = get_post_meta($ID, 'post_numerotation', true); $tags = get_the_terms($ID, 'etiquettes'); +$media_types = get_field('media_type', $ID); + +$media_types_list = array( + 'audio' => 'Audio', + 'video' => 'Vidéo', + 'photo' => 'Photo', + 'image' => 'Image', + 'article' => 'Article', +); + ?> - +
<?php echo $title; ?> @@ -40,7 +50,7 @@ $tags = get_the_terms($ID, 'etiquettes');
- +
    @@ -65,6 +75,20 @@ $tags = get_the_terms($ID, 'etiquettes');
+ + +
    + + +
  • 1 ? 's' : ''); ?>
  • + +
+
diff --git a/template-parts/post-types/archives-presse/archives-presse-grid.php b/template-parts/post-types/archives-presse/archives-presse-grid.php index e5c90af..c8777ad 100644 --- a/template-parts/post-types/archives-presse/archives-presse-grid.php +++ b/template-parts/post-types/archives-presse/archives-presse-grid.php @@ -1,52 +1,77 @@ 'archives-presse', - 'posts_per_page' => 10, + 'posts_per_page' => -1, + 'meta_key' => 'year', + 'orderby' => 'meta_value_num', + 'order' => 'ASC', )); -$archives_presse_by_decade = array(); +$archives_presse_by_decade = []; +$used_media_types_by_decade = []; foreach ($archives_presse as $archive) { $year = (int) get_field('year', $archive->ID); - if (!$year) { - continue; - } + $media_types = get_field('media_type', $archive->ID); + + if (!$year) continue; $decade = floor($year / 10) * 10; $archives_presse_by_decade[$decade][] = $archive; + + if (isset($media_types) && is_array($media_types)) { + foreach ($media_types as $media_type) { + if (!isset($used_media_types_by_decade[$decade])) { + $used_media_types_by_decade[$decade] = []; + } + if (!in_array($media_type['acf_fc_layout'], $used_media_types_by_decade[$decade])) { + $used_media_types_by_decade[$decade][] = $media_type['acf_fc_layout']; + } + } + } } -write_log($archives_presse_by_decade); +$media_types_list = array( + 'audio' => 'Audios', + 'video' => 'Vidéos', + 'photo' => 'Photo', + 'image' => 'Images', + 'article' => 'Articles', +); + ?> - -

Ce que dit la presse de nous

-
+
- - $archive->ID)); ?> + $archives) : ?> +
+
+

+
+
    + +
  • + +
  • + +
+ + $archive->ID)); ?> + +
-
- - -
- - -
\ No newline at end of file