Skip to content

Commit

Permalink
Introduce new Landing Page layout (#2522)
Browse files Browse the repository at this point in the history
* Introduce new Landing Page layout

* Fix UI

* Add i18n copy

* Change outer padding mobile

* CR changes

* Add aria-label
  • Loading branch information
lmuntaner authored Jul 2, 2024
1 parent 5a685b0 commit 61e6696
Show file tree
Hide file tree
Showing 7 changed files with 314 additions and 12 deletions.
35 changes: 25 additions & 10 deletions src/frontend/src/components/authenticateBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { promptUserNumber } from "./promptUserNumber";

import { DerEncodedPublicKey } from "@dfinity/agent";
import copyJson from "./authenticateBox.json";
import { landingPage } from "./landingPage";

/** Template used for rendering specific authentication screens. See `authnScreens` below
* for meaning of "firstTime", "useExisting" and "pick". */
Expand Down Expand Up @@ -562,12 +563,22 @@ export const authnPages = (i18n: I18n, props: AuthnTemplates) => {
const templates = authnTemplates(i18n, props);

return {
firstTime: (opts: Parameters<typeof templates.firstTime>[0]) =>
page(templates.firstTime(opts)),
firstTime: (
opts: Parameters<typeof templates.firstTime>[0],
// TODO: remove this parameter once the landing page is ready.
landingPageTemplate: boolean = false
) =>
// TODO: Use the landing page template always when ready.
page(templates.firstTime(opts), landingPageTemplate),
useExisting: (opts: Parameters<typeof templates.useExisting>[0]) =>
page(templates.useExisting(opts)),
pick: (opts: Parameters<typeof templates.pick>[0]) =>
page(templates.pick(opts)),
pick: (
opts: Parameters<typeof templates.pick>[0],
// TODO: remove this parameter once the landing page is ready.
landingPageTemplate: boolean = false
) =>
// TODO: Use the landing page template always when ready.
page(templates.pick(opts), landingPageTemplate),
};
};

Expand Down Expand Up @@ -615,12 +626,16 @@ export const authnScreens = (i18n: I18n, props: AuthnTemplates) => {
};

// Wrap the template with header & footer and render the page
const page = (slot: TemplateResult) => {
const template = mainWindow({
slot: html` <!-- The title is hidden but used for accessibility -->
<h1 data-page="authenticate" class="is-hidden">Internet Identity</h1>
${slot}`,
});
const page = (slot: TemplateResult, landingPageTemplate: boolean = false) => {
const template = landingPageTemplate
? landingPage({
slot,
})
: mainWindow({
slot: html` <!-- The title is hidden but used for accessibility -->
<h1 data-page="authenticate" class="is-hidden">Internet Identity</h1>
${slot}`,
});
const container = document.getElementById("pageContent") as HTMLElement;
render(template, container);
};
Expand Down
6 changes: 6 additions & 0 deletions src/frontend/src/components/landingPage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"en": {
"title": "Secure, seamless & privacy-preserving digital identity",
"subtitle": "Internet Identity is a decentralized identity solution running end-to-end on the Internet Computer blockchain."
}
}
58 changes: 58 additions & 0 deletions src/frontend/src/components/landingPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { I18n } from "$src/i18n";
import { html, TemplateResult } from "lit-html";
import { navigationLink } from "./footer";
import { githubIcon, icLogo, questionIcon } from "./icons";
import copyJson from "./landingPage.json";

/**
* Landing page template
*
* It is a component with split panes left and right in desktop view.
* To the left there is some static content, and to the right there is a slot.
*
* In movile view, the static content is below the slot.
*
*/
export const landingPage = ({
slot,
}: {
slot: TemplateResult;
}): TemplateResult => {
const i18n = new I18n();
const copy = i18n.i18n(copyJson);

return html` <main class="c-landingPage">
<div class="c-landingPage__logo">
<div class="c-logo">${icLogo}</div>
</div>
<section class="c-landingPage__right">
<div class="c-landingPage__right__content">
<div class="c-landingPage__right__content--full-width">${slot}</div>
</div>
</section>
<section class="c-landingPage__left" aria-label="Action Pane">
<div class="c-landingPage__left__content">
<h1 class="t-title t-title--main">${copy.title}</h1>
<p class="t-paragraph">{${copy.subtitle}}</p>
</div>
<div class="c-landingPage__left__footer">
${navigationLink({
icon: questionIcon,
labelText: "Support",
id: "support-link",
url: "https://internetidentity.zendesk.com/hc/en-us",
rel: "noopener noreferrer",
classes: "t-link--discreet c-footer__link",
})}
${navigationLink({
icon: githubIcon,
labelText: "Source code",
id: "source-link",
url: "https://github.com/dfinity/internet-identity",
rel: "noopener noreferrer",
classes: "t-link--discreet c-footer__link",
})}
</div>
</section>
</main>`;
};
178 changes: 176 additions & 2 deletions src/frontend/src/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@
--vc-brand-alt: rgba(215, 205, 235, 1);
--vc-grey: grey;
--vc-light-grey: #d4d8e5;
--vc-brand-gradient: linear-gradient(
90deg,
var(--vc-brand-purple),
var(--vc-brand-purple-light)
);

/**
* value tokens: sizes (--vs => valueSize)
Expand All @@ -150,6 +155,8 @@

--vs-border-radius: 0.8rem;

--vs-screen-width: 40rem;

/*
* reference tokens
*
Expand Down Expand Up @@ -203,6 +210,9 @@

--rc-button--disabled: var(--vc-shadow);

--rc-background--highlight: var(--vc-brand-gradient);
--rc-background--highlight-text: var(--vc-snow);

/*
color used to elevate something from its background
secondary button, card, icon button
Expand Down Expand Up @@ -254,6 +264,8 @@
--rg-brand-bruised: var(--vc-brand-blue) 50%, var(--vc-brand-purple) 90%;

/* reference tokens: sizes */
--rs-main-content-width: var(--vs-screen-width);

--rs-inline-grid-gap: var(--vs-inline);
--rs-inline-icon-gap: var(--vs-inline);

Expand Down Expand Up @@ -313,6 +325,15 @@
--rs-line--thick: calc(var(--rs-line) * 4);

--rs-footer-height: 4rem;

--rs-split-page-padding--mobile: calc(var(--vs-stack) * 3);
--rs-split-page-left-pane-padding: calc(var(--vs-gutter) * 8);
--rs-split-page-right-pane-padding--desktop: 10vmax;
--rs-split-page-right-pane-padding--mobile: calc(var(--vs-stack) * 2);
--rs-split-page-stack: calc(var(--vs-stack) * 4);

/* This is not used in CSS, but it's used to compensate for the logo size. */
--rs-logo-height: 3rem;
}

