-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor and move NavigationBar code to components package #10
- Loading branch information
1 parent
da92d9d
commit 71985dd
Showing
11 changed files
with
104 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './general'; | ||
export * from './list'; | ||
export * from './navigation'; |
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 @@ | ||
export * from './navigationBar.component'; |
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
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,22 +1,31 @@ | ||
import { LinkType } from './link.type'; | ||
import { AppPath } from './appPath.type'; | ||
import { RouteProps } from 'react-router'; | ||
import { RouteProps, RouteComponentProps } from 'react-router'; | ||
|
||
/** | ||
* Each Approute can have a specific link (i.e., path with filled parameter placeholders), | ||
* a display Name, i.e., text of the link and a nonoptional (!) path | ||
*/ | ||
export interface AppRoute extends RouteProps { | ||
// Use this if the link target differs from the path specification, | ||
// i.e., if the path url contains paramter specifications etc | ||
/** | ||
* Use this if the link target differs from the path specification, | ||
* i.e., if the path url contains paramter specifications etc | ||
*/ | ||
readonly link?: LinkType; | ||
|
||
// link text (Human readable!) | ||
/** link text (Human readable!) */ | ||
readonly displayName?: string; | ||
|
||
// optional icon displayed next to the link name | ||
/** optional icon displayed next to the link name */ | ||
readonly icon?: JSX.Element; | ||
|
||
// AppRoutes must have a path - deoptionalize this property | ||
/** AppRoutes must have a path - deoptionalize this property */ | ||
readonly path: AppPath; | ||
|
||
/** render is required for AppRoutes */ | ||
readonly render: (props: RouteComponentProps<any>) => React.ReactNode; | ||
|
||
/** prevent usage of component/children props, i.e., AppRoutes must use render! */ | ||
readonly component?: never; | ||
readonly children?: never; | ||
} |
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,22 @@ | ||
import { AppRoute } from './appRoute.type'; | ||
import { LinkType } from './link.type'; | ||
|
||
/** | ||
* Retrieves the url which other pages can use to link to a certain | ||
* app path | ||
* | ||
* @param route | ||
*/ | ||
export function getLinkForRoute(route: AppRoute): LinkType { | ||
return route.link || route.path; | ||
} | ||
|
||
/** | ||
* Retrieves the human readable link title/displayed name for | ||
* a given route | ||
* | ||
* @param route | ||
*/ | ||
export function getDisplayNameForRoute(route: AppRoute): string { | ||
return route.displayName || getLinkForRoute(route); | ||
} |
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,3 +1,4 @@ | ||
export * from './appPath.type'; | ||
export * from './appRoute.type'; | ||
export * from './appRoute.util'; | ||
export * from './link.type'; |