This repository was archived by the owner on May 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Utkarsha/language switcher component #158
Open
utkarsha-deriv
wants to merge
17
commits into
binary-com:master
Choose a base branch
from
utkarsha-deriv:utkarsha/language-switcher-component
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 13 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
4567243
feat: feat1
utkarsha-deriv 5a904df
feat: dropdown
utkarsha-deriv b3547a5
fix: gap with hover not possible
utkarsha-deriv 58442da
feat: fixed it with hover
utkarsha-deriv a43d75c
refactor: code refactor
utkarsha-deriv 52c6612
style: modify
utkarsha-deriv 520f36d
feat: mobile version
utkarsha-deriv 5cd40ca
test: pr fix
utkarsha-deriv 35ec304
style: mobile dropdown
utkarsha-deriv 7cf6c5c
Merge branch 'master' into utkarsha/language-switcher-component
utkarsha-deriv 32bb5fd
test: modified testcase for diff language case
utkarsha-deriv 5a6cdfc
style: modified design
utkarsha-deriv ea56a0d
fix: fix testcase
utkarsha-deriv a1ddedc
refactor: use classnames
utkarsha-deriv eb7545c
chore: added new languages
utkarsha-deriv 3c08280
fix: config for label for langauge switcher
utkarsha-deriv 39acb44
fix: localeConfig fix
utkarsha-deriv 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,52 @@ | ||
import React from 'react'; | ||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; | ||
import { useAlternatePageUtils } from '@docusaurus/theme-common/internal'; | ||
import { useLocation } from '@docusaurus/router'; | ||
import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem'; | ||
import type { LinkLikeNavbarItemProps } from '@theme/NavbarItem'; | ||
import type { Props } from '@theme/NavbarItem/LocaleDropdownNavbarItem'; | ||
|
||
export default function LocaleDropdownNavbarItem({ | ||
// mobile, | ||
dropdownItemsBefore, | ||
dropdownItemsAfter, | ||
...props | ||
}: Props): JSX.Element { | ||
const { | ||
i18n: { currentLocale, locales, localeConfigs }, | ||
} = useDocusaurusContext(); | ||
const alternatePageUtils = useAlternatePageUtils(); | ||
const { search, hash } = useLocation(); | ||
|
||
const localeItems = locales.map((locale): LinkLikeNavbarItemProps => { | ||
const baseTo = `pathname://${alternatePageUtils.createUrl({ | ||
locale, | ||
fullyQualified: false, | ||
})}`; | ||
// preserve ?search#hash suffix on locale switches | ||
const to = `${baseTo}${search}${hash}`; | ||
return { | ||
label: localeConfigs[locale].label, | ||
lang: localeConfigs[locale].htmlLang, | ||
to, | ||
target: '_self', | ||
autoAddBaseUrl: false, | ||
className: | ||
// eslint-disable-next-line no-nested-ternary | ||
locale === currentLocale ? 'dropdown__link--active' : '', | ||
}; | ||
}); | ||
|
||
const items = [...dropdownItemsBefore, ...localeItems, ...dropdownItemsAfter]; | ||
|
||
const dropdownLabel = localeConfigs[currentLocale].label; | ||
|
||
return ( | ||
<DropdownNavbarItem | ||
{...props} | ||
// mobile={mobile} | ||
utkarsha-deriv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
label={<>{dropdownLabel === 'English' ? 'EN' : 'PT'}</>} | ||
items={items} | ||
/> | ||
); | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.