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

feat: gradient color on navbar links #12

Merged
merged 6 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/assets/Logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/assets/css/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,11 @@ button {
opacity: 0;
transition: opacity 400ms;
}

.gradient {
background: linear-gradient(to right, #625cbf, #c55fa3, #fccc50);
background-clip: text;
-webkit-background-clip: text;
color: transparent;
-webkit-text-fill-color: transparent;
}
24 changes: 18 additions & 6 deletions src/containers/Navbar/Navbar.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,29 @@ export const StyledNavbar = styled.nav`
}
`;

export const NavLink = styled(Link)<{ order?: number; disabled?: boolean }>`
text-transform: uppercase;
order: ${({ order }) => order ?? "initial"};
export const NavLinkContainer = styled.div<{ order?: number }>`
width: 120px;
text-align: center;
margin: 0 30px;
order: ${({ order }) => order ?? "initial"};
display: flex;
justify-content: center;
`;

export const NavLink = styled(Link)<{ disabled?: boolean }>`
text-transform: uppercase;

&:hover {
background: linear-gradient(to right, #625cbf, #c55fa3, #fccc50);
background-clip: text;
-webkit-background-clip: text;
color: transparent;
-webkit-text-fill-color: transparent;
}

margin: 0 auto;
${({ disabled }) =>
disabled &&
`
pointer-events: none;
opacity: .6;
`};

@media screen and (max-width: ${MOBILE_MAX_WIDTH}) {
Expand Down
43 changes: 32 additions & 11 deletions src/containers/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
LogoContainer,
MenuButton,
NavLink,
NavLinkContainer,
StyledNavbar,
WonderLogo,
} from "./Navbar.styles";
Expand Down Expand Up @@ -42,6 +43,22 @@ interface NavbarProps {}

export const Navbar = ({}: NavbarProps) => {
const [showNavbar, setShowNavbar] = useState(false);
const [navLink, setNavLink] = useState(navLinks);
turtlemoji marked this conversation as resolved.
Show resolved Hide resolved

const handleClick = (i: number) => {
setShowNavbar(!showNavbar);

// reset values
const newNavLink = navLink.map((link) => ({
name: link.name,
url: link.url,
disabled: false,
}));

newNavLink[i].disabled = true;
setNavLink(newNavLink);
};

return (
<StyledNavbar id={showNavbar ? "show" : ""}>
<LogoContainer>
Expand All @@ -53,17 +70,21 @@ export const Navbar = ({}: NavbarProps) => {
</MenuButton>
</LogoContainer>

{navLinks.map((link, i) => (
<NavLink
id={showNavbar ? "" : "hide"}
to={link.url}
order={i + 1}
key={link.name}
disabled={link.disabled}
onClick={() => setShowNavbar(!showNavbar)}
>
{link.name}
</NavLink>
{navLink.map((link, i) => (
<NavLinkContainer order={i + 1}>
<NavLink
id={showNavbar ? "" : "hide"}
to={link.url}
key={link.name}
disabled={link.disabled}
className={link.disabled ? "gradient" : ""}
onClick={() => {
handleClick(i);
}}
>
{link.name}
</NavLink>
</NavLinkContainer>
))}
</StyledNavbar>
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Intro/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
NAVBAR_INDEX,
Section,
} from "~/components/common";
import LogoImage from "~/assets/Logo.png";
import LogoImage from "~/assets/Logo.svg";
import KEYHOLE from "~/assets/key.png";
import VLINE from "~/assets/dotted_line.svg";
import INTROKEY from "~/assets/intro_key.svg";
Expand Down