| 1 |
import { Page as Centered } from './centered/Page'; |
| 2 |
import { Page as Choice } from './choice/Page'; |
| 3 |
import { Page as Modal } from './modal/Page'; |
| 4 |
import { Page as Split } from './split/Page'; |
| 5 |
import { Page as Stacked } from './stacked/Page'; |
| 6 |
|
| 7 |
/** |
| 8 |
* A template arranges the page; it never builds its parts. The flow passes them |
| 9 |
* in already wired, so no template can drop the required-plugin pre-install, an |
| 10 |
* A/B assignment or the submit flow by omitting a slot. |
| 11 |
* |
| 12 |
* One registry per screen: a template built for one renders blank in the other. |
| 13 |
*/ |
| 14 |
export const DESCRIPTION_PAGES = { centered: Centered, split: Split }; |
| 15 |
export const PROGRESS_PAGES = { stacked: Stacked }; |
| 16 |
export const CHOICE_PAGES = { choice: Choice }; |
| 17 |
export const MODAL_PAGES = { modal: Modal }; |
| 18 |
|
| 19 |
// Which layout ships when a design names none. Change these to ship another. |
| 20 |
export const ACTIVE_DESCRIPTION_TEMPLATE = 'centered'; |
| 21 |
export const ACTIVE_PROGRESS_TEMPLATE = 'stacked'; |
| 22 |
export const ACTIVE_CHOICE_TEMPLATE = 'choice'; |
| 23 |
export const ACTIVE_MODAL_TEMPLATE = 'modal'; |
| 24 |
|
| 25 |
let chosen = {}; |
| 26 |
|
| 27 |
// An unknown layout falls back to the shipped one, or an old install draws blank. |
| 28 |
export const chooseTemplates = (templates) => { |
| 29 |
chosen = templates ?? {}; |
| 30 |
}; |
| 31 |
|
| 32 |
const pageFor = (pages, name, shipped, fallback) => |
| 33 |
pages[chosen[name]] ?? pages[shipped] ?? fallback; |
| 34 |
|
| 35 |
export const activeDescriptionTemplate = () => |
| 36 |
pageFor( |
| 37 |
DESCRIPTION_PAGES, |
| 38 |
'description', |
| 39 |
ACTIVE_DESCRIPTION_TEMPLATE, |
| 40 |
Centered, |
| 41 |
); |
| 42 |
|
| 43 |
export const activeProgressTemplate = () => |
| 44 |
pageFor(PROGRESS_PAGES, 'progress', ACTIVE_PROGRESS_TEMPLATE, Stacked); |
| 45 |
|
| 46 |
export const activeChoiceTemplate = () => |
| 47 |
pageFor(CHOICE_PAGES, 'choice', ACTIVE_CHOICE_TEMPLATE, Choice); |
| 48 |
|
| 49 |
export const activeModalTemplate = () => |
| 50 |
pageFor(MODAL_PAGES, 'modal', ACTIVE_MODAL_TEMPLATE, Modal); |
| 51 |
|