/* II) Optional Theme Settings: DarkMode, LightMode, Product Specific stuff */
Expand Down Expand Up @@ -755,8 +776,8 @@ a:hover,
.l-container {
position: relative;
font-size: 1.6rem;
min-width: 40rem;
max-width: 40rem;
min-width: var(--rs-main-content-width);
max-width: var(--rs-main-content-width);
/* centers the container and adds a bit of space to make sure the footer does not stick to it */
margin: 0 auto 2rem;
}
Expand Down Expand Up @@ -949,6 +970,159 @@ a:hover,
color: rgba(0, 0, 0, 0.5);
}

/**
* LandingPage component
*/

.c-landingPage {
display: grid;
grid-template-columns: 1fr minmax(var(--rs-main-content-width), 1fr);
grid-template-areas: "left right";

height: 100dvh;
}

.c-landingPage__logo {
position: absolute;
left: var(--rs-split-page-left-pane-padding);
top: var(--rs-split-page-left-pane-padding);

color: var(--rc-background--highlight-text);
}

.c-landingPage__logo .c-logo {
padding: 0;
}

.c-landingPage__left {
background: var(--rc-background--highlight);
color: var(--rc-background--highlight-text);

grid-area: left;

display: flex;
flex-direction: column;
align-items: flex-start;

padding: var(--rs-split-page-left-pane-padding);
}

