From 7160caf94ff3d7f91280587efb9cbffbe1254b17 Mon Sep 17 00:00:00 2001
From: Julien Castets
Date: Mon, 4 Oct 2021 15:38:47 +0200
Subject: [PATCH] Remove client-side transitions completely
With nextjs, internal links must be wrapped by a component to
enable client-side transition.
dsfr framework is broken with SPA, and the menu doesn't display
on mobile after you click on a link.
The hack in _app.jsx disables client side transitions completely.
---
components/ButtonLink.jsx | 18 ++++++++++-----
components/QuestionSection.jsx | 10 ++++++---
layouts/BaseLayout.jsx | 40 ++++++++++++++++++++++------------
pages/_app.jsx | 26 +++++++++++++++++++++-
pages/index.jsx | 17 +++++++++++----
5 files changed, 84 insertions(+), 27 deletions(-)
diff --git a/components/ButtonLink.jsx b/components/ButtonLink.jsx
index 3b71031..01008ab 100644
--- a/components/ButtonLink.jsx
+++ b/components/ButtonLink.jsx
@@ -2,11 +2,19 @@ import React from 'react';
import PropTypes from 'prop-types';
const ButtonLink = React.forwardRef(
- ({ onClick, children, variant }, ref) => (
-
- ),
+ ({ onClick, children, variant }, ref) => {
+ const classes = ['fr-btn'];
+
+ if (variant === 'secondary') {
+ classes.push('fr-btn--secondary');
+ }
+
+ return (
+
+ );
+ }
);
ButtonLink.defaultProps = {
diff --git a/components/QuestionSection.jsx b/components/QuestionSection.jsx
index bcf0b73..20050fa 100644
--- a/components/QuestionSection.jsx
+++ b/components/QuestionSection.jsx
@@ -1,3 +1,5 @@
+import Link from 'next/link';
+
import ButtonLink from '@/components/ButtonLink';
import styles from '@/styles/components/QuestionSection.module.css';
@@ -8,9 +10,11 @@ export default function QuestionSection() {
diff --git a/layouts/BaseLayout.jsx b/layouts/BaseLayout.jsx
index 297b71c..779e873 100644
--- a/layouts/BaseLayout.jsx
+++ b/layouts/BaseLayout.jsx
@@ -25,9 +25,11 @@ function Header() {