Repository navigation
MSPCA-51 Add navbar to the app layout #31
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
Merged
Juwang110
merged 18 commits into
pk/mspca-46-animal-availability-frontend-endpoint
from
jw/mspca-51-navbar
Nov 13, 2026
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
5108fce
MSPCA-51: add volunteer helpers, getVolunteer, and useVolunteerId
Juwang110 f36f43e
MSPCA-51: add responsive Navbar component
Juwang110 f69239a
MSPCA-51: render Navbar in shared app layout
Juwang110 7434226
MSPCA-51: use URL volunteer ID for match requests
Juwang110 5156e6a
MSPCA-51: keep navbar on page errors and fix double-height scroll
Juwang110 fe7cf19
MSPCA-51: reject unsafe volunteer IDs and warn on failed volunteer fetch
Juwang110 0d55633
MSPCA-51: remove navbar, modal, and route specs
Juwang110 d2205d5
Merge pk/mspca-46-animal-availability-frontend-endpoint into jw/mspca…
Juwang110 a538b06
MSPCA-51: remove unneeded comments
Juwang110 cb4eaba
MSPCA-51: mirror the full GET /volunteers/:id response in Volunteer type
Juwang110 df4a2f6
MSPCA-51: remove comments from types.ts
Juwang110 e7d44b8
MSPCA-51: restore types.ts comments except the Volunteer shape note
Juwang110 2d99608
MSPCA-51: remove /test route and Test component
Juwang110 ce83158
MSPCA-51: use Chakra Button in Navbar, inline avatar, drop hover unde…
Juwang110 ccbde66
MSPCA-51: fix app spec so it passes in CI
Juwang110 dc0299c
MSPCA-51: add frontend test workflow, rename jest workflow to backend…
Juwang110 a1bd83a
Merge pk/mspca-46-animal-availability-frontend-endpoint into jw/mspca…
Juwang110 fd94b4b
MSPCA-51: use Trello label colors for volunteer avatars
Juwang110 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| name: Frontend tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: ['**'] | ||
| pull_request: | ||
| branches: ['**'] | ||
|
|
||
| jobs: | ||
| frontend-tests: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 24.x | ||
| cache: 'yarn' | ||
| - run: yarn install --frozen-lockfile | ||
| - run: npx vitest run --root apps/frontend |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| import { useEffect, useState } from 'react'; | ||
| import { Button, Flex, Image, Text } from '@chakra-ui/react'; | ||
|
|
||
| import apiClient from '@api/apiClient'; | ||
| import type { Volunteer } from '../types'; | ||
| import { useVolunteerId } from '@utils/useVolunteerId'; | ||
| import { getAvatarColor, getInitials } from '@utils/volunteer'; | ||
| import logo from '../assets/mspca-logo.png'; | ||
|
|
||
| /** Site-wide header: MSPCA logo and the current volunteer's profile button. */ | ||
| const Navbar: React.FC = () => { | ||
| const volunteerId = useVolunteerId(); | ||
| const [loaded, setLoaded] = useState<Volunteer | null>(null); | ||
| const volunteer = loaded?.volunteerId === volunteerId ? loaded : null; | ||
|
|
||
| useEffect(() => { | ||
| if (volunteerId === null) return; | ||
|
|
||
| let cancelled = false; | ||
| apiClient | ||
| .getVolunteer(volunteerId) | ||
| .then((result) => { | ||
| if (!cancelled) setLoaded(result); | ||
| }) | ||
| .catch((err: unknown) => { | ||
| console.warn(`Could not load volunteer ${volunteerId}`, err); | ||
| }); | ||
| return () => { | ||
| cancelled = true; | ||
| }; | ||
| }, [volunteerId]); | ||
|
|
||
| return ( | ||
| <Flex | ||
| as="header" | ||
| px={{ base: '4', md: '8' }} | ||
| py="4" | ||
| minH={{ md: '120px' }} | ||
| bg="gray.50" | ||
| boxShadow="card" | ||
| justify="space-between" | ||
| align="center" | ||
| > | ||
| <Image | ||
| src={logo} | ||
| alt="MSPCA - Kindness and Care for Animals" | ||
| w={{ base: '142px', md: '196px' }} | ||
| h={{ base: '64px', md: '88px' }} | ||
| objectFit="contain" | ||
| /> | ||
| {/* TODO: link to the volunteer profile page once it exists. */} | ||
| <Button | ||
| type="button" | ||
| aria-label="My Profile" | ||
| variant="plain" | ||
| display="flex" | ||
| alignItems="center" | ||
| gap="4" | ||
| h="auto" | ||
| cursor="pointer" | ||
| > | ||
| <Flex | ||
| data-testid="navbar-avatar" | ||
| boxSize={{ base: '50px', md: '66px' }} | ||
| flexShrink={0} | ||
| align="center" | ||
| justify="center" | ||
| bg={volunteer ? getAvatarColor(volunteer.volunteerId) : 'gray.300'} | ||
| color="white" | ||
| borderRadius="full" | ||
| boxShadow="card" | ||
| outline="3px solid" | ||
| outlineColor="neutrals.black" | ||
| outlineOffset="-3px" | ||
| fontSize={{ base: '20px', md: '24px' }} | ||
| fontWeight="semibold" | ||
| lineHeight="1" | ||
| > | ||
| {volunteer | ||
| ? getInitials(volunteer.firstName, volunteer.lastName) | ||
| : ''} | ||
| </Flex> | ||
| <Text | ||
| display={{ base: 'none', md: 'block' }} | ||
| color="neutrals.black" | ||
| fontSize="24px" | ||
| fontWeight="semibold" | ||
| lineHeight="36px" | ||
| > | ||
| My Profile | ||
| </Text> | ||
| </Button> | ||
| </Flex> | ||
| ); | ||
| }; | ||
|
|
||
| export default Navbar; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { Flex } from '@chakra-ui/react'; | ||
| import { Outlet } from 'react-router-dom'; | ||
|
|
||
| import Navbar from '@components/Navbar'; | ||
|
|
||
| /** | ||
| * Shared app shell: the navbar sits above every page. The column fills the | ||
| * viewport so pages can grow into the remaining height with `flex="1"`. | ||
| */ | ||
| const Layout: React.FC = () => ( | ||
| <Flex direction="column" minH="100vh"> | ||
| <Navbar /> | ||
| <Outlet /> | ||
| </Flex> | ||
| ); | ||
|
|
||
| export default Layout; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.