-
Notifications
You must be signed in to change notification settings - Fork 12
refactor: implement new CTA card component and fix UI #2088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0dcefd4
feat: implement new CTA card component with responsive design and upd…
yvalentin 80f6a74
fix: simplify structure of CTA card component
yvalentin 03b2713
feat: introduce TeeHeaderLogoCard component for improved image handli…
yvalentin 8183715
fix: update logo handling in components and replace default logo path
yvalentin e7725e1
fix: simplify testimony image
yvalentin 5de2ef5
fix: update title handling in TeeCtaCard and TeeIframeCard components
yvalentin 50a1329
fix: remove empty scoped style block from TeeHeaderLogoCard component
yvalentin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,207 +1,69 @@ | ||
<template> | ||
<div class="fr-container fr-px-0"> | ||
<div class="fr-grid-row"> | ||
<div class="fr-col-12"> | ||
<div class="fr-card fr-card--cta fr-card--horizontal fr-card--grey fr-p-4v"> | ||
<div class="fr-card__body"> | ||
<div class="fr-card__content fr-justify-center"> | ||
<h2 | ||
class="fr-card__title fr-text--blue" | ||
v-html="title" | ||
/> | ||
<p | ||
class="fr-card__desc fr-text--md" | ||
v-html="description" | ||
/> | ||
<div | ||
class="fr-card fr-enlarge-link fr-card--horizontal fr-card--grey fr-p-4v fr-card--no-border" | ||
:class="{ 'fr-card--no-icon': target === '_self' }" | ||
v-if="ctaBtnTitle" | ||
class="fr-card__end" | ||
> | ||
<div class="fr-card__body"> | ||
<div class="fr-card__content fr-justify-center"> | ||
<component | ||
:is="titleTag" | ||
class="fr-card__title" | ||
> | ||
<a | ||
v-if="onClick" | ||
href="#" | ||
:target="target" | ||
:rel="target === '_blank' ? 'noopener external' : 'noopener'" | ||
@click.prevent="onClick()" | ||
v-html="resolvedTitle" | ||
/> | ||
<a | ||
v-else | ||
:href="resolvedLink" | ||
:target="target" | ||
:rel="target === '_blank' ? 'noopener external' : 'noopener'" | ||
v-html="resolvedTitle" | ||
/> | ||
</component> | ||
<p | ||
class="fr-card__desc fr-text--md" | ||
v-html="resolvedDescription" | ||
/> | ||
<div | ||
v-if="ctaBtnTitle" | ||
class="fr-card__end" | ||
> | ||
<TeeDsfrButton class="inline-flex fr-text--yellow fr-text--bold fr-btn-align-center"> | ||
<template #default> | ||
{{ ctaBtnTitle }} | ||
</template> | ||
</TeeDsfrButton> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="fr-card__header"> | ||
<div | ||
class="fr-card__img" | ||
:class="[bgColor ? `fr-bg--${bgColor}` : '', objectFit === 'contain' ? 'fr-card__img--contain' : '']" | ||
> | ||
<img | ||
class="fr-responsive-img" | ||
:src="resolvedImageSrc" | ||
:alt="resolvedImageAlt" | ||
/> | ||
<img | ||
class="fr-card__logo" | ||
:src="img('/images/logos/mission-transition-logo-alone.png', { height: 50, width: 50, quality: 100, loading: 'lazy' })" | ||
alt="Transition Ecologique des Entreprises - ADEME" | ||
/> | ||
</div> | ||
</div> | ||
<TeeDsfrButton | ||
class="inline-flex fr-text--yellow fr-text--bold fr-btn-align-center" | ||
@click.prevent="onClick()" | ||
> | ||
<template #default> | ||
{{ ctaBtnTitle }} | ||
</template> | ||
</TeeDsfrButton> | ||
</div> | ||
</div> | ||
</div> | ||
<TeeHeaderLogoCard | ||
:image-src="imageSrc" | ||
:image-alt="imageAlt" | ||
:img-bg-color="imgBgColor" | ||
:object-fit="objectFit" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { Image } from '@/tools/image' | ||
import { computed } from 'vue' | ||
import { useRouter } from 'vue-router' | ||
import { Color, RouteName } from '@/types' | ||
import { Color } from '@/types' | ||
|
||
interface Props { | ||
link?: string | ||
title?: string | ||
description?: string | ||
description: string | ||
imageSrc?: string | ||
imageAlt?: string | ||
objectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down' | ||
bgColor?: Color | ||
imgBgColor?: Color | ||
ctaBtnTitle?: string | ||
target?: '_blank' | '_self' | '_parent' | '_top' | ||
onClick?: CallableFunction | ||
titleTag?: 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | ||
withIframeResizer?: boolean | ||
onClick: CallableFunction | ||
} | ||
|
||
const props = withDefaults(defineProps<Props>(), { | ||
link: undefined, | ||
title: undefined, | ||
withDefaults(defineProps<Props>(), { | ||
title: 'Accédez aux aides publiques pour votre projet de transition écologique', | ||
imageSrc: undefined, | ||
imageAlt: undefined, | ||
objectFit: 'cover', | ||
bgColor: undefined, | ||
ctaBtnTitle: undefined, | ||
target: '_blank', | ||
onClick: undefined, | ||
titleTag: 'h3', | ||
withIframeResizer: true | ||
imgBgColor: undefined, | ||
ctaBtnTitle: undefined | ||
}) | ||
|
||
const router = useRouter() | ||
|
||
const defaultLink = router.resolve({ name: RouteName.Homepage }).href | ||
const defaultTitle = 'Accédez aux aides publiques pour votre projet de transition écologique' | ||
const defaultImageSrc = 'images/TEE_iframe_transparent.webp' | ||
const defaultImageAlt = "Image de la page d'accueil de mission transition écologique" | ||
|
||
const resolvedLink = computed(() => props.link || defaultLink) | ||
const resolvedTitle = computed(() => props.title || defaultTitle) | ||
const resolvedDescription = computed( | ||
() => | ||
props.description || | ||
'Le service public <strong>Transition écologique des entreprises</strong> vous permet de trouver les aides, accompagnements' + | ||
"et ressources issues de l'ensemble des acteurs publics pour vous aider à réaliser votre projet de transition écologique" + | ||
'(ADEME, CCI, CMA, Bpifrance, DGFiP, etc.)' | ||
) | ||
const resolvedImageSrc = computed(() => | ||
props.imageSrc | ||
? img(props.imageSrc, { height: 250, quality: 70, loading: 'lazy' }) | ||
: img(defaultImageSrc, { height: 350, quality: 100, loading: 'lazy' }) | ||
) | ||
const resolvedImageAlt = computed(() => props.imageAlt || defaultImageAlt) | ||
|
||
const img = Image.getUrl | ||
|
||
if (props.withIframeResizer) { | ||
const imageResizerChild = () => import('@iframe-resizer/child') | ||
imageResizerChild() | ||
} | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
@use '@/assets/scss/tool'; | ||
|
||
.fr-card { | ||
.fr-card--no-icon { | ||
a::after { | ||
display: none !important; | ||
} | ||
} | ||
|
||
.fr-card__title { | ||
a { | ||
background-image: none; | ||
outline-width: 0; | ||
|
||
&::after { | ||
display: inline-block !important; | ||
} | ||
} | ||
} | ||
|
||
@include tool.media-query-respond-from(md) { | ||
.fr-card__header { | ||
flex-basis: 30%; | ||
} | ||
} | ||
|
||
@include tool.media-query-respond-from(lg) { | ||
.fr-card__header { | ||
flex-basis: 25%; | ||
} | ||
} | ||
|
||
.fr-card__header { | ||
align-content: center; | ||
} | ||
|
||
@include tool.media-query-respond-from(md) { | ||
.fr-card__img { | ||
max-height: 250px; | ||
} | ||
} | ||
|
||
.fr-card__img { | ||
position: relative; | ||
|
||
img { | ||
max-height: 250px; | ||
} | ||
|
||
&::after { | ||
content: ''; | ||
position: absolute; | ||
z-index: 0; // Lower layer | ||
height: 100%; | ||
width: 100%; | ||
top: 0; | ||
left: 0; | ||
background: linear-gradient(to bottom right, rgb(255 255 255 / 0%) 70%, rgb(255 255 255 / 100%) 95%) !important; | ||
} | ||
|
||
.fr-card__logo { | ||
position: absolute; | ||
bottom: 0; | ||
right: 0; | ||
width: 50px; | ||
height: 50px; | ||
z-index: 1; // Higher than the gradient | ||
} | ||
:hover:not(button, button *) { | ||
cursor: default !important; | ||
} | ||
} | ||
</style> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.