Skip to content

Refactor/split index css - #1498

Open
Thadd102 wants to merge 1 commit into
CalloraOrg:mainfrom
Thadd102:refactor/split-index-css
Open

Thadd102 wants to merge 1 commit into
CalloraOrg:mainfrom
Thadd102:refactor/split-index-css

Conversation

@Thadd102

@Thadd102 Thadd102 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1385

Splits the 8,108-line monolith src/index.css into co-located per-feature and per-component stylesheets imported directly by their owning components, shrinking src/index.css to 3,103 lines (-61.7%) while keeping only global resets, design tokens, @layer focus, shared shell/button/badge/toast/skeleton utilities, and @media print rules in src/index.css.

  • Removes the duplicate Category Pills block (lines 7569–7581, an exact subset of lines 6381–6393) as well as exact duplicate blocks for Share Snapshot Button (lines 7561–7567), LandingPage (.lp-card*, .lp-footer*, @media .lp-*), and FiltersSidebar accessibility rules.
  • Preserves cascade order across @layer focus, src/styles/*, and existing co-located stylesheets (BillingHistory.css, ApiDetailStickyTOC.css, QuotaBanner.css, DepositPreview.css).
  • Documents the three-layer stylesheet architecture in docs/UI-Design-System.md.

Stylesheet Inventory

Feature / Section Target Stylesheet Owning Component(s) Lines
Global tokens, resets, @layer focus, shell, nav, buttons, status chips, toast, skeleton, @media print src/index.css src/main.tsx 3,103
Marketplace layout, catalog grid, skeleton, filter modal, mobile toggle src/pages/MarketplacePage.css src/pages/MarketplacePage.tsx, src/pages/MarketplacePage.skeleton.tsx 296
API card, compact variant, stats, responsive breakpoints, skeleton CLS stability src/components/ApiCard.css src/components/ApiCard.tsx, src/pages/MarketplacePage.skeleton.tsx 345
Filters sidebar, collapsible filter groups, accessibility, price validation src/components/FiltersSidebar.css src/components/FiltersSidebar.tsx 205
Category pills (deduplicated) src/components/CategoryPills.css src/components/CategoryPills.tsx 49
Sort menu src/pages/SortMenu.css src/pages/SortMenu.tsx 28
API tag filter rail src/pages/ApiTagFilter.css src/pages/ApiTagFilter.tsx 173
Deposit modal, presets, preview rows, tx hash actions & DepositPreview src/components/DepositPreview.css src/components/DepositPreview.tsx, src/App.tsx 356
Billing history list & rows (prepended before .billing-history.bh-page) src/pages/BillingHistory.css src/pages/BillingHistory.tsx 417
Invoice card & sticky action bar src/pages/InvoiceCard.css src/pages/InvoiceCard.tsx 138
Landing page (.launch-home, .lp-*, deduplicated) src/app/landing.css src/app/LandingPage.tsx 189
API detail hero, layout, metrics, pricing shortcut hint, endpoints, responsive src/pages/ApiDetailPage.css src/pages/ApiDetailPage.tsx, src/pages/ApiDetailPage.skeleton.tsx 504
Quota banner (appended after existing rules to preserve cascade) src/pages/QuotaBanner.css src/pages/QuotaBanner.tsx 132
Endpoint group hover preview src/components/EndpointGroupHover.css src/components/EndpointGroupHover.tsx 161
Endpoint preview panel src/components/EndpointPreview.css src/components/EndpointPreview.tsx 152
Sticky TOC (prepended before existing rules to preserve cascade) src/components/ApiDetailStickyTOC.css src/components/ApiDetailStickyTOC.tsx 154
WhyApi accordion src/components/WhyApi.css src/components/WhyApi.tsx 144
SubscribeCTA sticky bottom bar src/pages/SubscribeCTA.css src/pages/SubscribeCTA.tsx 190
API usage page, call history table, responsive audit & reduced-motion fallback src/pages/ApiUsage.css src/pages/ApiUsage.tsx, src/ApiUsage.tsx 674
Request history panel & mobile bottom sheet src/components/RequestHistoryPanel.css src/components/RequestHistoryPanel.tsx 208
Calls heatmap src/components/CallsHeatmap.css src/components/CallsHeatmap.tsx 91
Response diff highlighting (CallHistoryRow) src/components/CallHistoryRow.css src/components/CallHistoryRow.tsx 277
Webhook deliveries src/pages/WebhookDeliveries.css src/pages/WebhookDeliveries.tsx 170
Latency chart page src/pages/LatencyChart.css src/pages/LatencyChart.tsx 140
Theme playground & token editor src/pages/ThemePlayground.css src/pages/ThemePlayground.tsx 214

Verification

1. Rule-Set Diff (Zero Lost / Zero Added Rules)

Ran a Node.js CSS rule parser that strips comments, recursively tracks @media / @supports / @layer contexts, splits comma-separated selectors, normalizes declarations, and diffs the sorted rule multiset before (src/index.css + 4 existing component CSS files) vs. after (src/index.css + all 24 co-located CSS files):

  • Before: 1,576 normalized selector rules
  • After: 1,551 normalized selector rules
  • Lost rules: 0
  • Added / duplicated rules: 0
  • Exact duplicates removed (2 → 1): 25 (Category Pills .pill-bar / .pill-bar::-webkit-scrollbar, .share-snapshot-button, duplicate .lp-card* / .lp-footer* / @media .lp-* / .app-shell, and duplicate .filter-* base rules)

2. CSS Bundle Size Comparison (via esbuild CSS minifier across all stylesheets)

  • Before: 262,378 B raw / 150,358 B minified (src/index.css: 8,108 lines)
  • After: 253,341 B raw (-3.4%) / 150,704 B minified (+0.23%) (src/index.css: 3,103 lines)

Note on npm run build: Unrelated pre-existing TypeScript/esbuild errors currently exist on main (e.g. duplicate timelineData in src/components/HealthTimeline.tsx, duplicate ep in src/components/CollectionsMenu.tsx, and src/components/OpenAPIImport.tsx). Per issue scope, no unrelated files were modified.

3. Tests (npx vitest run)

All CSS contract tests and touched component suites pass with zero assertion edits:

  • src/focus-layer.test.ts (18/18 passed)
  • src/styles/patterns.test.tsx (6/6 passed)
  • src/patterns.test.ts (11/11 passed)
  • src/styles/forcedColors.test.ts (8/8 passed)
  • src/coverage-config.test.ts (6/6 passed)
  • src/pages/SortMenu.test.tsx (2/2 passed)
  • src/components/DepositPreview.test.tsx (7/7 passed)
  • src/pages/BillingHistory.test.tsx (73/73 passed)
  • src/pages/InvoiceCard.test.tsx (14/14 passed)
  • src/pages/ThemePlayground.test.tsx (25/25 passed)
  • src/components/WhyApi.test.tsx (36/36 passed)
  • src/components/CallsHeatmap.test.tsx (14/14 passed)
  • src/pages/LatencyChart.test.tsx (12/12 passed)

4. Visual Spot Checks

  • Attach light/dark screenshots of Landing, Marketplace, API Detail, Billing, and Deposit once main's pre-existing HealthTimeline.tsx / CollectionsMenu.tsx syntax errors are resolved.

@drips-wave

drips-wave Bot commented Nov 25, 2026

Copy link
Copy Markdown

@Thadd102 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@greatest0fallt1me

Copy link
Copy Markdown
Contributor

Hi @Thadd102, thanks for this PR! It currently deletes 5,988 lines of existing code, most likely because your branch is based on an older copy of main. Please rebase on the latest main and keep only the changes for your issue, then push again. We'll merge it as soon as that's done. 🙏

@Thadd102

Copy link
Copy Markdown
Contributor Author

Hi @Thadd102, thanks for this PR! It currently deletes 5,988 lines of existing code, most likely because your branch is based on an older copy of main. Please rebase on the latest main and keep only the changes for your issue, then push again. We'll merge it as soon as that's done. 🙏

i resolved a conflict, check and merge

…lesheets (CalloraOrg#1385)

Extract marketplace, deposit, billing, landing, API detail, API usage, webhook, latency chart, and theme playground sections from src/index.css (8,108 -> 3,103 lines) into co-located CSS files imported by their owning components.

- Remove exact duplicate Category Pills, Share Snapshot, LandingPage, and FiltersSidebar rules (verified 0 lost / 0 added rules via normalized AST diff).
- Preserve cascade order for @layer focus, BillingHistory.css, ApiDetailStickyTOC.css, QuotaBanner.css, and DepositPreview.css.
- Document the co-located stylesheet architecture in docs/UI-Design-System.md.
@Thadd102
Thadd102 force-pushed the refactor/split-index-css branch from 32f73c0 to 8f30a5b Compare November 30, 2026 10:35
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.

Split src/index.css (7,300+ lines) into per-feature stylesheets imported by their components

2 participants