-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement Portfolio page with base layout (#6062)
# Motivation The new page for the Portfolio route features a layout with the following sections: * Top section * `TotalAssetsCard`: that takes 100% the width when the user is logged in but only 1/3 of the space when the `LoginCard` is present. * `LoginCard` occupies 2/3 of the space when displayed and appears as the first card on mobile devices. * Main section * Cards will take up 50% of the available space, and the stack will appear on small screens. https://github.com/user-attachments/assets/7bfbe843-ef68-45bf-801e-4e1cdca3a705 # Changes - New `Portfolio` page component - Renders the new `Portfolio` page under the `Portfolio` route - Displays the appropriate layout in the `(app)/(home)/layout` when the feature toggle is on; the `Portfolio` page is the default page # Tests - Unit tests to verify that the `LoginCard` renders when the user is not logged in. # Todos - [ ] Add entry to changelog (if necessary). Not necessary
- Loading branch information
Showing
5 changed files
with
116 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<script lang="ts"> | ||
import Card from "$lib/components/portfolio/Card.svelte"; | ||
import LoginCard from "$lib/components/portfolio/LoginCard.svelte"; | ||
import { authSignedInStore } from "$lib/derived/auth.derived"; | ||
</script> | ||
|
||
<main data-tid="portfolio-page-component"> | ||
<div class="top" class:single-card={$authSignedInStore}> | ||
{#if !$authSignedInStore} | ||
<LoginCard /> | ||
{/if} | ||
<Card>Card1</Card> | ||
</div> | ||
<div class="content"> | ||
<Card>Card3</Card> | ||
<Card>Card4</Card> | ||
</div> | ||
</main> | ||
|
||
<style lang="scss"> | ||
@use "@dfinity/gix-components/dist/styles/mixins/media"; | ||
main { | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--padding-2x); | ||
padding: var(--padding-2x); | ||
@include media.min-width(large) { | ||
display: grid; | ||
grid-template-rows: auto 1fr; | ||
gap: var(--padding-3x); | ||
padding: var(--padding-3x); | ||
} | ||
.top { | ||
display: grid; | ||
grid-template-columns: 1fr; | ||
gap: var(--padding-2x); | ||
@include media.min-width(large) { | ||
display: grid; | ||
grid-template-columns: 1fr 2fr; | ||
> :global(article:first-of-type) { | ||
order: 1; | ||
} | ||
&.single-card { | ||
grid-template-columns: 1fr; | ||
} | ||
} | ||
} | ||
.content { | ||
display: grid; | ||
grid-template-columns: 1fr; | ||
gap: var(--padding-2x); | ||
@include media.min-width(large) { | ||
display: grid; | ||
grid-template-columns: repeat(2, 1fr); | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<script lang="ts"> | ||
import TestIdWrapper from "$lib/components/common/TestIdWrapper.svelte"; | ||
import Portfolio from "$lib/pages/Portfolio.svelte"; | ||
</script> | ||
|
||
<TestIdWrapper testId="portfolio-route-component"></TestIdWrapper> | ||
<TestIdWrapper testId="portfolio-route-component"><Portfolio /></TestIdWrapper> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Portfolio from "$lib/pages/Portfolio.svelte"; | ||
import { resetIdentity, setNoIdentity } from "$tests/mocks/auth.store.mock"; | ||
import { PortfolioPagePo } from "$tests/page-objects/PortfolioPage.page-object"; | ||
import { JestPageObjectElement } from "$tests/page-objects/jest.page-object"; | ||
import { render } from "@testing-library/svelte"; | ||
|
||
describe("Portfolio page", () => { | ||
const renderPage = () => { | ||
const { container } = render(Portfolio); | ||
|
||
return PortfolioPagePo.under(new JestPageObjectElement(container)); | ||
}; | ||
|
||
beforeEach(() => { | ||
resetIdentity(); | ||
}); | ||
|
||
it("should display the login card when the user is not logged in", async () => { | ||
setNoIdentity(); | ||
const po = renderPage(); | ||
expect(await po.getLoginCard().isPresent()).toBe(true); | ||
}); | ||
|
||
it("should not display the login card when the user is logged in", async () => { | ||
const page = renderPage(); | ||
expect(await page.getLoginCard().isPresent()).toBe(false); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
frontend/src/tests/page-objects/PortfolioPage.page-object.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { PageObjectElement } from "$tests/types/page-object.types"; | ||
import { BasePageObject } from "./base.page-object"; | ||
|
||
export class PortfolioPagePo extends BasePageObject { | ||
private static readonly TID = "portfolio-page-component"; | ||
|
||
static under(element: PageObjectElement): PortfolioPagePo { | ||
return new PortfolioPagePo(element.byTestId(PortfolioPagePo.TID)); | ||
} | ||
|
||
getLoginCard() { | ||
return this.getElement("portfolio-login-card"); | ||
} | ||
} |