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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
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
// Idle | |
// after 30 seconds check status | |
// if in timezone && status promise resolves | |
// state => live | |
// live State | |
// after 30 seconds check status | |
// substate state == stop && outside timezone => state: idle | |
// substate state == play && fetch response reject => state: closing | |
// neither conditions pass => no op. check again in 30 seconds | |
// substates |
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
export const ContentBox = createRegisterableComponent( | |
"content-box", | |
(props: { content: string }, services) => ( | |
<div> | |
<p>{props.content}</p> | |
{services.featureState.showSpecial && ( | |
<div>Special content item - enabled with feature toggle service</div> | |
)} | |
</div> | |
) |
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
<Layout.CompositionsRenderer | |
services={{ featureState: { showSpecial: true } }} | |
compositions={[definition]} | |
/> |
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
const definition = Layout.composition({ | |
type: "site-composition", | |
props: {}, | |
contentAreas: { | |
header: [ | |
{ | |
type: "site-header", | |
props: { | |
title: "Main title" | |
} |
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
const Layout = new LayoutRegistration<LayoutServices>() | |
.registerComponents(registrar => | |
registrar | |
.registerComponent(SiteHeader) | |
.registerComponent(ContentBox) | |
) | |
.registerCompositions(registrar => | |
registrar | |
.registerComposition(SiteComposition) | |
.registerComposition(SplitComposition) |
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
export const SiteComposition = createRegisterableComposition< | |
"header" | "content" | |
>()("site-composition", contentAreas => ( | |
<div> | |
<header>{contentAreas.header}</header> | |
<main>{contentAreas.content}</main> | |
</div> | |
)); |
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
import { | |
getRegistrationCreators, | |
LayoutRegistration | |
} from "json-react-layouts"; | |
const { | |
createRegisterableComponent, | |
createRegisterableComposition | |
} = getRegistrationCreators<LayoutServices>(); |
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
interface LayoutServices { | |
featureState: { showSpecial: boolean }; | |
} |
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
export const SiteHeader = createRegisterableComponent( | |
"site-header", | |
(props: { title: string }, services) => ( | |
<header> | |
<h1>{props.title}</h1> | |
</header> | |
) | |
); |
NewerOlder