Skip to content

Commit

Permalink
chore: removed language picker from legacy-main
Browse files Browse the repository at this point in the history
  • Loading branch information
ovflowd committed Oct 28, 2023
1 parent c42f97b commit 37f51fe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 33 deletions.
31 changes: 18 additions & 13 deletions components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import classNames from 'classnames';
import Image from 'next/image';
import { useTheme } from 'next-themes';
import { useState } from 'react';
import { useIntl } from 'react-intl';

import { useLocale } from '@/hooks/useLocale';
Expand All @@ -16,6 +17,8 @@ const Header = () => {
const { asPath, basePath } = useRouter();
const { theme, setTheme } = useTheme();

const [showLangPicker, setShowLangPicker] = useState(false);

const getLinkClassName = (href: string) =>
classNames({ active: isCurrentLocaleRoute(href, href !== '/') });

Expand Down Expand Up @@ -85,6 +88,7 @@ const Header = () => {
type="button"
title={toggleLanguage}
aria-label={toggleLanguage}
onClick={() => setShowLangPicker(!showLangPicker)}
aria-controls="lang-picker"
aria-expanded="false"
>
Expand All @@ -98,19 +102,20 @@ const Header = () => {
</button>
</div>

<ul id="lang-picker" className="lang-picker hidden">
{availableLocales.map(locale => (
<li key={locale.code}>
<a
data-lang={locale.code}
title={locale.name}
href={currentRouteLocalized(locale.code)}
>
{locale.localName}
</a>
</li>
))}
</ul>
{showLangPicker && (
<ul className="lang-picker">
{availableLocales.map(locale => (
<li key={locale.code}>
<a
title={locale.name}
href={currentRouteLocalized(locale.code)}
>
{locale.localName}
</a>
</li>
))}
</ul>
)}
</div>
</header>
);
Expand Down
20 changes: 0 additions & 20 deletions public/static/js/legacyMain.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
const listenLanguagePickerButton = () => {
const langPickerTogglerElement = document.querySelector(
'.lang-picker-toggler'
);

const langPickerElement = document.querySelector('.lang-picker');

const toggleFunction = function () {
langPickerElement.classList.toggle('hidden');

const isAriaExpanded =
langPickerTogglerElement.getAttribute('aria-expanded') === 'true';

langPickerTogglerElement.setAttribute('aria-expanded', !isAriaExpanded);
};

langPickerTogglerElement.addEventListener('click', toggleFunction);
};

const listenScrollToTopButton = () => {
const scrollToTop = document.querySelector('#scroll-to-top');

Expand All @@ -38,7 +19,6 @@ const listenScrollToTopButton = () => {
};

const startLegacyApp = () => {
listenLanguagePickerButton();
listenScrollToTopButton();
};

Expand Down

0 comments on commit 37f51fe

Please sign in to comment.