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

Show support links on loading and error screens. #2702

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/frontend/src/components/displayError.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ERROR_SUPPORT_URL } from "$src/config";
import { TemplateElement } from "$src/utils/lit-html";
import { nonNullish } from "@dfinity/utils";
import { html, render } from "lit-html";
Expand Down Expand Up @@ -40,6 +41,13 @@ ${options.detail}</pre
>
${options.primaryButton}
</button>
<a
href="${ERROR_SUPPORT_URL}"
target="_blank"
class="c-button c-button--secondary"
>
Go to support
</a>
</div>`,
});

Expand Down
34 changes: 26 additions & 8 deletions src/frontend/src/components/loader.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
import { ERROR_SUPPORT_URL } from "$src/config";
import { html, render } from "lit-html";
import loaderUrl from "./loader.svg";

const loader = () => html` <div id="loader" class="c-loader">
<img class="c-loader__image" src=${loaderUrl} alt="loading" />
</div>`;
// Duration in milliseconds a user considers as taking forever
const TAKING_FOREVER = 10000;

const loader = (takingForever = false) =>
html` <div id="loader" class="c-loader">
<img class="c-loader__image" src=${loaderUrl} alt="loading" />
${takingForever &&
html`<a
href="${ERROR_SUPPORT_URL}"
target="_blank"
rel="noopener noreferrer"
class="c-loader__link"
>Ongoing issues</a
>`}
</div>`;

const startLoader = () => {
const container = document.getElementById("loaderContainer") as HTMLElement;
render(loader(), container);
};

const endLoader = () => {
const container = document.getElementById("loaderContainer") as HTMLElement;
render(html``, container);
const takingForeverTimeout = setTimeout(
() => render(loader(true), container),
TAKING_FOREVER
);

return () => {
clearTimeout(takingForeverTimeout);
render(html``, container);
};
};

export const withLoader = async <A>(action: () => Promise<A>): Promise<A> => {
startLoader();
const endLoader = startLoader();
try {
return await action();
} finally {
Expand Down
4 changes: 4 additions & 0 deletions src/frontend/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ export const OFFICIAL_II_URL = "https://" + OFFICIAL_II_URL_NO_PROTOCOL;
export const LEGACY_II_URL = "https://identity.ic0.app";

export const PORTAL_II_URL = "https://internetcomputer.org/internet-identity";

// Default support page URL for when error is shown to user
export const ERROR_SUPPORT_URL =
"https://identitysupport.dfinity.org/hc/en-us/articles/32301362727188";
33 changes: 27 additions & 6 deletions src/frontend/src/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1718,12 +1718,6 @@ by all browsers (FF is missing) */
fill: currentColor;
}

.c-button--secondary {
background: var(--rc-button-secondary);
color: var(--rc-onButton-secondary);
border: var(--rs-line) solid var(--rc-line-interaction);
}

.c-button--textOnly {
background: transparent;
color: var(--rc-interaction-text);
Expand All @@ -1737,10 +1731,23 @@ by all browsers (FF is missing) */

.c-button:not([disabled]):focus,
.c-button:not([disabled]):hover {
color: var(--rc-onButton);
opacity: 0.9;
box-shadow: 0 0 0 2px #ffffff, 0 0 3px 5px var(--rc-interaction);
outline: 2px dotted transparent;
outline-offset: 2px;
text-decoration: none;
}

.c-button--secondary {
background: var(--rc-button-secondary);
color: var(--rc-onButton-secondary);
border: var(--rs-line) solid var(--rc-line-interaction);
}

.c-button--secondary:not([disabled]):hover,
.c-button--secondary:not([disabled]):focus {
color: var(--rc-onButton-secondary);
}

/* Copy pasted from the focus and hover, but with different opacity to show action */
Expand Down Expand Up @@ -3144,6 +3151,20 @@ input[type="checkbox"] {
animation-timing-function: ease-in-out;
}

.c-loader__link {
color: var(--rc-surface);
display: block;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, 72px);
}

.c-loader__link:hover,
.c-loader__link:focus {
color: var(--rc-surface);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you change the color on hover? We do that for the secondary button

}

/* Wrap QR codes in a white square (for legibility) and prettify a bit */
.c-qrcode canvas {
display: block;
Expand Down