-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prise en compte des retours PR vitejs
- Creation d'un composnant <BrowserOnly /> pour éviter le CLS - Restaure l'animation de chargement et le message de navigateur obsolète - Correction d'une chaîne de caractère dans l'UI avec des tabulations - Répare la section nouveautés - Suppression du rehooks/local-storage - Suppression de swr
- Loading branch information
1 parent
05b3692
commit 0dc45b4
Showing
23 changed files
with
249 additions
and
156 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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,56 +1,59 @@ | ||
// import { useLocalStorage, writeStorage } from '@rehooks/local-storage' | ||
import { Appear } from 'Components/ui/animate' | ||
import Emoji from 'Components/utils/Emoji' | ||
import { SitePathsContext } from 'Components/utils/SitePathsContext' | ||
import lastRelease from 'Data/last-release.json' | ||
import { Banner, HideButton, InnerBanner } from 'DesignSystem/banner' | ||
import { Link } from 'DesignSystem/typography/link' | ||
import { useContext, useEffect } from 'react' | ||
import { useContext, useEffect, useState } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { getItem, setItem } from '../../storage/safeLocalStorage' | ||
|
||
const localStorageKey = 'last-viewed-release' | ||
|
||
export const hideNewsBanner = () => { | ||
// writeStorage(localStorageKey, lastRelease.name) | ||
setItem(localStorageKey, lastRelease.name) | ||
} | ||
|
||
export const determinant = (word: string) => | ||
/^[aeiouy]/i.exec(word) ? 'd’' : 'de ' | ||
|
||
export default function NewsBanner() { | ||
// const [lastViewedRelease] = useLocalStorage(localStorageKey) | ||
const sitePaths = useContext(SitePathsContext) | ||
const { i18n, t } = useTranslation() | ||
const { t } = useTranslation() | ||
const lastViewedRelease = getItem(localStorageKey) | ||
const [showBanner, setShowBanner] = useState( | ||
lastViewedRelease && lastViewedRelease !== lastRelease.name | ||
) | ||
|
||
// We only want to show the banner to returning visitors, so we initiate the | ||
// local storage value with the last release. | ||
useEffect(() => { | ||
// writeStorage( | ||
// localStorageKey, | ||
// lastViewedRelease === undefined ? lastRelease.name : lastViewedRelease | ||
// ) | ||
setItem( | ||
localStorageKey, | ||
lastViewedRelease == undefined ? lastRelease.name : lastViewedRelease | ||
) | ||
}, []) | ||
|
||
const showBanner = false | ||
|
||
if (!showBanner) { | ||
return null | ||
} | ||
return ( | ||
<Appear> | ||
<Banner className="print-hidden"> | ||
<InnerBanner> | ||
<span> | ||
<Emoji emoji="✨" /> Découvrez les nouveautés{' '} | ||
{determinant(lastRelease.name)} | ||
<Link to={sitePaths.nouveautés}> | ||
{lastRelease.name.toLowerCase()} | ||
</Link> | ||
</span> | ||
<HideButton onPress={hideNewsBanner} aria-label={t('Fermer')}> | ||
× | ||
</HideButton> | ||
</InnerBanner> | ||
</Banner> | ||
</Appear> | ||
<Banner className="print-hidden" onClick={() => setShowBanner(false)}> | ||
<InnerBanner> | ||
<span> | ||
<Emoji emoji="✨" /> Découvrez les nouveautés{' '} | ||
{determinant(lastRelease.name)} | ||
<Link to={sitePaths.nouveautés}> | ||
{lastRelease.name.toLowerCase()} | ||
</Link> | ||
</span> | ||
<HideButton | ||
onPress={() => setShowBanner(false)} | ||
aria-label={t('Fermer')} | ||
> | ||
× | ||
</HideButton> | ||
</InnerBanner> | ||
</Banner> | ||
) | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Appear } from 'Components/ui/animate' | ||
import React from 'react' | ||
|
||
// We add a animation for all coponents displayed on the client only but not on | ||
// the SSR to avoid augment the CLS (Cumulative Layout Shift). | ||
export default function BrowserOnly({ | ||
children, | ||
}: { | ||
children: React.ReactNode | ||
}) { | ||
if (import.meta.env.SSR) { | ||
return null | ||
} | ||
return <Appear>{children}</Appear> | ||
} |
This file contains 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 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 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 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 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 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
Oops, something went wrong.