Skip to content
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 for external links href #4

Merged
merged 1 commit into from Aug 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/Menu/Item.js
Expand Up @@ -7,10 +7,10 @@ const Item = props => {

let linky;
if (!external) {
linky = <Link to={to} className={"hiddenItem" in props ? "inHiddenItem" : ""}onClick={onClick}data-slug={to}>{label}</Link>
linky = <Link to={to} className={"hiddenItem" in props ? "inHiddenItem" : ""} onClick={onClick} data-slug={to} data-external={external}>{label}</Link>
}
else {
linky = <a href={to}>{label}</a>
linky = <a href={to} className={"hiddenItem" in props ? "inHiddenItem" : ""} data-external={external}>{label}</a>
}
return (
<React.Fragment>
Expand Down Expand Up @@ -43,7 +43,7 @@ const Item = props => {
.item {
:global(a) {
text-shadow:
-1px -1px 2px ${theme.hero.backgroundColor},
-1px -1px 2px ${theme.hero.backgroundColor},
1px -1px 2px ${theme.hero.backgroundColor},
-1px 1px 2px ${theme.hero.backgroundColor},
1px 1px 2px ${theme.hero.backgroundColor};
Expand Down
17 changes: 9 additions & 8 deletions src/components/Menu/Menu.js
Expand Up @@ -23,9 +23,9 @@ class Menu extends React.Component {
this.items = [
{ to: "/category/", label: "Categories", icon: FaTag },
...pages,
{ to: "https://medium.com/samsung-internet-dev", label: "Blog", icon: FaTag },
{ to: "https://github.com/SamsungInternet/support/issues", label: "Support", icon: FaTag },
{ to: "https://github.com/SamsungInternet", label: "Demos", icon: FaTag }
{ to: "https://medium.com/samsung-internet-dev", label: "Blog", icon: FaTag, external: true },
{ to: "https://github.com/SamsungInternet/support/issues", label: "Support", icon: FaTag, external: true },
{ to: "https://github.com/SamsungInternet", label: "Demos", icon: FaTag, external: true }
];

this.renderedItems = []; // will contain references to rendered DOM elements of menu
Expand Down Expand Up @@ -90,8 +90,9 @@ class Menu extends React.Component {
item.classList.add("hideItem");
item.classList.remove("item");
result.hiddenItems.push({
to: link.getAttribute("data-slug"),
label: link.text
to: link.getAttribute("href"),
label: link.text,
external: link.getAttribute("data-external")
});
}
return result;
Expand Down Expand Up @@ -145,15 +146,15 @@ class Menu extends React.Component {
<nav className={`menu ${open ? "open" : ""}`} rel="js-menu">
<ul className="itemList" ref={this.itemList}>
{this.items.map(item => (
<Item item={item} key={item.label} theme={theme} external={false} />
<Item item={item} key={item.label} theme={theme} external={item.external} />
))}
</ul>
{this.state.hiddenItems.length > 0 && <Expand onClick={this.toggleMenu} theme={theme} />}
{open &&
screenWidth >= 1024 && (
<ul className="hiddenItemList">
{this.state.hiddenItems.map(item => (
<Item item={item} key={item.label} hiddenItem theme={theme} />
<Item item={item} key={item.label} hiddenItem theme={theme} external={item.external} />
))}
</ul>
)}
Expand All @@ -170,7 +171,7 @@ class Menu extends React.Component {
width: 100%;
z-index: 1;
transition: all ${theme.time.duration.default};

}

@media (max-width: 1024px) {
Expand Down