Skip to content

Commit

Permalink
feat(canary-react): added dark mode features, stories & tests to data…
Browse files Browse the repository at this point in the history
…-table

added dark mode colours, tests and stories

BREAKING CHANGE: removed appearance option from updatingOptions, loadingOptions & paginationOptions
  • Loading branch information
GCHQ-Developer-741 committed Nov 27, 2024
1 parent 3a7cc89 commit 018ea76
Show file tree
Hide file tree
Showing 27 changed files with 455 additions and 170 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ...-image-diff-screenshots/baseline/IcDataTable.cy.tsx-icons-only-in-some-rows.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
581 changes: 439 additions & 142 deletions packages/canary-react/src/component-tests/IcDataTable/IcDataTable.cy.tsx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { IcDataTableColumnObject } from "@ukic/canary-web-components";
import { DATA } from "@ukic/canary-web-components/src/components/ic-data-table/story-data";

const FIRST_NAME_TITLE = "First name";

export const singleColumnWidth = (
firstNameWidth: string
): IcDataTableColumnObject[] => [
{
key: "firstName",
title: "First name",
title: FIRST_NAME_TITLE,
dataType: "string",
columnWidth: firstNameWidth,
},
Expand All @@ -28,7 +30,7 @@ export const multipleColumnWidth = (
): IcDataTableColumnObject[] => [
{
key: "firstName",
title: "First name",
title: FIRST_NAME_TITLE,
dataType: "string",
columnWidth: firstNameWidth,
},
Expand All @@ -50,7 +52,7 @@ export const singleMinWidthColumn = (
): IcDataTableColumnObject[] => [
{
key: "firstName",
title: "First name",
title: FIRST_NAME_TITLE,
dataType: "string",
columnWidth: {
minWidth: minWidth,
Expand All @@ -73,7 +75,7 @@ export const singleColumnTruncationWidth = (
): IcDataTableColumnObject[] => [
{
key: "firstName",
title: "First name",
title: FIRST_NAME_TITLE,
dataType: "string",
},
{
Expand All @@ -89,7 +91,8 @@ export const singleColumnTruncationWidth = (
},
];

export const newData = () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const newData = (): { [key: string]: any }[] => {
return DATA.map((d) => ({
firstName: d.firstName,
lastName: d.lastName,
Expand Down
31 changes: 8 additions & 23 deletions packages/canary-react/src/stories/ic-data-table.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,6 @@ export default DataTable;
When a user wants to fetch their data asynchronously, a `loading` prop can be set to `true`, which then renders a circular variant of the `IcLoadingIndicator`.
The loading indicator can be customised using the `loadingOptions` prop:

- `appearance` can be `light` or `dark`
- `description` sets the aria-label of the component
- `label` sets the visual message
- `labelDuration` is the number of milliseconds before the label changes
Expand Down Expand Up @@ -1777,7 +1776,6 @@ export const UpdatingData = () => {
showItemsPerPageControl: true,
showGoToPageControl: true,
rangeLabelType: "page",
appearance: "default"
}}
/>
<div style={{ display: "flex", gap: "8px", marginTop: "8px" }}>
Expand Down Expand Up @@ -1886,7 +1884,6 @@ export const defaultPaginationBarArgs = {
showItemsPerPageControl: true,
showGoToPageControl: true,
alignment: "right",
appearance: "default",
itemLabel: "Item",
pageLabel: "Page",
hideRangeLabel: false
Expand Down Expand Up @@ -2092,7 +2089,6 @@ export const defaultArgs = {
height: "",
hideColumnHeaders: false,
loading: false,
loadingAppearance: "dark",
loadingDesc: "loading",
loadingLabel: "Loading data...",
loadingLabelDuration: 20,
Expand All @@ -2111,7 +2107,6 @@ export const defaultArgs = {
paginationShowItemsPerPageControl: true,
paginationShowGoToPageControl: true,
paginationAlignment: "right",
paginationAppearance: "default",
paginationItemLabel: "Item",
paginationPageLabel: "Page",
paginationHideRangeLabel: false,
Expand All @@ -2122,7 +2117,6 @@ export const defaultArgs = {
stickyColumnHeaders: false,
stickyRowHeaders: false,
updating: false,
updatingAppearance: "dark",
updatingDesc: "loading",
updatingMax: 100,
updatingMin: 0,
Expand All @@ -2136,7 +2130,8 @@ export const defaultArgs = {
titleBarMetadata: "128 items | 32gb | Updated: 01/02/03",
titleBarPrimaryActionSlot: true,
titleBarCustomActionSlot: true,
width: ""
width: "",
theme: "inherit",
};

<Canvas withSource="none">
Expand All @@ -2147,14 +2142,6 @@ export const defaultArgs = {
options: ["default", "dense", "spacious"],
control: { type: "inline-radio" },
},
loadingAppearance: {
options: ["dark", "light"],
control: { type: "inline-radio" },
},
paginationAppearance: {
options: ["default", "dark", "light"],
control: { type: "inline-radio" },
},
paginationRangeLabelType: {
options: ["page", "data"],
control: { type: "inline-radio" },
Expand All @@ -2175,10 +2162,6 @@ export const defaultArgs = {
options: ["tooltip", "show-hide"],
control: { type: "inline-radio" },
},
updatingAppearance: {
options: ["dark", "light"],
control: { type: "inline-radio" },
},
titleBarSlot: {
mapping: {
true: "title-bar",
Expand All @@ -2197,6 +2180,10 @@ export const defaultArgs = {
false: "",
}
},
theme: {
options: ["inherit", "light", "dark"],
control: { type: "inline-radio" },
},
}}
name="Playground example"
>
Expand All @@ -2213,7 +2200,6 @@ export const defaultArgs = {
hideColumnHeaders={args.hideColumnHeaders}
loading={args.loading}
loadingOptions={{
appearance: args.loadingAppearance,
description: args.loadingDesc,
label: args.loadingLabel,
labelDuration: args.loadingLabelDuration,
Expand All @@ -2228,8 +2214,7 @@ export const defaultArgs = {
rangeLabelType: args.paginationRangeLabelType,
type: args.paginationType,
showItemsPerPageControl: args.paginationShowItemsPerPageControl,
showGoToPageControl: args.paginationShowGoToPageControl,
appearance: args.paginationAppearance,
showGoToPageControl: args.paginationShowGoToPageControl,
alignment: args.paginationAlignment,
pageLabel: args.paginationPageLabel,
itemLabel: args.paginationItemLabel,
Expand All @@ -2247,13 +2232,13 @@ export const defaultArgs = {
truncationPattern={args.truncationPattern}
updating={args.updating}
updatingOptions={{
appearance: args.updatingAppearance,
description: args.updatingDesc,
max: args.updatingMax,
min: args.updatingMin,
progress: args.updatingProgress
}}
width={args.width}
theme={args.theme}
>
<IcDataTableTitleBar
slot={args.titleBarSlot}
Expand Down

0 comments on commit 018ea76

Please sign in to comment.