.c-landingPage__left__content {
flex: 1;

display: flex;
flex-direction: column;
align-items: center;
justify-content: center;

padding: 0 20%;

margin-top: var(--rs-logo-height);
}

.c-landingPage__logo--mobile {
display: none;
}

.c-landingPage__logo--desktop {
display: block;
}

.c-landingPage__right {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;

grid-area: right;

overflow-y: scroll;
}

.c-landingPage__right__content {
min-width: var(--rs-main-content-width);
max-width: var(--rs-main-content-width);
/* This is necessary in case the content is bigger than the parent. */
/* It keeps the start of the box at the top of the container. */
max-height: 90%;

display: flex;
flex-direction: column;
align-items: stretch;
}

.c-landingPage__right__content--full-width {
width: 100%;
}

.c-landingPage .c-footer__link {
padding: 0;
}

.c-landingPage__left__footer {
display: flex;
gap: var(--rs-inline-grid-gap);
}

@media (max-width: 512px) {
.c-landingPage {
display: block;

padding: 0 var(--rs-split-page-padding--mobile);

background: var(--rc-background--highlight);

height: auto;
min-height: 100vh;
}

.c-landingPage__logo {
display: flex;
position: static;
top: unset;
left: unset;
justify-content: center;

order: 1;
color: var(--rc-background--highlight-text);

padding: var(--rs-split-page-stack) 0;
}

.c-landingPage__left {
background: none;
order: 2;

padding: 0;
margin-top: var(--rs-split-page-stack);
padding-bottom: var(--rs-split-page-stack);

gap: var(--rs-split-page-stack);
}

.c-landingPage__left__content {
padding: 0;
/* We don't need to account for the logo with absolute position */
margin-top: 0;
}

.c-landingPage__right {
order: 1;

background: var(--rc-light);
border-radius: var(--rs-card-border-radius);
padding: var(--rs-split-page-right-pane-padding--mobile);

overflow: auto;
}

.c-landingPage__right__content {
min-width: auto;
max-width: none;
width: 100%;
}
}

/**
* Card components
*/
Expand Down
15 changes: 15 additions & 0 deletions src/showcase/src/pages/manageNewLanding.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
import Screen from "../layouts/Screen.astro";
---

<Screen title="Manage New" pageName="manageNew">
<script>
import { toast } from "$src/components/toast";
import { manage } from "../templates";

manage.firstTime({
useExisting: () => toast.info("Asked for existing"),
register: () => toast.info("Asked for registration"),
}, true);
</script>
</Screen>
17 changes: 17 additions & 0 deletions src/showcase/src/pages/managePickManyNewLanding.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
import Screen from "../layouts/Screen.astro";
---

<Screen title="Manage Pick" pageName="managePick">
<script>
import { toast } from "$src/components/toast";
import { manage } from "../templates";

manage.pick({
anchors: [BigInt(10000), BigInt(243099), BigInt(10000), BigInt(243099), BigInt(10000), BigInt(243099), BigInt(10000), BigInt(243099), BigInt(10000), BigInt(243099), BigInt(10000), BigInt(243099), BigInt(10000), BigInt(243099),BigInt(10000), BigInt(243099),BigInt(10000), BigInt(243099),BigInt(10000), BigInt(243099)],
moreOptions: () => toast.info("Asked for more options"),
onSubmit: (userNumber) =>
toast.info(`User number submitted: ${userNumber.toString()}`),
}, true);
</script>
</Screen>
Loading

0 comments on commit 61e6696

Please sign in to comment.