-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Motivation Add `SplitBlock` component to use on full-content-width pages. # Changes New component # Screenshots <img width="1138" alt="image" src="https://github.com/dfinity/gix-components/assets/98811342/c3296eca-138e-4c9d-a1c4-68982e82591b"> <img width="751" alt="image" src="https://github.com/dfinity/gix-components/assets/98811342/4b3ee3e1-134b-4950-955c-4756df28cd0f">
- Loading branch information
1 parent
fe753a8
commit d322d0a
Showing
7 changed files
with
125 additions
and
0 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,13 @@ | ||
import { expect, test } from "@playwright/test"; | ||
|
||
const testUrl = "/components/split-block"; | ||
|
||
test("Should display start slot content", async ({ page }) => { | ||
await page.goto(testUrl); | ||
await expect(page.getByTestId("start")).toHaveText("Start slot content"); | ||
}); | ||
|
||
test("Should display end slot content", async ({ page }) => { | ||
await page.goto(testUrl); | ||
await expect(page.getByTestId("end")).toHaveText("End slot content"); | ||
}); |
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
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,38 @@ | ||
<div class="split-block"> | ||
<div class="start"> | ||
<slot name="start" /> | ||
</div> | ||
<hr /> | ||
<div class="end"> | ||
<slot name="end" /> | ||
</div> | ||
</div> | ||
|
||
<style lang="scss"> | ||
@use "../styles/mixins/media"; | ||
.split-block { | ||
display: grid; | ||
grid-template-rows: auto 1px auto; | ||
grid-template-columns: auto; | ||
grid-row-gap: var(--padding-2x); | ||
@include media.min-width(large) { | ||
grid-template-columns: 1fr 1px 1fr; | ||
grid-template-rows: auto; | ||
grid-row-gap: 0; | ||
grid-column-gap: var(--padding-2x); | ||
} | ||
} | ||
hr { | ||
margin: 0; | ||
height: 1px; | ||
background: var(--line); | ||
@include media.min-width(large) { | ||
width: 1px; | ||
height: auto; | ||
} | ||
} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<script lang="ts"> | ||
import SplitBlock from "$lib/components/SplitBlock.svelte"; | ||
</script> | ||
|
||
# Split Content | ||
|
||
This component displays two slots in a column on mobile devices and in a row on desktops, with a 1px separation line. | ||
|
||
```javascript | ||
<SplitBlock> | ||
<div slot="start">Content A</div> | ||
<div slot="end">Content B</div> | ||
</SplitBlock> | ||
``` | ||
|
||
## Properties | ||
|
||
No properties | ||
|
||
## Slots | ||
|
||
| Slot name | Description | | ||
| --------- | ------------------------- | | ||
| `start` | First column on desktop. | | ||
| `end` | Second column on desktop. | | ||
|
||
## Showcase | ||
|
||
> Colors added for demo purposes | ||
<div class="container"> | ||
<SplitBlock> | ||
<div slot="start" class="item" data-tid="start">Start slot content</div> | ||
<div slot="end" class="item" data-tid="end">End slot content</div> | ||
</SplitBlock> | ||
</div> | ||
|
||
<style lang="scss"> | ||
.container { | ||
background: var(--card-background-contrast); | ||
} | ||
|
||
.item { | ||
background: var(--card-background); | ||
} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { render } from "@testing-library/svelte"; | ||
import SplitBlockTest from "./SplitBlockTest.svelte"; | ||
|
||
describe("SplitBlock", () => { | ||
it("should render slotted elements", () => { | ||
const { getByTestId } = render(SplitBlockTest); | ||
|
||
expect(getByTestId("content-test-start-slot")).not.toBeNull(); | ||
expect(getByTestId("content-test-end-slot")).not.toBeNull(); | ||
}); | ||
}); |
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,8 @@ | ||
<script lang="ts"> | ||
import SplitBlock from "$lib/components/SplitBlock.svelte"; | ||
</script> | ||
|
||
<SplitBlock> | ||
<div data-tid="content-test-start-slot" slot="start" /> | ||
<div data-tid="content-test-end-slot" slot="end" /> | ||
</SplitBlock> |