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
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@ src/
- [x] Initial setup (folder structure, routing, styles solution, linting/formatting, error boundary, tests, CI)
- [x] Dashboard UI (static): sidebar with mobile drawer, header, toolbar, five status columns, task cards
- [x] API connection — fetch tasks into their status columns, with loading skeleton, failure alert + retry, and empty state
- [ ] Create task
- [ ] Update task
- [ ] Delete task
- [x] Create task — the + buttons open a Figma-matched modal (full-screen page on mobile, floating panel on desktop) with custom estimate/assignee/tag menus and per-breakpoint date pickers; createTask + cache invalidation + error handling
- [x] Update task — Edit via the card/list options menu, reusing the shared TaskForm with all six required editable fields (name, due date, position, status, tags, estimate) plus assignee; success/failure notifications
- [x] Delete task — 'Delete Task?' confirmation via the options menu, deleteTask by id, success/failure notifications
- [x] View toggle & My Task — grid/list layouts on both views (list = the mockup's grouped table with due-date row indicators); My Task filters to tasks assigned to the logged-in user via the profile query
- [ ] Search & filter
- [ ] User settings page

Expand All @@ -123,6 +124,11 @@ src/

- **Generated GraphQL code is committed on purpose.** `src/graphql/generated/` (output of `npm run codegen`) is checked into git so CI can typecheck and build without holding the API token. Regenerate after changing any query/mutation; never edit by hand.
- **Quality gates are CI-enforced, not hook-enforced.** There are deliberately no git hooks (husky/lint-staged): CI runs format check, lint, typecheck, tests, and build on every PR, and the same scripts run locally on demand. Hooks can be added later if commit-time enforcement proves necessary.
- **Tag labels derive from the API enum.** The mockups show sample tag texts that contradict each other across surfaces (the same tag renders "IOS APP" on cards but "IOS" in the tag menu, "ANDROID" on cards but "Android App" in the menu). Since the API's TaskTag enum is the real domain, labels derive from the enum values (IOS, ANDROID, REACT, NODE JS, RAILS) and are identical everywhere.
- **List group-header hover icons are omitted.** One mockup group header shows +/… icons; they have no behavior behind them (non-working UI, same principle as the bell).
- **List rows have an actions column the mockup lacks.** The requirement ties update/delete to the options icon, and a list-only user would otherwise have no way to reach them — requirements outrank mockups, so each row ends with the same options menu the cards use.
- **List-view row borders follow the due date.** The mockup's task table shows rows with identical dates but different left-border colors — an inconsistency the team acknowledged in Slack ("we use to have those in real projects"). Per the team's guidance that the border is a due-date indicator, the rule implemented is: overdue = red (primary), due within two days = amber (tertiary), later = green (secondary).
- **The header bell is THE notification system.** Mutation successes and failures are recorded to a notification center the bell opens (unread dot, ten-entry history, marked read on open); failures additionally surface as inline alerts in the dialog that caused them, so errors are impossible to miss. Transient toasts were built first and deliberately removed — two presentations of the same event stream duplicated a function; the bell is the one the Figma shows. The panel's own design has no mockup, so it reuses the app's menu anatomy. The card metric icons below stay omitted because their data provably does not exist in the schema — the bell's does.
- **Card attachment/fork/comment icons are omitted.** The Figma shows those metrics on task cards, but the API's Task type exposes no fields for them. Per mentor guidance not to expose non-working UI, the icons are removed until the schema provides the data; the SVGs live in git history for easy reintroduction.
- **Node 24 is a hard requirement** — `.npmrc` sets `engine-strict=true`, so `npm install` fails fast on older Node instead of warning.
- **A11y deviation from the design, flagged and recommended per mentor guidance:** the Figma's active-tab red (`primary-4`, `#da584b`) on the dark surface measures ≈3.5:1 below WCAG AA's 4.5:1 for 15px text. Following the design team's process (flag + recommend), the active label uses `primary-3` (`#e27d73`) one step up the design system's own red scale measuring ≈4.7:1 (≈4.5:1 worst-case over the 5% gradient wash). The indicator bar stays `primary-4` (non-text graphic, 3:1 rule, passes). The active state is also conveyed non-visually via `aria-current="page"`.
Expand Down
22 changes: 15 additions & 7 deletions src/app/router.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import userEvent from '@testing-library/user-event'
import { createMemoryRouter, RouterProvider } from 'react-router'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { routes } from '@/app/router'
import { makeFixtureTasks, tasksRequestMock } from '@/test/fixtures'
import { NotificationsProvider } from '@/components/ui/notifications'
import { makeFixtureProfile, makeFixtureTasks, tasksRequestMock } from '@/test/fixtures'
import { ProfileDocument } from '@/features/tasks/queries'

vi.mock('@/lib/graphql-client', () => ({
graphqlClient: { request: vi.fn() },
Expand All @@ -14,7 +16,11 @@ beforeEach(() => {
vi.useFakeTimers({ toFake: ['Date'] })
vi.setSystemTime(new Date('2026-08-06T12:00:00Z'))
tasksRequestMock().mockReset()
tasksRequestMock().mockResolvedValue({ tasks: makeFixtureTasks() })
tasksRequestMock().mockImplementation((document: unknown) =>
document === ProfileDocument
? Promise.resolve({ profile: makeFixtureProfile() })
: Promise.resolve({ tasks: makeFixtureTasks() }),
)
})

afterEach(() => {
Expand All @@ -30,7 +36,9 @@ function renderAt(path: string) {
const router = createMemoryRouter(routes, { initialEntries: [path] })
return render(
<QueryClientProvider client={queryClient}>
<RouterProvider router={router} />
<NotificationsProvider>
<RouterProvider router={router} />
</NotificationsProvider>
</QueryClientProvider>,
)
}
Expand Down Expand Up @@ -98,17 +106,17 @@ describe('dashboard main content', () => {
)
if (!card) throw new Error('expected the Twitter card to render inside an <article>')
const scoped = within(card)
expect(scoped.getByText(/8 pts/i)).toBeInTheDocument()
expect(scoped.getByText(/8 points/i)).toBeInTheDocument()
expect(scoped.getByText(/yesterday/i)).toBeInTheDocument()
expect(scoped.getByText('REACT')).toBeInTheDocument()
expect(scoped.getByRole('img', { name: /unassigned/i })).toBeInTheDocument()
expect(scoped.getByRole('img', { name: /task options/i })).toBeInTheDocument()
expect(scoped.getByRole('button', { name: /task options/i })).toBeInTheDocument()
})

it('renders the toolbar view icons and the add-task affordance', () => {
renderAt('/')
expect(screen.getByRole('img', { name: /grid view/i })).toBeInTheDocument()
expect(screen.getByRole('img', { name: /list view/i })).toBeInTheDocument()
expect(screen.getByRole('button', { name: /grid view/i })).toBeInTheDocument()
expect(screen.getByRole('button', { name: /list view/i })).toBeInTheDocument()
expect(screen.getAllByRole('button', { name: /add task/i }).length).toBeGreaterThan(0)
})

Expand Down
7 changes: 4 additions & 3 deletions src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useState } from 'react'
import avatarUrl from '@/assets/avatar.png'
import { BellIcon, SearchIcon } from '@/components/ui/icons'
import { SearchIcon } from '@/components/ui/icons'
import { NotificationsBell } from '@/components/layout/NotificationsBell'

interface HeaderProps {
sidebarOpen: boolean
Expand Down Expand Up @@ -34,10 +35,10 @@ export function Header({ sidebarOpen, onOpenSidebar }: HeaderProps) {
/>
<div className="ml-auto flex items-center gap-3 lg:hidden">
<SearchIcon className="size-6 text-neutral-2" />
<BellIcon className="size-6 text-neutral-2" />
<NotificationsBell />
</div>
<div className="hidden shrink-0 items-center gap-6 lg:flex">
<BellIcon className="size-6 text-neutral-2" />
<NotificationsBell />
<img className="size-10 rounded-full" src={avatarUrl} alt="Profile" />
</div>
</header>
Expand Down
68 changes: 68 additions & 0 deletions src/components/layout/NotificationsBell.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { useState } from 'react'
import { BellIcon } from '@/components/ui/icons'
import { useNotifications } from '@/components/ui/notifications-context'

export function NotificationsBell() {
const { notifications, markAllRead } = useNotifications()
const [open, setOpen] = useState(false)
const hasUnread = notifications.some((item) => !item.read)

const toggle = () => {
if (!open) markAllRead()
setOpen((current) => !current)
}

return (
<div
className="relative"
onKeyDown={(event) => {
if (event.key === 'Escape') setOpen(false)
}}
>
<button
type="button"
aria-label="Notifications"
aria-expanded={open}
onClick={toggle}
className="relative flex size-8 items-center justify-center text-neutral-2"
>
<BellIcon className="size-6" />
{hasUnread && (
<span className="absolute top-0.5 right-0.5 size-2 rounded-full bg-primary-4" />
)}
</button>
{open && (
<>
<button
type="button"
aria-label="Close notifications"
tabIndex={-1}
onClick={() => {
setOpen(false)
}}
className="fixed inset-0 z-10 cursor-default"
/>
<div className="absolute top-full right-0 z-20 mt-2 flex w-72 flex-col rounded-lg border border-neutral-2 bg-neutral-3 py-2 shadow-drop-large">
<span className="flex h-8 items-center px-4 text-body-xl font-semibold text-neutral-2">
Notifications
</span>
{notifications.length === 0 ? (
<p className="px-4 py-2 text-body-m text-neutral-2">No notifications yet.</p>
) : (
notifications.map((item) => (
<p
key={item.id}
className={`border-l-4 px-4 py-2 text-body-m text-neutral-1 ${
item.tone === 'error' ? 'border-primary-4' : 'border-secondary-4'
}`}
>
{item.message}
</p>
))
)}
</div>
</>
)}
</div>
)
}
38 changes: 38 additions & 0 deletions src/components/ui/notifications-context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { createContext, useContext } from 'react'

export interface AppNotification {
id: number
message: string
tone: 'success' | 'error'
read: boolean
}

export type Notify = (message: string, tone: AppNotification['tone']) => void

export interface NotificationsContextValue {
notify: Notify
notifications: AppNotification[]
markAllRead: () => void
}

export const NotificationsContext = createContext<NotificationsContextValue | null>(null)

function useNotificationsContext(): NotificationsContextValue {
const value = useContext(NotificationsContext)
if (value === null) {
throw new Error('Notification hooks require a NotificationsProvider above — check main.tsx')
}
return value
}

export function useNotify(): Notify {
return useNotificationsContext().notify
}

export function useNotifications(): Pick<
NotificationsContextValue,
'notifications' | 'markAllRead'
> {
const { notifications, markAllRead } = useNotificationsContext()
return { notifications, markAllRead }
}
33 changes: 33 additions & 0 deletions src/components/ui/notifications.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { useCallback, useMemo, useRef, useState, type ReactNode } from 'react'
import {
NotificationsContext,
type AppNotification,
type Notify,
type NotificationsContextValue,
} from '@/components/ui/notifications-context'

export function NotificationsProvider({ children }: { children: ReactNode }) {
const [notifications, setNotifications] = useState<AppNotification[]>([])
const nextId = useRef(0)

const notify = useCallback<Notify>((message, tone) => {
const id = nextId.current
nextId.current += 1
setNotifications((current) => [{ id, message, tone, read: false }, ...current].slice(0, 10))
}, [])

const markAllRead = useCallback(() => {
setNotifications((current) =>
current.some((item) => !item.read)
? current.map((item) => (item.read ? item : { ...item, read: true }))
: current,
)
}, [])

const value = useMemo<NotificationsContextValue>(
() => ({ notify, notifications, markAllRead }),
[notify, notifications, markAllRead],
)

return <NotificationsContext.Provider value={value}>{children}</NotificationsContext.Provider>
}
41 changes: 41 additions & 0 deletions src/components/ui/use-dialog-focus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { useEffect, useRef, useState, type KeyboardEvent as ReactKeyboardEvent } from 'react'

export function useDialogFocus(onEscape: () => void) {
const containerRef = useRef<HTMLDivElement>(null)
const [opener] = useState(() => document.activeElement)

useEffect(() => {
return () => {
if (opener instanceof HTMLElement) opener.focus()
}
}, [opener])

useEffect(() => {
const onKeyDown = (event: KeyboardEvent) => {
if (event.key === 'Escape') onEscape()
}
window.addEventListener('keydown', onKeyDown)
return () => {
window.removeEventListener('keydown', onKeyDown)
}
}, [onEscape])

const trapFocus = (event: ReactKeyboardEvent) => {
if (event.key !== 'Tab' || containerRef.current === null) return
const focusables = [...containerRef.current.querySelectorAll<HTMLElement>('button, input')]
.filter((el) => el.tabIndex !== -1 && !el.hasAttribute('disabled'))
.filter((el) => el.getClientRects().length > 0)
const first = focusables.at(0)
const last = focusables.at(-1)
if (first === undefined || last === undefined) return
if (event.shiftKey && document.activeElement === first) {
event.preventDefault()
last.focus()
} else if (!event.shiftKey && document.activeElement === last) {
event.preventDefault()
first.focus()
}
}

return { containerRef, trapFocus }
}
Loading