feat(SW-187): simplify dropdown menu

This commit is contained in:
Pontus Dreij
2024-09-09 14:58:22 +02:00
parent ef33d082d8
commit 07eb0401bb
9 changed files with 93 additions and 158 deletions

View File

@@ -13,6 +13,7 @@ import { useTrapFocus } from "@/hooks/useTrapFocus"
import styles from "./languageSwitcherContent.module.css"
import { DropdownType } from "@/types/components/dropdown/dropdown"
import type { LanguageSwitcherProps } from "@/types/components/languageSwitcher/languageSwitcher"
export default function LanguageSwitcherContent({
@@ -21,10 +22,13 @@ export default function LanguageSwitcherContent({
}: LanguageSwitcherProps) {
const intl = useIntl()
const currentLanguage = useLang()
const { toggleLanguageSwitcher } = useDropdownStore()
const { toggleDropdown } = useDropdownStore()
const languageSwitcherRef = useTrapFocus()
const urlKeys = Object.keys(urls) as Lang[]
const position = type === "footer" ? "footer" : "header"
const position =
type === "footer"
? DropdownType.FooterLanguage
: DropdownType.HeaderLanguage
return (
<div className={styles.languageSwitcherContent} ref={languageSwitcherRef}>
@@ -33,7 +37,7 @@ export default function LanguageSwitcherContent({
<button
type="button"
className={styles.backButton}
onClick={() => toggleLanguageSwitcher(position)}
onClick={() => toggleDropdown(position)}
>
<ChevronLeftIcon color="red" />
<Subtitle type="one">Main Menu</Subtitle>