Skip to content

Commit

Permalink
[#36] fix: clicking twice problem solved.
Browse files Browse the repository at this point in the history
- Changed language links found in sidebar component to <a> tags.
  • Loading branch information
damla committed Jan 1, 2021
1 parent 8ec47bd commit 1184ffb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
3 changes: 2 additions & 1 deletion components/layout/layout.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ export default function Layout({
children,
data: { announcement, sidebar, navbar, footer },
}) {
const [isOpen, setIsOpen] = useState(false);

const isMobile = useMediaQuery({ query: "(max-width: 475px)" });
const isDesktopOrLaptop = useMediaQuery({
query: "(min-width: 1131px)",
});
const [isOpen, setIsOpen] = useState(false);

useEffect(() => {
if (typeof window !== "undefined") disableScrollBody(isOpen);
Expand Down
4 changes: 2 additions & 2 deletions components/layout/side-bar/side-bar.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export default function SideBar({
<MenuItem href={factory.link}>{factory.text}</MenuItem>
<MenuItem href={catalog.link}>{catalog.text}</MenuItem>
<MenuItem href={contact.link}>{contact.text}</MenuItem>
<MenuItem href={turkish.link} lang={turkish.locale}>
<MenuItem href={turkish.link} lang={turkish.locale} refresh>
{turkish.text}
</MenuItem>
<MenuItem href={english.link} lang={english.locale}>
<MenuItem href={english.link} lang={english.locale} refresh>
{english.text}
</MenuItem>
</div>
Expand Down
22 changes: 16 additions & 6 deletions components/menu-item/menu-item.component.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
import Link from "next/link";
import styles from "./menu-item.module.scss";

export default function MenuItem({ href, children, lang }) {
export default function MenuItem({ href, children, lang, refresh }) {
// TODO: Ignore warning from here
return (
<li>
<Link href={href} locale={lang}>
<a className={styles.container}>{children}</a>
</Link>
</li>
<>
{refresh ? (
<li>
<a href={href} locale={lang} className={styles.container}>
{children}
</a>
</li>
) : (
<li>
<Link href={href} locale={lang}>
<a className={styles.container}>{children}</a>
</Link>
</li>
)}
</>
);
}
/* TODO: fix the bug about links */

0 comments on commit 1184ffb

Please sign in to comment.