Improve layout (#74)
This improves the layout of all our pages to look more like the mandala page.
Additionally, some form widgets now have better layout, and the header takes up less vertical space.
At an implementation level, the component hierarchy of pages has been inverted to make this kind of layout easier. Now fully laid-out pages are contained within `<Page>` components that are at the top of the component hierarchy, and which are defined by each specific page (mandala, creature, vocabulary, etc).
I had to do a few architectural things to avoid circular imports, though; most notably, this involved the creation of a new React context called a `PageContext`.
It uses CSS grid, which should be pretty well-supported amongst recent browsers.
2021-04-02 23:00:29 +00:00
|
|
|
import { WavesPage } from "./waves-page";
|
|
|
|
import { VocabularyPage } from "./vocabulary-page";
|
|
|
|
import { CreaturePage } from "./creature-page";
|
|
|
|
import { MandalaPage } from "./mandala-page";
|
|
|
|
import { DebugPage } from "./debug-page";
|
|
|
|
|
|
|
|
export const Pages = {
|
|
|
|
vocabulary: VocabularyPage,
|
|
|
|
creature: CreaturePage,
|
|
|
|
waves: WavesPage,
|
|
|
|
mandala: MandalaPage,
|
|
|
|
debug: DebugPage,
|
|
|
|
};
|
|
|
|
|
|
|
|
export type PageName = keyof typeof Pages;
|
|
|
|
|
|
|
|
export const pageNames = Object.keys(Pages) as PageName[];
|
|
|
|
|
2021-04-02 23:02:40 +00:00
|
|
|
export const DEFAULT_PAGE: PageName = "mandala";
|
Improve layout (#74)
This improves the layout of all our pages to look more like the mandala page.
Additionally, some form widgets now have better layout, and the header takes up less vertical space.
At an implementation level, the component hierarchy of pages has been inverted to make this kind of layout easier. Now fully laid-out pages are contained within `<Page>` components that are at the top of the component hierarchy, and which are defined by each specific page (mandala, creature, vocabulary, etc).
I had to do a few architectural things to avoid circular imports, though; most notably, this involved the creation of a new React context called a `PageContext`.
It uses CSS grid, which should be pretty well-supported amongst recent browsers.
2021-04-02 23:00:29 +00:00
|
|
|
|
|
|
|
export function isPageName(page: string): page is PageName {
|
|
|
|
return pageNames.includes(page as any);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function toPageName(page: string, defaultValue: PageName): PageName {
|
|
|
|
if (isPageName(page)) return page;
|
|
|
|
return defaultValue;
|
|
|
|
}
|