-
-
Notifications
You must be signed in to change notification settings - Fork 731
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
feat: enabling i18n feature for smaller screens #3556
Open
devilkiller-ag
wants to merge
7
commits into
asyncapi:master
Choose a base branch
from
devilkiller-ag:i18n-for-smaller-screen
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d152a10
added langauge option in mobile navbar
devilkiller-ag 57955e1
updated locale names
devilkiller-ag 6879ec8
added functionality to highlight current language
devilkiller-ag eec0f74
added language icon
devilkiller-ag 9e7a307
fixed nav items spacing
devilkiller-ag ac2f811
updated add translations doc
devilkiller-ag 616595b
updated add translations doc
devilkiller-ag File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react'; | ||
|
||
/* eslint-disable max-len */ | ||
/** | ||
* @description Icons for asyncapi website | ||
*/ | ||
export default function IconLanguage({ className = '' }) { | ||
return ( | ||
<svg | ||
xmlns='http://www.w3.org/2000/svg' | ||
fill='none' | ||
viewBox='0 0 24 24' | ||
strokeWidth={1.5} | ||
stroke='currentColor' | ||
className={`size-5 ${className}`} | ||
> | ||
<path | ||
strokeLinecap='round' | ||
strokeLinejoin='round' | ||
d='m10.5 21 5.25-11.25L21 21m-9-3h7.5M3 5.621a48.474 48.474 0 0 1 6-.371m0 0c1.12 0 2.233.038 3.334.114M9 5.25V3m3.334 2.364C11.176 10.658 7.69 15.08 3 17.502m9.334-12.138c.896.061 1.785.147 2.666.257m-4.589 8.495a18.023 18.023 0 0 1-3.827-5.802' | ||
/> | ||
</svg> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ import Link from 'next/link'; | |
import React, { useState } from 'react'; | ||
|
||
import { SearchButton } from '../AlgoliaSearch'; | ||
import IconLanguage from '../icons/Language'; | ||
import NavItemDropdown from '../icons/NavItemDropdown'; | ||
import SearchIcon from '../icons/SearchIcon'; | ||
import AsyncAPILogo from '../logos/AsyncAPILogo'; | ||
|
@@ -19,13 +20,21 @@ interface MenuItem { | |
|
||
interface MobileNavMenuProps { | ||
onClickClose?: () => void; | ||
uniqueLangs: { key: string; text: string; value: string }[]; | ||
currentLanguage: string; | ||
changeLanguage: (locale: string, langPicker: boolean) => void; | ||
} | ||
|
||
/** | ||
* @description MobileNavMenu component for displaying a responsive navigation menu on mobile devices. | ||
* @param {MobileNavMenuProps} props - The props for the MobileNavMenu component. | ||
*/ | ||
export default function MobileNavMenu({ onClickClose = () => {} }: MobileNavMenuProps) { | ||
export default function MobileNavMenu({ | ||
onClickClose = () => {}, | ||
uniqueLangs, | ||
currentLanguage, | ||
changeLanguage | ||
}: MobileNavMenuProps) { | ||
const [open, setOpen] = useState<string | null>(null); | ||
|
||
/** | ||
|
@@ -104,7 +113,7 @@ export default function MobileNavMenu({ onClickClose = () => {} }: MobileNavMenu | |
</h4> | ||
{open === 'community' && <MenuBlocks items={communityItems} />} | ||
</div> | ||
<div className='space-y-2 px-5 py-2' onClick={() => showMenu('others')} data-testid='MobileNav-others'> | ||
<div className='space-y-2 px-5 pt-2' onClick={() => showMenu('others')} data-testid='MobileNav-others'> | ||
<div className='grid gap-4'> | ||
<div> | ||
<h4 className='mb-4 flex justify-between font-medium text-gray-800'> | ||
|
@@ -127,6 +136,29 @@ export default function MobileNavMenu({ onClickClose = () => {} }: MobileNavMenu | |
</div> | ||
</div> | ||
</div> | ||
<div className='space-y-2 px-5 py-2' onClick={() => showMenu('language')}> | ||
<div className='grid gap-4'> | ||
<div> | ||
<h4 className='mb-4 flex justify-between font-medium text-gray-800'> | ||
<a className='flex cursor-pointer items-center gap-x-2'> | ||
Language <IconLanguage /> | ||
</a> | ||
<NavItemDropdown /> | ||
</h4> | ||
{open === 'language' && | ||
uniqueLangs.map((lang) => ( | ||
<button | ||
key={lang.key} | ||
onClick={() => changeLanguage(lang.value.toLowerCase(), true)} | ||
className={`mb-4 ml-2 block w-full rounded-lg py-1 text-start text-sm font-medium leading-6 text-gray-700 transition duration-150 ease-in-out hover:bg-gray-50 ${currentLanguage.toLowerCase() === lang.text.toLowerCase() ? 'text-secondary-500' : ''}`} | ||
data-testid='MobileNav-language-item' | ||
> | ||
{lang.text} | ||
</button> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
Comment on lines
+139
to
+161
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve accessibility of the language selection menu. The current implementation has two potential accessibility issues:
Consider this improvement: - <div className='space-y-2 px-5 py-2' onClick={() => showMenu('language')}>
+ <div className='space-y-2 px-5 py-2'>
+ <button
+ onClick={() => showMenu('language')}
+ aria-expanded={open === 'language'}
+ aria-controls="language-menu"
+ className="w-full text-left"
+ >
<div className='grid gap-4'>
<div>
<h4 className='mb-4 flex justify-between font-medium text-gray-800'>
<a className='flex cursor-pointer items-center gap-x-2'>
Language <IconLanguage />
</a>
<NavItemDropdown />
</h4>
- {open === 'language' &&
+ <div
+ id="language-menu"
+ role="menu"
+ className={open === 'language' ? 'block' : 'hidden'}
+ >
uniqueLangs.map((lang) => (
<button
key={lang.key}
onClick={() => changeLanguage(lang.value.toLowerCase(), true)}
+ role="menuitem"
className={`mb-4 ml-2 block w-full rounded-lg py-1 text-start text-sm font-medium leading-6 text-gray-700 transition duration-150 ease-in-out hover:bg-gray-50 ${
currentLanguage.toLowerCase() === lang.text.toLowerCase() ? 'text-secondary-500' : ''
}`}
data-testid='MobileNav-language-item'
>
{lang.text}
</button>
- ))}
+ )}
+ </div>
</div>
</div>
+ </button>
</div>
|
||
</div> | ||
</div> | ||
</div> | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Documentation inconsistency confirmed
The documentation refers to two different configuration files:
next-i18next-static-site.config.js
(incorrect reference)next-i18next.config.js
(actual file)The correct configuration file name is
next-i18next.config.js
, as verified in the repository. The reference tonext-i18next-static-site.config.js
should be updated to maintain consistency.🔗 Analysis chain
Verify configuration file references
The documentation refers to
next-i18next.config.js
, but earlier sections mentionnext-i18next-static-site.config.js
. This inconsistency needs to be addressed.Let's verify the correct configuration file name:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 72
Script:
Length of output: 159
🧰 Tools
🪛 Markdownlint (0.37.0)
255-255: Expected: 0; Actual: 2
Unordered list indentation
(MD007, ul-indent)
256-256: Expected: 0; Actual: 2
Unordered list indentation
(MD007, ul-indent)
260-260: Expected: 0; Actual: 2
Unordered list indentation
(MD007, ul-indent)