Skip to content
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

New Tabs component implementation #2061

Merged
merged 30 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
00ec29e
Implemented new Tabs structure
Mil4n0r Jul 22, 2024
0067bfb
Removed %SystemDrive%
Mil4n0r Jul 22, 2024
3f0a14c
Merge branch 'master' of github.com:dxc-technology/halstack-react int…
Mil4n0r Jul 25, 2024
3d1df95
Started progressing with functional tests
Mil4n0r Jul 25, 2024
71d1f22
Added more tests to new Tabs
Mil4n0r Jul 26, 2024
d752b05
Added visual tests, accessibility tests and remaining functional tests
Mil4n0r Jul 26, 2024
18c3cba
Fixed differences in Tabs stories
Mil4n0r Jul 26, 2024
b02d44f
Added doc for new Tabs structure
Mil4n0r Jul 29, 2024
f29cbf3
Merge branch 'master' into Mil4n0r/new_tabs_implementation
Mil4n0r Jul 29, 2024
46ab1ec
Merge branch 'master' into Mil4n0r/new_tabs_implementation
jsuarezgonz Aug 27, 2024
39baccf
Added controlled/uncontrolled behaviour + fixed styles
Jialecl Sep 4, 2024
55924a8
Added and fixed tests based on behaviour changes
Jialecl Sep 5, 2024
67e2645
Tabs documentation updated
Jialecl Sep 5, 2024
314a471
improved controlled behaviour for the tabs
Jialecl Sep 5, 2024
c90ef2c
Solved test due to controlled + disabled behaviour
Jialecl Sep 6, 2024
87e3650
Added tooltip support for the Tab component
Jialecl Sep 13, 2024
8429986
examples name formatted as other folders
Jialecl Sep 13, 2024
33f5941
Fixed examples path
Jialecl Sep 13, 2024
5dd24a9
removed old examples from Tabs usage
Jialecl Sep 13, 2024
37e39f3
Merge branch 'master' into Mil4n0r/new_tabs_implementation
Mil4n0r Sep 16, 2024
08c1ec0
Small example update
GomezIvann Sep 16, 2024
f7788f7
Merge branch 'Mil4n0r/new_tabs_implementation' of https://github.com/…
GomezIvann Sep 16, 2024
cdedbd1
Removed unneeded value for same property name
Mil4n0r Sep 16, 2024
e1a70ca
Removed refTabList from useEffect dependency array (not encouraged)
Mil4n0r Sep 16, 2024
efe04e2
Removed unneeded comment
Mil4n0r Sep 16, 2024
33fd164
Added missing prop 'label' to dependency arrays
Mil4n0r Sep 16, 2024
9e13b56
Added missing dependencies for children handling
Mil4n0r Sep 17, 2024
9e75f1e
Added back stories
Mil4n0r Sep 17, 2024
4c62dcd
Reduced variables that depend on each other
Mil4n0r Sep 17, 2024
02d702f
Merge branch 'master' into Mil4n0r/new_tabs_implementation
Mil4n0r Sep 17, 2024
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
210 changes: 201 additions & 9 deletions apps/website/screens/components/tabs/code/TabsCodePage.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { DxcFlex, DxcLink, DxcTable } from "@dxc-technology/halstack-react";
import { DxcFlex, DxcLink, DxcParagraph, DxcTable } from "@dxc-technology/halstack-react";
import QuickNavContainer from "@/common/QuickNavContainer";
import QuickNavContainerLayout from "@/common/QuickNavContainerLayout";
import DocFooter from "@/common/DocFooter";
import Code from "@/common/Code";
import Example from "@/common/example/Example";
import controlled from "./examples/controlled";
import uncontrolled from "./examples/uncontrolled";
import icons from "./examples/icons";
import controlledLegacy from "./examples-old/controlled";
import uncontrolledLegacy from "./examples-old/uncontrolled";
import iconsLegacy from "./examples-old/icons";
import TableCode from "@/common/TableCode";
import StatusBadge from "@/common/StatusBadge";
import controlled from "./examples-new/controlled";
import uncontrolled from "./examples-new/uncontrolled";
import icons from "./examples-new/icons";

