Skip to content

Commit

Permalink
Merge pull request #40 from damla/link-fix
Browse files Browse the repository at this point in the history
[#36] fix: problem with the language links solved
  • Loading branch information
damla authored Jan 1, 2021
2 parents f34df61 + 1184ffb commit 05f5313
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 77 deletions.
34 changes: 20 additions & 14 deletions components/custom-button/custom-button.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,31 @@ import styles from "./custom-button.module.scss";
import Link from "next/link";
import classNames from "classnames";

export default function CustomButton({
onClick,
href,
children,
button,
inverted,
}) {
export default function CustomButton({ onClick, href, children, inverted }) {
return (
<div onClick={onClick ? onClick : null}>
<Link href={href ? href : "/"} scroll={false}>
<a
<>
{href ? (
<Link href={href} scroll={false}>
<a
className={classNames(
styles.container,
inverted && styles.container__inverted
)}
>
<div className={styles.body}>{children}</div>
</a>
</Link>
) : (
<button
onClick={onClick}
className={classNames(
button && styles.container,
styles.container,
inverted && styles.container__inverted
)}
>
<div className={styles.body}>{children}</div>
</a>
</Link>
</div>
</button>
)}
</>
);
}
8 changes: 2 additions & 6 deletions 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 All @@ -33,11 +34,6 @@ export default function Layout({
: document.querySelector("body").classList.remove("disableScroll");
};

// console.log("announcement", announcement);
// console.log("sidebar", sidebar);
// console.log("navbar", navbar);
// console.log("footer", footer);

return (
<div className={styles.container}>
<Announcement>
Expand Down
38 changes: 8 additions & 30 deletions components/layout/nav-bar/nav-bar.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,18 @@ export default function NavBar({
{isDesktopOrLaptop && (
<>
<Menu align="left">
<MenuItem href={about_us.link} locale={about_us.locale}>
{about_us.text}
</MenuItem>
<MenuItem href={factory.link} locale={factory.locale}>
{factory.text}
</MenuItem>
<MenuItem href={catalog.link} locale={catalog.locale}>
{catalog.text}
</MenuItem>
<MenuItem href={contact.link} locale={contact.locale}>
{contact.text}
</MenuItem>
<MenuItem href={about_us.link}>{about_us.text}</MenuItem>
<MenuItem href={factory.link}>{factory.text}</MenuItem>
<MenuItem href={catalog.link}>{catalog.text}</MenuItem>
<MenuItem href={contact.link}>{contact.text}</MenuItem>
</Menu>
<Menu align="right">
<div className={styles.lang_container}>
<MenuItem href={english.link} locale={english.locale}>
<MenuItem href={english.link} lang={english.locale}>
{english.text}
</MenuItem>
<span className={styles.seperator}>|</span>
<MenuItem href={turkish.link} locale={turkish.locale}>
<MenuItem href={turkish.link} lang={turkish.locale}>
{turkish.text}
</MenuItem>
</div>
Expand All @@ -73,26 +65,12 @@ export default function NavBar({
{isTabletOrMobile && (
<>
<Menu align="left">
<MenuItem
href={
localStorage.getItem("lang") === "tr"
? turkish.link
: english.link
}
locale={
localStorage.getItem("lang") === "tr"
? turkish.locale
: english.locale
}
>
<MenuItem href="/">
<Logo width={120} height={40} />
</MenuItem>
</Menu>
<Menu align="right">
<MenuItem href="#" locale={english.locale}>
{hamburgerButton}
</MenuItem>
{/* TODO: LINK ICINDE LINK VAR! */}
<MenuItem href="#">{hamburgerButton}</MenuItem>
</Menu>
</>
)}
Expand Down
20 changes: 6 additions & 14 deletions components/layout/side-bar/side-bar.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,14 @@ export default function SideBar({
<div className={styles.container_content}>
<div className={styles.container_header}>{hamburgerButton}</div>
<div className={styles.container_body}>
<MenuItem href={about_us.link} locale={about_us.locale}>
{about_us.text}
</MenuItem>
<MenuItem href={factory.link} locale={factory.locale}>
{factory.text}
</MenuItem>
<MenuItem href={catalog.link} locale={catalog.locale}>
{catalog.text}
</MenuItem>
<MenuItem href={contact.link} locale={contact.locale}>
{contact.text}
</MenuItem>
<MenuItem href={turkish.link} locale={turkish.locale}>
<MenuItem href={about_us.link}>{about_us.text}</MenuItem>
<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} refresh>
{turkish.text}
</MenuItem>
<MenuItem href={english.link} locale={english.locale}>
<MenuItem href={english.link} lang={english.locale} refresh>
{english.text}
</MenuItem>
</div>
Expand Down
24 changes: 17 additions & 7 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, locale }) {
export default function MenuItem({ href, children, lang, refresh }) {
// TODO: Ignore warning from here
return (
<li>
<Link href={href} locale={locale}>
<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: Burayi test et, oncesinde {"classname"} seklinde yazilmis, problem cikarabilirdi */
/* TODO: fix the bug about links */
3 changes: 2 additions & 1 deletion global/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ body {
}
}
ul,
li {
li,
button {
border: 0;
font-size: 100%;
font: inherit;
Expand Down
2 changes: 1 addition & 1 deletion pages/about-us/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function AboutUs({ common, page: { title } }) {
</BlockQuote>
}
button={
<CustomButton button href="/en/about-us">
<CustomButton href="/en/about-us">
<span>Daha Fazlası</span>
<span>&#8594;</span>
</CustomButton>
Expand Down
2 changes: 1 addition & 1 deletion pages/factory/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function Factory({ common, page: { title } }) {
</BlockQuote>
}
button={
<CustomButton button href="/en/factory">
<CustomButton href="/en/factory">
<span>Daha Fazlası</span>
<span>&#8594;</span>
</CustomButton>
Expand Down
6 changes: 3 additions & 3 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function Anasayfa({ common, page: { title } }) {
</BlockQuote>
}
button={
<CustomButton button onClick={() => scrollToSection("section-2")}>
<CustomButton onClick={() => scrollToSection("section-2")}>
<span>Daha Fazlası</span>
<span>&#8594;</span>
</CustomButton>
Expand Down Expand Up @@ -93,7 +93,7 @@ export default function Anasayfa({ common, page: { title } }) {
</BlockQuote>
}
button={
<CustomButton button>
<CustomButton linked>
<span>Daha Fazlası</span>
<span>&#8594;</span>
</CustomButton>
Expand All @@ -116,7 +116,7 @@ export default function Anasayfa({ common, page: { title } }) {
</BlockQuote>
}
button={
<CustomButton button>
<CustomButton href="/about-us">
<span>Daha Fazlası</span>
<span>&#8594;</span>
</CustomButton>
Expand Down

1 comment on commit 05f5313

@vercel
Copy link

@vercel vercel bot commented on 05f5313 Jan 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

Please sign in to comment.