-
Notifications
You must be signed in to change notification settings - Fork 26
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
feat: Handle new configuration for logos #2034
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,20 +3,19 @@ import { useClient, useQuery } from 'cozy-client' | |
import { buildContextQuery } from 'queries' | ||
import Divider from 'cozy-ui/transpiled/react/Divider' | ||
|
||
import { getHomeLogos } from 'components/FooterLogo/helpers' | ||
|
||
export const FooterLogo = () => { | ||
const client = useClient() | ||
const rootURL = client.getStackClient().uri | ||
|
||
const contextQuery = buildContextQuery() | ||
const { data } = useQuery(contextQuery.definition, contextQuery.options) | ||
|
||
const logos = getHomeLogos(data, rootURL) | ||
const logos = data?.logos?.home?.light || [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on pourrait commenter ici pour indiquer que seul le theme light est supporté (car forcé). D'ailleurs, pourquoi light puisqu'on est en dark sur la home, non ? 🤔 Ca veut dire que les logos ne sont pas rangé par theme, mais par "style" ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. vu en zoom, ils sont bien rangés par thème 👍 donc home.light fait référence au logo pour un thème light (donc une version foncé du logo). |
||
const secondaries = logos.filter(logos => logos.type === 'secondary') | ||
JF-Cozy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const main = logos.find(logos => logos.type === 'main') | ||
|
||
const hasSecondaries = | ||
logos.secondaries && Object.keys(logos.secondaries).length !== 0 | ||
const hasMain = logos.main !== undefined | ||
const hasSecondaries = secondaries.length !== 0 | ||
const hasMain = main !== undefined | ||
|
||
if (!hasMain && !hasSecondaries) return <div className="u-mt-3-s"></div> | ||
|
||
|
@@ -27,9 +26,9 @@ export const FooterLogo = () => { | |
<div className="u-flex u-mh-auto u-maw-100 u-flex-items-center"> | ||
{hasMain ? ( | ||
<img | ||
key={logos.main.url} | ||
src={logos.main.url} | ||
alt={logos.main.alt} | ||
key={main.src} | ||
src={`${rootURL}/assets${main.src}`} | ||
alt={main.alt} | ||
className="u-ph-1 u-pv-1 u-mah-3" | ||
/> | ||
) : null} | ||
|
@@ -40,11 +39,11 @@ export const FooterLogo = () => { | |
) : null} | ||
{hasSecondaries ? ( | ||
<div className="u-flex u-flex-grow-1 u-ov-auto u-filter-gray-100 u-pv-1"> | ||
{Object.entries(logos.secondaries).map(([logoSrc, logoAlt]) => ( | ||
{secondaries.map(({ src, alt }) => ( | ||
<img | ||
key={logoSrc} | ||
src={logoSrc} | ||
alt={logoAlt} | ||
key={src} | ||
src={`${rootURL}/assets${src}`} | ||
alt={alt} | ||
className="u-ph-1 u-mah-3" | ||
style={{ | ||
objectFit: 'contain' | ||
|
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
le fait d'avoir un helper permet de tester spécifiquement, cf la question sur le plantage si logos vaut un tableau vide
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Encore faut-il que ça vaille la peine d'être testé. Ici en l'occurrence, je suis assez d'accord avec ce qui a été fait. On peut effectivement ajouter un test sur un homeLogo vide et vérifier que rien n'est affiché. AMA pas besoin de plus.