feat: 💄 Wrap dsfr css imports in a dsfr layer #400
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR just wraps the included dsfr css in a dsfr layer. This allows codebases that are using the nextjs pages dir to better prioritize the dsfr css with respect to their own or third party libraries.
For example, at Réfugiés.info, we have a legacy codebase with several different frameworks historically including for example some bootstrap. We use a @layers directive to help prioritize these different and sometimes conflicting css files.
https://github.com/refugies-info/karfur/blob/89b999a95d7d547a3f0749da41c7e17a0d7379f7/apps/client/src/css/index.css#L1
Since react-dsfr imports dsfr.min.css in the Next Pages Router integration:
react-dsfr/src/next-pagesdir.tsx
Line 24 in 16f7f11
We currently resort to patching the dsfr.min.css file, however this requires updating the patch for each new react-dsfr release, which is not ideal.
https://github.com/refugies-info/karfur/blob/89b999a95d7d547a3f0749da41c7e17a0d7379f7/package.json#L26