const sections = [
{
Expand All @@ -25,15 +28,25 @@ const sections = [
</thead>
<tbody>
<tr>
<td>defaultActiveTabIndex</td>
<td>
<DxcFlex direction="column" gap="0.25rem" alignItems="baseline">
<StatusBadge status="legacy" />
defaultActiveTabIndex
</DxcFlex>
</td>
<td>
<TableCode>number</TableCode>
</td>
<td>Initially active tab, only when it is uncontrolled.</td>
<td>-</td>
</tr>
<tr>
<td>activeTabIndex</td>
<td>
<DxcFlex direction="column" gap="0.25rem" alignItems="baseline">
<StatusBadge status="legacy" />
activeTabIndex
</DxcFlex>
</td>
<td>
<TableCode>number</TableCode>
</td>
Expand All @@ -46,7 +59,7 @@ const sections = [
<tr>
<td>
<DxcFlex direction="column" gap="0.25rem" alignItems="baseline">
<StatusBadge status="required" />
<StatusBadge status="legacy" />
tabs
</DxcFlex>
</td>
Expand Down Expand Up @@ -86,6 +99,22 @@ const sections = [
</td>
<td>-</td>
</tr>
<tr>
<td>
<DxcFlex direction="column" gap="0.25rem" alignItems="baseline">
{/* TODO: Swap experimental for required once old logic is removed */}
<StatusBadge status="experimental" />
children
</DxcFlex>
</td>
<td>
<TableCode>React.ReactNode</TableCode>
</td>
<td>
Contains one or more <Code>DxcTabs.Tab</Code>.
</td>
<td>-</td>
</tr>
<tr>
<td>iconPosition</td>
<td>
Expand All @@ -97,7 +126,12 @@ const sections = [
</td>
</tr>
<tr>
<td>onTabClick</td>
<td>
<DxcFlex direction="column" gap="0.25rem" alignItems="baseline">
<StatusBadge status="legacy" />
onTabClick
</DxcFlex>
</td>
<td>
<TableCode>{"(index: number) => void"}</TableCode>
</td>
Expand All @@ -108,7 +142,12 @@ const sections = [
<td>-</td>
</tr>
<tr>
<td>onTabHover</td>
<td>
<DxcFlex direction="column" gap="0.25rem" alignItems="baseline">
<StatusBadge status="legacy" />
onTabHover
</DxcFlex>
</td>
<td>
<TableCode>{"(index: number) => void"}</TableCode>
</td>
Expand Down Expand Up @@ -145,6 +184,142 @@ const sections = [
</DxcTable>
),
},
{
title: "DxcTabs.Tab",
content: <DxcParagraph>Single tab, part of the set of Tabs.</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>active</td>
<td>
<TableCode>boolean</TableCode>
</td>
<td>Whether the tab is active or not.</td>
<td>
<TableCode>false</TableCode>
</td>
</tr>
<tr>
<td>defaultActive</td>
<td>
<TableCode>boolean</TableCode>
</td>
<td>Whether the tab is active or not by default, but mantaining the uncontrolled behaviour.</td>
<td>
<TableCode>false</TableCode>
</td>
</tr>
<tr>
<td>disabled</td>
<td>
<TableCode>boolean</TableCode>
</td>
<td>Whether the tab is disabled or not.</td>
<td>
<TableCode>false</TableCode>
</td>
</tr>
<tr>
<td>
<DxcFlex direction="column" gap="0.25rem" alignItems="baseline">
<StatusBadge status="required" />
label
</DxcFlex>
</td>
<td>
<TableCode>string</TableCode>
</td>
<td>Tab label text.</td>
<td>-</td>
</tr>
<tr>
<td>
<DxcFlex direction="column" gap="0.25rem" alignItems="baseline">
title
</DxcFlex>
</td>
<td>
<TableCode>string</TableCode>
</td>
<td>Tooltip text for the tab.</td>
<td>-</td>
</tr>
<tr>
<td>icon</td>
<td>
<TableCode>string | {"(React.ReactNode & React.SVGProps <SVGSVGElement>)"}</TableCode>
</td>
<td>
<DxcLink newWindow href="https://fonts.google.com/icons">
Material Symbol
</DxcLink>{" "}
name or SVG element as the icon that will be displayed in the tab. When using Material Symbols,
replace spaces with underscores. By default they are outlined if you want it to be filled prefix the
symbol name with <TableCode>"filled_"</TableCode>.
</td>
<td>-</td>
</tr>
<tr>
<td>onClick</td>
<td>
<TableCode>{"() => void"}</TableCode>
</td>
<td>This function will be called when the user clicks on this tab. </td>
<td>-</td>
</tr>
<tr>
<td>onHover</td>
<td>
<TableCode>{"() => void"}</TableCode>
</td>
<td>This function will be called when the user hovers this tab.</td>
<td>-</td>
</tr>
<tr>
<td>notificationNumber</td>
<td>
<TableCode>boolean | number</TableCode>
</td>
<td>
If true, an empty badge will appear. If false or if the tab is disabled, no badge will appear. If a
number is specified, the component will display a badge with the value as its label. Take into account
that if that number is greater than 99, it will appear as <TableCode>+99</TableCode> in the badge.
</td>
<td>
<TableCode>false</TableCode>
</td>
</tr>
<tr>
<td>
<DxcFlex direction="column" gap="0.25rem" alignItems="baseline">
<StatusBadge status="required" />
children
</DxcFlex>
</td>
<td>
<TableCode>React.ReactNode</TableCode>
</td>
<td>Contains the component to be rendered when this tab is active.</td>
<td>-</td>
</tr>
</tbody>
</DxcTable>
),
},
],
},
{
title: "Examples",
subSections: [
Expand All @@ -162,6 +337,23 @@ const sections = [
},
],
},
{
title: "Examples (Legacy)",
subSections: [
{
title: "Controlled",
content: <Example example={controlledLegacy} defaultIsVisible />,
},
{
title: "Uncontrolled",
content: <Example example={uncontrolledLegacy} defaultIsVisible />,
},
{
title: "Icons and notifications",
content: <Example example={iconsLegacy} defaultIsVisible />,
},
],
},
];

const TabsUsagePage = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { DxcTabs, DxcInset } from "@dxc-technology/halstack-react";
import { useState } from "react";

const code = `() => {
const [selectedTab, setSelectedTab] = useState("Mail");
return (
<DxcInset space="2rem">
<DxcTabs>
<DxcTabs.Tab label="Mail" active={selectedTab === "Mail"} onClick={() => setSelectedTab("Mail")}>
<></>
</DxcTabs.Tab>
<DxcTabs.Tab label="Calendar" active={selectedTab === "Calendar"} onClick={() => setSelectedTab("Calendar")}>
<></>
</DxcTabs.Tab>
<DxcTabs.Tab label="Contacts" active={selectedTab === "Contacts"} onClick={() => setSelectedTab("Contacts")}>
<></>
</DxcTabs.Tab></DxcTabs>
</DxcInset>
);
}`;

const scope = {
DxcTabs,
DxcInset,
useState,
};

export default { code, scope };
45 changes: 45 additions & 0 deletions apps/website/screens/components/tabs/code/examples-new/icons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { DxcTabs, DxcInset } from "@dxc-technology/halstack-react";

const code = `() => {
const mobileIcon = (
<svg
xmlns="http://www.w3.org/2000/svg"
height="24px"
viewBox="0 0 24 24"
width="24px"
fill="currentColor"
>
<g>
<path d="M0,0h24v24H0V0z" fill="none" />
</g>
<g>
<g>
<path d="M3,7v2h5v2H4v2h4v2H3v2h5c1.1,0,2-0.9,2-2v-1.5c0-0.83-0.67-1.5-1.5-1.5c0.83,0,1.5-0.67,1.5-1.5V9c0-1.1-0.9-2-2-2H3z M21,11v4c0,1.1-0.9,2-2,2h-5c-1.1,0-2-0.9-2-2V9c0-1.1,0.9-2,2-2h5c1.1,0,2,0.9,2,2h-7v6h5v-2h-2.5v-2H21z" />
</g>
</g>
</svg>
);

return (
<DxcInset space="2rem">
<DxcTabs>
<DxcTabs.Tab label="3G Mobile" icon={mobileIcon} notificationNumber={true}>
<></>
</DxcTabs.Tab>
<DxcTabs.Tab label="Ethernet" icon="settings_ethernet" notificationNumber={2} disabled>
<></>
</DxcTabs.Tab>
<DxcTabs.Tab label="Wifi" icon="wifi" notificationNumber={120}>
<></>
</DxcTabs.Tab>
</DxcTabs>
</DxcInset>
);
}`;

const scope = {
DxcTabs,
DxcInset,
};

export default { code, scope };
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { DxcTabs, DxcInset } from "@dxc-technology/halstack-react";

const code = `() => {
return (
<DxcInset space="2rem">
<DxcTabs>
<DxcTabs.Tab label="Mail" defaultActive>
<></>
</DxcTabs.Tab>
<DxcTabs.Tab label="Calendar">
<></>
</DxcTabs.Tab>
<DxcTabs.Tab label="Contacts">
<></>
</DxcTabs.Tab></DxcTabs>
</DxcInset>
);
}`;

const scope = {
DxcTabs,
DxcInset,
};

export default { code, scope };
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Figure from "@/common/Figure";
import DocFooter from "@/common/DocFooter";
import tabsUsage from "./examples/usage";
import defaultUsage from "./examples/default";
import scrollableUsage from "./examples/scrollable";
import contentUsageTabImage from "./images/tabs_content.png";
import typographyUsageTabImage from "./images/tabs_typography.png";
import tabsPlacement from "./images/tabs_placement.png";
Expand All @@ -16,7 +17,6 @@ import tabsAlignment from "./images/tabs_alignment.png";
import tabsPanelBehavior from "./images/tabs_panel_behavior.png";
import tabsScrollablePanelBehavior from "./images/tabs_scrollable_panel_behavior.png";
import Example from "@/common/example/Example";
import scrollableUsage from "./examples/scrollable";

const sections = [
{
Expand Down
Loading
Loading