refactor: streamline locale handling in components
- Removed unnecessary checks in locale handling functions across NavUser, LocaleSelector, and LocaleSwitcher components to simplify the code. - Adjusted padding in NavbarMobile component for improved layout consistency and user experience.
This commit is contained in:
parent
7211e6981c
commit
23aa0f179e
@ -60,10 +60,6 @@ export function NavUser({ user, className }: NavUserProps) {
|
||||
// }
|
||||
|
||||
const setLocale = (nextLocale: Locale) => {
|
||||
if (currentLocale === nextLocale) {
|
||||
return;
|
||||
}
|
||||
|
||||
setCurrentLocale(nextLocale);
|
||||
|
||||
startTransition(() => {
|
||||
|
@ -37,10 +37,6 @@ export default function LocaleSelector() {
|
||||
}, [locale, setCurrentLocale]);
|
||||
|
||||
const onSelectChange = (nextLocale: Locale) => {
|
||||
if (locale === nextLocale) {
|
||||
return;
|
||||
}
|
||||
|
||||
setCurrentLocale(nextLocale);
|
||||
|
||||
startTransition(() => {
|
||||
|
@ -37,10 +37,6 @@ export default function LocaleSwitcher() {
|
||||
}, [locale, setCurrentLocale]);
|
||||
|
||||
const setLocale = (nextLocale: Locale) => {
|
||||
if (locale === nextLocale) {
|
||||
return;
|
||||
}
|
||||
|
||||
setCurrentLocale(nextLocale);
|
||||
|
||||
startTransition(() => {
|
||||
|
@ -197,7 +197,7 @@ function MainMobileMenu({ userLoggedIn, onLinkClicked }: MainMobileMenuProps) {
|
||||
type="button"
|
||||
variant="ghost"
|
||||
className={cn(
|
||||
'flex w-full !pl-0 items-center justify-between text-left',
|
||||
'flex w-full !pl-2 items-center justify-between text-left',
|
||||
'bg-transparent text-muted-foreground cursor-pointer',
|
||||
'hover:bg-transparent hover:text-foreground',
|
||||
'focus:bg-transparent focus:text-foreground',
|
||||
@ -213,7 +213,7 @@ function MainMobileMenu({ userLoggedIn, onLinkClicked }: MainMobileMenuProps) {
|
||||
)}
|
||||
</Button>
|
||||
</CollapsibleTrigger>
|
||||
<CollapsibleContent className="pl-0">
|
||||
<CollapsibleContent className="pl-2">
|
||||
<ul className="mt-2 space-y-2 pl-0">
|
||||
{item.items.map((subItem) => {
|
||||
const isSubItemActive =
|
||||
@ -306,7 +306,7 @@ function MainMobileMenu({ userLoggedIn, onLinkClicked }: MainMobileMenuProps) {
|
||||
rel={item.external ? 'noopener noreferrer' : undefined}
|
||||
className={cn(
|
||||
buttonVariants({ variant: 'ghost' }),
|
||||
'w-full !pl-0 justify-start cursor-pointer group',
|
||||
'w-full !pl-2 justify-start cursor-pointer group',
|
||||
'bg-transparent text-muted-foreground',
|
||||
'hover:bg-transparent hover:text-foreground',
|
||||
'focus:bg-transparent focus:text-foreground',
|
||||
|
Loading…
Reference in New Issue
Block a user