Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion lib/src/table/ActionsCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const overwriteTheme = (theme: DeepPartial<AdvancedTheme>) => {
newTheme.dropdown.buttonIconColor = theme.table.actionIconColor;
newTheme.dropdown.disabledColor = theme.table.disabledActionIconColor;
newTheme.dropdown.disabledButtonBackgroundColor = theme.table.disabledActionBackgroundColor;
console.log(newTheme);
return newTheme;
};

Expand Down
6 changes: 3 additions & 3 deletions website/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion website/screens/common/TableCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const ExtendedTableCode = ({

const ExtendedCodeContainer = styled.div`
width: 100%;
white-space: pre-wrap;
white-space: pre;
padding: 2px 4px;
background-color: #f2eafa;
border-radius: 0.25rem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
import { DxcFlex, DxcTable } from "@dxc-technology/halstack-react";
import {
DxcFlex,
DxcLink,
DxcParagraph,
DxcTable,
} from "@dxc-technology/halstack-react";
import QuickNavContainerLayout from "@/common/QuickNavContainerLayout";
import QuickNavContainer from "@/common/QuickNavContainer";
import Code from "@/common/Code";
import DocFooter from "@/common/DocFooter";
import Example from "@/common/example/Example";
import basicUsage from "./examples/basicUsage";
import sortable from "./examples/sortable";
import TableCode from "@/common/TableCode";
import TableCode, { ExtendedTableCode } from "@/common/TableCode";
import StatusTag from "@/common/StatusTag";
import reduced from "./examples/reduced";
import Link from "next/link";

const actionsType = `{
icon: string | SVG;
title: string;
onClick: () => void;
disabled?: boolean;
tabIndex?: number;
}[] | {
title: string;
onClick: (value?: string) => void;
disabled?: boolean;
tabIndex?: number;
options: Option[];
}[]`;

const sections = [
{
Expand Down Expand Up @@ -90,11 +110,12 @@ const sections = [
<td>
The available table modes:
<ul>
<li>
<li>
<b>default</b>: Default table size.
</li>
<li>
<b>reduced</b>: More compact table with less spacing for high density information.
<b>reduced</b>: More compact table with less spacing for high
density information.
</li>
</ul>
</td>
Expand Down Expand Up @@ -178,6 +199,66 @@ const sections = [
</DxcTable>
),
},
{
title: "DxcResultsetTable.ActionsCell",
content: (
<DxcParagraph>
A compound component aimed to be used inside the resultset table's
displayValue to display up to three actions.
</DxcParagraph>
),
subSections: [
{
title: "Props",
content: (
<DxcTable>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<DxcFlex
direction="column"
gap="0.25rem"
alignItems="baseline"
>
<StatusTag status="Required">Required</StatusTag>actions
</DxcFlex>
</td>
<td>
<ExtendedTableCode>{actionsType}</ExtendedTableCode>
</td>
<td>
<p>
It represents a list of interactuable elements that will
work as buttons or as a dropdown. Those with an{" "}
<TableCode>icon</TableCode> are treated as buttons. If any
element lacks an <TableCode>icon</TableCode> and includes{" "}
<TableCode>options</TableCode>, it is interpreted as a
dropdown. Only the first action with options will be
displayed and only up to 3 actions. In the case of the
dropdown the click function will pass the value assigned to
the option, click{" "}
<Link href="/components/dropdown" passHref legacyBehavior>
<DxcLink>here</DxcLink>
</Link>{" "}
for more details.
</p>
</td>
<td>-</td>
</tr>
</tbody>
</DxcTable>
),
},
],
},
{
title: "Examples",
subSections: [
Expand All @@ -187,9 +268,7 @@ const sections = [
},
{
title: "Reduced usage",
content: (
<Example example={reduced} defaultIsVisible />
),
content: <Example example={reduced} defaultIsVisible />,
},
{
title: "Sortable",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
DxcResultsetTable,
DxcInset,
} from "@dxc-technology/halstack-react";
import { DxcResultsetTable, DxcInset } from "@dxc-technology/halstack-react";
import { deleteIcon } from "./Icons";

const code = `() => {
Expand All @@ -18,6 +15,20 @@ const code = `() => {
title: "icon",
onClick: () => {},
},
{
title: "edit",
onClick: (value) => {},
options:[
{
value: "1",
label: "Edit",
},
{
value: "2",
label: "Mark as selected",
},
]
},
];

const rows = [
Expand Down
98 changes: 91 additions & 7 deletions website/screens/components/table/code/TableCodePage.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
import { DxcFlex, DxcTable } from "@dxc-technology/halstack-react";
import {
DxcFlex,
DxcLink,
DxcParagraph,
DxcTable,
} from "@dxc-technology/halstack-react";
import QuickNavContainerLayout from "@/common/QuickNavContainerLayout";
import QuickNavContainer from "@/common/QuickNavContainer";
import DocFooter from "@/common/DocFooter";
import Example from "@/common/example/Example";
import basic from "./examples/basicUsage";
import TableCode, { ExtendedTableCode } from "@/common/TableCode";
import StatusTag from "@/common/StatusTag";
import TableCode from "@/common/TableCode";
import basic from "./examples/basicUsage";
import reduced from "./examples/reduced";
import Link from "next/link";
import actions from "./examples/actions";

const actionsType = `{
icon: string | SVG;
title: string;
onClick: () => void;
disabled?: boolean;
tabIndex?: number;
}[] | {
title: string;
onClick: (value?: string) => void;
disabled?: boolean;
tabIndex?: number;
options: Option[];
}[]`;

const sections = [
{
Expand Down Expand Up @@ -53,7 +74,8 @@ const sections = [
<b>default</b>: Default table size.
</li>
<li>
<b>reduced</b>: More compact table with less spacing for high density information.
<b>reduced</b>: More compact table with less spacing for high
density information.
</li>
</ul>
</td>
Expand All @@ -80,6 +102,66 @@ const sections = [
</DxcTable>
),
},
{
title: "DxcTable.ActionsCell",
content: (
<DxcParagraph>
A compound component aimed to be used inside the table to display up to
three actions.
</DxcParagraph>
),
subSections: [
{
title: "Props",
content: (
<DxcTable>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<DxcFlex
direction="column"
gap="0.25rem"
alignItems="baseline"
>
<StatusTag status="Required">Required</StatusTag>actions
</DxcFlex>
</td>
<td>
<ExtendedTableCode>{actionsType}</ExtendedTableCode>
</td>
<td>
<p>
It represents a list of interactuable elements that will
work as buttons or as a dropdown. Those with an{" "}
<TableCode>icon</TableCode> are treated as buttons. If any
element lacks an <TableCode>icon</TableCode> and includes{" "}
<TableCode>options</TableCode>, it is interpreted as a
dropdown. Only the first action with options will be
displayed and only up to 3 actions. In the case of the
dropdown the click function will pass the value assigned to
the option, click{" "}
<Link href="/components/dropdown" passHref legacyBehavior>
<DxcLink>here</DxcLink>
</Link>{" "}
for more details.
</p>
</td>
<td>-</td>
</tr>
</tbody>
</DxcTable>
),
},
],
},
{
title: "Examples",
subSections: [
Expand All @@ -93,9 +175,11 @@ const sections = [
},
{
title: "Reduced usage",
content: (
<Example example={reduced} defaultIsVisible />
),
content: <Example example={reduced} defaultIsVisible />,
},
{
title: "Actions cell",
content: <Example example={actions} defaultIsVisible />,
},
],
},
Expand Down
9 changes: 9 additions & 0 deletions website/screens/components/table/code/examples/Icons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from "react";

export const deleteIcon = (
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
<path fill="currentColor" d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z" />
<path d="M0 0h24v24H0z" fill="none" />
</svg>
);

64 changes: 64 additions & 0 deletions website/screens/components/table/code/examples/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { DxcTable, DxcInset } from "@dxc-technology/halstack-react";
import { deleteIcon } from "./Icons";

const code = `() => {
const actions = [
{
icon: deleteIcon,
title: "icon",
onClick: () => {},
},
{
title: "edit",
onClick: (value) => {},
options:[
{
value: "1",
label: "Edit",
},
{
value: "2",
label: "Mark as selected",
},
]
},
];
return (
<DxcInset space="2rem">
<DxcTable mode="reduced">
<thead>
<tr>
<th>header 1</th>
<th>header 2</th>
<th>actions</th>
</tr>
</thead>
<tbody>
<tr>
<td>cell 1</td>
<td>cell 2</td>
<td><DxcTable.ActionsCell actions={actions} /></td>
</tr>
<tr>
<td>cell 4</td>
<td>cell 5</td>
<td><DxcTable.ActionsCell actions={actions} /></td>
</tr>
<tr>
<td>cell 7</td>
<td>cell 8</td>
<td><DxcTable.ActionsCell actions={actions} /></td>
</tr>
</tbody>
</DxcTable>
</DxcInset>
);
}`;

const scope = {
DxcTable,
DxcInset,
deleteIcon,
};

export default { code, scope };