Skip to content

Commit

Permalink
fix: disable tippy by default
Browse files Browse the repository at this point in the history
- disabled tippy by default.
- avoided using nested interactive elements.
  • Loading branch information
honeymaro committed Mar 26, 2024
1 parent d2e1885 commit a126cd3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
36 changes: 23 additions & 13 deletions src/components/NavBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,29 @@ interface NavBarProps {
function NavBar({ items, flex = true }: NavBarProps) {
return (
<Wrapper>
{items.map(({ key, disabled, to, tippyProps, ...navItemProps }) => (
<Tippy {...tippyProps}>
<NavItem
className={`${navItemProps.className ?? ""} ${
disabled ? "disabled" : ""
}`}
key={key ?? `${to.toString()}`}
to={disabled ? "#" : to}
{...navItemProps}
flex={flex}
/>
</Tippy>
))}
{items.map(
({
key,
disabled,
to,
tippyProps = {
disabled: true,
},
...navItemProps
}) => (
<Tippy {...tippyProps}>
<NavItem
className={`${navItemProps.className ?? ""} ${
disabled ? "disabled" : ""
}`}
key={key ?? `${to.toString()}`}
to={disabled ? "#" : to}
{...navItemProps}
flex={flex}
/>
</Tippy>
),
)}
</Wrapper>
);
}
Expand Down
12 changes: 10 additions & 2 deletions src/layout/Main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Header, {
BANNER_HEIGHT,
} from "layout/Main/Header";
import NavBar from "components/NavBar";
import IconButton from "components/IconButton";
import Typography from "components/Typography";
import iconOverview from "assets/icons/icon-overview-24px.svg";
import iconTrade from "assets/icons/icon-trade.svg";
Expand Down Expand Up @@ -56,6 +55,15 @@ const NavBarOffset = styled.div`
pointer-events: none;
`;

const NavBarIcon = styled.div`
width: 100%;
height: 24px;
position: relative;
background-size: contain;
background-repeat: no-repeat;
background-position: 50% 50%;
`;

const FooterWrapper = styled.div`
width: 100%;
height: auto;
Expand Down Expand Up @@ -97,7 +105,7 @@ const navBar = (
items={navLinks.map((navLink) => {
const children = (
<div>
<IconButton icons={{ default: navLink.icon }} size={24} />
<NavBarIcon style={{ backgroundImage: `url(${navLink.icon})` }} />
<Typography size={12} weight={900} color="primary">
{navLink.label}
</Typography>
Expand Down

0 comments on commit a126cd3

Please sign in to comment.