-
Notifications
You must be signed in to change notification settings - Fork 51
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 sidebar English language #286
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,10 @@ import { useEffect, useRef } from 'react'; | |
import useFocusTrap from '../hooks/useFocusTrap'; | ||
import { useTheme } from 'next-themes'; | ||
import Link from 'next/link'; | ||
import LocalSwitcher from './LocalSwitcher'; | ||
import useTypedLocale from '@/hooks/useTypedLocale'; | ||
import clsx from 'clsx'; | ||
import { useTranslations } from 'next-intl'; | ||
|
||
type NavigationItems = { | ||
title: string; | ||
|
@@ -18,41 +22,41 @@ type NavItem = { | |
text?: string; | ||
}; | ||
|
||
const navigationItems: NavigationItems[] = [ | ||
{ | ||
title: 'Newbies', | ||
text: 'פעם ראשונה בקוד פתוח', | ||
linkPath: '/newbies', | ||
}, | ||
{ | ||
title: 'Members', | ||
text: 'מי שכבר התנסה בקוד פתוח', | ||
linkPath: '/members', | ||
}, | ||
{ | ||
title: 'Maintainers', | ||
text: 'בעלי פרויקטים שרוצים להצטרף', | ||
linkPath: '/maintainers', | ||
}, | ||
{ | ||
title: 'מי אנחנו', | ||
linkPath: '/about', | ||
}, | ||
{ | ||
title: 'הפרויקטים', | ||
linkPath: '/projects', | ||
}, | ||
]; | ||
|
||
interface SidebarProps { | ||
isOpen: boolean; | ||
toggleSidebar: () => void; | ||
} | ||
|
||
const Sidebar: React.FC<SidebarProps> = ({ isOpen, toggleSidebar }) => { | ||
const sidebarRef = useRef<HTMLDivElement | null>(null); | ||
|
||
const localActive = useTypedLocale(); | ||
const { theme } = useTheme(); | ||
const t = useTranslations('Components.sideBar'); | ||
const navigationItems: NavigationItems[] = [ | ||
{ | ||
title: 'Newbies', | ||
text: 'פעם ראשונה בקוד פתוח', | ||
linkPath: '/newbies', | ||
}, | ||
{ | ||
title: 'Members', | ||
text: 'מי שכבר התנסה בקוד פתוח', | ||
linkPath: '/members', | ||
}, | ||
{ | ||
title: 'Maintainers', | ||
text: 'בעלי פרויקטים שרוצים להצטרף', | ||
linkPath: '/maintainers', | ||
}, | ||
{ | ||
title: 'מי אנחנו', | ||
linkPath: '/about', | ||
}, | ||
{ | ||
title: 'הפרויקטים', | ||
linkPath: '/projects', | ||
}, | ||
]; | ||
|
||
useEffect(() => { | ||
const handleOutsideClick = (event: MouseEvent) => { | ||
|
@@ -83,14 +87,26 @@ const Sidebar: React.FC<SidebarProps> = ({ isOpen, toggleSidebar }) => { | |
return ( | ||
<div | ||
ref={sidebarRef} | ||
className={`fixed inset-y-0 right-0 z-50 bg-lightBg dark:bg-darkBg border-l border-l-blue-400 w-[75%] shadow-lg transform transition-transform ease-in-out duration-300 ${ | ||
isOpen ? '-translate-x-0' : 'translate-x-full' | ||
}`} | ||
className={clsx( | ||
`fixed inset-y-0 z-50 bg-lightBg dark:bg-darkBg border-l | ||
border-l-blue-400 w-[75%] shadow-lg transform transition-transform | ||
ease-in-out duration-300`, | ||
{ | ||
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. can we not use dir here? 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. It didn't worked so well using dir |
||
'left-0': localActive === 'en', | ||
'right-0': localActive === 'he', | ||
'-translate-x-0': isOpen, | ||
'-translate-x-full': !isOpen && localActive === 'en', | ||
'translate-x-full': !isOpen && localActive === 'he', | ||
} | ||
)} | ||
> | ||
{isOpen ? ( | ||
<div className="p-5 flex flex-col gap-14"> | ||
<div className="flex items-center justify-between"> | ||
<Darkmode /> | ||
<div className="flex gap-3 items-center"> | ||
<LocalSwitcher /> | ||
<Darkmode /> | ||
</div> | ||
<button onClick={toggleSidebar}> | ||
{theme === 'dark' ? ( | ||
<Image | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
in this scope this array will be re declared on every render
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.
I know, but how can I use the "useTranslations" hook outside this scope?