Option A — Phase 9: Theme & Design System
This document is the plan for Phase 9 of AppiFire AI Chat (Option A): adopting a professional, widely used design system so the admin UI (and optionally the storefront chat widget) looks consistent and polished instead of basic custom styling.
Prerequisites: Admin app routes exist (e.g. Phase 4 settings, Phase 5 billing, Phase 8 chat logs). No functional changes to business logic; this phase is about visual consistency and component library.
Objective
Section titled “Objective”- Replace ad‑hoc styling (inline styles, custom
s-*elements, hardcoded hex colors) with a single design system used across the project. - Use components and tokens (spacing, color, typography) so pages look professional and consistent.
- Prefer a market-standard, open-source approach that fits a Shopify embedded app (React).
1. Recommended approach: Shopify Polaris (React)
Section titled “1. Recommended approach: Shopify Polaris (React)”Primary choice: Shopify Polaris React (@shopify/polaris).
- Widely used for Shopify admin and embedded apps; matches the host admin chrome.
- Professional components: Page, Card, IndexTable (expandable rows), DataTable, Badge, Banner, TextField, Button, Box, Stack, etc.
- Design tokens: Color, spacing, typography built in; no need to invent a palette.
- Fits the stack: React, and the app already uses
@shopify/app-bridge-reactand@shopify/polaris-types(types only today). - Single source of truth: One library for layout, tables, forms, and feedback across all admin routes.
What changes:
- Add
@shopify/polarisand its CSS to the app (root layout or app shell). - Replace custom layout (e.g.
s-page,s-section, raw<table>) with Polaris components:Page,Card,IndexTable,DataTable,Text,Box,Banner, etc. - Use Polaris for all admin routes (Home, Settings, Billing, AI Chats, Additional) so the whole project shares one theme.
Note: Polaris React is being succeeded by Polaris Web Components long-term; for current React-based admin UIs it remains the standard and is well documented.
2. Optional: Tailwind CSS
Section titled “2. Optional: Tailwind CSS”- Use case: Utility-first styling for one-off tweaks, or if you want a second “theme layer” (e.g. custom marketing/landing pages) without full Polaris.
- Recommendation: Introduce only if needed. For an admin-only app, Polaris alone is enough. If you add Tailwind later, keep Polaris for structure and use Tailwind for spacing/color overrides where necessary.
- This plan: Phase 9 focuses on Polaris first; Tailwind can be a later, optional step.
3. Scope
Section titled “3. Scope”| Area | In scope for Phase 9 | Notes |
|---|---|---|
| Admin app routes | Yes | All routes under /app/*: Home, Settings, Billing, AI Chats, Additional. Use Polaris Page, Card, tables, forms, banners. |
| Auth / login | Yes | Use Polaris layout and components where it makes sense (e.g. Card, TextField, Button). |
| Chat widget (storefront) | Optional | Widget is customer-facing; can stay custom or use a small subset of tokens. Document in this plan that widget theming is separate. |
| Root layout | Yes | Load Polaris CSS (and font if not already) in app/root.jsx or the layout that wraps admin UI. |
4. Implementation steps
Section titled “4. Implementation steps”4.1 Install and wire Polaris
Section titled “4.1 Install and wire Polaris”-
Install:
npm install @shopify/polaris -
Load Polaris CSS in the root that wraps the app (e.g.
app/root.jsx):- Import Polaris styles:
import '@shopify/polaris/build/esm/styles.css'; - Or link the built CSS from
node_modulesif the bundler supports it. - Ensure the Inter font is loaded (Polaris expects it); the project already has a link to Shopify’s Inter in
root.jsx.
- Import Polaris styles:
-
Optional: AppProvider
Polaris can be wrapped inAppProviderfor i18n and other context. If the app already uses a provider from@shopify/shopify-app-react-router, confirm how (or whether) to nest Polaris’sAppProviderso there are no duplicate or conflicting wrappers. Prefer a single root provider if possible.
4.2 Migrate admin layout and shell
Section titled “4.2 Migrate admin layout and shell”-
App shell (
app/routes/app.jsx):
Replace or complement custom nav (s-app-nav,s-link) with Polaris navigation components if available (e.g.Navigation,NavItem) so the sidebar/tabs use Polaris look and feel. If the template’s nav is required for embedding, keep it but style it with Polaris tokens or minimal overrides. -
Shared layout:
Ensure every admin page is rendered inside a consistent wrapper so Polaris CSS and tokens apply (e.g. a single layout route that wraps/appand loads Polaris).
4.3 Migrate routes to Polaris components
Section titled “4.3 Migrate routes to Polaris components”-
AI Chats (
app/routes/app.chat-logs.jsx):- Use
Pagefor title and optional primary action. - Use
Cardfor each session block (accordion-style). - Use
IndexTablefor the list of sessions with expandable rows, orDataTablefor the inner “User or AI | Message | Time | Charged” table. - Use
Badgefor “User” / “AI” if desired. - Use
Text,Boxfor spacing and typography. - Remove inline theme objects and raw
<table>in favor of Polaris table components where possible.
- Use
-
Billing (
app/routes/app.billing.jsx):- Use
Page,Card,Layout(orBlockStack/InlineStack). - Use
DataTableor structured lists for billing history and subscription list. - Use
Bannerfor success/error/info (e.g. cancel success, redirecting). - Use
Button,Textfrom Polaris.
- Use
-
Settings (
app/routes/app.settings.jsx):- Use
Page,Card,FormLayout,TextField,Select,Checkbox,Button,Banner. - Replace custom form markup with Polaris form components where it improves clarity and consistency.
- Use
-
Home (
app/routes/app._index.jsx) and Additional (app/routes/app.additional.jsx):- Use
Page,Card,Text,Button,BlockStack/InlineStackso these pages match the rest of the admin.
- Use
-
Auth / login:
- Use Polaris
Card,TextField,Button,Textfor a consistent look with the rest of the app.
- Use Polaris
4.4 Cleanup and docs
Section titled “4.4 Cleanup and docs”-
Remove or reduce custom styling:
- Prefer Polaris components and tokens; delete or trim large inline style objects (e.g. the
themeobject inapp.chat-logs.jsx) as you replace them with Polaris. - Keep minimal custom CSS only where Polaris doesn’t cover the case (e.g. storefront widget).
- Prefer Polaris components and tokens; delete or trim large inline style objects (e.g. the
-
Document design decisions:
- In this doc or in a short “Design system” section in the main docs: “Admin UI uses Shopify Polaris React. Do not introduce another component library for admin without updating this plan.”
5. Checklist
Section titled “5. Checklist”- Install
@shopify/polarisand add Polaris CSS (and AppProvider) in root and app layout. - Ensure Inter font is loaded; no conflicting global resets.
- App shell/nav: Polaris AppProvider wraps admin content; nav remains s-app-nav for embedding.
- app.chat-logs.jsx: Page, Card, DataTable, Badge, Collapsible, Text, BlockStack, InlineStack.
- app.billing.jsx: Page, Card, DataTable, Banner, Button, Text, ProgressBar, Box, BlockStack, InlineStack.
- app.settings.jsx: Page, Card, FormLayout, TextField, Select, Checkbox, Button, Banner.
- app._index.jsx and app.additional.jsx: Page, Card, Text, Button, Link, BlockStack, InlineStack, Box.
- Auth/login route uses Polaris Page, Card, TextField, Button, BlockStack (with Polaris AppProvider).
- Custom inline theme objects removed from chat-logs; Polaris components used throughout.
- Admin UI uses Shopify Polaris React; storefront chat widget theming is separate.
6. File summary
Section titled “6. File summary”| Item | Action |
|---|---|
package.json | Add @shopify/polaris. |
app/root.jsx (or admin layout) | Import Polaris CSS; ensure font. |
app/routes/app.jsx | Use or align nav with Polaris. |
app/routes/app.chat-logs.jsx | Refactor to Polaris Page, Card, IndexTable/DataTable. |
app/routes/app.billing.jsx | Refactor to Polaris Page, Card, tables, Banner. |
app/routes/app.settings.jsx | Refactor to Polaris form components. |
app/routes/app._index.jsx, app.additional.jsx | Use Polaris Page, Card, Text, Button. |
| Auth route(s) | Use Polaris Card, form controls. |
docs/Option-A-Phase-9-theme-and-design-system.md | This plan; implemented. |
7. Out of scope / later
Section titled “7. Out of scope / later”- Chat widget (storefront): Themes and styling for the storefront widget can stay custom or use a small shared token file; document separately.
- Tailwind: Not required for Phase 9; add later if you want utility-first overrides.
- Polaris Web Components: Migration to web components can be a future phase once Shopify’s guidance and examples are the default for new apps.
Next: After Phase 9, the admin app will have a single, professional design system (Polaris); new admin pages should use Polaris components and tokens from the start.