+ Object used to configure the header logo. The logo will be placed in the header, but if no global app header
+ exists, it will be shown in the sidenav instead.
+
Object used to configure the header application title.
-
-
-
-
-
- logo
-
-
-
- {logoTypeString}
-
-
Object used to configure the header logo.
-
-
-
navItems
diff --git a/apps/website/screens/components/header/overview/HeaderOverviewPage.tsx b/apps/website/screens/components/header/overview/HeaderOverviewPage.tsx
index 443815f60..322c1bd60 100644
--- a/apps/website/screens/components/header/overview/HeaderOverviewPage.tsx
+++ b/apps/website/screens/components/header/overview/HeaderOverviewPage.tsx
@@ -37,7 +37,7 @@ const sections = [
{/* It is also where the searchbar will be displayed once that feature is triggered. */}
- Right slot: it's the place where all utilities related to an application are hosted. It’s
+ Right slot: it's the place where all utilities related to an application are hosted. It's
highly adaptable for each product's needs.
diff --git a/apps/website/screens/components/sidenav/code/SidenavCodePage.tsx b/apps/website/screens/components/sidenav/code/SidenavCodePage.tsx
index 9237e9723..8eb283ba6 100644
--- a/apps/website/screens/components/sidenav/code/SidenavCodePage.tsx
+++ b/apps/website/screens/components/sidenav/code/SidenavCodePage.tsx
@@ -4,18 +4,6 @@ import Code, { ExtendedTableCode, TableCode } from "@/common/Code";
import { DxcFlex, DxcTable } from "@dxc-technology/halstack-react";
import StatusBadge from "@/common/StatusBadge";
-const brandingTypeString = `{
- logo?: Logo;
- appTitle?: string;
-}`;
-
-const logoTypeString = `{
- alt: string;
- href?: string;
- onClick?: (event: MouseEvent) => void;
- src: string;
-}`;
-
const commonItemTypeString = `badge?: ReactElement;
icon?: string | SVG;
label: string;`;
@@ -63,27 +51,6 @@ const sections = [
The content rendered in the bottom part of the sidenav, under the navigation menu.
-
-
-
-
-
- branding
-
-
-
- {"Branding | ReactNode"}
-
- being Branding an object with the following properties:
-
- {brandingTypeString}
-
- and Logo an object with the following properties:
-
- {logoTypeString}
-
-
Object with the properties of the branding placed at the top of the sidenav.
-
-
-
diff --git a/apps/website/screens/components/sidenav/overview/SidenavOverviewPage.tsx b/apps/website/screens/components/sidenav/overview/SidenavOverviewPage.tsx
index 1c0c7c819..36675aa7b 100644
--- a/apps/website/screens/components/sidenav/overview/SidenavOverviewPage.tsx
+++ b/apps/website/screens/components/sidenav/overview/SidenavOverviewPage.tsx
@@ -40,8 +40,7 @@ const sections = [
Contains collapse/expand toggle for the sidenav.
- If no global app header exists, this area should be used for branding (logo,
- product/app name).
+ If no global app header exists, this area will be used for logo and application name.
diff --git a/packages/lib/src/footer/Footer.stories.tsx b/packages/lib/src/footer/Footer.stories.tsx
index 003a178fb..73b52fb5a 100644
--- a/packages/lib/src/footer/Footer.stories.tsx
+++ b/packages/lib/src/footer/Footer.stories.tsx
@@ -468,9 +468,9 @@ const items = [
const FooterInLayout = () => (
isResponsive ? (
@@ -546,9 +546,9 @@ const FooterInLayout = () => (
const ReducedFooterInLayout = () => (
isResponsive ? (
diff --git a/packages/lib/src/header/Header.accessibility.test.tsx b/packages/lib/src/header/Header.accessibility.test.tsx
index 5dd429bb0..e337488f2 100644
--- a/packages/lib/src/header/Header.accessibility.test.tsx
+++ b/packages/lib/src/header/Header.accessibility.test.tsx
@@ -16,20 +16,6 @@ const disabledRules = {
rules: formatRules(rules),
};
-const iconSVG = (
-
-);
-
-const iconUrl = "https://iconape.com/wp-content/files/yd/367773/svg/logo-linkedin-logo-icon-png-svg.png";
-
-const logo = {
- src: iconSVG,
- alt: "DXC Logo",
- href: iconUrl,
-};
const appTitle =
"Application Title with a very long name that exceeds the normal length to test how the header manages overflow situations";
@@ -71,7 +57,6 @@ describe("Header component accessibility tests", () => {
it("Should not have basic accessibility issues", async () => {
const { container } = render(
);
-const logo = {
- src: "https://picsum.photos/id/1000/104/34",
- alt: "DXC Logo",
- href: "https://www.dxc.com",
-};
-
const dxcBrandedLogo = {
src: dxcLogo,
alt: "DXC Logo",
@@ -73,12 +67,6 @@ const dxcBrandedLogo = {
const longAppTitle = "This is a very long application title to test the header component behavior with long titles";
-const longLogo = {
- src: "https://picsum.photos/id/1000/104/34",
- alt: "DXC Logo",
- href: "https://www.dxc.com",
-};
-
const longSideContent = `Long side content that is intended to test how the header component handles situations where the side content exceeds the typical length. This content should ideally wrap or be truncated based on the design specifications of the header component within the application.`;
const items = [
@@ -122,30 +110,26 @@ const longItems = [
const Header = () => (
-
-
- Side Content} />
- Side Content} />
+
+
+ Side Content} />
+ Side Content} />
- {longSideContent}} />
-
- {longSideContent}} />
- {longSideContent}} />
-
- {longSideContent}}
- />
+ {longSideContent}} />
+
+ {longSideContent}} />
+ {longSideContent}} />
+
+ {longSideContent}} />
);
const HeaderInLayout = () => (
isResponsive ? (
diff --git a/packages/lib/src/header/Header.test.tsx b/packages/lib/src/header/Header.test.tsx
index e835df1f2..a1546a6d4 100644
--- a/packages/lib/src/header/Header.test.tsx
+++ b/packages/lib/src/header/Header.test.tsx
@@ -3,11 +3,6 @@ import "@testing-library/jest-dom";
import DxcHeader from "./Header";
import { Item, GroupItem } from "../base-menu/types";
-const defaultHeaderBranding = {
- src: "url-to-dxc-logo",
- alt: "DXC Logo",
-};
-
describe("Header component tests", () => {
const mockMatchMedia = jest.fn();
@@ -26,11 +21,6 @@ describe("Header component tests", () => {
}));
});
- test("Header renders with default logo", () => {
- const { getByAltText } = render();
- expect(getByAltText("DXC Logo")).toBeTruthy();
- });
-
test("hamburger button triggers onClick when clicked", () => {
mockMatchMedia.mockImplementation(() => ({
matches: true,
@@ -39,7 +29,7 @@ describe("Header component tests", () => {
}));
const navItems: Item[] = [{ label: "Home", onSelect: jest.fn() }];
- render();
+ render();
const menuButton = screen.getByRole("button", { name: /toggle menu/i });
fireEvent.click(menuButton);
@@ -63,7 +53,7 @@ describe("Header component tests", () => {
},
];
- render();
+ render();
expect(screen.getByText("Services")).toBeInTheDocument();
expect(screen.queryByText("Development")).not.toBeInTheDocument();
expect(screen.queryByText("Frontend")).not.toBeInTheDocument();
diff --git a/packages/lib/src/header/Header.tsx b/packages/lib/src/header/Header.tsx
index 72c8151bc..d175649c1 100644
--- a/packages/lib/src/header/Header.tsx
+++ b/packages/lib/src/header/Header.tsx
@@ -6,11 +6,12 @@ import DxcDivider from "../divider/Divider";
import DxcHeading from "../heading/Heading";
import { isGroupItem } from "../base-menu/utils";
import { GroupItem, Item } from "../base-menu/types";
-import { useEffect, useMemo, useState } from "react";
+import { useContext, useEffect, useMemo, useState } from "react";
import DxcNavigationTree from "../navigation-tree/NavigationTree";
import { responsiveSizes } from "../common/variables";
import DxcButton from "../button/Button";
import scrollbarStyles from "../styles/scroll";
+import ApplicationLayoutContext from "../layout/ApplicationLayoutContext";
const MAX_MAIN_NAV_SIZE = "60%";
const LEVEL_LIMIT = 1;
@@ -54,10 +55,10 @@ const RightSideContainer = styled(SideContainer)`
justify-content: flex-end;
`;
-const LogoContainer = styled.div<{ isClickable: boolean }>`
+const LogoContainer = styled.div<{ hasAction?: boolean; href?: string }>`
display: flex;
align-items: center;
- cursor: ${(props) => (props.isClickable ? "pointer" : "default")};
+ cursor: ${(props) => (props.hasAction ? "pointer" : "default")};
svg {
height: var(--height-m);
width: auto;
@@ -131,9 +132,10 @@ const sanitizeNavItems = (navItems: HeaderProps["navItems"], level?: number): (G
return sanitizedItems;
};
-const DxcHeader = ({ logo, appTitle, navItems, sideContent, responsiveBottomContent }: HeaderProps): JSX.Element => {
+const DxcHeader = ({ appTitle, navItems, sideContent, responsiveBottomContent }: HeaderProps): JSX.Element => {
const [isResponsive, setIsResponsive] = useState(false);
const [isMenuVisible, setIsMenuVisible] = useState(false);
+ const logo = useContext(ApplicationLayoutContext).logo || undefined;
useEffect(() => {
const handleResize = () => {
@@ -161,11 +163,7 @@ const DxcHeader = ({ logo, appTitle, navItems, sideContent, responsiveBottomCont
0
- ? [
- `minmax(auto, calc((100% - ${MAX_MAIN_NAV_SIZE}) / 2))`,
- `minmax(auto, ${MAX_MAIN_NAV_SIZE})`,
- `minmax(auto, calc((100% - ${MAX_MAIN_NAV_SIZE}) / 2))`,
- ]
+ ? [`auto`, `minmax(auto, ${MAX_MAIN_NAV_SIZE})`, `auto`]
: ["auto", "auto"]
}
templateRows={["var(--height-xxxl)"]}
@@ -173,21 +171,24 @@ const DxcHeader = ({ logo, appTitle, navItems, sideContent, responsiveBottomCont
placeItems="center"
>
-
- {typeof logo.src === "string" ? (
-
- ) : (
- logo.src
- )}
-
+ {logo && (
+
+ {typeof logo.src === "string" ? (
+
+ ) : (
+ logo.src
+ )}
+
+ )}
{appTitle && !isResponsive && (
<>
-
+ {logo && }
>
)}
diff --git a/packages/lib/src/header/types.ts b/packages/lib/src/header/types.ts
index 3c053a81d..472004b61 100644
--- a/packages/lib/src/header/types.ts
+++ b/packages/lib/src/header/types.ts
@@ -1,13 +1,5 @@
import { ReactNode } from "react";
import { CommonItemProps, Item } from "../base-menu/types";
-import { SVG } from "../common/utils";
-
-type LogoPropsType = {
- src: string | SVG;
- alt: string;
- href?: string;
- onClick?: () => void;
-};
type GroupItem = CommonItemProps & {
items: Item[];
@@ -16,7 +8,6 @@ type GroupItem = CommonItemProps & {
type MainNavPropsType = (GroupItem | Item)[];
type Props = {
- logo: LogoPropsType;
appTitle?: string;
navItems?: MainNavPropsType;
responsiveBottomContent?: ReactNode;
diff --git a/packages/lib/src/layout/ApplicationLayout.stories.tsx b/packages/lib/src/layout/ApplicationLayout.stories.tsx
index 446b2f508..4f1fa5b29 100644
--- a/packages/lib/src/layout/ApplicationLayout.stories.tsx
+++ b/packages/lib/src/layout/ApplicationLayout.stories.tsx
@@ -8,9 +8,35 @@ export default {
component: DxcApplicationLayout,
} satisfies Meta;
+const dxcLogo = (
+
+);
+
+const logo = {
+ src: dxcLogo,
+ alt: "DXC Logo",
+ href: "https://www.dxc.com",
+};
+
const ApplicationLayout = () => (
<>
-
+ }>