Skip to content

Commit 037bc44

Browse files
NoamGaashclaude
andauthored
feat: Add hackathon landing page at /hackathon (#1576)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 6a70b24 commit 037bc44

13 files changed

Lines changed: 2252 additions & 2 deletions

File tree

src/layout/sidebar/menu/Menu.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { CalendarOutlined } from '@ant-design/icons'
12
import type { MenuProps } from 'antd'
23
import { Menu } from 'antd'
34
import React, { useContext, useEffect, useState } from 'react'
@@ -7,6 +8,7 @@ import { LayoutContextInterface, LayoutCtx } from 'src/layout/LayoutContext'
78
import { useTheme } from 'src/layout/ThemeContext'
89
import { getPathWithoutLang } from 'src/locale/allTranslations'
910
import DonateModal from 'src/pages/DonateModal/DonateModal'
11+
import { EVENT_DATE_ISO, REGISTRATION_CLOSE_ISO } from 'src/pages/hackathon/challenges'
1012
import { PAGES } from 'src/routes'
1113
import './menu.scss'
1214

@@ -53,12 +55,37 @@ function getGroup(label: React.ReactNode, key: React.Key, children: MenuItem[]):
5355
}
5456
}
5557

58+
const HACKATHON_REG_CLOSE_MS = new Date(REGISTRATION_CLOSE_ISO).getTime()
59+
const HACKATHON_EVENT_MS = new Date(EVENT_DATE_ISO).getTime()
60+
const HACKATHON_MENU_HIDE_MS = HACKATHON_EVENT_MS + 3 * 24 * 60 * 60 * 1000 // hide 3 days after event
61+
5662
const MainMenu = ({ collapsed = false }: MainMenuProps) => {
5763
const { t } = useTranslation()
5864
const { currentLanguage } = useTheme()
5965
const { setDrawerOpen } = useContext<LayoutContextInterface>(LayoutCtx)
6066
const [isDonateModalVisible, setDonateModalVisible] = useState(false)
6167

68+
const now = Date.now()
69+
const showHackathon = now < HACKATHON_MENU_HIDE_MS
70+
71+
const hackathonDaysLeft =
72+
now < HACKATHON_REG_CLOSE_MS
73+
? Math.ceil((HACKATHON_REG_CLOSE_MS - now) / (1000 * 60 * 60 * 24))
74+
: null
75+
76+
const hackathonItem = showHackathon
77+
? getItem(
78+
<Link to={`/${currentLanguage}/hackathon`} onClick={() => setDrawerOpen(false)}>
79+
{t('hackathon_title')}
80+
{hackathonDaysLeft !== null && (
81+
<span className="hackathon-badge">{hackathonDaysLeft}d</span>
82+
)}
83+
</Link>,
84+
'/hackathon',
85+
<CalendarOutlined />,
86+
)
87+
: null
88+
6289
const handleDonateClick = (e: React.MouseEvent) => {
6390
e.preventDefault()
6491
setDonateModalVisible(true)
@@ -87,6 +114,7 @@ const MainMenu = ({ collapsed = false }: MainMenuProps) => {
87114

88115
const groupedItems: MenuItem[] = [
89116
routeItems['/'],
117+
hackathonItem,
90118
...MENU_GROUPS.map(({ key, paths }) =>
91119
getGroup(
92120
<span className="sidebar-menu-group-title">{t(key)}</span>,
@@ -98,6 +126,7 @@ const MainMenu = ({ collapsed = false }: MainMenuProps) => {
98126

99127
const flatItems: MenuItem[] = [
100128
routeItems['/'],
129+
hackathonItem,
101130
...MENU_GROUPS.flatMap(({ paths }) => paths.map((path) => routeItems[path]).filter(Boolean)),
102131
].filter(Boolean)
103132

src/layout/sidebar/menu/menu.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@
5454
}
5555
}
5656

57+
.hackathon-badge {
58+
display: inline-block;
59+
font-size: 10px;
60+
background: #e6f4ff;
61+
color: #1677ff;
62+
border-radius: 4px;
63+
padding: 1px 5px;
64+
margin-inline-start: 6px;
65+
font-weight: 700;
66+
line-height: 1.5;
67+
vertical-align: middle;
68+
}
69+
5770
.dark .sidebar-menu {
5871
.ant-menu-item-group-title {
5972
color: rgb(255 255 255 / 65%);

src/locale/en.json

Lines changed: 336 additions & 1 deletion
Large diffs are not rendered by default.

src/locale/he.json

Lines changed: 332 additions & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)