@tdb/web
Version:
Common condiguration for serving a web-site and testing web-based UI components.
69 lines • 3.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var link_1 = require("next/link");
var common_1 = require("../common");
var Page = (function (_super) {
tslib_1.__extends(Page, _super);
function Page() {
return _super !== null && _super.apply(this, arguments) || this;
}
Page.getInitialProps = function (ctx) {
var path = ctx.asPath, query = ctx.query;
common_1.log.group('getInitialProps');
common_1.log.info('ctx.asPath', ctx.asPath);
common_1.log.info('query', query);
common_1.log.groupEnd();
return { path: path, id: query.id, q: query.q };
};
Page.prototype.componentDidMount = function () {
common_1.log.info('Mounted:', this.props);
};
Page.prototype.render = function () {
common_1.log.info('Render:', this.props);
var styles = {
base: common_1.css({}),
hr: common_1.css({ MarginY: 30 }),
};
return (common_1.React.createElement("div", tslib_1.__assign({}, styles.base),
common_1.React.createElement("h1", null, "range.tsx"),
common_1.React.createElement("ul", null,
common_1.React.createElement("li", null,
"props:",
common_1.React.createElement("ul", null,
common_1.React.createElement("li", null,
"path: ",
common_1.React.createElement("code", null, this.props.path)),
common_1.React.createElement("li", null,
"id: ",
common_1.React.createElement("code", null, this.props.id)),
common_1.React.createElement("li", null,
"q: ",
common_1.React.createElement("code", null, this.props.q))))),
common_1.React.createElement("hr", tslib_1.__assign({}, styles.hr)),
common_1.React.createElement("ul", null,
common_1.React.createElement(LinkItem, { href: '/range?id=foo&q=123', as: '/range/foo?q=123' }),
common_1.React.createElement(LinkItem, { href: '/range?id=bar', as: '/range/bar' }),
common_1.React.createElement(LinkItem, { href: '/range?id=baz&q=456', as: '/range/baz?q=456' })),
common_1.React.createElement("hr", tslib_1.__assign({}, styles.hr)),
common_1.React.createElement("a", { href: '/' }, "Home")));
};
return Page;
}(common_1.React.PureComponent));
exports.default = Page;
var LinkItem = function (props) {
var href = props.href;
var asRef = props.as || href;
return (common_1.React.createElement("li", null,
common_1.React.createElement(link_1.default, { href: href, as: asRef },
common_1.React.createElement("a", null,
"Link:",
' ',
common_1.React.createElement("code", null,
"href=\"",
href,
"\", as=\"",
asRef,
"\"")))));
};
//# sourceMappingURL=range.js.map