diff --git a/src/elements/common/navbar.scss b/src/elements/common/navbar.scss
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/elements/common/navbar.ts b/src/elements/common/rvt-nav.ts
similarity index 97%
rename from src/elements/common/navbar.ts
rename to src/elements/common/rvt-nav.ts
index d49aded5..e3d60ec6 100644
--- a/src/elements/common/navbar.ts
+++ b/src/elements/common/rvt-nav.ts
@@ -2,13 +2,11 @@ import { html, LitElement, PropertyValues, TemplateResult } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import { cssify } from '../../utils/css';
import global from '../../utils/global';
-import cloud from '@rivet-gg/cloud';
-import styles from './navbar.scss';
+import cloud, { GameFull } from '@rivet-gg/cloud';
import routes from '../../routes';
import * as api from '../../utils/api';
import { when } from 'lit/directives/when.js';
import logging from '../../utils/logging';
-import { GameFull } from '@rivet-gg/cloud';
import assets from '../../data/assets';
import { ifDefined } from 'lit/directives/if-defined.js';
import { CloudGameCache, GroupProfileCache } from '../../data/cache';
@@ -31,13 +29,13 @@ interface CrumbDisplay {
component?: TemplateResult;
}
-@customElement('nav-bar')
-export default class NavBar extends LitElement {
+@customElement('rvt-nav')
+export default class RvtNav extends LitElement {
// Required since Tailwind styles get applied within 'cssify'
- static styles = cssify(styles);
+ static styles = cssify();
@property({ type: String })
- routeTitle: string = '';
+ routeTitle = '';
@property({ type: Object })
breadcrumbs: Breadcrumb = undefined;
@@ -364,7 +362,7 @@ export default class NavBar extends LitElement {
render() {
return html`
- UIRoot.shared.openRegisterPanel()}
+ RvtRoot.shared.openRegisterPanel()}
>Register Now
diff --git a/src/elements/root/ui-root.scss b/src/elements/root/rvt-root.scss
similarity index 97%
rename from src/elements/root/ui-root.scss
rename to src/elements/root/rvt-root.scss
index f0e450fe..1cda040c 100644
--- a/src/elements/root/ui-root.scss
+++ b/src/elements/root/rvt-root.scss
@@ -31,17 +31,6 @@
// min-height: 100vh;
// left: consts.$sidebar-width;
// top: 0px;
-
- ui-router {
- box-sizing: border-box;
- position: relative;
- min-height: 100%;
- }
-
- &.mobile {
- left: 0;
- width: 100%;
- }
}
// === MEDIA HOLDER ===
diff --git a/src/elements/root/ui-root.ts b/src/elements/root/rvt-root.ts
similarity index 80%
rename from src/elements/root/ui-root.ts
rename to src/elements/root/rvt-root.ts
index 857eea56..5b48f8f6 100644
--- a/src/elements/root/ui-root.ts
+++ b/src/elements/root/rvt-root.ts
@@ -1,15 +1,11 @@
import { customElement, property, query } from 'lit/decorators.js';
import { html, LitElement, TemplateResult } from 'lit';
-import { classMap } from 'lit/directives/class-map.js';
-import { when } from 'lit/directives/when.js';
-import { repeat } from 'lit/directives/repeat.js';
-import { ifDefined } from 'lit/directives/if-defined.js';
import { cssify } from '../../utils/css';
import global, { GlobalStatus } from '../../utils/global';
import { globalEventGroups, GlobalStatusChangeEvent, windowEventGroups } from '../../utils/global-events';
import timing from '../../utils/timing';
-import styles from './ui-root.scss';
-import UIRouter, { RouteChangeEvent, RouteTitleChangeEvent } from './ui-router';
+import styles from './rvt-root.scss';
+import RvtRouter, { RouteChangeEvent, RouteTitleChangeEvent } from './rvt-router';
import { AlertOption } from '../overlay/alert-panel';
import { ActionSheetItem } from '../overlay/action-sheet';
import RegisterPanel from '../overlay/register-panel';
@@ -19,7 +15,11 @@ import { DeferredStageEvent, Stage } from '../pages/link-game';
import StylizedButton from '../common/stylized-button';
import { Alignment, Orientation } from '../common/overlay-positioning';
import { DropDownSelectEvent, DropDownSelection } from '../dev/drop-down-list';
-import { Breadcrumb } from '../common/navbar';
+import { Breadcrumb } from '../common/rvt-nav';
+import { ifDefined } from 'lit/directives/if-defined.js';
+import { when } from 'lit/directives/when.js';
+import { repeat } from 'lit/directives/repeat.js';
+import { classMap } from 'lit/directives/class-map.js';
export const MIN_SWIPE_THRESHOLD = 10;
const TRANSITION_LENGTH = timing.milliseconds(200); // Match with consts.scss/$transition-length
@@ -66,15 +66,15 @@ interface DropDownListData {
highlightColor: string;
}
-@customElement('ui-root')
-export default class UIRoot extends LitElement {
+@customElement('rvt-root')
+export default class RvtRoot extends LitElement {
static styles = cssify(styles);
- static shared: UIRoot;
+ static shared: RvtRoot;
// === COMPONENTS ===
- @query('ui-router')
- router: UIRouter;
+ @query('rvt-router')
+ router: RvtRouter;
@query('register-panel')
registerPanel: RegisterPanel;
@@ -147,8 +147,8 @@ export default class UIRoot extends LitElement {
super();
// Set singleton
- if (UIRoot.shared != null) throw new Error('UIRoot.shared has already been set.');
- UIRoot.shared = this;
+ if (RvtRoot.shared != null) throw new Error('UIRoot.shared has already been set.');
+ RvtRoot.shared = this;
// Hook in to fetch events
if (config.DEBUG) {
@@ -163,7 +163,6 @@ export default class UIRoot extends LitElement {
// === LIFECYCLE ===
connectedCallback() {
super.connectedCallback();
-
// Handle status change
this.handleStatusChange = this.onStatusChange.bind(this);
globalEventGroups.add('status-change', this.handleStatusChange);
@@ -373,7 +372,6 @@ export default class UIRoot extends LitElement {
// === RENDER ===
render() {
let content = null;
-
// NOTE: Game link page has own flow
if (
window.location.pathname.startsWith('/link/') &&
@@ -386,9 +384,9 @@ export default class UIRoot extends LitElement {
let token = window.location.pathname.split('/')[2];
content = html`
(this.deferredLinkGameStage = e.stage)}
+ .token="${token}"
+ .initStage="${ifDefined(this.deferredLinkGameStage)}"
+ @deferred-stage="${(e: DeferredStageEvent) => (this.deferredLinkGameStage = e.stage)}"
>
${this.renderBasicOverlays()}
`;
@@ -399,11 +397,9 @@ export default class UIRoot extends LitElement {
case GlobalStatus.Bootstrapping:
this.showLoading();
break;
-
- // Interactive
case GlobalStatus.Consenting:
this.hideLoading();
- content = html``;
+ content = html` `;
break;
case GlobalStatus.Connected:
case GlobalStatus.Reconnecting:
@@ -449,7 +445,7 @@ export default class UIRoot extends LitElement {
inFlightHostCountsSorted,
x => x[0],
x => {
- return html`
+ return html`
${x[0]}: ${x[1]}
`;
}
@@ -462,44 +458,49 @@ export default class UIRoot extends LitElement {
renderContent() {
return html`
-
-
+
-
-
+
+
-
-
-
+
-
+
@@ -510,29 +511,29 @@ export default class UIRoot extends LitElement {
renderBasicOverlays() {
return html`
@@ -541,10 +542,10 @@ export default class UIRoot extends LitElement {
${this.contextMenuData.content}
`;
diff --git a/src/elements/root/rvt-router.scss b/src/elements/root/rvt-router.scss
new file mode 100644
index 00000000..e7dd94c8
--- /dev/null
+++ b/src/elements/root/rvt-router.scss
@@ -0,0 +1,7 @@
+@use '../shared/common';
+@use '../shared/consts';
+
+:host {
+ flex-grow: 1;
+ position: relative;
+}
diff --git a/src/elements/root/ui-router.ts b/src/elements/root/rvt-router.ts
similarity index 89%
rename from src/elements/root/ui-router.ts
rename to src/elements/root/rvt-router.ts
index 5b025507..d5541cc7 100644
--- a/src/elements/root/ui-router.ts
+++ b/src/elements/root/rvt-router.ts
@@ -1,15 +1,11 @@
-import { LitElement, html, PropertyValues } from 'lit';
-import { customElement, property, query } from 'lit/decorators.js';
-import { repeat } from 'lit/directives/repeat.js';
+import { html, LitElement, PropertyValues } from 'lit';
+import { customElement, property } from 'lit/decorators.js';
import { cssify } from '../../utils/css';
-import global from '../../utils/global';
import timing from '../../utils/timing';
-import { windowEventGroups, bodyEventGroups } from '../../utils/global-events';
+import { windowEventGroups } from '../../utils/global-events';
import logging from '../../utils/logging';
import { classMap } from 'lit/directives/class-map.js';
-import { styleMap } from 'lit/directives/style-map.js';
-import styles from './ui-router.scss';
-import UIRoot, { MIN_SWIPE_THRESHOLD } from './ui-root';
+import styles from './rvt-router.scss';
import routes, {
RenderResult,
RenderResultRedirect,
@@ -19,9 +15,7 @@ import routes, {
} from '../../routes';
import * as uuid from 'uuid';
-import { Breadcrumb } from '../common/navbar';
-
-const PAGE_ANIMATION_DURATION = timing.milliseconds(250);
+import { Breadcrumb } from '../common/rvt-nav';
interface PageState {
scrollTop: number;
@@ -66,11 +60,11 @@ export class RouteTitleChangeEvent extends Event {
}
}
-@customElement('ui-router')
-export default class UIRouter extends LitElement {
+@customElement('rvt-router')
+export default class RvtRouter extends LitElement {
static styles = cssify(styles);
- static shared: UIRouter;
+ static shared: RvtRouter;
@property({ type: Array })
history: RemovablePage[] = [];
@@ -89,6 +83,7 @@ export default class UIRouter extends LitElement {
handleScroll: (e: Event) => void;
/*=== Navigation State ===*/
+
/// Returns the full URL for the current page.
get fullPath(): string {
return location.href;
@@ -126,7 +121,7 @@ export default class UIRouter extends LitElement {
super();
// Set singleton
- UIRouter.shared = this;
+ RvtRouter.shared = this;
// Parse the path url
let url = routes.home.build({});
@@ -315,6 +310,11 @@ export default class UIRouter extends LitElement {
this.history[i].old = true;
this.history[i].new = false;
this.history[i].state = this.buildPageState();
+ if (this.history.length > 0) {
+ if (!this.removePage(this.history[i])) {
+ logging.error(`Failed to remove page "${this.history[i].src}"`);
+ }
+ }
break;
}
}
@@ -435,14 +435,9 @@ export default class UIRouter extends LitElement {
page.new = false;
page.state.scrollTop = document.body.scrollTop;
- // Remove current page from history after animation is over
- page.removalTimeout = window.setTimeout(() => {
- if (!this.removePage(page)) {
- logging.error(`Failed to remove page "${page.src}"`);
- }
-
- this.requestUpdate('history');
- }, PAGE_ANIMATION_DURATION);
+ if (!this.removePage(page)) {
+ logging.error(`Failed to remove page "${page.src}"`);
+ }
}
// Navigate to previous page
else if (page.old) {
@@ -535,32 +530,20 @@ export default class UIRouter extends LitElement {
render() {
// Clone the page history list so it will not be mutated
let pageList = [...this.history];
- // Count how many back animation pages there are (used for animation purposes)
- let backedPages = this.getBackedPages();
let newestPage = pageList[pageList.length - 1];
- if (!newestPage) return html``;
+ if (!newestPage) return html``;
// Create class map
let classes = classMap({
page: true,
old: newestPage.old,
new: newestPage.new,
- back: newestPage.back
- });
-
- // Position old pages in the proper y-pos based on scroll
- let scrollStyle = styleMap({
- transform: newestPage.old ? `translateY(${-newestPage.state.scrollTop + this.scrollTop}px)` : null
+ back: newestPage.back,
+ first: pageList.length == 1
});
- // Two divs are used here because you cannot animate separate transform properties in
- // css separately
- return html`
-
-
${newestPage.renderResult.template}
-
-
`;
+ return html`${newestPage.renderResult.template}
`;
}
}
diff --git a/src/elements/root/ui-router.scss b/src/elements/root/ui-router.scss
deleted file mode 100644
index cf3342bc..00000000
--- a/src/elements/root/ui-router.scss
+++ /dev/null
@@ -1,86 +0,0 @@
-@use '../shared/common';
-@use '../shared/consts';
-
-$transition-duration: 250ms; // Also update in ui-router
-
-#base {
- display: flex;
- flex-direction: column;
-
- .page {
- position: relative;
- left: 0;
- top: 0;
- width: 100%;
- // min-height: 93vh;
- min-height: calc(100% - 4rem);
- }
-}
-
-@media only screen and (max-width: consts.$mobile-width-threshold) {
- #base {
- .page {
- transform: translateX(100vw);
- box-shadow: 0 0 128px rgba(0, 0, 0, 0.8);
-
- .y-scroll {
- min-height: calc(100% - 4rem);
- background-color: $base-bg;
- }
-
- &.back {
- transform: translateX(-100vw);
- }
-
- // Home page has a lesser shadow
- &.home {
- box-shadow: 0 0 64px rgba(0, 0, 0, 0.6);
- }
-
- &.old {
- // Position and width have to be manually set because old pages are removed from normal flow
- position: absolute;
- left: 0;
- top: 0;
- width: 100vw;
-
- transform: translateX(-100vw);
-
- &.back {
- transform: translateX(100vw);
- }
- }
-
- &.new {
- transform: translateX(0vh);
- }
- }
-
- &.notouch {
- .page {
- &.old {
- box-shadow: none;
- transition:
- box-shadow $transition-duration,
- transform $transition-duration * 4;
- transition-timing-function: ease-out;
-
- &.back {
- transition:
- box-shadow $transition-duration,
- transform $transition-duration;
- transition-timing-function: ease-out;
- }
- }
-
- &.new {
- box-shadow: none;
- transition:
- box-shadow $transition-duration,
- transform $transition-duration;
- transition-timing-function: ease-out;
- }
- }
- }
- }
-}
diff --git a/src/hub.ts b/src/hub.ts
index fea5be43..17afd7f8 100644
--- a/src/hub.ts
+++ b/src/hub.ts
@@ -1,7 +1,7 @@
import './utils/start-posthog';
import './elements/mod';
import numbro from 'numbro';
-import UIRoot from './elements/root/ui-root';
+import RvtRoot from './elements/root/rvt-root';
import global from './utils/global';
import logging from './utils/logging';
@@ -9,7 +9,7 @@ numbro.setDefaults({ roundingFunction: Math.floor });
window.addEventListener('load', async () => {
// Add main UI
- let uiRoot = new UIRoot();
+ let uiRoot = new RvtRoot();
document.body.appendChild(uiRoot);
// initiate
diff --git a/src/routes.ts b/src/routes.ts
index b59c96a6..6a9efcaa 100644
--- a/src/routes.ts
+++ b/src/routes.ts
@@ -1,12 +1,12 @@
-import { TemplateResult, html } from 'lit';
+import { html, TemplateResult } from 'lit';
import * as pathToRegexp from 'path-to-regexp';
import global from './utils/global';
import utils from './utils/utils';
import { DevGameRootConfig } from './elements/pages/dev/game/pages/game';
-import UIRoot from './elements/root/ui-root';
+import RvtRoot from './elements/root/rvt-root';
import { RivetError } from '@rivet-gg/api-internal';
import { isDeveloper } from './utils/identity';
-import { Breadcrumb } from './elements/common/navbar';
+import { Breadcrumb } from './elements/common/rvt-nav';
import { GameSettingsRootConfig } from './elements/pages/dev/game/settings/game-settings';
import { GroupSettingsRootConfig } from './elements/pages/dev/group/settings/group-settings';
@@ -66,11 +66,13 @@ class Route {
namespace routes {
export let home = new Route<{}>({
path: '/',
- render({}) {
+ render() {
return {
title: 'Home',
breadcrumb: { type: 'Home' },
- template: html` `
+ template: html`
+
+ `
};
}
});
@@ -99,7 +101,7 @@ namespace routes {
// Reuse the same template in order to preserve the same `page-group-settings` instance.
function renderPageGroupSettings(groupId: string, config?: GroupSettingsRootConfig) {
- return html``;
+ return html` `;
}
export let groupSettingsRedirect = new Route<{ groupId: string }>({
@@ -134,7 +136,7 @@ namespace routes {
return {
title: 'Group',
breadcrumb: { type: 'Group', groupId: id },
- template: html``
+ template: html` `
};
}
});
@@ -207,9 +209,9 @@ namespace routes {
// Reuse the same template in order to preserve the same `page-dev-game` instance.
function renderPageDevGame(gameId: string, namespaceId: string, config: DevGameRootConfig) {
return html``;
}
@@ -222,7 +224,7 @@ namespace routes {
return {
title: 'Game',
breadcrumb: { type: 'Game', gameId, title: 'Overview' },
- template: html` `
+ template: html` `
};
}
});
@@ -238,7 +240,10 @@ namespace routes {
});
function renderPageDevGameSettings(gameId: string, config: GameSettingsRootConfig) {
- return html``;
+ return html``;
}
export let devGameSettingsRedirect = new Route<{ gameId: string }>({
@@ -471,14 +476,15 @@ export namespace responses {
404
Page Not Found
- Go Home
+ Go Home
`
};
@@ -490,7 +496,7 @@ export namespace responses {
breadcrumb: {
type: 'Custom'
},
- template: html`
+ template: html`
Coming Soon
This page isn't available yet. Come back soon!
@@ -506,15 +512,15 @@ export namespace responses {
breadcrumb: {
type: 'Custom'
},
- template: html`
+ template: html`
Registered Only
This page isn't available for guest accounts. Register to save your account.
- UIRoot.shared.openRegisterPanel()}
- >Register Now
+ Register Now
+
`
};
@@ -526,7 +532,7 @@ export namespace responses {
breadcrumb: {
type: 'Custom'
},
- template: html`
+ template: html`
Desktop Only
This page is only available on a Desktop platform.
`
@@ -539,7 +545,7 @@ export namespace responses {
breadcrumb: {
type: 'Custom'
},
- template: html``
+ template: html` `
};
}
@@ -548,7 +554,7 @@ export namespace responses {
let errorMessage: string;
if (typeof error == 'string') errorMessage = error;
else if (error instanceof RivetError) {
- return html``;
@@ -561,7 +567,7 @@ export namespace responses {
errorMessage = err.statusText ? err.statusText : err.status.toString() ?? 'Error';
} else errorMessage = 'Error';
- return html``;
+ return html` `;
}
}
diff --git a/src/ui/helpers.ts b/src/ui/helpers.ts
index caf985a0..f3954531 100644
--- a/src/ui/helpers.ts
+++ b/src/ui/helpers.ts
@@ -1,5 +1,5 @@
import { html, TemplateResult } from 'lit';
-import UIRoot from '../elements/root/ui-root';
+import RvtRoot from '../elements/root/rvt-root';
import { AlertOption } from '../elements/overlay/alert-panel';
import { ActionSheetItem } from '../elements/overlay/action-sheet';
import * as api from '../utils/api';
@@ -14,11 +14,11 @@ export function tooltip(text: string): (e: Event) => void {
let element = event.currentTarget as HTMLElement;
// Show tooltip
- UIRoot.shared.showTooltip(element, text);
+ RvtRoot.shared.showTooltip(element, text);
// Add hide event; we register click, since that may cause the tooltip to disappear on an action
let hideTooltip = () => {
- UIRoot.shared.hideTooltip();
+ RvtRoot.shared.hideTooltip();
element.removeEventListener('mouseleave', hideTooltip);
element.removeEventListener('click', hideTooltip);
@@ -77,7 +77,7 @@ function abstractContextMenu(cb: () => TemplateResult): (e: MouseEvent) => void
let element = event.currentTarget as HTMLElement;
// Show contextmenu
- UIRoot.shared.showContextMenu(element, event.clientX, event.clientY, cb());
+ RvtRoot.shared.showContextMenu(element, event.clientX, event.clientY, cb());
// Stop default context menu from being enabled
event.preventDefault();
@@ -103,11 +103,11 @@ export function showAlert(
options: AlertOption[] = [{ label: 'Dismiss' }]
) {
// Show alert
- UIRoot.shared.showAlertPanel({ title, details, options, active: true });
+ RvtRoot.shared.showAlertPanel({ title, details, options, active: true });
}
export function showActionSheet(anchor: HTMLElement, options: ActionSheetItem[]) {
- UIRoot.shared.showActionSheet({
+ RvtRoot.shared.showActionSheet({
contextElement: anchor,
options,
active: true
diff --git a/src/utils/auth.ts b/src/utils/auth.ts
index 8e2df98b..2b863574 100644
--- a/src/utils/auth.ts
+++ b/src/utils/auth.ts
@@ -29,7 +29,7 @@ export class Token {
}
// TODO: Delay changing global status when refreshing token by 1-3 seconds so there is no state change
-// that causes the to be unloaded and then reloaded again
+// that causes the to be unloaded and then reloaded again
export class AuthManager {
public token?: Token;
public authenticationFailed = false;
diff --git a/src/utils/global.ts b/src/utils/global.ts
index 61363851..eaaf7e5a 100644
--- a/src/utils/global.ts
+++ b/src/utils/global.ts
@@ -1,9 +1,9 @@
import logging from './logging';
import config from '../config';
-import { AuthManager, Token } from './auth';
+import { AuthManager } from './auth';
import settings, { SettingChange } from './settings';
import timing from './timing';
-import { windowEventGroups, globalEventGroups } from './global-events';
+import { globalEventGroups, windowEventGroups } from './global-events';
import * as api from './api';
import * as cloud from '@rivet-gg/cloud';
import { RootCache } from '../data/cache';
@@ -77,7 +77,7 @@ export class GlobalState {
liveInitiated = false;
liveBlockingBypass: number = null;
- bootstrapFailed: boolean = false;
+ bootstrapFailed = false;
bootstrapData: Rivet.cloud.BootstrapResponse;
identityStream: api.RepeatingRequest;
@@ -212,9 +212,6 @@ export class GlobalState {
this.bootstrap();
- // Establish push notifications
- this.pushNotifications = new PushNotifications();
-
// Set initial status
this.updateStatus();
@@ -254,7 +251,7 @@ export class GlobalState {
}
/// Fetches configuration information from the servers & creates the intiital auth token.
- bootstrap(noCache: boolean = false) {
+ bootstrap(noCache = false) {
// Reset bootstrap state
this.bootstrapFailed = false;
this.bootstrapData = undefined;
@@ -404,7 +401,6 @@ export class GlobalState {
if (this.troubleConnecting) status = GlobalStatus.Reconnecting;
else status = GlobalStatus.Connected;
}
- console.log('status', status);
// Dispatch event
if (status !== this.status) {