-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support custom search param propagation (#519)
This also removes the non-standard `v-panel` from default behaviour. ```diff + <ScoobieLinkProvider propagateSearchParams={['debug', 'v']}> <BraidProvider linkComponent={ScoobieLink} theme={apacTheme}> <TextLink href="/root-relative">Internal link</TextLink> </BraidProvider> + </ScoobieLinkProvider> ```
- Loading branch information
Showing
6 changed files
with
109 additions
and
30 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,29 @@ | ||
import React, { type ReactNode, createContext, useContext } from 'react'; | ||
|
||
interface ScoobieLinkContext { | ||
propagateSearchParams: string[]; | ||
} | ||
|
||
const ctx = createContext<ScoobieLinkContext>({ | ||
propagateSearchParams: ['v'], | ||
}); | ||
|
||
interface ScoobieLinkProviderProps { | ||
children: ReactNode; | ||
|
||
/** | ||
* The search parameters to propagate on internal links. | ||
* | ||
* This defaults to `['v']` in the absence of a `ScoobieLinkProvider`. | ||
*/ | ||
propagateSearchParams: string[]; | ||
} | ||
|
||
export const ScoobieLinkProvider = ({ | ||
children, | ||
...value | ||
}: ScoobieLinkProviderProps) => { | ||
<ctx.Provider value={value}>{children}</ctx.Provider>; | ||
}; | ||
|
||
export const useScoobieLink = () => useContext(ctx); |
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