Skip to content

MSPCA-32 Add Chakra UI v3 and theme.ts - #15

Merged
Juwang110 merged 6 commits into
mainfrom
jw/mspca-32-theme-chakra
Oct 20, 2026
Merged

Juwang110 merged 6 commits into
mainfrom
jw/mspca-32-theme-chakra

Conversation

@Juwang110

@Juwang110 Juwang110 commented Oct 16, 2026 •

Copy link
Copy Markdown

ℹ️ Issue

Closes MSPCA-32

📝 Description

Adds Chakra UI v3 and a theme.ts with the brand colors and typography from the MSPCA UI Kit in Figma, so frontend pages can use named tokens like color="blue.primary" or textStyle="h3" instead of hardcoded hex codes and font sizes. Changing a value in theme.ts changes it across the whole app.

Changes:

  1. Installed @chakra-ui/react (v3.37) and @emotion/react.
  2. Added apps/frontend/src/theme.ts, built from the Figma file's variables and text styles:
    • colors holds every brand color's hex code (black, gray 0–900, error, blue, orange, green, teal, brown, neutrals, and the Trello foster-restriction label colors). It's exported for places where Chakra props aren't available, and the same values are registered as Chakra tokens (blue.primary, trello.dogFreeHome, ...).
    • black is pure #000000, which Figma uses directly in fg, text.fg, and bg.inverted. It replaces Chakra's default black (#09090B). It's not the same as the brand black neutrals.black (#231f20).
    • Semantic tokens (bg, fg, border, text, neutral) use the Figma values in place of Chakra's defaults.
    • Typography: Montserrat for headings and body, weights thin–black, and text styles h1–h7, body, body-small, xs, and 2xs (defined with defineTextStyles). Figma only has font sizes for xs (12/10px) and 2xs (10/8px), with no text style or line height, so those two use Chakra's default line heights (1rem and 0.75rem). Each text style includes its weight (semibold for headings, normal for body), so <Text textStyle="h3"> looks the same as a plain <h3>, and a fontWeight prop can still override it. Figma defines Desktop and Mobile sizes, so each text style uses the mobile size below Chakra's md breakpoint (768px) and the desktop size above it.
    • Common tags get typography by default through globalCss: body, h1–h6, p, li, label, small, figcaption, a, and form controls.
  3. Wrapped the app in <ChakraProvider value={system}> in main.tsx, outside the auth branch so both paths get the theme.
  4. Loaded Montserrat from Google Fonts in index.html as a variable font (wght@100..900), so every weight token works from a single font file.
  5. Imported @aws-amplify/ui-react/styles.css in main.tsx. The Amplify sign-in form never had its stylesheet and relied on browser defaults, which Chakra's CSS reset removes (inputs lost their borders and buttons looked like plain text). With the stylesheet, it renders Amplify's styled sign-in card. This adds ~30 kB of gzipped CSS.

Radii and spacing aren't overridden: the Figma values match Chakra's defaults.

✔️ Verification

  • npx nx run frontend:typecheck, npx nx lint frontend, and npx nx build frontend pass.
  • Ran npx nx serve frontend and checked computed styles in the browser for each tag:
    • Desktop: h1 60/90px, h2 48/72, h3 36/54, h4 30/46, h5 24/36, h6 20/30, p 16/24, small 14/20, all Montserrat. This matches the Figma text styles.
    • At 390px wide, sizes switch to the Figma mobile values (h1 36px down to p 14px).
    • <Text textStyle="h3"> and <Heading textStyle="h2"> match the plain tags (36px/600 and 48px/600), and fontWeight="bold" overrides to 700.
    • With COGNITO_* set, the Amplify sign-in form renders as a styled card (bordered inputs, filled button) in Montserrat at desktop and mobile widths.
    • The CSS variables resolve to the Figma hex codes (e.g. --chakra-colors-blue-primary = #009cde; --chakra-colors-fg, -text-fg, and -bg-inverted = #000000 via colors.black), and there are no console errors.
    • textStyle="xs" / "2xs" produce 10px / 8px on mobile and 12px / 10px from md up.
    • Montserrat weights 100 and 900 both load.
  • nx test frontend was already failing on main (parseCLI is not a function: the @nx/vite:test executor doesn't support vitest 0.32). Running npx vitest run directly in apps/frontend gives the same result before and after this change: the stale "Welcome frontend" assertion fails and apiClient logs network errors.

To try a token, render something like <Heading as="h2" textStyle="h2" color="blue.primary">Hello</Heading> or <Text textStyle="body-small" color="fg.muted">...</Text> in root.tsx. If COGNITO_USER_POOL_ID and COGNITO_CLIENT_ID are set in .env, the sign-in form shows first, so comment them out (and restart the dev server) to see the page directly.

🏕️ (Optional) Future Work / Notes

Juwang110 and others added 2 commits October 16, 2026 19:00
- Install @chakra-ui/react v3 and @emotion/react.
- Add apps/frontend/src/theme.ts with the Figma colors (exported as
  `colors` and registered as Chakra tokens), the semantic bg/fg/border/
  text/neutral tokens, Montserrat fonts and weights, and h1-h7/body/
  body-small text styles that switch to the Figma mobile sizes below md.
- Give common tags (body, h1-h6, p, li, label, small, a, form controls)
  their typography through globalCss.
- Wrap the app in ChakraProvider and load Montserrat from Google Fonts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Juwang110
Juwang110 marked this pull request as ready for review October 17, 2026 15:35
Juwang110 and others added 2 commits October 17, 2026 11:45
- Each text style now sets its own fontWeight (semibold for headings,
  normal for body), so <Text textStyle="h3"> matches a raw <h3>.
- Drop the globalCss heading/body fontWeight rules this replaces.
- Wrap text styles in defineTextStyles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Authenticator was never given its stylesheet, so it relied on browser
defaults; Chakra's CSS reset removed those, leaving borderless inputs and
buttons that looked like plain text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@dburkhart07 dburkhart07 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks very good aside from a few small things. tysm for this justin!!!

Comment thread apps/frontend/src/theme.ts
Comment thread apps/frontend/src/theme.ts
Comment thread apps/frontend/index.html Outdated
Comment thread apps/frontend/src/theme.ts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@pujitakalinadhabhotla pujitakalinadhabhotla left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

@Juwang110
Juwang110 merged commit 4b3c192 into main Oct 20, 2026
10 checks passed
@Juwang110
Juwang110 deleted the jw/mspca-32-theme-chakra branch October 20, 2026 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants