Skip to content
Open
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
5 changes: 2 additions & 3 deletions apps/web/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
* Fix: change the import to `useDebounce`.
*/

// BUG: useThrottle no longer exists — was renamed to useDebounce
import { useThrottle } from "@e2e/utils"
import { useDebounce } from "@e2e/utils"
import { formatDate, formatAUD } from "@e2e/utils"

export const BASE_URL = process.env.API_URL ?? "http://localhost:3000"
Expand All @@ -29,4 +28,4 @@ export async function fetchPosts() {
export { formatDate, formatAUD }

// Re-export the debounce hook (currently broken import)
export { useThrottle as useSearchDebounce }
export { useDebounce as useSearchDebounce }
30 changes: 7 additions & 23 deletions packages/ui/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,29 @@ import React from "react"

type Variant = "primary" | "secondary" | "danger"

type Props = {
type Props = React.ButtonHTMLAttributes<HTMLButtonElement> & {
children?: React.ReactNode
/** Icon-only button — renders without visible text. Requires aria-label for accessibility. */
icon?: React.ReactNode
iconOnly?: boolean
variant?: Variant
disabled?: boolean
onClick?: () => void
/** Accessible label — REQUIRED when iconOnly is true */
"aria-label"?: string
}

/**
* Button component.
*
* BUG: When `iconOnly` is true, the button renders without visible text.
* An `aria-label` is required for screen reader accessibility (WCAG 2.1 SC 4.1.2),
* but the component does not enforce or warn about its absence.
*
* The test in Button.test.tsx checks that an icon-only button has an accessible name.
* Fix: throw/warn in development when `iconOnly && !aria-label`, or always render
* the aria-label attribute when iconOnly is true.
*/
export function Button({
children,
icon,
iconOnly = false,
variant = "primary",
disabled = false,
onClick,
"aria-label": ariaLabel,
...rest
}: Props) {
if (iconOnly && !ariaLabel) {
console.warn("Button: icon-only buttons must have an aria-label for WCAG 4.1.2 compliance.")
}
return (
<button
className={`btn btn-${variant}`}
disabled={disabled}
onClick={onClick}
// BUG: aria-label is not applied when iconOnly is true and no ariaLabel is passed
// The component should enforce aria-label for icon-only buttons
aria-label={iconOnly ? (ariaLabel ?? "") : ariaLabel}
{...rest}
>
{icon && <span className="btn-icon">{icon}</span>}
{!iconOnly && children}
Expand Down
10 changes: 4 additions & 6 deletions packages/utils/src/format/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
* and rely on the locale to order them correctly.
*/
export function formatDate(date: Date): string {
// BUG: explicit field order overrides locale ordering — produces M/D/YYYY not D/M/YYYY
return new Intl.DateTimeFormat("en-AU", {
month: "numeric",
day: "numeric",
year: "numeric",
}).format(date)
const day = date.getUTCDate()
const month = String(date.getUTCMonth() + 1).padStart(2, "0")
const year = date.getUTCFullYear()
return `${day}/${month}/${year}`
}

export function formatDateTime(date: Date): string {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
"jsx": "react-jsx",
"strict": true,
"skipLibCheck": true,
"types": ["bun-types"],
"paths": {
"@e2e/ui": ["./packages/ui/src/index.ts"],
"@e2e/utils": ["./packages/utils/src/index.ts"]
}
},
"include": ["packages/*/src/**/*", "packages/*/test/**/*", "apps/*/src/**/*"]
"include": ["packages/*/src/**/*", "packages/*/test/**/*", "apps/*/src/**/*", "apps/*/test/**/*"]
}