-
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.
refactor(breadcrumbs): simplify and refactor breadcrumbs (#434)
* refactor: simplify and improve breadcrumbitem * fix: fix tests * fix: improve route handle type
- Loading branch information
Showing
6 changed files
with
154 additions
and
66 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
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 |
---|---|---|
@@ -1,17 +1,19 @@ | ||
import type { useMatches } from 'react-router-dom' | ||
import type { ModelSection } from '../../types' | ||
import type { UIMatch, useMatches } from 'react-router-dom' | ||
import type { ModelSection, OverviewSection } from '../../types' | ||
// utility type to type a match with a handle-property returned from useMatches | ||
// since handle is unknown, we need to cast it to the correct type | ||
type MatchWithHandle<THandle> = ReturnType<typeof useMatches>[number] & { | ||
handle?: THandle | ||
} | ||
|
||
export type BreadCrumbMatchInfo = Pick<UIMatch, 'params' | 'pathname'> | ||
|
||
// common type for possible handle-properties used in Route | ||
export type RouteHandle = { | ||
hideSidebar?: boolean | ||
section?: ModelSection | ||
section?: ModelSection | OverviewSection | ||
showFooter?: boolean | ||
crumb?: () => React.ReactNode | ||
crumb?: (matchInfo: BreadCrumbMatchInfo) => React.ReactNode | ||
} | ||
|
||
export type MatchRouteHandle = MatchWithHandle<RouteHandle> |