-
Notifications
You must be signed in to change notification settings - Fork 21
[BOOKINGSG-9293][ZZ] migrate table to linaria #1167
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
90a7ef1
[BOOKINGSG-9293][ZZ] refactor: rename styles file
ziggyzet c5da075
[BOOKINGSG-9293][ZZ] refactor: migrate v3 to v4 tokens
ziggyzet 96f5a93
[BOOKINGSG-9293][ZZ] refactor: migrate table to Linaria
ziggyzet 1e30f63
[BOOKINGSG-9293][ZZ] test: adding unit tests for table
ziggyzet 4efd9ab
[BOOKINGSG-9293][ZZ] test: e2e test for table
ziggyzet 7e02ba0
[BOOKINGSG-9293][ZZ] test: generate screenshots for test results
ziggyzet 35cd901
[BOOKINGSG-9293][ZZ] refactor: reuse existing components
ziggyzet 101afb8
[BOOKINGSG-9293][ZZ] refactor: update comment syntax in style
ziggyzet f339c9c
[BOOKINGSG-9293][ZZ] test: update test suite to use get by role
ziggyzet ad95dd6
[BOOKINGSG-9293][ZZ] test: adding test id to wrapper
ziggyzet 34ddcaa
[BOOKINGSG-9293][ZZ] test: remove unused tests and locators
ziggyzet 42ed190
[BOOKINGSG-9293][ZZ] test: rename test suites and adding test for ver…
ziggyzet 18b9248
[BOOKINGSG-9293][ZZ] test: regenerate screenshots
ziggyzet 8765e9f
[BOOKINGSG-9293][ZZ] refactor: remove unneccessary destructure
ziggyzet 66daf18
[BOOKINGSG-9293][ZZ] style: remove unneccessary property addition
ziggyzet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,33 @@ | ||
| "use client"; | ||
| import { Table } from "@lifesg/react-design-system/table"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <Table data-testid="table"> | ||
| <Table.Head> | ||
| <Table.Row> | ||
| <Table.HeaderCell>Name</Table.HeaderCell> | ||
| <Table.HeaderCell>Email</Table.HeaderCell> | ||
| <Table.HeaderCell>Status</Table.HeaderCell> | ||
| </Table.Row> | ||
| </Table.Head> | ||
| <Table.Body> | ||
| <Table.Row data-testid="row-1"> | ||
| <Table.Cell>Alice Tan</Table.Cell> | ||
| <Table.Cell>alice@example.com</Table.Cell> | ||
| <Table.Cell>Active</Table.Cell> | ||
| </Table.Row> | ||
| <Table.Row data-testid="row-2"> | ||
| <Table.Cell>Bob Lim</Table.Cell> | ||
| <Table.Cell>bob@example.com</Table.Cell> | ||
| <Table.Cell>Inactive</Table.Cell> | ||
| </Table.Row> | ||
| <Table.Row data-testid="row-3"> | ||
| <Table.Cell>Carol Wong</Table.Cell> | ||
| <Table.Cell>carol@example.com</Table.Cell> | ||
| <Table.Cell>Pending</Table.Cell> | ||
| </Table.Row> | ||
| </Table.Body> | ||
| </Table> | ||
| ); | ||
| } |
37 changes: 37 additions & 0 deletions
37
e2e/nextjs-app/src/app/components/table/horizontal-overflow.e2e.tsx
This file contains hidden or 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,37 @@ | ||
| "use client"; | ||
| import { Table } from "@lifesg/react-design-system/table"; | ||
| import styles from "./table.module.css"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <div className={styles["table-overflow"]}> | ||
| <Table data-testid="table"> | ||
| <Table.Head> | ||
| <Table.Row> | ||
| <Table.HeaderCell>First name</Table.HeaderCell> | ||
| <Table.HeaderCell>Last name</Table.HeaderCell> | ||
| <Table.HeaderCell>Email address</Table.HeaderCell> | ||
| <Table.HeaderCell>Department</Table.HeaderCell> | ||
| <Table.HeaderCell>Status</Table.HeaderCell> | ||
| </Table.Row> | ||
| </Table.Head> | ||
| <Table.Body> | ||
| <Table.Row> | ||
| <Table.Cell>Alice</Table.Cell> | ||
| <Table.Cell>Tan</Table.Cell> | ||
| <Table.Cell>alice@example.com</Table.Cell> | ||
| <Table.Cell>Engineering</Table.Cell> | ||
| <Table.Cell>Active</Table.Cell> | ||
| </Table.Row> | ||
| <Table.Row> | ||
| <Table.Cell>Bob</Table.Cell> | ||
| <Table.Cell>Lim</Table.Cell> | ||
| <Table.Cell>bob@example.com</Table.Cell> | ||
| <Table.Cell>Design</Table.Cell> | ||
| <Table.Cell>Inactive</Table.Cell> | ||
| </Table.Row> | ||
| </Table.Body> | ||
| </Table> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or 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,7 @@ | ||
| .table-overflow { | ||
| width: 400px; | ||
| } | ||
|
|
||
| .table-vertical-overflow { | ||
| max-height: 200px; | ||
| } |
33 changes: 33 additions & 0 deletions
33
e2e/nextjs-app/src/app/components/table/vertical-overflow.e2e.tsx
This file contains hidden or 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,33 @@ | ||
| "use client"; | ||
| import { Table } from "@lifesg/react-design-system/table"; | ||
| import styles from "./table.module.css"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <Table.Container | ||
| data-testid="table-wrapper" | ||
| className={styles["table-vertical-overflow"]} | ||
| > | ||
| <Table.Table data-testid="table"> | ||
| <Table.Head> | ||
| <Table.Row> | ||
| <Table.HeaderCell>Name</Table.HeaderCell> | ||
| <Table.HeaderCell>Email</Table.HeaderCell> | ||
| <Table.HeaderCell>Status</Table.HeaderCell> | ||
| </Table.Row> | ||
| </Table.Head> | ||
| <Table.Body> | ||
| {Array.from({ length: 10 }).map((_, i) => ( | ||
| <Table.Row key={i} data-testid={`row-${i + 1}`}> | ||
| <Table.Cell>User {i + 1}</Table.Cell> | ||
| <Table.Cell>user{i + 1}@example.com</Table.Cell> | ||
| <Table.Cell> | ||
| {i % 2 === 0 ? "Active" : "Inactive"} | ||
| </Table.Cell> | ||
| </Table.Row> | ||
| ))} | ||
| </Table.Body> | ||
| </Table.Table> | ||
| </Table.Container> | ||
| ); | ||
| } |
Binary file added
BIN
+13.3 KB
e2e/tests/components/table/__screenshots__/chromium/Table-Default-table--mount.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+13.5 KB
...onents/table/__screenshots__/chromium/Table-Default-table-dark-mode---mount.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.4 KB
.../__screenshots__/chromium/Table-Horizontal-overflow-scrollable-table--mount.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.95 KB
...__screenshots__/chromium/Table-Table-can-be-scrolled-horizontally--scrolled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.7 KB
...e/__screenshots__/chromium/Table-Table-can-be-scrolled-vertically--scrolled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.84 KB
...le/__screenshots__/chromium/Table-Vertical-overflow-scrollable-table--mount.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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,107 @@ | ||
| import { test as base, expect, Locator, Page } from "@playwright/test"; | ||
| import { AbstractStoryPage, compareScreenshot } from "../../utils"; | ||
|
|
||
| class StoryPage extends AbstractStoryPage { | ||
| protected readonly component = "table"; | ||
|
|
||
| public readonly locators: { | ||
| table: Locator; | ||
| tableWrapper: Locator; | ||
| }; | ||
|
|
||
| constructor(page: Page) { | ||
| super(page); | ||
|
|
||
| this.locators = { | ||
| table: page.getByTestId("table"), | ||
| tableWrapper: page.getByTestId("table-wrapper"), | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| const test = base.extend<{ story: StoryPage }>({ | ||
| story: async ({ page }, use) => { | ||
| const story = new StoryPage(page); | ||
| await use(story); | ||
| }, | ||
| }); | ||
|
|
||
| test.describe("Table", () => { | ||
| test.describe(() => { | ||
| test.beforeEach(async ({ story }) => { | ||
| await story.init("basic"); | ||
| }); | ||
|
|
||
| test("Default table", async ({ story }) => { | ||
| await compareScreenshot(story, "mount"); | ||
|
|
||
| await expect(story.locators.table).toMatchAriaSnapshot(` | ||
| - table: | ||
| - rowgroup: | ||
| - row "Name Email Status": | ||
| - columnheader "Name" | ||
| - columnheader "Email" | ||
| - columnheader "Status" | ||
| - rowgroup: | ||
| - row "Alice Tan alice@example.com Active": | ||
| - cell "Alice Tan" | ||
| - cell "alice@example.com" | ||
| - cell "Active" | ||
| - row "Bob Lim bob@example.com Inactive": | ||
| - cell "Bob Lim" | ||
| - cell "bob@example.com" | ||
| - cell "Inactive" | ||
| - row "Carol Wong carol@example.com Pending": | ||
| - cell "Carol Wong" | ||
| - cell "carol@example.com" | ||
| - cell "Pending" | ||
| `); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe(() => { | ||
| test.beforeEach(async ({ story }) => { | ||
| await story.init("basic", { mode: "dark" }); | ||
| }); | ||
|
|
||
| test("Default table (dark mode)", async ({ story }) => { | ||
| await compareScreenshot(story, "mount"); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe(() => { | ||
| test.beforeEach(async ({ story }) => { | ||
| await story.init("horizontal-overflow"); | ||
| }); | ||
|
|
||
| test("Horizontal overflow scrollable table", async ({ story }) => { | ||
| await compareScreenshot(story, "mount"); | ||
| }); | ||
|
|
||
| test("Table can be scrolled horizontally", async ({ story }) => { | ||
| await story.locators.tableWrapper.hover(); | ||
| await story.page.mouse.wheel(200, 0); | ||
| await compareScreenshot(story, "scrolled", { | ||
| locator: story.locators.tableWrapper, | ||
| }); | ||
| }); | ||
|
qroll marked this conversation as resolved.
|
||
| }); | ||
|
|
||
| test.describe(() => { | ||
| test.beforeEach(async ({ story }) => { | ||
| await story.init("vertical-overflow"); | ||
| }); | ||
|
|
||
| test("Vertical overflow scrollable table", async ({ story }) => { | ||
| await compareScreenshot(story, "mount"); | ||
| }); | ||
|
|
||
| test("Table can be scrolled vertically", async ({ story }) => { | ||
| await story.locators.tableWrapper.hover(); | ||
| await story.page.mouse.wheel(0, 200); | ||
| await compareScreenshot(story, "scrolled", { | ||
| locator: story.locators.tableWrapper, | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or 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,79 @@ | ||
| import { css } from "@linaria/core"; | ||
|
|
||
| import { Border, Colour, Radius, Spacing } from "../theme"; | ||
|
|
||
| // ============================================================================= | ||
| // STYLES CONSTANTS | ||
| // ============================================================================= | ||
| const borderColor = Colour["border"]; | ||
| const fontColor = Colour["text"]; | ||
|
|
||
| // ============================================================================= | ||
| // STYLES | ||
| // ============================================================================= | ||
| export const tableWrapper = css` | ||
| overflow: auto; | ||
| border: ${Border["width-010"]} ${Border["solid"]} ${borderColor}; | ||
| border-radius: ${Radius["md"]}; | ||
|
|
||
| /* Hide scrollbar */ | ||
| &::-webkit-scrollbar { | ||
| display: none; | ||
| } | ||
| * { | ||
| -ms-overflow-style: none; /* IE and Edge */ | ||
| scrollbar-width: none; /* Firefox */ | ||
| } | ||
| `; | ||
|
|
||
| export const tableComponent = css` | ||
| text-align: left; | ||
| border-collapse: separate; | ||
| border-spacing: 0; | ||
| width: 100%; | ||
| `; | ||
|
|
||
| export const tableBody = css` | ||
| :where(tr:last-child) { | ||
| td { | ||
| border-bottom: none; | ||
| } | ||
| } | ||
| `; | ||
|
|
||
| export const headerCell = css` | ||
| padding: ${Spacing["spacing-20"]} ${Spacing["spacing-16"]}; | ||
| text-align: left; | ||
| cursor: default; | ||
| vertical-align: middle; | ||
| color: ${fontColor}; | ||
| background-color: ${Colour["bg-stronger"]}; | ||
| height: 6rem; | ||
| border-bottom: ${Border["width-010"]} ${Border["solid"]} ${borderColor}; | ||
|
|
||
| &:where(&:first-child) { | ||
| padding-left: ${Spacing["spacing-24"]}; | ||
| } | ||
| &:where(&:last-child) { | ||
| padding-right: ${Spacing["spacing-24"]}; | ||
| } | ||
| `; | ||
|
|
||
| export const bodyRow = css` | ||
| background-color: ${Colour["bg"]}; | ||
| border-top: ${Border["width-010"]} ${Border["solid"]} ${borderColor}; | ||
| `; | ||
|
zhaoyanxzy marked this conversation as resolved.
|
||
|
|
||
| export const bodyCell = css` | ||
| padding: ${Spacing["spacing-20"]} ${Spacing["spacing-16"]}; | ||
| vertical-align: middle; | ||
| color: ${fontColor}; | ||
| border-bottom: ${Border["width-010"]} ${Border["solid"]} ${borderColor}; | ||
|
|
||
| &:where(&:first-child) { | ||
| padding-left: ${Spacing["spacing-24"]}; | ||
| } | ||
| &:where(&:last-child) { | ||
| padding-right: ${Spacing["spacing-24"]}; | ||
| } | ||
| `; | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.