-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(page-metadata): adding ability to send page metadata to host
- Loading branch information
1 parent
bc17ac3
commit a087ab2
Showing
7 changed files
with
128 additions
and
8 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { | ||
array, | ||
constant, | ||
Decoder, | ||
mixed, | ||
object, | ||
optional, | ||
string | ||
} from 'decoders'; | ||
import { labeledDecoder, LabeledMsg } from './LabeledMsg'; | ||
|
||
/** | ||
* The Page metadata | ||
*/ | ||
export interface PageMetadata { | ||
/** Title of the Page for the browser */ | ||
title: string; | ||
/** Breadcrumbs that lead to page */ | ||
breadcrumbs: Breadcrumb[]; | ||
/** holder for any custom data client wants to send for page */ | ||
custom?: any; | ||
} | ||
|
||
/** | ||
* Single breadcrumb | ||
*/ | ||
export interface Breadcrumb { | ||
/** UI text for breadcrumb */ | ||
text: string; | ||
/** link href for routing to breadcrumb's page */ | ||
href: string; | ||
} | ||
|
||
/** | ||
* A message used to send metadata of a page | ||
* from the clients to the host application. | ||
*/ | ||
export interface LabeledPageMetadata | ||
extends LabeledMsg<'pageMetadata', PageMetadata> { | ||
/** Message identifier */ | ||
msgType: 'pageMetadata'; | ||
/** Modal request details (type and data) */ | ||
msg: PageMetadata; | ||
} | ||
|
||
const decoder: Decoder<LabeledPageMetadata> = labeledDecoder( | ||
constant<'pageMetadata'>('pageMetadata'), | ||
object({ | ||
title: string, | ||
breadcrumbs: array( | ||
object({ | ||
text: string, | ||
href: string | ||
}) | ||
), | ||
custom: optional(mixed) | ||
}) | ||
); | ||
|
||
export { decoder }; |