Skip to content

Commit

Permalink
🏓 Permettre l'export PDF ou impression du comparateur de statut #2406 (…
Browse files Browse the repository at this point in the history
…#2835)

* feat : ajout du bouton "Imprimer/sauvegarder PDF"

* feat : ajout de mise en page pour l'impression

* fix : ajouts des donnes cruciales

* fix: suppresion dans l'impression du bouton "Modifier mes options"

* fix : suppresion de l'affichage du bouton tout deplier lors de l'impression

* fix: suppression padding, margin, border bleue et reduction taille des textes
Co-authored-by: Jofresh <gaborit.geoffray@gmail.com>
  • Loading branch information
Grunt471 authored Jan 31, 2024
1 parent c20a7cb commit d7fb260
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 33 deletions.
14 changes: 13 additions & 1 deletion site/source/design-system/accordion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const Accordion = <T extends object>(
<StyledGrid container>
<Grid item>{title}</Grid>
{isFoldable && (
<Grid item>
<Grid item className="print-hidden">
<StyledFoldButton
underline
onClick={() => (allItemsOpen ? closeAll() : openAll())}
Expand Down Expand Up @@ -204,10 +204,17 @@ const StyledTitle = styled.h3`
const StyledAccordionItem = styled.div`
&:not(:first-child) {
border-top: 1px solid ${({ theme }) => theme.colors.bases.primary[400]};
@media print {
border-top: none;
}
}
`

const StyledButton = styled.button<{ $variant?: 'light' }>`
@media print {
margin: 0;
padding: 0;
}
display: flex;
width: 100%;
background: none;
Expand Down Expand Up @@ -262,6 +269,11 @@ const StyledContent = styled(animated.div)<{
$variant?: 'light'
}>`
overflow: hidden;
@media print {
overflow: visible;
display: table;
> div {margin: 1rem 0 !important;}
}
> div {
margin: ${({ theme, $variant }) =>
$variant !== 'light' && theme.spacings.lg};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function Comparateur({ namedEngines }: { namedEngines: EngineComparison }) {
paddingTop: '1rem',
}}
>
<ModifierOptions namedEngines={namedEngines} />
<ModifierOptions namedEngines={namedEngines} className="print-hidden" />
</div>
</Container>
<DĂ©tails namedEngines={namedEngines} expandRevenuSection />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,11 @@ const DetailsRowCards = ({
.filter((arrayOfStatus) => arrayOfStatus.length > 0)

return (
<Grid container spacing={4}>
<StyledGridContainer container spacing={4}>
{groupedOptions.map((sameValueOptions) => {
const statusObject = sameValueOptions[0]

return (

Check failure on line 93 in site/source/pages/simulateurs/comparaison-statuts/components/DetailsRowCards.tsx

View workflow job for this annotation

GitHub Actions / lint

Expected blank line before this statement
<Grid
<StyledGrid
key={statusObject.name}
item
{...getGridSizes(sameValueOptions.length, options.length)}
Expand Down Expand Up @@ -189,10 +188,10 @@ const DetailsRowCards = ({
)}
</StyledBody>
</StatusCard>
</Grid>
</StyledGrid>
)
})}
</Grid>
</StyledGridContainer>
)
}
const StyledSmall = styled.small`
Expand Down Expand Up @@ -232,6 +231,18 @@ const StyledDiv = styled.div`
display: flex;
align-items: center;
`
const StyledGrid = styled(Grid)`
@media print {
width: 33%;
padding: 5px;
}
`

const StyledGridContainer = styled(Grid)`
@media print {
margin-left: -5px;
}
`

export default DetailsRowCards
const StyledBody = styled(Body)`
Expand All @@ -242,4 +253,7 @@ const StyledBody = styled(Body)`
font-weight: 700;
margin: 0;
margin-top: 0.75rem;
@media print {
font-size: 18px;
}
`
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const DĂ©tails = ({
: theme.colors.bases.primary[200]
}
>
<Accordion
<StyledAccordion
$variant="light"
defaultExpandedKeys={expandRevenuSection ? ['revenus'] : []}
title={
Expand All @@ -47,7 +47,8 @@ const DĂ©tails = ({
}
isFoldable
>
<Item

<StyledItem
title={
<ItemTitle>
<Trans>Vos revenus</Trans>&nbsp;
Expand All @@ -57,6 +58,7 @@ const DĂ©tails = ({
key="revenus"
hasChildItems={false}
>
<OuterOuterContainer>
<StyledH4>
<Trans>Revenu net mensuel après impôts</Trans>

Expand Down Expand Up @@ -157,9 +159,9 @@ const DĂ©tails = ({
</Condition>
)}
/>
</Item>

<Item
</OuterOuterContainer>
</StyledItem>
<StyledItem
title={
<ItemTitle>
<Trans>Vos droits pour la retraite</Trans>&nbsp;
Expand All @@ -169,6 +171,7 @@ const DĂ©tails = ({
key="retraite"
hasChildItems={false}
>
<OuterOuterContainer>
<Body>
<Trans>
Le montant de votre retraite est constitué de{' '}
Expand Down Expand Up @@ -197,7 +200,8 @@ const DĂ©tails = ({
namedEngines={namedEngines}
unit="€/mois"
/>

</OuterOuterContainer>
<OuterOuterContainer>
<StyledH4>
<Trans>Retraite complémentaire</Trans>
<ExplicableRule dottedName="protection sociale . retraite . complémentaire" />
Expand All @@ -224,8 +228,9 @@ const DĂ©tails = ({
unit="€/mois"
evolutionLabel={<Trans>au bout de 10 ans</Trans>}
/>
</Item>
<Item
</OuterOuterContainer>
</StyledItem>
<StyledItem
title={
<ItemTitle>
<Trans>Vos prestations santé</Trans>&nbsp;
Expand All @@ -235,6 +240,7 @@ const DĂ©tails = ({
key="santé"
hasChildItems={false}
>
<OuterOuterContainer>
<Body
style={{
marginBottom: '0',
Expand Down Expand Up @@ -320,7 +326,8 @@ const DĂ©tails = ({
</Condition>
)}
/>

</OuterOuterContainer>
<OuterOuterContainer>
<StyledH4>
<Trans>Accident du travail et maladie professionnelle</Trans>
<ExplicableRule dottedName="protection sociale . maladie . accidents du travail et maladies professionnelles . indemmnités" />
Expand All @@ -340,8 +347,9 @@ const DĂ©tails = ({
evolutionDottedName="protection sociale . maladie . accidents du travail et maladies professionnelles . indemmnités . à partir du 29ème jour"
evolutionLabel={<Trans>à partir du 29ème jour</Trans>}
/>
</Item>
<Item
</OuterOuterContainer>
</StyledItem>
<StyledItem
title={
<ItemTitle>
<Trans>La maternité, paternité et adoption</Trans>&nbsp;
Expand All @@ -351,6 +359,7 @@ const DĂ©tails = ({
key="enfants"
hasChildItems={false}
>
<OuterOuterContainer>
<Body
style={{
marginBottom: '0',
Expand Down Expand Up @@ -378,7 +387,8 @@ const DĂ©tails = ({
namedEngines={namedEngines}
unit="€/jour"
/>

</OuterOuterContainer>
<OuterOuterContainer>
<StyledH4>
<Trans>Maternité</Trans>
<ExplicableRule dottedName="protection sociale . maladie . maternité paternité adoption . allocation forfaitaire de repos maternel" />
Expand All @@ -398,7 +408,8 @@ const DĂ©tails = ({
namedEngines={namedEngines}
label={<Trans>versés en deux fois</Trans>}
/>

</OuterOuterContainer>
<OuterOuterContainer>
<StyledH4>
<Trans>Adoption</Trans>
<ExplicableRule dottedName="protection sociale . maladie . maternité paternité adoption . allocation forfaitaire de repos adoption" />
Expand All @@ -418,8 +429,9 @@ const DĂ©tails = ({
namedEngines={namedEngines}
label={<Trans>versés en une fois</Trans>}
/>
</Item>
<Item
</OuterOuterContainer>
</StyledItem>
<StyledItem
title={
<ItemTitle>
<Trans>Votre couverture invalidité et décès</Trans>&nbsp;
Expand All @@ -429,6 +441,7 @@ const DĂ©tails = ({
key="maladie"
hasChildItems={false}
>
<OuterOuterContainer>
<Body>
<Trans>
Tous les statuts cotisent pour une{' '}
Expand Down Expand Up @@ -485,6 +498,8 @@ const DĂ©tails = ({
</span>
}
/>
</OuterOuterContainer>
<OuterOuterContainer>
<Body>
<Trans>
Pour une invalidité causée par un{' '}
Expand All @@ -497,7 +512,8 @@ const DĂ©tails = ({
namedEngines={namedEngines}
unit="€/mois"
/>

</OuterOuterContainer>
<OuterOuterContainer>
<StyledH4>
<Trans>Décès</Trans>
<ExplicableRule dottedName="protection sociale . invalidité et décès . capital décès" />
Expand All @@ -514,7 +530,8 @@ const DĂ©tails = ({
label="pour vos proches"
namedEngines={namedEngines}
/>

</OuterOuterContainer>
<OuterOuterContainer>
<Body>
<Trans>
En plus du capital décès, une{' '}
Expand All @@ -529,7 +546,8 @@ const DĂ©tails = ({
label={'maximum'}
namedEngines={namedEngines}
/>

</OuterOuterContainer>
<OuterOuterContainer>
<Body>
<Trans>
Pour un décès survenu dans le cadre d’un{' '}
Expand All @@ -544,7 +562,8 @@ const DĂ©tails = ({
unit="€/mois"
label={t("en cas d'accident pro")}
/>

</OuterOuterContainer>
<OuterOuterContainer>
<Body>
<Trans>
Un <Strong>capital « orphelin »</Strong> est versé aux{' '}
Expand All @@ -558,8 +577,9 @@ const DĂ©tails = ({
namedEngines={namedEngines}
unit="€/enfant"
/>
</Item>
<Item
</OuterOuterContainer>
</StyledItem>
<StyledItem
title={
<ItemTitle>
<Trans>
Expand All @@ -570,6 +590,7 @@ const DĂ©tails = ({
key="administratif"
hasChildItems={false}
>
<OuterOuterContainer>
<StyledH4>
<Trans>Coût de création</Trans>
<ExplicableRule dottedName="entreprise . coût formalités . création" />
Expand All @@ -588,7 +609,8 @@ const DĂ©tails = ({
namedEngines={namedEngines}
leastIsBest
/>

</OuterOuterContainer>
<OuterOuterContainer>
<StyledH4>
<Trans>Statut du conjoint</Trans>
</StyledH4>
Expand Down Expand Up @@ -629,14 +651,19 @@ const DĂ©tails = ({
}}
namedEngines={namedEngines}
/>
</Item>
</Accordion>
</OuterOuterContainer>
</StyledItem>
</StyledAccordion>
</Container>
)
}

const StyledH4 = styled(H4)`
color: ${({ theme }) => theme.colors.bases.primary[600]};
@media print {
margin: 0 0 1rem 0;
}
`
// TODO : décommenter une fois l'implémentation du calcul des coûts de créations
// ajouté à modèle-social
Expand All @@ -662,7 +689,7 @@ const Precisions = styled.span`

const StyledDiv = styled.div`
display: flex;
svg {
width: 2.5rem;
margin-right: 1rem;
Expand All @@ -682,4 +709,23 @@ const BlackColoredLink = styled(StyledLink)`
color: ${({ theme }) => theme.colors.extended.grey[800]};
`

const OuterOuterContainer = styled.div`
@media print {
page-break-inside: avoid !important;
}
`

const StyledAccordion = styled(Accordion)`
@media print {
page-break-after: avoid !important;
border: none !important;
}
`

const StyledItem = styled(Item)`
@media print {
page-break-inside: avoid;
}
`

export default DĂ©tails
Loading

0 comments on commit d7fb260

Please sign in to comment.