/** Normalize JS */
import 'babel-polyfill';
/** Normaize CSS */
import { normalize } from "csstips";
normalize();
import { forceRenderStyles, cssRaw } from 'typestyle';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { routeState } from './routeState';
import { observer } from 'mobx-react';
import { router } from './router';
import { links } from './links';
/**
* Some page CSS customizations.
* Note: Creating componentized CSS would detract from the points of the demo
*/
cssRaw(`
#root {
padding: 10px;
}
`);
import { Button, Alert, Vertical, Horizontal, AlertSuccess } from './ui/components';
/**
* A sample nav
*/
export const Nav = observer(() => {
return
{routeState.loggedIn &&
Dave
John
}
{routeState.loggedIn && }
Code for the demo
Yester Docs
Star it on github ⭐
;
});
/**
* Pages
*/
export const Login = observer(() =>
Login Page
{!routeState.loggedIn && }
{routeState.loggedIn && You are logged in! Visit some profile Pages :)}
{routeState.loginRequiredMessage && {routeState.loginRequiredMessage}}
);
export const Profile = observer(({ profileId }: { profileId: string }) =>
Profile of : {profileId}
);
/**
* Example of how a link component could be implemented
*/
const Link = ({path, replace, children}: {path: string, replace?: boolean, children?: any}) => {
return router.handleAnchorClick(e.nativeEvent, replace, path)}>{children};
}
/**
* Route -> Page
*/
const Page = observer(() => {
switch (routeState.route) {
case 'login': return ;
case 'profile': return
default:
const _ensure: never = routeState.route;
return
}
});
/**
* Kickoff
*/
ReactDOM.render(, document.getElementById('root'))
router.init();
forceRenderStyles();
/** Set stateful modules */
import { setStatefulModules } from 'fuse-box/modules/fuse-hmr';
setStatefulModules((n) => /routeState/.test(n));