Skip to content

Commit 7dd221a

Browse files
authored
Merge pull request #133 from SSWConsulting/country-flag-updates
Show/Hide Flag drop down in mobile view
2 parents 7b6eb15 + 752c532 commit 7dd221a

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

lib/components/CountryDropdown/CountryDropdown.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use client";
22
import { Popover, Transition } from "@headlessui/react";
3+
import type { ClassValue } from "clsx";
34
import { Fragment, useEffect, useState } from "react";
45
import { useLinkComponent } from "../../hooks/useLinkComponent";
56
import { Countries } from "../../types/country";
@@ -23,9 +24,10 @@ const websites: { country: Countries; url: string }[] = [
2324

2425
type CountryDropdownProps = {
2526
url?: string;
27+
className?: ClassValue;
2628
};
2729

28-
const CountryDropdown = ({ url }: CountryDropdownProps) => {
30+
const CountryDropdown = ({ url, className }: CountryDropdownProps) => {
2931
const [isOpened, setIsOpened] = useState(false);
3032
const [currentCountry, setCurrentCountry] = useState<Countries>("Australia");
3133

@@ -46,10 +48,10 @@ const CountryDropdown = ({ url }: CountryDropdownProps) => {
4648
}, [url]);
4749

4850
return (
49-
<Popover>
51+
<Popover className={cx(className)}>
5052
<Popover.Button
5153
className={cx(
52-
"flex items-center justify-center gap-x-1 rounded-md px-1 py-1 text-sm font-semibold text-ssw-black outline-none xs:px-4",
54+
"flex items-center justify-center gap-x-1 rounded-md px-4 py-1 text-sm font-semibold text-ssw-black outline-none xs:px-5",
5355
"hover:scale-105",
5456
)}
5557
onClick={() => setIsOpened(!isOpened)}

lib/components/MegaMenuLayout/MegaMenuLayout.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import DesktopMenu from "../DesktopMenu/DesktopMenu";
1616
import { Logo } from "../Logo";
1717
import MobileMenu from "../MobileMenu/MobileMenu";
1818
import { PhoneButton } from "../PhoneButton";
19+
import { Divider } from "../ui/Divider";
1920

2021
export type MegaMenuWrapperProps = {
2122
className?: ClassValue;
@@ -26,6 +27,7 @@ export type MegaMenuWrapperProps = {
2627
rightSideActionsOverride?: () => JSX.Element;
2728
callback?: (searchTerm: string) => void;
2829
linkComponent?: LinkComponentType;
30+
isFlagVisible?: boolean;
2931
} & React.PropsWithChildren &
3032
(Tagline | Title);
3133

@@ -49,6 +51,7 @@ const MegaMenuContents: React.FC<MegaMenuWrapperProps> = ({
4951
menuBarItems,
5052
rightSideActionsOverride,
5153
callback,
54+
isFlagVisible = true,
5255
}) => {
5356
const [searchTerm, setSearchTerm] = useState<string>("");
5457
const performSearch = (e: React.FormEvent<HTMLFormElement>) => {
@@ -114,8 +117,8 @@ const MegaMenuContents: React.FC<MegaMenuWrapperProps> = ({
114117
) : (
115118
<PhoneButton className="max-sm:hidden" />
116119
)}
117-
<CountryDropdown />
118-
<Divider />
120+
{isFlagVisible && <CountryDropdown />}
121+
{isFlagVisible && <Divider />}
119122
<button
120123
type="button"
121124
className="inline-flex items-center justify-center rounded-md px-1 text-gray-700 xs:px-4"
@@ -155,10 +158,6 @@ const MegaMenuContents: React.FC<MegaMenuWrapperProps> = ({
155158
);
156159
};
157160

158-
const Divider: React.FC = () => {
159-
return <div className="h-4 w-px bg-gray-700/30 sm:block"></div>;
160-
};
161-
162161
const MegaMenuLayout: React.FC<MegaMenuWrapperProps> = ({
163162
children,
164163
...props

lib/components/MobileMenu/MobileMenu.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ const MobileMenu: React.FC<MobileMenuProps> = ({
3030
};
3131
return (
3232
<Dialog as="div" open={isMobileMenuOpen} onClose={onCloseMobileMenu}>
33-
<div className="fixed inset-0 z-10" />
33+
<div className="fixed inset-0 z-10" />
3434
<Dialog.Panel className="fixed inset-y-0 right-0 z-10 w-full overflow-y-auto bg-white sm:max-w-sm sm:ring-1 sm:ring-ssw-black/10 xl:hidden">
35-
<div className="flex h-16 flex-row-reverse">
35+
<div className="flex h-16 items-center justify-end p-4">
3636
<button
3737
type="button"
38-
className="p-4 text-gray-700"
38+
className="p-2 text-gray-700 xs:p-4"
3939
onClick={onCloseMobileMenu}
4040
>
4141
<span className="sr-only">Close menu</span>

lib/components/ui/Divider.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { ClassValue } from "clsx";
2+
import { cx } from "../../util/cx";
3+
4+
export const Divider = ({ className }: { className?: ClassValue }) => (
5+
<div className={cx("h-4 w-px bg-gray-700/30", className)}></div>
6+
);

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ssw.megamenu",
3-
"version": "4.13.2",
3+
"version": "4.13.3",
44
"type": "module",
55
"main": "dist/index.js",
66
"module": "dist/index.js",
@@ -87,4 +87,4 @@
8787
]
8888
},
8989
"packageManager": "pnpm@9.5.0"
90-
}
90+
}

0 commit comments

Comments
 (0)