Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { PartyProvider } from '@/app/components/party-manager/party-context';
import { BoardSessionBridge } from '@/app/components/persistent-session';
import { Metadata } from 'next';
import BoardPageSkeleton from '@/app/components/board-page/board-page-skeleton';
import BottomTabBar from '@/app/components/bottom-tab-bar/bottom-tab-bar';

// Helper to get board details for any board type
function getBoardDetailsUniversal(parsedParams: ParsedBoardRouteParameters): BoardDetails {
Expand Down Expand Up @@ -139,7 +140,7 @@ export default async function BoardLayout(props: PropsWithChildren<BoardLayoutPr
parsedParams = await parseBoardRouteParamsWithSlugs(params);
}

const { board_name, angle } = parsedParams;
const { angle } = parsedParams;

// Fetch the board details server-side
const boardDetails = getBoardDetailsUniversal(parsedParams);
Expand Down Expand Up @@ -171,7 +172,8 @@ export default async function BoardLayout(props: PropsWithChildren<BoardLayoutPr
</Content>

<Affix offsetBottom={0}>
<QueueControlBar board={board_name} boardDetails={boardDetails} angle={angle} />
<QueueControlBar boardDetails={boardDetails} angle={angle} />
<BottomTabBar boardDetails={boardDetails} angle={angle} />
</Affix>
</PartyProvider>
</GraphQLQueueProvider>
Expand Down
118 changes: 100 additions & 18 deletions packages/web/app/components/board-page/climbs-list.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
'use client';
import React, { useEffect, useRef, useCallback } from 'react';
import { Row, Col } from 'antd';
import React, { useEffect, useRef, useCallback, useState } from 'react';
import { Row, Col, Button, Flex } from 'antd';
import { AppstoreOutlined, UnorderedListOutlined } from '@ant-design/icons';
import { track } from '@vercel/analytics';
import { Climb, ParsedBoardRouteParameters, BoardDetails } from '@/app/lib/types';
import { useQueueContext } from '../graphql-queue';
import ClimbCard from '../climb-card/climb-card';
import ClimbListItem from '../climb-card/climb-list-item';
import { ClimbCardSkeleton } from './board-page-skeleton';
import { useSearchParams } from 'next/navigation';
import { themeTokens } from '@/app/theme/theme-config';

type ViewMode = 'grid' | 'list';

const VIEW_MODE_STORAGE_KEY = 'climbListViewMode';

function getInitialViewMode(): ViewMode {
if (typeof window === 'undefined') return 'grid';
try {
const stored = localStorage.getItem(VIEW_MODE_STORAGE_KEY);
if (stored === 'grid' || stored === 'list') return stored;
} catch {
// localStorage not available
}
// Default: list on mobile, grid on desktop
return window.matchMedia('(min-width: 768px)').matches ? 'grid' : 'list';
}

type ClimbsListProps = ParsedBoardRouteParameters & {
boardDetails: BoardDetails;
Expand Down Expand Up @@ -34,6 +53,17 @@ const ClimbsList = ({ boardDetails, initialClimbs }: ClimbsListProps) => {

const searchParams = useSearchParams();
const page = searchParams.get('page');
const [viewMode, setViewMode] = useState<ViewMode>(getInitialViewMode);

const handleViewModeChange = useCallback((mode: ViewMode) => {
setViewMode(mode);
try {
localStorage.setItem(VIEW_MODE_STORAGE_KEY, mode);
} catch {
// localStorage not available
}
track('View Mode Changed', { mode });
}, []);

// Queue Context provider uses React Query infinite to fetch results, which can only happen clientside.
// That data equals null at the start, so when its null we use the initialClimbs array which we
Expand Down Expand Up @@ -131,40 +161,92 @@ const ClimbsList = ({ boardDetails, initialClimbs }: ClimbsListProps) => {
}, [handleObserver]);

return (
<div style={{ paddingTop: '5px' }}>
<Row gutter={[16, 16]}>
{climbs.map((climb, index) => (
<Col xs={24} lg={12} xl={12} id={climb.uuid} key={climb.uuid}>
<div style={{ paddingTop: themeTokens.spacing[1] }}>
{/* View mode toggle */}
<Flex
justify="flex-end"
style={{
padding: `${themeTokens.spacing[1]}px ${themeTokens.spacing[1]}px ${themeTokens.spacing[2]}px`,
}}
>
<Button.Group size="small">
<Button
icon={<UnorderedListOutlined />}
type={viewMode === 'list' ? 'primary' : 'default'}
onClick={() => handleViewModeChange('list')}
aria-label="List view"
/>
<Button
icon={<AppstoreOutlined />}
type={viewMode === 'grid' ? 'primary' : 'default'}
onClick={() => handleViewModeChange('grid')}
aria-label="Grid view"
/>
</Button.Group>
</Flex>

{viewMode === 'grid' ? (
/* Grid (card) mode */
<Row gutter={[themeTokens.spacing[4], themeTokens.spacing[4]]}>
{climbs.map((climb, index) => (
<Col xs={24} lg={12} xl={12} id={climb.uuid} key={climb.uuid}>
<div
ref={(el) => {
climbsRefs.current[climb.uuid] = el;
}}
{...(index === 0 ? { id: 'onboarding-climb-card' } : {})}
>
<ClimbCard
climb={climb}
boardDetails={boardDetails}
selected={currentClimb?.uuid === climb.uuid}
onCoverDoubleClick={() => handleClimbDoubleClick(climb)}
/>
</div>
</Col>
))}
{isFetchingClimbs && (!climbs || climbs.length === 0) ? (
<ClimbsListSkeleton aspectRatio={boardDetails.boardWidth / boardDetails.boardHeight} />
) : null}
</Row>
) : (
/* List (compact) mode */
<div>
{climbs.map((climb, index) => (
<div
key={climb.uuid}
id={climb.uuid}
ref={(el) => {
climbsRefs.current[climb.uuid] = el;
}}
{...(index === 0 ? { id: 'onboarding-climb-card' } : {})}
>
<ClimbCard
<ClimbListItem
climb={climb}
boardDetails={boardDetails}
selected={currentClimb?.uuid === climb.uuid}
onCoverDoubleClick={() => handleClimbDoubleClick(climb)}
onSelect={() => handleClimbDoubleClick(climb)}
/>
</div>
</Col>
))}
{isFetchingClimbs && (!climbs || climbs.length === 0) ? (
<ClimbsListSkeleton aspectRatio={boardDetails.boardWidth / boardDetails.boardHeight} />
) : null}
</Row>
))}
{isFetchingClimbs && (!climbs || climbs.length === 0) ? (
<Row gutter={[themeTokens.spacing[4], themeTokens.spacing[4]]}>
<ClimbsListSkeleton aspectRatio={boardDetails.boardWidth / boardDetails.boardHeight} />
</Row>
) : null}
</div>
)}

{/* Sentinel element for Intersection Observer - needs min-height to be observable */}
<div ref={loadMoreRef} style={{ minHeight: '20px', marginTop: '16px' }}>
<div ref={loadMoreRef} style={{ minHeight: themeTokens.spacing[5], marginTop: themeTokens.spacing[4] }}>
{isFetchingClimbs && climbs.length > 0 && (
<Row gutter={[16, 16]}>
<Row gutter={[themeTokens.spacing[4], themeTokens.spacing[4]]}>
<ClimbsListSkeleton aspectRatio={boardDetails.boardWidth / boardDetails.boardHeight} />
</Row>
)}
{!hasMoreResults && climbs.length > 0 && (
<div style={{ textAlign: 'center', padding: '20px', color: '#888' }}>
No more climbs 🤐
<div style={{ textAlign: 'center', padding: themeTokens.spacing[5], color: themeTokens.neutral[400] }}>
No more climbs
</div>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.tabBar {
display: flex;
justify-content: space-around;
align-items: center;
width: 100%;
border-top: 1px solid #e5e7eb;
background-color: #fff;
padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tabItem {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
flex: 1;
padding: 6px 0 4px;
cursor: pointer;
transition: color 150ms ease;
-webkit-tap-highlight-color: transparent;
touch-action: manipulation;
user-select: none;
background: none;
border: none;
}

.tabLabel {
font-size: 10px;
margin-top: 2px;
line-height: 1;
}

/* Hide on desktop - search/queue available in sidebar, create in header */
@media (min-width: 768px) {
.tabBar {
display: none;
}
}
Loading
Loading