-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update document title and change filename of downloaded data
- Loading branch information
Showing
10 changed files
with
54 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { LunaticSlotComponents } from '@inseefr/lunatic' | ||
import { slotComponents as dsfrSlotsComponents } from '@inseefr/lunatic-dsfr' | ||
import { useSequenceTitle } from 'hooks/useDocumentTitle' | ||
import { assert } from 'tsafe/assert' | ||
|
||
const Sequence: LunaticSlotComponents['Sequence'] = (props) => { | ||
const DsfrSequence = dsfrSlotsComponents['Sequence'] | ||
|
||
assert(DsfrSequence !== undefined) | ||
|
||
useSequenceTitle(props.label) | ||
|
||
return <DsfrSequence {...props} /> | ||
} | ||
|
||
export const slotComponents = { ...dsfrSlotsComponents, Sequence } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,26 @@ | ||
import { useEffect } from 'react' | ||
import { useEffect, type ReactNode } from 'react' | ||
import { renderToString } from 'react-dom/server' | ||
|
||
export function useDocumentTitle(title: string) { | ||
useEffect(() => { | ||
|
||
const prevTitle = document.title | ||
|
||
document.title = title | ||
|
||
return () => { | ||
document.title = prevTitle | ||
} | ||
}) | ||
} | ||
|
||
export function useSequenceTitle(sequenceLabel: ReactNode) { | ||
//TODO get the name of the site (in metadata.json I hope) | ||
/** | ||
* This is a dirty, sequenceLabel is today a LabelType VTL|MD, | ||
* it will be replaced by VTL only so we will be able to just sequenceLabel.toString() | ||
*/ | ||
return useDocumentTitle( | ||
`${renderToString(sequenceLabel)} | Filière d'Enquête` | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters