Skip to content

Commit

Permalink
Mise à jour des paragraphes
Browse files Browse the repository at this point in the history
  • Loading branch information
mariheck committed Jan 22, 2024
1 parent 6993dfd commit d3519db
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 15 deletions.
46 changes: 36 additions & 10 deletions packages/site/app/programme/[uid]/ParagrapheService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import {ParagrapheData} from './types';
const ParagrapheService = ({
tailleParagraphe,
titre,
titreCentre = false,
imageTitre,
tailleImageTitre,
sousTitre,
texte,
images,
alignementImageDroite,
Expand Down Expand Up @@ -38,26 +40,50 @@ const ParagrapheService = ({
/>
))}

<div>
<Titre className={classNames({'mb-3': !!imageTitre})}>{titre}</Titre>
<div className="w-full">
<Titre
className={classNames({
'text-center': titreCentre,
'mb-3': !!imageTitre || !!sousTitre,
'mb-0': !imageTitre && !sousTitre && !texte,
})}
>
{titre}
</Titre>

<h3
className={classNames('text-primary-7', {
'text-center': titreCentre,
'mb-3': !!imageTitre,
'mb-0': !imageTitre && !texte,
})}
>
{sousTitre}
</h3>

{!!imageTitre && (
<StrapiImage
data={imageTitre}
className={classNames('mb-6', {
'mx-auto': titreCentre,
'mb-0': !texte,
'h-6': tailleImageTitre === 'sm' || !tailleImageTitre,
'h-20': tailleImageTitre === 'md',
'h-52': tailleImageTitre === 'lg',
})}
/>
)}
<Markdown
texte={texte}
className={classNames('-mb-6', {
'max-md:paragraphe-18 md:paragraphe-22':
tailleParagraphe === 'lg' || !tailleParagraphe,
'paragraphe-18': tailleParagraphe === 'md',
})}
/>

{!!texte && (
<Markdown
texte={texte}
className={classNames('-mb-6', {
'max-md:paragraphe-18 md:paragraphe-22':
tailleParagraphe === 'lg' || !tailleParagraphe,
'paragraphe-18': tailleParagraphe === 'md',
})}
/>
)}
</div>
</Section>
);
Expand Down
8 changes: 6 additions & 2 deletions packages/site/app/programme/[uid]/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ export type ParagrapheFetchedData = {
__component: 'services.paragraphe';
taille_paragraphe?: 'md' | 'lg';
titre?: string;
titre_centre?: boolean;
image_titre?: {data: StrapiItem};
taille_image_titre?: 'sm' | 'md' | 'lg';
texte: string;
sous_titre?: string;
texte?: string;
images?: {data: StrapiItem[]};
alignement_image_droite?: boolean;
};
Expand All @@ -21,9 +23,11 @@ export type ParagrapheData = {
type: 'paragraphe';
tailleParagraphe?: 'md' | 'lg';
titre?: string;
titreCentre?: boolean;
imageTitre?: StrapiItem;
tailleImageTitre?: 'sm' | 'md' | 'lg';
texte: string;
sousTitre?: string;
texte?: string;
images?: StrapiItem[];
alignementImageDroite?: boolean;
};
Expand Down
2 changes: 2 additions & 0 deletions packages/site/app/programme/[uid]/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ export const getServiceStrapiData = async (uid: string) => {
type: 'paragraphe',
tailleParagraphe: paragrapheData.taille_paragraphe,
titre: paragrapheData.titre,
titreCentre: paragrapheData.titre_centre,
imageTitre: paragrapheData.image_titre?.data,
tailleImageTitre: paragrapheData.taille_image_titre,
sousTitre: paragrapheData.sous_titre,
texte: paragrapheData.texte,
images: paragrapheData.images?.data,
alignementImageDroite: paragrapheData.alignement_image_droite,
Expand Down
11 changes: 9 additions & 2 deletions strapi/src/components/services/paragraphe.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"type": "string",
"maxLength": 255
},
"titre_centre": {
"type": "boolean",
"default": false
},
"image_titre": {
"type": "media",
"multiple": false,
Expand All @@ -28,9 +32,12 @@
"default": "sm",
"required": false
},
"sous_titre": {
"type": "string",
"maxLength": 255
},
"texte": {
"type": "richtext",
"required": true
"type": "richtext"
},
"alignement_image_droite": {
"type": "boolean",
Expand Down
7 changes: 6 additions & 1 deletion strapi/types/generated/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,15 @@ export interface ServicesParagraphe extends Schema.Component {
Attribute.SetMinMaxLength<{
maxLength: 255;
}>;
titre_centre: Attribute.Boolean & Attribute.DefaultTo<false>;
image_titre: Attribute.Media;
taille_image_titre: Attribute.Enumeration<['sm', 'md', 'lg']> &
Attribute.DefaultTo<'sm'>;
texte: Attribute.RichText & Attribute.Required;
sous_titre: Attribute.String &
Attribute.SetMinMaxLength<{
maxLength: 255;
}>;
texte: Attribute.RichText;
alignement_image_droite: Attribute.Boolean & Attribute.DefaultTo<false>;
images: Attribute.Media;
};
Expand Down

0 comments on commit d3519db

Please sign in to comment.