Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fork and embed pagejs #21

Merged
merged 13 commits into from
Aug 9, 2022
Merged
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/node_modules/
yarn-error.log
*.d.ts
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ and ids so the strings are maintainable.
* MAIN-DASHBOARD DETAIL-VIEW
*/

import RouteData from '@jack-henry/web-component-router/lib/route-data.js';
import RouteTreeNode from '@jack-henry/web-component-router/lib/route-tree-node.js';
import {RouteData, RouteTreeNode} from '@jack-henry/web-component-router';

const dashboard = new RouteTreeNode(
new RouteData('MainDashboard', 'MAIN-DASHBOARD', '/'));
Expand Down Expand Up @@ -206,11 +205,9 @@ The root element typically has a slightly different configuration.

```js
import myAppRouteTree from './route-tree.js';
import router from '@jack-henry/web-component-router';
import routeMixin from '@jack-henry/web-component-router/routing-mixin.js';
import pageJs from 'page';
import router, {Context, routingMixin} from '@jack-henry/web-component-router';

class AppElement extends routeMixin(Polymer.Element) {
class AppElement extends routingMixin(Polymer.Element) {
static get is() { return 'app-element'; }

connectedCallback() {
Expand Down Expand Up @@ -259,10 +256,9 @@ issue.

```js
import myAppRouteTree from './route-tree.js';
import router from '@jack-henry/web-component-router';
import routeMixin from '@jack-henry/web-component-router/routing-mixin.js';
import router, {routingMixin} from '@jack-henry/web-component-router';

class AppElement extends routeMixin(Polymer.Element) {
class AppElement extends routingMixin(Polymer.Element) {
static get is() { return 'app-element'; }

connectedCallback() {
Expand All @@ -280,7 +276,7 @@ class AppElement extends routeMixin(Polymer.Element) {
}

/**
* @param {!pageJs.Context} context
* @param {!Context} context
* @param {function(boolean=)} next
* @private
*/
Expand Down Expand Up @@ -338,7 +334,7 @@ router.go(path, params);

/**
* Register an exit callback to be invoked on every route change
* @param {function(!pageJs.Context, function(boolean=))} callback
* @param {function(!Context, function(boolean=))} callback
*/
router.addGlobalExitHandler(callback);

Expand Down Expand Up @@ -372,7 +368,7 @@ router.removeRouteChangeCompleteCallback(callback);
* Anonymize the route path by replacing param values with their
* param name. Used for analytics tracking
*
* @param {!pageJs.Context} context route enter context
* @param {!Context} context route enter context
* @return {!string}
*/
const urlPath = router.getRouteUrlWithoutParams(context);
Expand Down
9 changes: 6 additions & 3 deletions animated-routing-mixin.js → lib/animated-routing-mixin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import RouteTreeNode from './lib/route-tree-node.js';
import page from 'page';
const Context = page.Context;
import RouteTreeNode from './route-tree-node.js';
import {Context} from './page.js';
import basicRoutingMixin from './routing-mixin.js';
import BasicRoutingInterface from './routing-interface.js';

Expand All @@ -16,6 +15,7 @@ function animatedRoutingMixin(Superclass, className) {
* @extends {Superclass}
* @implements {BasicRoutingInterface}
*/
// @ts-ignore
const BasicRoutingElement = basicRoutingMixin(Superclass);

/**
Expand All @@ -26,6 +26,7 @@ function animatedRoutingMixin(Superclass, className) {
*/
class AnimatedRouting extends BasicRoutingElement {
connectedCallback() {
// @ts-ignore
super.connectedCallback();
document.documentElement.scrollTop = document.body.scrollTop = 0;
}
Expand All @@ -37,6 +38,7 @@ function animatedRoutingMixin(Superclass, className) {
* @param {!RouteTreeNode|undefined} nextNodeIfExists
* @param {string} routeId
* @param {!Context} context
* @return {!Promise<boolean|void>}
*/
async routeEnter(currentNode, nextNodeIfExists, routeId, context) {
const currentElement = currentNode.getValue().element;
Expand All @@ -59,6 +61,7 @@ function animatedRoutingMixin(Superclass, className) {
* @param {!RouteTreeNode|undefined} nextNode
* @param {string} routeId
* @param {!Context} context
* @return {!Promise<void>}
*/
async routeExit(currentNode, nextNode, routeId, context) {
const currentElement = currentNode.getValue().element;
Expand Down
Loading