Skip to content
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

fix: use configuration to use a custom logo and css in the report #285

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion report/www/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ function MyApp({ Component, pageProps }: AppProps) {
init({ url: MATOMO_URL, siteId: "" + MATOMO_SITE_ID });
}, []);
return (
<div className={(dashlordConfig.marianne ? "" : "nonGovernementalWebsite")}>
<div className={(dashlordConfig.marianne ? "" : "non-governemental-website")}>
{ dashlordConfig.customCss &&
<link rel="stylesheet" type="text/css" href={dashlordConfig.customCss}/>
}
<Head>
<meta charSet="utf-8" lang="FR-fr" />
<meta
Expand Down
28 changes: 19 additions & 9 deletions report/www/src/components/HeaderSite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,23 @@ const TitleLink = ({
);
};

const CustomHeader = () => <div className="custom-header">
<img src={dashlordConfig.logo} alt={dashlordConfig.logoAltTxt}/>
<div className="custom-title">
<h1>{dashlordConfig.title}</h1>
<p>{dashlordConfig.description}</p>
</div>
</div>

const MarianneHeader = () => <div>
<Marianne asLink={<TitleLink href="/"/>} splitCharacter={10}>{dashlordConfig.entity}</Marianne>
<Service
asLink={<TitleLink href="/" />}
title={dashlordConfig.title}
description={dashlordConfig.description}
/>
</div>

export const HeaderSite: React.FC<HeaderSiteProps> = ({ report }) => {
const sortedReport = (report && report.sort(sortByKey("url"))) || [];
const categories = uniq(
Expand All @@ -65,19 +82,12 @@ export const HeaderSite: React.FC<HeaderSiteProps> = ({ report }) => {
const tags = uniq(
sortedReport.filter((u) => u.category).flatMap((u) => u.tags)
).sort() as string[];
const Logo = dashlordConfig.marianne ? Marianne : () => <div />;
const ConfigHeader = dashlordConfig.marianne ? MarianneHeader : CustomHeader;
return (
<>
<Header>
<HeaderBody>
<Logo asLink={<TitleLink href="/" />} splitCharacter={10}>
{dashlordConfig.entity}
</Logo>
<Service
asLink={<TitleLink href="/" />}
title={dashlordConfig.title}
description={dashlordConfig.description}
/>
<ConfigHeader/>
<Tool closeButtonLabel="fermer">
<ToolItemGroup>
{dashlordConfig.loginUrl && (
Expand Down
23 changes: 21 additions & 2 deletions report/www/src/overrideDSFR.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,26 @@

}

.nonGovernementalWebsite {
.custom-header {
display: flex;
img {
max-width: 200px;
max-height: 150px;
}

.custom-title {
margin: 0 50px;
h1 {
font-size: 25px;
}
}

.fr-header__brand {
display: none;
}
}

.non-governemental-website {
/* most crucial change, remove use of the Marianne protected font */
font-family: Helvetica, Arial, sans-serif;

Expand Down Expand Up @@ -40,6 +59,6 @@
background-color:var(--background-default-green-non-france);
color:var(--text-action-high-grey);
font-weight: bold;
}
}
}

3 changes: 3 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ type DashlordConfig = {
tools?: DashlordTool[] | Record<DashlordTool, boolean>;
urls: UrlConfig[];
marianne?: boolean;
logo?: string;
logoAltTxt?: string;
customCss?: string;
loginUrl?: string;
matomoId?: number;
matomoUrl?: string;
Expand Down
Loading