Skip to content

Commit

Permalink
Merge pull request #32 from near/develop
Browse files Browse the repository at this point in the history
Deploy nav fixes to production
  • Loading branch information
calebjacob authored May 23, 2024
2 parents 9d999fc + 5abf63a commit 414f0c3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"lint:fix": "next lint --fix",
"lint:pre-commit": "next lint --max-warnings 0",
"prettier": "prettier --check 'src/**/*.{js,jsx,ts,tsx,json}'",
"prettier:write": "prettier --write 'src/**/*.{js,jsx,ts,tsx,json}'",
"ts:check": "tsc --noEmit --incremental",
"pre-commit": "npm run lint && npm run prettier:write && npm run ts:check",
"pre-commit": "npm run lint:pre-commit && npm run prettier && npm run ts:check",
"sync-submodules": "git submodule init && git submodule update",
"prepare": "husky"
},
Expand Down
1 change: 1 addition & 0 deletions src/components/CookiePrompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Text } from './lib/Text';

const Wrapper = styled.div`
position: fixed;
z-index: 1000;
bottom: 1rem;
left: 0;
right: 0;
Expand Down
2 changes: 0 additions & 2 deletions src/components/CtaSection.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { CREATE_ACCOUNT_URL } from '@/utils/constants';

import { Button } from './lib/Button';
import { Container } from './lib/Container';
import { Flex } from './lib/Flex';
Expand Down
17 changes: 15 additions & 2 deletions src/components/navigation/desktop/MainNavigationMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as NavigationMenu from '@radix-ui/react-navigation-menu';
import Link from 'next/link';
import type { MouseEventHandler } from 'react';
import styled from 'styled-components';

import { recordMouseEnter } from '@/utils/analytics';
Expand Down Expand Up @@ -44,7 +45,7 @@ const NavTrigger = styled(NavigationMenu.Trigger)`
transition: all 200ms;
&:hover,
&:focus,
&:focus-visible,
&[data-state='open'] {
background: var(--sand4);
}
Expand Down Expand Up @@ -146,6 +147,16 @@ const NavSection = styled.div`
`;

export const MainNavigationMenu = () => {
const navTriggerClick: MouseEventHandler<HTMLButtonElement> = (event) => {
const target = event.target as HTMLButtonElement;

if (target.getAttribute('data-state') === 'open') {
// When a nav trigger is already open and then clicked, we ignore the click to keep the nav dropdown open
event.preventDefault();
event.stopPropagation();
}
};

return (
<Wrapper>
<NavRoot delayDuration={0}>
Expand All @@ -154,7 +165,9 @@ export const MainNavigationMenu = () => {
.filter((category) => category.visible === 'all' || category.visible === 'desktop')
.map((category) => (
<NavItem key={category.title}>
<NavTrigger onMouseEnter={recordMouseEnter}>{category.title}</NavTrigger>
<NavTrigger onMouseEnter={recordMouseEnter} onClick={navTriggerClick}>
{category.title}
</NavTrigger>

<NavContent>
<Container>
Expand Down
4 changes: 2 additions & 2 deletions src/components/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ export const Home = () => {

<Grid $columns="1fr 1fr 1fr" $gap="24px" $mobileGap="48px">
{news.map((post) => (
<Article key={post.title} href={post.url} target="_blank">
<Article key={post.title + post.createdAt} href={post.url} target="_blank">
<ArticleImage>
<img src={post.thumbnail} alt={post.title} />
</ArticleImage>
Expand Down Expand Up @@ -818,7 +818,7 @@ export const Home = () => {

<Grid $columns="1fr 1fr 1fr" $gap="24px" $mobileGap="48px">
{events.map((event) => (
<Article key={event.title} href={event.url} target="_blank" style={{ minWidth: 0 }}>
<Article key={event.title + event.date} href={event.url} target="_blank" style={{ minWidth: 0 }}>
<ArticleImage>
<img src={event.thumbnail} alt={event.title} />
</ArticleImage>
Expand Down

0 comments on commit 414f0c3

Please sign in to comment.