Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixed the i18n feature for smaller screens #2877

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/languageSelector/LanguageSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function LanguageSelect({
return (
<select data-testid="Select-form"
onChange={(ev) => onChange(ev.target.value)}
className={twMerge(`form-select h-full py-0 px-3 pr-7 inline-flex justify-center rounded-md border border-gray-300 shadow-sm py-2 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:border-gray-500 focus:outline-none focus:ring-0 focus:ring-black ${className}`)}
className={twMerge(`form-select h-full px-3 pr-7 inline-flex justify-center rounded-md border border-gray-300 shadow-sm py-2 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:border-gray-500 focus:outline-none focus:ring-0 focus:ring-black ${className}`)}
value={selected}
>
{options.map((option, index) => (
Expand Down
3 changes: 2 additions & 1 deletion components/navigation/MobileNavMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Link from 'next/link';
import NavItemDropdown from '../icons/NavItemDropdown';
import { useState } from 'react';

export default function MobileNavMenu({ onClickClose = () => {} }) {
export default function MobileNavMenu({ onClickClose = () => {}, LanguagePicker }) {
const [open, setOpen] = useState();
function showMenu(menu) {
if (open === menu) {
Expand All @@ -30,6 +30,7 @@ export default function MobileNavMenu({ onClickClose = () => {} }) {
</a>
</Link>
<div className="flex flex-row items-center justify-content -mr-2" data-testid="MobileNav-button">
{LanguagePicker}
<SearchButton
className="flex items-center text-left space-x-2 p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 focus:text-gray-500 transition duration-150 ease-in-out"
aria-label="Open Search"
Expand Down
22 changes: 13 additions & 9 deletions components/navigation/NavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ export default function NavBar({
setOpen(null);
}, [asPath]);

const LanguagePicker = (
TenzDelek marked this conversation as resolved.
Show resolved Hide resolved
<LanguageSelect
options={uniqueLangs}
onChange={(value) => {
changeLanguage(value.toLowerCase(), true);
}}
className=""
selected={i18n.language ? i18n.language.toUpperCase() : "EN"}
/>
);
return (
<div className={`bg-white ${className} z-50`}>
{/* <a href="#main-content" className="block md:inline-block absolute transform -translate-y-20 focus:translate-y-0 bg-gray-100 text-gray-700 p-5 text-md font-semibold" alt="Skip to main content">Skip to main content</a> */}
Expand All @@ -146,6 +156,7 @@ export default function NavBar({
)}

<div className="flex flex-row items-center justify-center -mr-2 -my-2 lg:hidden" data-testid="Navbar-search">
{LanguagePicker}
<SearchButton
className="flex items-center text-left space-x-2 p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 focus:text-gray-500 transition duration-150 ease-in-out"
aria-label="Open Search"
Expand Down Expand Up @@ -207,14 +218,7 @@ export default function NavBar({
</SearchButton>

{/* // Language Picker Component */}
<LanguageSelect
options={uniqueLangs}
onChange={(value) => {
changeLanguage(value.toLowerCase(), true);
}}
className=""
selected={i18n.language ? i18n.language.toUpperCase() : "EN"}
/>
{LanguagePicker}

<GithubButton text="Star on GitHub" href="https://github.com/asyncapi/spec" className="py-2 ml-2" inNav="true" />
</div>
Expand All @@ -223,7 +227,7 @@ export default function NavBar({
</div>

{/* Mobile menu, show/hide based on mobile menu state. */}
{mobileMenuOpen && <MobileNavMenu onClickClose={() => setMobileMenuOpen(false)} />}
{mobileMenuOpen && <MobileNavMenu onClickClose={() => setMobileMenuOpen(false)} LanguagePicker={LanguagePicker}/>}

</div>
)
Expand Down
Loading