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

Add main window with sidebar component and css #1732

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions src/frontend/src/components/authenticateBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
signInIcon,
} from "./icons";
import { withLoader } from "./loader";
import { mainWindow } from "./mainWindow";
import { mainWindowWithSidebar } from "./mainWindowWithSidebar";
import { promptUserNumber } from "./promptUserNumber";

import copyJson from "./authenticateBox.json";
Expand Down Expand Up @@ -322,7 +322,7 @@ export const authenticate = async (

// Wrap the template with header & footer and render the page
const page = (slot: TemplateResult) => {
const template = mainWindow({
const template = mainWindowWithSidebar({
slot: html` <!-- The title is hidden but used for accessibility -->
<h1 data-page="authenticate" class="is-hidden">Internet Identity</h1>
${slot}`,
Expand Down
127 changes: 127 additions & 0 deletions src/frontend/src/components/mainWindowWithSidebar.ts
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can I put this in the authenticateBox.ts module or nearby? There's not need to make this a general "component" if we don't use this anywhere else. Plus the comments & name are misleading, this isn't really a "main window" "[used] to wrap the content of each page" since we only use it in one page

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes of course. Let me know if I should look into that

Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import { html, TemplateResult } from "lit-html";
import { ifDefined } from "lit-html/directives/if-defined.js";
import { footer } from "./footer";
import { icLogo } from "./icons";

import { getDapps } from "$src/flows/dappsExplorer/dapps";
import { dappsHeader } from "$src/flows/dappsExplorer/teaser";
import { shuffleArray } from "$src/utils/utils";

/** dapps visual used in sidebar */
const dappsVisual = (): TemplateResult => {
const dapps = shuffleArray(getDapps());
return dappsHeader({
dapps,
clickable: false,
});
};

/**
* main window template
*
* To avoid having to repeat the same structure in every page,
* we use this component to wrap the content of each page.
* This way, we can change the structure of the main window
* in one place.
*
* It is a component that includes the logo, the footer, and the container.
*
*/
export const mainWindowWithSidebar = ({
slot,
id,
showFooter = true,
showLogo = true,
isWideContainer = false,
additionalContainerClasses = [],
}: {
slot: TemplateResult;
id?: string;
showFooter?: boolean;
showLogo?: boolean;
isWideContainer?: boolean;
additionalContainerClasses?: string[];
HTMLwrapperTag?: string;
}): TemplateResult => {
const containerClasses = ["l-container"];
if (isWideContainer === true) {
containerClasses.push("l-container--wide");
}
if (additionalContainerClasses.length > 0) {
containerClasses.push(...additionalContainerClasses);
}
return html`
<div class="l-wrap l-wrap--sidebar">
<div class="l-sidebar is-hidden--mobile">
<div class="l-sidebar__main">
<div class="c-logo c-logo--sidebar">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 233 111"
>
<defs>
Copy link
Collaborator

Choose a reason for hiding this comment

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

IIRC you're inlining the logo because the IDs cannot be duplicated, can you leave a comment about this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

exactly. Im adding a comment

<linearGradient
id="grad-o-y-sidebar"
x1="145.304"
x2="221.385"
y1="7.174"
y2="85.958"
gradientUnits="userSpaceOnUse"
>
<stop offset=".21" stop-color="#F15A24" />
<stop offset=".684" stop-color="#FBB03B" />
</linearGradient>
<linearGradient
id="grad-p-p-sidebar"
x1="85.087"
x2="9.006"
y1="101.622"
y2="22.838"
gradientUnits="userSpaceOnUse"
>
<stop offset=".21" stop-color="#ED1E79" />
<stop offset=".893" stop-color="#522785" />
</linearGradient>
</defs>
<g transform="translate(0 2)">
<path
fill="url(#grad-o-y-sidebar)"
d="M174.433 0c-12.879 0-26.919 6.6-41.758 19.6-7.04 6.159-13.12 12.759-17.679 18.038l.04.04v-.04s7.199 7.84 15.159 16.24c4.28-5.08 10.44-12 17.519-18.24 13.2-11.559 21.799-13.999 26.719-13.999 18.52 0 33.559 14.68 33.559 32.719 0 17.92-15.079 32.599-33.559 32.719-.84 0-1.92-.12-3.28-.4 5.4 2.32 11.2 4 16.72 4 33.918 0 40.558-22.12 40.998-23.72 1-4.04 1.52-8.28 1.52-12.64C230.391 24.4 205.272 0 174.433 0Z"
/>
<path
fill="url(#grad-p-p-sidebar)"
d="M55.958 108.796c12.88 0 26.919-6.6 41.758-19.6 7.04-6.16 13.12-12.759 17.679-18.039l-.04-.04v.04s-7.199-7.84-15.159-16.24c-4.28 5.08-10.44 12-17.52 18.24-13.199 11.56-21.798 14-26.718 14-18.52-.04-33.559-14.72-33.559-32.76C22.4 36.48 37.48 21.8 55.958 21.68c.84 0 1.92.12 3.28.4-5.4-2.32-11.2-4-16.72-4C8.6 18.08 2 40.2 1.52 41.76A52.8 52.8 0 0 0 0 54.397c0 29.999 25.119 54.398 55.958 54.398Z"
/>
<path
fill="#29ABE2"
d="M187.793 90.197c-17.36-.44-35.399-14.12-39.079-17.52-9.519-8.8-31.479-32.599-33.198-34.479C99.436 20.16 77.637 0 55.958 0h-.08C29.558.12 7.44 17.96 1.52 41.758c.44-1.56 9.12-24.119 40.958-23.319 17.36.44 35.479 14.32 39.199 17.72 9.52 8.8 31.479 32.598 33.199 34.478 16.079 18 37.878 38.159 59.557 38.159h.08c26.319-.12 48.478-17.96 54.358-41.759-.48 1.56-9.2 23.92-41.078 23.16Z"
/>
<g>
</svg>
<h1 class="c-logo__type">Internet Identity</h1>
</div>
<h2 class="t-title t-title--main">
Securely connect to dapps on the Internet Computer
</h2>
</div>
<div class="l-sidebar__decoration">${dappsVisual()}</div>
</div>
<div
id="${ifDefined(id !== null ? id : undefined)}"
class="${containerClasses.join(" ")}"
>

${
showLogo
? html`<div class="c-logo is-hidden--desktop">${icLogo}</div>`
: ""
}
<div class="c-card c-card--background">
<div class="c-card c-card--highlight">${slot}</div>
</div>
</div>
${showFooter ? footer : ""}
</div>
`;
};
66 changes: 65 additions & 1 deletion src/frontend/src/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
--vs-line-height: 1.4;

--vs-border-radius: 0.8rem;
--vs-gutter-relative: 5vmax;

/*
* reference tokens
Expand Down Expand Up @@ -167,6 +168,9 @@
--rc-background: var(--rc-light);
--rc-background-transparent: var(--rc-light-transparent);

--rc-sidebar: var(--vc-brand-purple);
--rc-onSidebar: var(--vc-snow);

--rc-footer: var(--rc-dark);
--rc-onFooter: var(--rc-light);

Expand Down Expand Up @@ -242,6 +246,9 @@
--rg-brand-bruised: var(--vc-brand-blue) 50%, var(--vc-brand-purple) 90%;

/* reference tokens: sizes */
--rs-bezel-layout: var(--vs-gutter-relative);
--rs-bezel-sidebar: calc(var(--vs-gutter-relative) * 0.5);

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

Expand Down Expand Up @@ -611,7 +618,38 @@ a:hover,
flex-direction: column;
align-items: center;
min-height: 100vh;
padding: 5vmax;
padding: var(--vs-gutter-relative);
}

.l-wrap--sidebar {
--sidebar-width: calc(30rem + var(--rs-bezel-sidebar) * 2);
padding-left: var(--sidebar-width);
}

.l-sidebar {
position: fixed;
left: 0;
top: 0;
bottom: 0;
display: flex;
flex-direction: column;
width: calc(30rem + var(--rs-bezel-sidebar) * 2);
background: var(--rc-sidebar);
color: var(--rc-onSidebar);
padding: var(--rs-bezel-sidebar);
}

.l-sidebar__main {
flex: 1;
display: flex;
flex-direction: column;
gap: 2rem;
}

.l-sidebar__decoration {
position: relative;
margin: 0 calc(var(--rs-bezel-sidebar) * -1)
calc(var(--rs-bezel-sidebar) * -1);
}

@media (max-width: 512px) {
Expand Down Expand Up @@ -646,6 +684,16 @@ a:hover,
right: 0;
}

.l-wrap--sidebar .l-footer {
left: var(--sidebar-width);
}

@media (max-width: 512px) {
.l-wrap--sidebar .l-footer {
left: 0;
}
}

/**
* Title with counter and Actions
*/
Expand Down Expand Up @@ -1147,6 +1195,10 @@ by all browsers (FF is missing) */
gap: 1em;
}

.c-logo--sidebar {
padding: var(--rs-logo-stack--top) 0 var(--rs-logo-stack--bottom);
}

.c-logo svg {
display: block;
width: 5.5rem;
Expand Down Expand Up @@ -2420,6 +2472,18 @@ a.c-action-list__item {
display: none !important;
}

@media (max-width: 512px) {
.is-hidden--mobile {
display: none !important;
}
}

@media (min-width: 513px) {
.is-hidden--desktop {
display: none !important;
}
}

.is-visible {
display: block !important;
}
Expand Down