Skip to content

Commit

Permalink
Actually address #286 #233 #183
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Aug 8, 2024
1 parent 36e683d commit 65f2664
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 54 deletions.
30 changes: 16 additions & 14 deletions src/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-inner-declarations */
import React, {
memo,
forwardRef,
Expand Down Expand Up @@ -173,7 +174,15 @@ export const Header = memo(
}

return cloneElement(node, {
"id": `${id}-quick-access-item-${i}-${usecase}`
"id": `${id}-quick-access-item-${i}${(() => {
switch (usecase) {
case "mobile":
return "-mobile";
case "desktop":
return "";
}
assert<Equals<typeof usecase, never>>();
})()}`
});
})()}
</li>
Expand Down Expand Up @@ -486,42 +495,35 @@ addHeaderTranslations({
export type HeaderQuickAccessItemProps = {
className?: string;
quickAccessItem: HeaderProps.QuickAccessItem;
id?: string;
};

export function HeaderQuickAccessItem(props: HeaderQuickAccessItemProps): JSX.Element {
const { className, quickAccessItem } = props;
const { className, quickAccessItem, id } = props;

const { Link } = getLink();

return quickAccessItem.linkProps !== undefined ? (
<Link
{...(() => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { id, ...rest } = quickAccessItem.linkProps;

return rest;
})()}
{...quickAccessItem.linkProps}
className={cx(
fr.cx("fr-btn", quickAccessItem.iconId),
quickAccessItem.linkProps.className,
className
)}
id={id}
>
{quickAccessItem.text}
</Link>
) : (
<button
{...(() => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { id, ...rest } = quickAccessItem.buttonProps;

return rest;
})()}
{...quickAccessItem.buttonProps}
className={cx(
fr.cx("fr-btn", quickAccessItem.iconId),
quickAccessItem.buttonProps.className,
className
)}
id={id}
>
{quickAccessItem.text}
</button>
Expand Down
12 changes: 6 additions & 6 deletions test/integration/cra/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1110,9 +1110,9 @@
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==

"@codegouvfr/react-dsfr@file:../../../dist":
version "1.6.0"
version "1.10.11"
dependencies:
tsafe "^1.6.3"
tsafe "^1.7.2"
yargs-parser "^21.1.1"

"@csstools/normalize.css@*":
Expand Down Expand Up @@ -8504,10 +8504,10 @@ tryer@^1.0.1:
resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8"
integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==

tsafe@^1.6.3:
version "1.6.3"
resolved "https://registry.yarnpkg.com/tsafe/-/tsafe-1.6.3.tgz#93a77510f542d9043c6f3ab9ed46267729431a59"
integrity sha512-55Tbbxn6XAx1NX7X+fNfIsKsM6XxcbFbUMZ47fjXlef1g9jV8w+mZi3rse0+9Dj5nQefyWLeYT4cAwyiakWszQ==
tsafe@^1.7.2:
version "1.7.2"
resolved "https://registry.yarnpkg.com/tsafe/-/tsafe-1.7.2.tgz#0f63d414876287ad01b135f832722f93e22da374"
integrity sha512-dAPfQLhCfCRre5qs+Z5Q2a7s2CV7RxffZUmvj7puGaePYjECzWREJFd3w4XSFe/T5tbxgowfItA/JSSZ6Ma3dA==

tsconfig-paths@^3.14.1:
version "3.14.1"
Expand Down
12 changes: 6 additions & 6 deletions test/integration/next-appdir/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@
to-fast-properties "^2.0.0"

"@codegouvfr/react-dsfr@file:../../../dist":
version "1.6.0"
version "1.10.11"
dependencies:
tsafe "^1.6.3"
tsafe "^1.7.2"
yargs-parser "^21.1.1"

"@emotion/babel-plugin@^11.10.5":
Expand Down Expand Up @@ -2481,10 +2481,10 @@ tsafe@^1.4.1:
resolved "https://registry.yarnpkg.com/tsafe/-/tsafe-1.4.1.tgz#59cdad8ac41babf88e56dcd1a683ae2fb145d059"
integrity sha512-3IDBalvf6SyvHFS14UiwCWzqdSdo+Q0k2J7DZyJYaHW/iraW9DJpaBKDJpry3yQs3o/t/A+oGaRW3iVt2lKxzA==

tsafe@^1.6.3:
version "1.6.3"
resolved "https://registry.yarnpkg.com/tsafe/-/tsafe-1.6.3.tgz#93a77510f542d9043c6f3ab9ed46267729431a59"
integrity sha512-55Tbbxn6XAx1NX7X+fNfIsKsM6XxcbFbUMZ47fjXlef1g9jV8w+mZi3rse0+9Dj5nQefyWLeYT4cAwyiakWszQ==
tsafe@^1.7.2:
version "1.7.2"
resolved "https://registry.yarnpkg.com/tsafe/-/tsafe-1.7.2.tgz#0f63d414876287ad01b135f832722f93e22da374"
integrity sha512-dAPfQLhCfCRre5qs+Z5Q2a7s2CV7RxffZUmvj7puGaePYjECzWREJFd3w4XSFe/T5tbxgowfItA/JSSZ6Ma3dA==

tsconfig-paths@^3.14.1:
version "3.14.1"
Expand Down
12 changes: 6 additions & 6 deletions test/integration/next-pagesdir/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@
to-fast-properties "^2.0.0"

"@codegouvfr/react-dsfr@file:../../../dist":
version "1.6.0"
version "1.10.11"
dependencies:
tsafe "^1.6.3"
tsafe "^1.7.2"
yargs-parser "^21.1.1"

"@emotion/babel-plugin@^11.10.5":
Expand Down Expand Up @@ -2391,10 +2391,10 @@ to-regex-range@^5.0.1:
dependencies:
is-number "^7.0.0"

tsafe@^1.6.3:
version "1.6.3"
resolved "https://registry.yarnpkg.com/tsafe/-/tsafe-1.6.3.tgz#93a77510f542d9043c6f3ab9ed46267729431a59"
integrity sha512-55Tbbxn6XAx1NX7X+fNfIsKsM6XxcbFbUMZ47fjXlef1g9jV8w+mZi3rse0+9Dj5nQefyWLeYT4cAwyiakWszQ==
tsafe@^1.7.2:
version "1.7.2"
resolved "https://registry.yarnpkg.com/tsafe/-/tsafe-1.7.2.tgz#0f63d414876287ad01b135f832722f93e22da374"
integrity sha512-dAPfQLhCfCRre5qs+Z5Q2a7s2CV7RxffZUmvj7puGaePYjECzWREJFd3w4XSFe/T5tbxgowfItA/JSSZ6Ma3dA==

tsconfig-paths@^3.14.1:
version "3.14.1"
Expand Down
32 changes: 16 additions & 16 deletions test/integration/vite/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
<meta http-equiv="Content-Security-Policy"
content="require-trusted-types-for 'script'; trusted-types react-dsfr react-dsfr-asap" />

<link rel="apple-touch-icon" href="/dsfr/favicon/apple-touch-icon.png" />
<link rel="icon" href="/dsfr/favicon/favicon.svg" type="image/svg+xml" />
<link rel="shortcut icon" href="/dsfr/favicon/favicon.ico" type="image/x-icon" />
<link rel="manifest" href="/dsfr/favicon/manifest.webmanifest" crossorigin="use-credentials" />
<link rel="apple-touch-icon" href="/dsfr/favicon/apple-touch-icon.png?v=1.12.1" />
<link rel="icon" href="/dsfr/favicon/favicon.svg?v=1.12.1" type="image/svg+xml" />
<link rel="shortcut icon" href="/dsfr/favicon/favicon.ico?v=1.12.1" type="image/x-icon" />
<link rel="manifest" href="/dsfr/favicon/manifest.webmanifest?v=1.12.1" crossorigin="use-credentials" />

<!--<link rel="preload" href="/dsfr/fonts/Marianne-Light.woff2" as="font" crossorigin="anonymous" />-->
<!--<link rel="preload" href="/dsfr/fonts/Marianne-Light_Italic.woff2" as="font" crossorigin="anonymous" />-->
<link rel="preload" href="/dsfr/fonts/Marianne-Regular.woff2" as="font" crossorigin="anonymous" />
<!--<link rel="preload" href="/dsfr/fonts/Marianne-Regular_Italic.woff2" as="font" crossorigin="anonymous" />-->
<link rel="preload" href="/dsfr/fonts/Marianne-Medium.woff2" as="font" crossorigin="anonymous" />
<!--<link rel="preload" href="/dsfr/fonts/Marianne-Medium_Italic.woff2" as="font" crossorigin="anonymous" />-->
<link rel="preload" href="/dsfr/fonts/Marianne-Bold.woff2" as="font" crossorigin="anonymous" />
<!--<link rel="preload" href="/dsfr/fonts/Marianne-Bold_Italic.woff2" as="font" crossorigin="anonymous" />-->
<!--<link rel="preload" href="/dsfr/fonts/Spectral-Regular.woff2" as="font" crossorigin="anonymous" />-->
<!--<link rel="preload" href="/dsfr/fonts/Spectral-ExtraBold.woff2" as="font" crossorigin="anonymous" />-->
<!--<link rel="preload" href="/dsfr/fonts/Marianne-Light.woff2?v=1.12.1" as="font" crossorigin="anonymous" />-->
<!--<link rel="preload" href="/dsfr/fonts/Marianne-Light_Italic.woff2?v=1.12.1" as="font" crossorigin="anonymous" />-->
<link rel="preload" href="/dsfr/fonts/Marianne-Regular.woff2?v=1.12.1" as="font" crossorigin="anonymous" />
<!--<link rel="preload" href="/dsfr/fonts/Marianne-Regular_Italic.woff2?v=1.12.1" as="font" crossorigin="anonymous" />-->
<link rel="preload" href="/dsfr/fonts/Marianne-Medium.woff2?v=1.12.1" as="font" crossorigin="anonymous" />
<!--<link rel="preload" href="/dsfr/fonts/Marianne-Medium_Italic.woff2?v=1.12.1" as="font" crossorigin="anonymous" />-->
<link rel="preload" href="/dsfr/fonts/Marianne-Bold.woff2?v=1.12.1" as="font" crossorigin="anonymous" />
<!--<link rel="preload" href="/dsfr/fonts/Marianne-Bold_Italic.woff2?v=1.12.1" as="font" crossorigin="anonymous" />-->
<!--<link rel="preload" href="/dsfr/fonts/Spectral-Regular.woff2?v=1.12.1" as="font" crossorigin="anonymous" />-->
<!--<link rel="preload" href="/dsfr/fonts/Spectral-ExtraBold.woff2?v=1.12.1" as="font" crossorigin="anonymous" />-->

<link rel="stylesheet" href="/dsfr/utility/icons/icons.min.css" />
<link rel="stylesheet" href="/dsfr/dsfr.min.css" />
<link rel="stylesheet" href="/dsfr/utility/icons/icons.min.css?hash=bd03f648" />
<link rel="stylesheet" href="/dsfr/dsfr.min.css?v=1.12.1" />

<title>Vite + React + TS</title>
</head>
Expand Down
12 changes: 6 additions & 6 deletions test/integration/vite/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@
to-fast-properties "^2.0.0"

"@codegouvfr/react-dsfr@file:../../../dist":
version "1.6.0"
version "1.10.11"
dependencies:
tsafe "^1.6.3"
tsafe "^1.7.2"
yargs-parser "^21.1.1"

"@emotion/babel-plugin@^11.11.0":
Expand Down Expand Up @@ -1195,10 +1195,10 @@ to-fast-properties@^2.0.0:
resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e"
integrity sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==

tsafe@^1.6.3:
version "1.6.3"
resolved "https://registry.yarnpkg.com/tsafe/-/tsafe-1.6.3.tgz#93a77510f542d9043c6f3ab9ed46267729431a59"
integrity sha512-55Tbbxn6XAx1NX7X+fNfIsKsM6XxcbFbUMZ47fjXlef1g9jV8w+mZi3rse0+9Dj5nQefyWLeYT4cAwyiakWszQ==
tsafe@^1.7.2:
version "1.7.2"
resolved "https://registry.yarnpkg.com/tsafe/-/tsafe-1.7.2.tgz#0f63d414876287ad01b135f832722f93e22da374"
integrity sha512-dAPfQLhCfCRre5qs+Z5Q2a7s2CV7RxffZUmvj7puGaePYjECzWREJFd3w4XSFe/T5tbxgowfItA/JSSZ6Ma3dA==

typescript@^4.6.4:
version "4.9.5"
Expand Down

0 comments on commit 65f2664

Please sign in to comment.