Skip to content

Commit

Permalink
Merge pull request #169 from ConductionNL/feature/GW-1542/topnav
Browse files Browse the repository at this point in the history
feature/GW-1542/topnav
  • Loading branch information
remko48 authored Dec 1, 2023
2 parents 6ee50a0 + 6de83f8 commit e61ee50
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 11 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

- **Version 2.2 (breaking changes from 2.1.x)**

- 2.2.39:
- Updated PrimaryTopNav component to include tooltip and better dropdown.
- Updated Logo component to have navbar option.
- 2.2.38: Updated DownloadCard to show only one icon.
- 2.2.37: Updated DownloadCard to include tooltip and Removed opacity token from Tooltip the fix bug.
- 2.2.35 & 2.2.36:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@conduction/components",
"version": "2.2.38",
"version": "2.2.39",
"description": "React (Gatsby) components used within the Conduction Skeleton Application (and its implementations)",
"main": "lib/index.js",
"scripts": {
Expand Down
12 changes: 11 additions & 1 deletion src/components/logo/Logo.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@

--conduction-logo-footer-inline-size: 330px;
--conduction-logo-footer-block-size: 60px;
--conduction-logo-footer-background-image: url("https://conduction.nl/wp-content/uploads/2021/07/cropped-conductionlogo-1.png");
--conduction-logo-footer-background-image: url("https://raw.githubusercontent.com/OpenCatalogi/web-app/df1e0533081d780c05b1d0b57ab327d97adcbdc6/pwa/src/assets/svgs/LogoConduction.svg");

--conduction-logo-navbar-inline-size: 150px;
--conduction-logo-navbar-block-size: 40px;
--conduction-logo-navbar-background-image: url("https://raw.githubusercontent.com/OpenCatalogi/web-app/df1e0533081d780c05b1d0b57ab327d97adcbdc6/pwa/src/assets/svgs/LogoConduction.svg");
}

.container {
Expand All @@ -26,6 +30,12 @@
background-image: var(--conduction-logo-footer-background-image);
}

.container.navbar {
inline-size: var(--conduction-logo-navbar-inline-size);
block-size: var(--conduction-logo-navbar-block-size);
background-image: var(--conduction-logo-navbar-background-image);
}

.container.clickable:hover {
cursor: pointer;
}
2 changes: 1 addition & 1 deletion src/components/logo/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as styles from "./Logo.module.css";
import clsx from "clsx";

interface LogoProps {
variant?: "header" | "footer";
variant?: "header" | "footer" | "navbar";
onClick?: () => any;
layoutClassName?: string;
}
Expand Down
26 changes: 23 additions & 3 deletions src/components/topNav/primaryTopNav/PrimaryTopNav.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
--conduction-primary-top-nav-toggle-icon-size: 24px;
--conduction-primary-top-nav-mobile-logo-padding: 18px;

--conduction-primary-top-nav-item-padding: var(--skeleton-size-md);
--conduction-primary-top-nav-item-padding: 18px;
--conduction-primary-top-nav-item-icon-margin: var(--skeleton-size-2x);
/* --conduction-primary-top-nav-item-border-radius: var(--skeleton-size-2x); */

Expand Down Expand Up @@ -103,6 +103,7 @@
.current:hover {
box-shadow: var(--conduction-primary-top-nav-current-box-shadow);
}

.current:hover > .currentLink {
color: var(--conduction-primary-top-nav-hover-color) !important;
}
Expand All @@ -111,8 +112,12 @@
color: var(--conduction-primary-top-nav-current-color) !important;
}

.currentLink svg path {
fill: var(--conduction-primary-top-nav-current-color) !important;
}

.mobileLink {
margin-block-end: var(--skeleton-size-md);
margin-block-end: 18px;
}
.primary .link {
text-decoration: none;
Expand All @@ -128,10 +133,18 @@
color: var(--conduction-primary-top-nav-color);
}

.primary .link:not(.currentLink) svg path {
fill: var(--conduction-primary-top-nav-color);
}

.primary .li:hover .link {
color: var(--conduction-primary-top-nav-hover-color);
}

.primary .li:hover svg path {
fill: var(--conduction-primary-top-nav-hover-color);
}

.link > * {
margin-inline-end: 8px;
}
Expand All @@ -146,6 +159,13 @@
background-color: var(--conduction-primary-top-nav-dropdown-background-color, var(--conduction-primary-top-nav-background-color));
}

.dropdownOverflow {
display: none;
max-height: 430px;
overflow-y: scroll;
border: 1px solid rgba(0, 0, 0, 0.2);
}

.dropdown.isOpen {
display: block;
}
Expand All @@ -168,7 +188,7 @@
}

.dropdown > li {
padding-inline-start: var(--skeleton-size-md);
padding-inline-start: 18px;
}

.toggleIcon {
Expand Down
16 changes: 11 additions & 5 deletions src/components/topNav/primaryTopNav/PrimaryTopNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { IconPrefix, IconName } from "@fortawesome/fontawesome-svg-core";
interface ITopNavItemBase {
label: string;
icon?: JSX.Element;
showToolTip?: boolean;
current?: boolean | ICurrentItemJSONFormat;
}

Expand Down Expand Up @@ -57,11 +58,12 @@ export type ITopNavItem = ITopNavItemWithSubItems | ITopNavItemWithoutSubItems;

export interface TopNavProps {
items: ITopNavItem[];
tooltipId: string;
mobileLogo?: JSX.Element;
layoutClassName?: string;
}

export const PrimaryTopNav = ({ items, mobileLogo, layoutClassName }: TopNavProps): JSX.Element => {
export const PrimaryTopNav = ({ items, mobileLogo, layoutClassName, tooltipId }: TopNavProps): JSX.Element => {
const [isOpen, setIsOpen] = React.useState<boolean>(false);
const [isMobile, setIsMobile] = React.useState<boolean>(window.innerWidth < 992);

Expand Down Expand Up @@ -103,20 +105,24 @@ export const PrimaryTopNav = ({ items, mobileLogo, layoutClassName }: TopNavProp
current && styles.currentLink,
)}
>
{icon}
{icon && icon}
{label}{" "}
{subItems && isMobile && <FontAwesomeIcon className={styles.toggleIcon} icon={faChevronRight} />}
</Link>

{subItems && (
<ul className={styles.dropdown}>
{subItems.map(({ label, icon, current, handleClick }, idx) => (
<ul className={clsx(styles.dropdown, [subItems.length > 8 && styles.dropdownOverflow])}>
{subItems.map(({ label, icon, current, handleClick, showToolTip }, idx) => (
<li
key={idx}
className={clsx(styles.li, current && styles.current)}
onClick={() => handleSubItemClick(handleClick)}
>
<Link className={clsx(styles.link, styles.label, current && styles.currentLink)}>
<Link
data-tooltip-id={showToolTip === true ? tooltipId : ""}
data-tooltip-content={showToolTip === true ? label : ""}
className={clsx(styles.link, styles.label, current && styles.currentLink)}
>
{icon}
{label}
</Link>
Expand Down

0 comments on commit e61ee50

Please sign in to comment.