feat(CRIT-012): redesign home, state, and county pages for 55+ audience

Complete visual overhaul of the three core public pages, establishing a
consistent design system with reusable CSS classes and theme tokens.

Phase 1 — Home Page:
- Hero section with flame badge, bold headline, bouncing arrow CTA
- SVG map wrapped in warm-glow container with hover indicator
- State navigation cards with per-state colors and hover lift
- Value propositions grid (Compare, Find, Save, Free)
- Subtle dealer login CTA

Phase 2 — State Page:
- Themed breadcrumb with ChevronLeft back-nav
- Per-state accent colors on header
- County map in .map-container with hover indicator
- County navigation card grid with bidirectional map cross-highlighting
- Skeleton loading and DaisyUI error states

Phase 3 — County/Tables Page:
- Price-hero styling makes pricing the dominant visual element
- Sortable desktop table with chevron icons and active column highlight
- Completely redesigned mobile cards: company + price top row, cash
  callout, icon-labeled details grid, tappable phone CTA
- Market prices section with info note
- Relative date formatting (Today, Yesterday, 3 days ago)
- Full skeleton loading states

Design System (shared across all pages):
- 19 reusable CSS classes in app.postcss (.accent-badge, .map-container,
  .price-hero, .listing-card, .county-card, .skeleton-box, etc.)
- oil-orange and oil-blue color scales in Tailwind config
- fade-in-up, fade-in, float animations
- Staggered section reveals with Svelte transitions
- Zero hardcoded colors — all theme tokens and DaisyUI semantics
- Full dark mode support throughout

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-10 14:59:07 -05:00
parent 27d22aefd4
commit d60c816002
6 changed files with 1589 additions and 454 deletions

140
README.md
View File

@@ -1,38 +1,142 @@
# create-svelte # NewEnglandBio Frontend
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte). SvelteKit web application for heating oil and biofuel price comparison across New England's 6 states (MA, CT, RI, VT, NH, ME).
## Creating a project ## Tech Stack
If you're seeing this, you've probably already done this step. Congrats! - **Framework:** SvelteKit with TypeScript
- **Styling:** Tailwind CSS + DaisyUI
- **Icons:** lucide-svelte
- **Build:** Vite, adapter-node
- **Maps:** Pure SVG (no map library) — path data in `src/lib/states/*.ts`
```bash ## Project Structure
# create a new project in the current directory
npm create svelte@latest
# create a new project in my-app ```
npm create svelte@latest my-app src/
├── lib/
│ ├── api/
│ │ ├── client.ts # Fetch wrapper with auth, error handling
│ │ ├── types.ts # API response types
│ │ └── index.ts
│ ├── types/
│ │ └── types.ts # App-wide TypeScript interfaces
│ ├── states/ # SVG county path data per state
│ │ ├── connecticut.ts
│ │ ├── maine.ts
│ │ ├── massachusetts.ts
│ │ ├── newhampshire.ts
│ │ ├── rhodeisland.ts
│ │ └── vermont.ts
│ └── states.ts # State/county stores and data
└── routes/
├── +error.svelte
└── (app)/
├── +layout.svelte # Navbar, footer, dark mode
├── +page.svelte # Home — interactive NE state map
├── login/+page.svelte
├── register/+page.svelte
├── [stateSlug]/
│ ├── +page.svelte # County map for a state
│ └── [countySlug]/
│ └── +page.svelte # Listings & oil prices for a county
└── vendor/
├── +layout.svelte
├── +page.svelte # Vendor dashboard
├── profile/+page.svelte # Edit company profile
└── listing/
├── +page.svelte # Create listing
└── [id]/+page.svelte # Edit listing
``` ```
## Developing ## Routes
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: | Path | Access | Description |
|------|--------|-------------|
| `/` | Public | Interactive New England map |
| `/login` | Public | Login form |
| `/register` | Public | Registration form |
| `/:stateSlug` | Public | County map for a state (e.g. `/MA`) |
| `/:stateSlug/:countySlug` | Public | Listings and oil prices for a county |
| `/vendor` | Auth | Vendor dashboard |
| `/vendor/profile` | Auth | Edit company profile |
| `/vendor/listing` | Auth | Create new listing |
| `/vendor/listing/:id` | Auth | Edit a listing |
## Setup
```bash
npm install
```
### Environment
Create `.env`:
```
PUBLIC_API_URL=http://localhost:9552
```
### Development
```bash ```bash
npm run dev npm run dev
# or start the server and open the app in a new browser tab
npm run dev -- --open
``` ```
## Building Dev server starts on **port 5169** with `--host` for network access. Vite proxies `/api` requests to the Rust API during development.
To create a production version of your app: ### Production Build
```bash ```bash
npm run build npm run build
node build
``` ```
You can preview the production build with `npm run preview`. Runs on **port 3000** using adapter-node.
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment. ## Docker
**Development:**
```bash
docker build -f Dockerfile -t frontend-dev .
```
**Production (multi-stage):**
```bash
docker build -f Dockerfile.prod -t frontend-prod .
docker run -p 3000:3000 frontend-prod
```
## API Client
The API client (`src/lib/api/client.ts`) provides typed methods for all backend interactions:
- **Auth:** `login()`, `register()`, `logout()`, `isAuthenticated()`, `getStoredUser()`
- **Company:** `getCompany()`, `createCompany()`, `updateCompany()`, `deleteCompany()`
- **Listings:** `getListings()`, `getListingById()`, `createListing()`, `updateListing()`, `deleteListing()`
- **Public:** `getListingsByCounty()`, `getOilPricesByCounty()`, `getCountiesByState()`, `getCategories()`
Auth uses JWT stored as an httpOnly cookie. User info cached in localStorage.
## Styling
Tailwind + DaisyUI with two themes (light/dark). Custom utility classes:
- `.btn-blue-oil` — primary CTA buttons
- `.bg-orange-oil` — accent backgrounds
- `.btn-state` — map state buttons
## Scripts
| Command | Description |
|---------|-------------|
| `npm run dev` | Dev server (port 5169) |
| `npm run build` | Production build |
| `npm run preview` | Preview production build |
| `npm run check` | Svelte type checking |
| `npm run check:watch` | Type checking (watch mode) |
## Known Issues
- Maine SVG map paths are inaccurate (CRIT-001)
- API URL `http://localhost:9552` is hardcoded in some components

View File

@@ -26,3 +26,156 @@
.btn-state { .btn-state {
@apply btn btn-outline btn-secondary btn-xs px-1 py-1 text-xs leading-none; @apply btn btn-outline btn-secondary btn-xs px-1 py-1 text-xs leading-none;
} }
/* Home page hero gradient - warm, inviting feel */
.hero-gradient {
background: linear-gradient(135deg, #0256bf 0%, #1d4ed8 40%, #7c2d12 100%);
}
/* Subtle warm glow behind the map */
.map-glow {
box-shadow: 0 0 60px rgba(255, 102, 0, 0.08), 0 0 120px rgba(2, 86, 191, 0.06);
}
[data-theme="dark"] .map-glow {
box-shadow: 0 0 60px rgba(255, 102, 0, 0.12), 0 0 120px rgba(2, 86, 191, 0.1);
}
/* State card hover lift effect */
.state-card {
@apply transition-all duration-200 ease-out;
}
.state-card:hover {
transform: translateY(-3px);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}
[data-theme="dark"] .state-card:hover {
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}
/* Staggered animation delays for scroll-reveal elements */
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }
.stagger-6 { animation-delay: 0.6s; }
/* Value prop icon container */
.value-icon {
@apply flex items-center justify-center w-14 h-14 rounded-full;
background: linear-gradient(135deg, #ff6600 0%, #fb923c 100%);
color: white;
}
[data-theme="dark"] .value-icon {
background: linear-gradient(135deg, #e55a00 0%, #c2410c 100%);
}
/* Reusable map container — wraps any interactive SVG map with glow + framing */
.map-container {
@apply relative map-glow rounded-2xl bg-base-100 p-4 sm:p-6 border border-base-300;
}
/* Map container label — "Interactive Map" / "Interactive County Map" */
.map-label {
@apply text-xs font-semibold uppercase tracking-wider text-base-content/40;
}
/* Map hover indicator — shows current hovered element name */
.map-hover-indicator {
@apply text-center mb-2 h-8 flex items-center justify-center;
}
/* Accent pill badge — used for section accents (flame badge, state badge, etc.) */
.accent-badge {
@apply inline-flex items-center gap-2 px-4 py-2 rounded-full
bg-oil-orange-50 border border-oil-orange-200
text-sm font-medium text-oil-orange-700;
}
[data-theme="dark"] .accent-badge {
@apply bg-oil-orange-900/20 border-oil-orange-700/40 text-oil-orange-300;
}
/* County card — interactive grid item with cross-highlight support */
.county-card {
@apply state-card rounded-xl border-2 p-3 sm:p-4
bg-base-100 border-base-300
cursor-pointer select-none
focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2;
}
.county-card:hover,
.county-card.is-highlighted {
@apply border-primary bg-primary/5;
}
[data-theme="dark"] .county-card:hover,
[data-theme="dark"] .county-card.is-highlighted {
@apply border-primary bg-primary/10;
}
/* Skeleton loading placeholder */
.skeleton-box {
@apply animate-pulse rounded-xl bg-base-300/50;
}
/* ============================================================
PRICE TABLE SYSTEM
Reusable table, row, and card styles for pricing pages
============================================================ */
/* Table wrapper — rounded container with border, no zebra */
.price-table-wrap {
@apply w-full rounded-xl border border-base-300 bg-base-100 overflow-hidden;
}
[data-theme="dark"] .price-table-wrap {
@apply border-base-300/60;
}
/* Sortable column header — clickable with hover + active state */
.sort-header {
@apply cursor-pointer select-none whitespace-nowrap
text-base-content/60 font-semibold text-xs uppercase tracking-wider
transition-colors duration-150;
}
.sort-header:hover {
@apply text-base-content;
}
.sort-header.is-active {
@apply text-primary;
}
/* Price display — the hero number on every listing */
.price-hero {
@apply text-2xl sm:text-3xl font-extrabold leading-none;
color: theme('colors.oil-orange.600');
}
[data-theme="dark"] .price-hero {
color: theme('colors.oil-orange.400');
}
/* Secondary price label (cash price, etc.) */
.price-secondary {
@apply text-sm font-medium text-base-content/50;
}
/* Listing card — mobile card for a single dealer/price row */
.listing-card {
@apply state-card rounded-xl border border-base-300
bg-base-100 p-4 sm:p-5;
}
[data-theme="dark"] .listing-card {
@apply border-base-300/60;
}
/* Section container — wraps Premium Dealers / Market Prices */
.price-section {
@apply rounded-2xl bg-base-200/30 border border-base-300/50 p-4 sm:p-6;
}
[data-theme="dark"] .price-section {
@apply bg-base-200/20 border-base-300/30;
}
/* Info note — subtle helper text below section headers */
.info-note {
@apply text-sm text-base-content/50 flex items-center gap-1.5;
}

View File

@@ -1,49 +1,37 @@
<!-- src/routes/+page.svelte --> <!-- src/routes/(app)/+page.svelte -->
<script lang="ts"> <script lang="ts">
import { newEnglandStates, mapViewBox, user } from '$lib/states'; import { newEnglandStates, mapViewBox, user } from '$lib/states';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import { browser } from '$app/environment'; // To ensure SVG interactions only run client-side import { browser } from '$app/environment';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { fade, fly } from 'svelte/transition';
import { import {
Scissors, Search,
Snowflake, DollarSign,
Hammer, MapPin,
Wrench, ThumbsUp,
Zap,
Bug,
Home,
Sparkles,
Eye,
Trash2,
Palette,
TreePine,
Fence,
Waves,
Camera,
Lock,
Refrigerator,
DoorOpen,
Eye as InspectionIcon,
GlassWater,
Shield,
Flame, Flame,
Square, ChevronRight,
Grid, ArrowDown,
Fan,
Clock,
Construction,
ExternalLink
} from 'lucide-svelte'; } from 'lucide-svelte';
interface ServiceCategory {
id: number;
name: string;
description: string;
clicks_total: number;
total_companies: number;
}
let hoveredState: string | null = null; let hoveredState: string | null = null;
let mounted = false;
// Visible tracking for scroll-reveal sections
let heroVisible = false;
let mapVisible = false;
let statesVisible = false;
let valueVisible = false;
onMount(() => {
mounted = true;
// Stagger the reveal of sections for a smooth page load
heroVisible = true;
setTimeout(() => { mapVisible = true; }, 200);
setTimeout(() => { statesVisible = true; }, 500);
setTimeout(() => { valueVisible = true; }, 800);
});
function handleStateClick(id: string) { function handleStateClick(id: string) {
goto(`/${id}`); goto(`/${id}`);
@@ -60,16 +48,122 @@
hoveredState = null; hoveredState = null;
} }
} }
// Map state IDs to warm descriptive colors for the cards
const stateColors: Record<string, { bg: string; border: string; text: string; hover: string }> = {
ME: { bg: 'bg-emerald-50', border: 'border-emerald-200', text: 'text-emerald-700', hover: 'hover:bg-emerald-100' },
VT: { bg: 'bg-green-50', border: 'border-green-200', text: 'text-green-700', hover: 'hover:bg-green-100' },
NH: { bg: 'bg-amber-50', border: 'border-amber-200', text: 'text-amber-700', hover: 'hover:bg-amber-100' },
MA: { bg: 'bg-blue-50', border: 'border-blue-200', text: 'text-blue-700', hover: 'hover:bg-blue-100' },
RI: { bg: 'bg-sky-50', border: 'border-sky-200', text: 'text-sky-700', hover: 'hover:bg-sky-100' },
CT: { bg: 'bg-indigo-50', border: 'border-indigo-200', text: 'text-indigo-700', hover: 'hover:bg-indigo-100' },
};
// Dark mode card variants
const stateColorsDark: Record<string, { bg: string; border: string; text: string; hover: string }> = {
ME: { bg: 'dark:bg-emerald-900/20', border: 'dark:border-emerald-700/40', text: 'dark:text-emerald-300', hover: 'dark:hover:bg-emerald-900/40' },
VT: { bg: 'dark:bg-green-900/20', border: 'dark:border-green-700/40', text: 'dark:text-green-300', hover: 'dark:hover:bg-green-900/40' },
NH: { bg: 'dark:bg-amber-900/20', border: 'dark:border-amber-700/40', text: 'dark:text-amber-300', hover: 'dark:hover:bg-amber-900/40' },
MA: { bg: 'dark:bg-blue-900/20', border: 'dark:border-blue-700/40', text: 'dark:text-blue-300', hover: 'dark:hover:bg-blue-900/40' },
RI: { bg: 'dark:bg-sky-900/20', border: 'dark:border-sky-700/40', text: 'dark:text-sky-300', hover: 'dark:hover:bg-sky-900/40' },
CT: { bg: 'dark:bg-indigo-900/20', border: 'dark:border-indigo-700/40', text: 'dark:text-indigo-300', hover: 'dark:hover:bg-indigo-900/40' },
};
const valueProps = [
{
icon: Search,
title: 'Compare Prices',
description: 'See heating oil and biofuel prices from local dealers side by side.',
},
{
icon: MapPin,
title: 'Find Local Dealers',
description: 'Discover trusted fuel dealers in your county and neighborhood.',
},
{
icon: DollarSign,
title: 'Save Money',
description: 'Find the best prices and stop overpaying for heating oil.',
},
{
icon: ThumbsUp,
title: 'Always Free',
description: 'No sign-up, no fees. Just honest price comparisons for homeowners.',
},
];
</script> </script>
<svelte:head>
<title>Biz Hero - Compare Heating Oil Prices in New England</title>
<meta name="description" content="Compare heating oil and biofuel prices across all six New England states. Find the best deals from local dealers in your county." />
</svelte:head>
<!-- ============================================================ -->
<div class="text-center mb-8"> <!-- HERO SECTION -->
<p class="text-lg mb-4">Welcome to TradeWar, your go-to source for fuel prices across New England. Compare prices by state and county to find the best deals.</p> <!-- ============================================================ -->
<p class="text-sm">Click your state to find prices.</p> <section class="text-center pt-6 pb-4 md:pt-10 md:pb-6">
{#if heroVisible}
<div in:fly={{ y: 24, duration: 500 }}>
<!-- Warm flame accent -->
<div class="flex justify-center mb-4">
<div class="accent-badge">
<Flame size={18} class="text-oil-orange-500" />
<span>New England's Heating Oil Price Guide</span>
</div>
</div> </div>
<div class="flex justify-center items-center"> <!-- Main headline - large, warm, readable -->
<h1 class="text-3xl sm:text-4xl md:text-5xl font-bold leading-tight text-base-content mb-4 px-2">
Find the <span class="text-primary">Best Heating Oil Prices</span>
<br class="hidden sm:block" />
in New England
</h1>
<!-- Subheadline -->
<p class="text-lg sm:text-xl text-base-content/70 max-w-2xl mx-auto mb-6 px-4 leading-relaxed">
Compare prices from local dealers across all six states.
<span class="hidden sm:inline">Save money on heating oil and biofuel this season.</span>
</p>
<!-- CTA hint -->
<div class="flex justify-center items-center gap-2 text-base-content/50 mb-2">
<ArrowDown size={18} class="animate-bounce" />
<span class="text-base font-medium">Click your state on the map to get started</span>
<ArrowDown size={18} class="animate-bounce" />
</div>
</div>
{/if}
</section>
<!-- ============================================================ -->
<!-- INTERACTIVE MAP SECTION -->
<!-- ============================================================ -->
<section class="flex justify-center items-center px-2 pb-6 md:pb-10">
{#if mapVisible}
<div
class="map-container w-full max-w-lg"
in:fade={{ duration: 400 }}
>
<!-- Map label -->
<div class="absolute top-3 left-4 sm:top-4 sm:left-6">
<span class="map-label">Interactive Map</span>
</div>
<!-- Hovered state name display -->
<div class="map-hover-indicator">
{#if hoveredState}
<span
class="text-lg font-semibold text-primary"
in:fade={{ duration: 120 }}
>
{newEnglandStates.find(s => s.id === hoveredState)?.name ?? ''}
</span>
{:else}
<span class="text-sm text-base-content/40">Hover or tap a state</span>
{/if}
</div>
<!-- THE SVG MAP - PRESERVED EXACTLY AS-IS -->
{#if browser} {#if browser}
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
@@ -92,7 +186,7 @@
role="link" role="link"
on:keydown={(e) => { if (e.key === 'Enter' || e.key === ' ') handleStateClick(state.id)}} on:keydown={(e) => { if (e.key === 'Enter' || e.key === ' ') handleStateClick(state.id)}}
> >
<title>{state.name}</title> <!-- Tooltip on hover --> <title>{state.name}</title>
</path> </path>
{/each} {/each}
</svg> </svg>
@@ -102,23 +196,117 @@
</div> </div>
{/if} {/if}
</div> </div>
{/if}
</section>
<div class="mt-8 text-center"> <!-- ============================================================ -->
<h2 class="text-2xl font-semibold mb-4">States:</h2> <!-- STATE NAVIGATION CARDS -->
<ul class="flex flex-wrap justify-center gap-4"> <!-- ============================================================ -->
{#each newEnglandStates as state} <section class="pb-10 md:pb-14 px-2">
<li> {#if statesVisible}
<a href="/{state.id}" class="text-blue-600 hover:text-blue-800 underline flex items-center gap-1"> <div in:fly={{ y: 20, duration: 400 }}>
<span>{state.name}</span> <h2 class="text-2xl sm:text-3xl font-bold text-center text-base-content mb-2">
<ExternalLink size={12} /> Browse by State
</a> </h2>
</li> <p class="text-base text-base-content/60 text-center mb-6 sm:mb-8">
{/each} Select your state to see prices in every county
</ul> </p>
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3 sm:gap-4 max-w-4xl mx-auto">
{#each newEnglandStates as state, i}
{@const colors = stateColors[state.id] ?? { bg: 'bg-base-200', border: 'border-base-300', text: 'text-base-content', hover: 'hover:bg-base-300' }}
{@const darkColors = stateColorsDark[state.id] ?? { bg: 'dark:bg-base-200', border: 'dark:border-base-300', text: 'dark:text-base-content', hover: 'dark:hover:bg-base-300' }}
<a
href="/{state.id}"
class="state-card stagger-{i + 1} opacity-0 animate-fade-in-up group
flex flex-col items-center gap-2 p-4 sm:p-5 rounded-xl border-2
{colors.bg} {colors.border} {colors.hover}
{darkColors.bg} {darkColors.border} {darkColors.hover}
focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2"
aria-label="View heating oil prices in {state.name}"
on:mouseenter={() => handleMouseEnter(state.id)}
on:mouseleave={handleMouseLeave}
>
<!-- State image thumbnail -->
<div class="w-12 h-12 sm:w-14 sm:h-14 rounded-lg overflow-hidden bg-base-300/30 flex items-center justify-center">
<img
src={state.image}
alt="{state.name} outline"
class="w-full h-full object-contain opacity-80 group-hover:opacity-100 transition-opacity"
loading="lazy"
/>
</div> </div>
{#if !$user} <!-- State name -->
<div class="mt-8 text-center"> <span class="text-base sm:text-lg font-semibold {colors.text} {darkColors.text}">
<a href="/login" class="btn btn-primary">Dealer Login</a> {state.name}
</span>
<!-- Arrow indicator -->
<ChevronRight
size={16}
class="text-base-content/30 group-hover:text-base-content/60 group-hover:translate-x-0.5 transition-all"
/>
</a>
{/each}
</div>
</div> </div>
{/if} {/if}
</section>
<!-- ============================================================ -->
<!-- VALUE PROPOSITIONS -->
<!-- ============================================================ -->
<section class="pb-12 md:pb-16 px-2">
{#if valueVisible}
<div in:fly={{ y: 20, duration: 400 }}>
<h2 class="text-2xl sm:text-3xl font-bold text-center text-base-content mb-2">
Why Use Biz Hero?
</h2>
<p class="text-base text-base-content/60 text-center mb-8 sm:mb-10">
Helping New England homeowners make smarter heating decisions
</p>
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6 max-w-5xl mx-auto">
{#each valueProps as prop, i}
<div
class="stagger-{i + 1} opacity-0 animate-fade-in-up
flex flex-col items-center text-center p-6 rounded-xl
bg-base-200/50 dark:bg-base-200/30 border border-base-300/60
hover:bg-base-200 dark:hover:bg-base-200/50 transition-colors duration-200"
>
<div class="value-icon mb-4 flex-shrink-0">
<svelte:component this={prop.icon} size={26} />
</div>
<h3 class="text-lg font-bold text-base-content mb-2">
{prop.title}
</h3>
<p class="text-base text-base-content/65 leading-relaxed">
{prop.description}
</p>
</div>
{/each}
</div>
</div>
{/if}
</section>
<!-- ============================================================ -->
<!-- BOTTOM CTA - SUBTLE DEALER LOGIN -->
<!-- ============================================================ -->
{#if !$user}
<section class="pb-8 text-center">
<div class="inline-flex flex-col items-center gap-2 px-6 py-4 rounded-xl bg-base-200/40 dark:bg-base-200/20 border border-base-300/40">
<p class="text-sm text-base-content/50">
Are you a heating oil dealer?
</p>
<a
href="/login"
class="btn btn-sm btn-outline btn-primary gap-1"
>
Dealer Login
<ChevronRight size={14} />
</a>
</div>
</section>
{/if}

View File

@@ -1,4 +1,4 @@
<!-- src/routes/[stateSlug]/+page.svelte --> <!-- src/routes/(app)/[stateSlug]/+page.svelte -->
<script lang="ts"> <script lang="ts">
import { page } from '$app/stores'; import { page } from '$app/stores';
import { import {
@@ -16,6 +16,13 @@
import { browser } from '$app/environment'; import { browser } from '$app/environment';
import { api } from '$lib/api'; import { api } from '$lib/api';
import type { County } from '$lib/api'; import type { County } from '$lib/api';
import { fade, fly } from 'svelte/transition';
import {
ChevronLeft,
ChevronRight,
MapPin,
Flame,
} from 'lucide-svelte';
const { stateSlug } = $page.params as { stateSlug: string }; const { stateSlug } = $page.params as { stateSlug: string };
@@ -26,7 +33,12 @@
let error: string | null = null; let error: string | null = null;
let hoveredCounty: string | null = null; let hoveredCounty: string | null = null;
// Clean county data access using object lookup // Staggered section reveal
let headerVisible = false;
let mapVisible = false;
let gridVisible = false;
// County data lookup
const countyDataMap: Record<string, NewEnglandState[]> = { const countyDataMap: Record<string, NewEnglandState[]> = {
MA: massachusettsCounties, MA: massachusettsCounties,
ME: maineCounties, ME: maineCounties,
@@ -36,20 +48,48 @@
CT: connecticutCounties CT: connecticutCounties
}; };
// Per-state accent colors (reused from home page pattern)
const stateAccent: Record<string, { badge: string; badgeDark: string }> = {
ME: { badge: 'text-emerald-700', badgeDark: 'dark:text-emerald-300' },
VT: { badge: 'text-green-700', badgeDark: 'dark:text-green-300' },
NH: { badge: 'text-amber-700', badgeDark: 'dark:text-amber-300' },
MA: { badge: 'text-blue-700', badgeDark: 'dark:text-blue-300' },
RI: { badge: 'text-sky-700', badgeDark: 'dark:text-sky-300' },
CT: { badge: 'text-indigo-700', badgeDark: 'dark:text-indigo-300' },
};
function getStateCounties(stateId: string): NewEnglandState[] { function getStateCounties(stateId: string): NewEnglandState[] {
return countyDataMap[stateId] || []; return countyDataMap[stateId] || [];
} }
function handleCountyClick(county: NewEnglandState) { /**
// Match county names between map data and API data * Match an API county name to its SVG map county ID.
const cleanMapName = county.name.toLowerCase().replace(/\s+county$/, '').replace(/[^a-z]/g, ''); * API names: "Barnstable", "Bristol", etc.
const apiCounty = filteredCounties.find((c: County) => * SVG IDs: "barnstable", "bristol", etc.
*/
function apiNameToSvgId(apiName: string): string {
return apiName.toLowerCase().replace(/[^a-z]/g, '');
}
/**
* Find the API county that matches a given SVG county (by name).
*/
function findApiCounty(svgCounty: NewEnglandState): County | undefined {
const cleanMapName = svgCounty.name.toLowerCase().replace(/\s+county$/, '').replace(/[^a-z]/g, '');
return filteredCounties.find((c: County) =>
cleanMapName === c.name.toLowerCase().replace(/[^a-z]/g, '') cleanMapName === c.name.toLowerCase().replace(/[^a-z]/g, '')
); );
}
function handleCountyClick(county: NewEnglandState) {
const apiCounty = findApiCounty(county);
goto(apiCounty ? `/${stateSlug}/${apiCounty.id}` : `/${stateSlug}/${county.slug}`); goto(apiCounty ? `/${stateSlug}/${apiCounty.id}` : `/${stateSlug}/${county.slug}`);
} }
function handleCardClick(apiCounty: County) {
goto(`/${stateSlug}/${apiCounty.id}`);
}
function handleMouseEnter(countyId: string) { function handleMouseEnter(countyId: string) {
if (browser) { if (browser) {
hoveredCounty = countyId; hoveredCounty = countyId;
@@ -62,6 +102,27 @@
} }
} }
/**
* Set hoveredCounty from an API county card (maps API name to SVG ID).
*/
function handleCardEnter(apiCounty: County) {
if (browser) {
hoveredCounty = apiNameToSvgId(apiCounty.name);
}
}
/**
* Get the display name for the currently hovered county.
*/
$: hoveredCountyName = hoveredCounty
? stateCounties.find(c => c.id === hoveredCounty)?.name ?? null
: null;
/**
* Computed accent for the current state.
*/
$: accent = stateAccent[stateSlug] ?? { badge: 'text-primary', badgeDark: '' };
onMount(async () => { onMount(async () => {
stateData = newEnglandStates.find((s: NewEnglandState) => s.id === stateSlug); stateData = newEnglandStates.find((s: NewEnglandState) => s.id === stateSlug);
if (stateData) { if (stateData) {
@@ -82,27 +143,98 @@
// Load map county data // Load map county data
stateCounties = getStateCounties(stateSlug); stateCounties = getStateCounties(stateSlug);
} }
});
// Stagger section reveals
headerVisible = true;
setTimeout(() => { mapVisible = true; }, 200);
setTimeout(() => { gridVisible = true; }, 500);
});
</script> </script>
<!-- SEO -->
<svelte:head>
{#if stateData} {#if stateData}
<!-- Breadcrumbs --> <title>Heating Oil Prices in {stateData.name} | Biz Hero</title>
<nav class="breadcrumb mb-6" aria-label="Breadcrumb"> <meta name="description" content="Compare heating oil and biofuel prices across all {stateData.name} counties. Find the best deals from local dealers near you." />
<ul class="flex space-x-2 text-sm"> {:else}
<li><a href="/" class="text-blue-500 hover:underline">Home</a></li> <title>State Not Found | Biz Hero</title>
<li class="text-gray-500">/</li> {/if}
<li class="text-gray-700 font-medium">{stateData.name}</li> </svelte:head>
</ul>
{#if stateData}
<!-- ============================================================ -->
<!-- BREADCRUMB -->
<!-- ============================================================ -->
<nav class="mb-6" aria-label="Breadcrumb">
<ol class="flex items-center gap-1 text-sm">
<li>
<a
href="/"
class="inline-flex items-center gap-1 text-primary hover:underline focus:outline-none focus:ring-2 focus:ring-primary rounded"
>
<ChevronLeft size={14} />
<span>All States</span>
</a>
</li>
<li class="text-base-content/40" aria-hidden="true">/</li>
<li class="font-medium text-base-content" aria-current="page">{stateData.name}</li>
</ol>
</nav> </nav>
<!-- Centered State Name --> <!-- ============================================================ -->
<div class="text-center mb-6"> <!-- STATE HEADER -->
<h1 class="text-4xl font-bold">{stateData.name}</h1> <!-- ============================================================ -->
{#if headerVisible}
<section class="text-center pb-4 md:pb-6" in:fly={{ y: 24, duration: 500 }}>
<!-- State accent badge -->
<div class="flex justify-center mb-4">
<div class="accent-badge">
<Flame size={18} class="text-oil-orange-500" />
<span>Heating Oil Prices</span>
</div>
</div> </div>
<!-- Interactive County Map --> <!-- State name -->
<div class="flex justify-center mb-6"> <h1 class="text-3xl sm:text-4xl md:text-5xl font-bold leading-tight text-base-content mb-3 px-2">
<span class={accent.badge + ' ' + accent.badgeDark}>{stateData.name}</span>
</h1>
<!-- Subtitle -->
<p class="text-lg sm:text-xl text-base-content/70 max-w-xl mx-auto leading-relaxed px-4">
Explore heating oil prices by county
</p>
</section>
{/if}
<!-- ============================================================ -->
<!-- INTERACTIVE COUNTY MAP -->
<!-- ============================================================ -->
{#if mapVisible}
<section class="flex justify-center items-center px-2 pb-6 md:pb-10" in:fade={{ duration: 400 }}>
<div class="map-container w-full max-w-2xl">
<!-- Map label -->
<div class="absolute top-3 left-4 sm:top-4 sm:left-6">
<span class="map-label">Interactive County Map</span>
</div>
<!-- Hovered county indicator -->
<div class="map-hover-indicator">
{#if hoveredCountyName}
<span
class="text-lg font-semibold text-primary"
in:fade={{ duration: 120 }}
>
{hoveredCountyName}
</span>
{:else}
<span class="text-sm text-base-content/40">Click a county to see local prices</span>
{/if}
</div>
<!-- THE SVG MAP - PRESERVED EXACTLY AS-IS -->
<div class="flex justify-center">
{#if browser && stateCounties.length > 0} {#if browser && stateCounties.length > 0}
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
@@ -130,36 +262,123 @@
{/each} {/each}
</svg> </svg>
{:else} {:else}
<div class="w-full max-w-2xl h-[400px] bg-gray-200 animate-pulse rounded-lg flex justify-center items-center"> <!-- Skeleton loader for map -->
<p>Loading county map...</p> <div class="w-full max-w-2xl h-64 sm:h-80 skeleton-box flex items-center justify-center">
<span class="loading loading-spinner loading-lg text-primary"></span>
</div> </div>
{/if} {/if}
</div> </div>
</div>
</section>
{/if}
<!-- ============================================================ -->
<!-- COUNTY NAVIGATION GRID -->
<!-- ============================================================ -->
{#if gridVisible}
<section class="pb-10 md:pb-14 px-2" in:fly={{ y: 20, duration: 400 }}>
<h2 class="text-2xl sm:text-3xl font-bold text-center text-base-content mb-2">
Counties in {stateData.name}
</h2>
<p class="text-base text-base-content/60 text-center mb-6 sm:mb-8">
Select a county to view local heating oil dealers and prices
</p>
<!-- Counties List -->
<div class="mt-4">
<h2 class="text-xl font-semibold mb-2 text-center">Counties:</h2>
{#if loading} {#if loading}
<p class="text-center">Loading counties...</p> <!-- Loading skeleton grid -->
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 sm:gap-4 max-w-4xl mx-auto">
{#each Array(8) as _, i}
<div class="skeleton-box h-20 sm:h-24 stagger-{(i % 6) + 1} opacity-0 animate-fade-in"></div>
{/each}
</div>
{:else if error} {:else if error}
<p class="text-center text-error">Error: {error}</p> <!-- Error alert -->
<div class="max-w-lg mx-auto">
<div class="alert alert-error shadow-sm">
<svg xmlns="http://www.w3.org/2000/svg" class="stroke-current shrink-0 h-6 w-6" fill="none" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<div>
<h3 class="font-bold">Could not load counties</h3>
<p class="text-sm">{error}</p>
</div>
</div>
</div>
{:else if filteredCounties.length === 0}
<!-- Empty state -->
<div class="text-center py-8">
<MapPin size={40} class="mx-auto text-base-content/30 mb-3" />
<p class="text-base-content/60 text-lg">No counties found for this state.</p>
</div>
{:else} {:else}
<div class="flex flex-col items-center gap-2"> <!-- County cards grid -->
{#each filteredCounties as county} <div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 sm:gap-4 max-w-4xl mx-auto">
<a href="/{stateSlug}/{county.id}" class="text-center text-blue-600 hover:underline block">{county.name}</a> {#each filteredCounties as county, i}
{@const svgId = apiNameToSvgId(county.name)}
{@const isHovered = hoveredCounty === svgId}
<a
href="/{stateSlug}/{county.id}"
class="county-card stagger-{(i % 6) + 1} opacity-0 animate-fade-in-up group
flex items-center gap-3"
class:is-highlighted={isHovered}
aria-label="View heating oil prices in {county.name}"
on:mouseenter={() => handleCardEnter(county)}
on:mouseleave={handleMouseLeave}
on:click|preventDefault={() => handleCardClick(county)}
>
<!-- County icon -->
<div class="flex-shrink-0 w-9 h-9 sm:w-10 sm:h-10 rounded-lg flex items-center justify-center
bg-primary/10 text-primary
group-hover:bg-primary group-hover:text-white
transition-colors duration-200">
<MapPin size={18} />
</div>
<!-- County name + arrow -->
<div class="flex-1 min-w-0">
<span class="block text-sm sm:text-base font-semibold text-base-content truncate leading-tight">
{county.name}
</span>
<span class="text-xs text-base-content/40">View prices</span>
</div>
<ChevronRight
size={16}
class="flex-shrink-0 text-base-content/20 group-hover:text-primary group-hover:translate-x-0.5 transition-all"
/>
</a>
{/each} {/each}
</div> </div>
{/if} {/if}
</div> </section>
{/if}
<!-- Back Button --> <!-- ============================================================ -->
<div class="text-center mt-6"> <!-- BACK NAVIGATION (subtle, bottom) -->
<a href="/" class="btn btn-primary">Back to Map</a> <!-- ============================================================ -->
<section class="pb-8 text-center">
<a
href="/"
class="inline-flex items-center gap-1 text-sm text-base-content/50 hover:text-primary transition-colors focus:outline-none focus:ring-2 focus:ring-primary rounded px-2 py-1"
>
<ChevronLeft size={14} />
<span>Back to all states</span>
</a>
</section>
{:else if !stateData && stateSlug}
<!-- State not found -->
<div class="text-center py-16">
<div class="mb-6">
<MapPin size={48} class="mx-auto text-base-content/20 mb-4" />
<h1 class="text-3xl font-bold text-error mb-3">State Not Found</h1>
<p class="text-base-content/60 text-lg">
Could not find information for state: "{stateSlug}"
</p>
</div> </div>
{:else if !stateData && stateSlug} <!-- Check if stateData is still undefined after onMount attempted to find it --> <a href="/" class="btn btn-primary gap-1">
<div class="text-center py-10"> <ChevronLeft size={16} />
<h1 class="text-3xl font-bold text-error">State Not Found</h1> Back to All States
<p class="mt-4">Could not find information for a state with ID: "{stateSlug}".</p> </a>
<a href="/" class="btn btn-primary mt-6">Go Back to Map</a>
</div> </div>
{/if} {/if}

View File

@@ -5,6 +5,22 @@
import { newEnglandStates } from '../../../../lib/states'; import { newEnglandStates } from '../../../../lib/states';
import { api } from '$lib/api'; import { api } from '$lib/api';
import type { Listing, OilPrice, County } from '$lib/api'; import type { Listing, OilPrice, County } from '$lib/api';
import { fade, fly } from 'svelte/transition';
import {
ChevronLeft,
ChevronUp,
ChevronDown,
Flame,
Phone,
MapPin,
DollarSign,
Droplets,
Wrench,
Globe,
Clock,
Info,
AlertCircle,
} from 'lucide-svelte';
const { stateSlug, countySlug } = $page.params as { stateSlug: string; countySlug: string }; const { stateSlug, countySlug } = $page.params as { stateSlug: string; countySlug: string };
let countyData: County | null = null; let countyData: County | null = null;
@@ -15,7 +31,12 @@
let error: string | null = null; let error: string | null = null;
let listingsError: string | null = null; let listingsError: string | null = null;
let sortColumn = 'price_per_gallon'; let sortColumn = 'price_per_gallon';
let sortDirection = 'asc'; // 'asc' or 'desc' - lowest price first let sortDirection = 'asc';
// Staggered section reveal
let headerVisible = false;
let premiumVisible = false;
let marketVisible = false;
onMount(async () => { onMount(async () => {
const result = await api.state.getCounty(stateSlug, countySlug); const result = await api.state.getCounty(stateSlug, countySlug);
@@ -25,11 +46,15 @@
countyData = null; countyData = null;
} else { } else {
countyData = result.data; countyData = result.data;
// Fetch both listings and oil prices in parallel
await fetchAllPrices(); await fetchAllPrices();
} }
loading = false; loading = false;
// Stagger section reveals
headerVisible = true;
setTimeout(() => { premiumVisible = true; }, 250);
setTimeout(() => { marketVisible = true; }, 500);
}); });
async function fetchAllPrices() { async function fetchAllPrices() {
@@ -97,276 +122,685 @@
const state = newEnglandStates.find(s => s.id === stateAbbr); const state = newEnglandStates.find(s => s.id === stateAbbr);
return state ? state.name : stateAbbr; return state ? state.name : stateAbbr;
} }
/**
* Format a date string into a friendly relative or short date.
*/
function formatDate(dateStr: string | undefined | null): string {
if (!dateStr) return 'N/A';
try {
const date = new Date(dateStr);
const now = new Date();
const diffMs = now.getTime() - date.getTime();
const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
if (diffDays === 0) return 'Today';
if (diffDays === 1) return 'Yesterday';
if (diffDays < 7) return `${diffDays} days ago`;
if (diffDays < 30) {
const weeks = Math.floor(diffDays / 7);
return `${weeks} week${weeks > 1 ? 's' : ''} ago`;
}
return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' });
} catch {
return dateStr;
}
}
/**
* Format online ordering status into human-readable text.
*/
function formatOnlineOrdering(value: string): string {
if (value === 'online_only') return 'Online Only';
if (value === 'both') return 'Phone & Online';
return 'Phone Only';
}
</script> </script>
<!-- SEO -->
<svelte:head>
{#if countyData}
<title>Heating Oil Prices in {countyData.name}, {getStateName(countyData.state)} | Biz Hero</title>
<meta name="description" content="Compare heating oil and biofuel prices from local dealers in {countyData.name}, {getStateName(countyData.state)}. Find the best deals today." />
{:else}
<title>County Not Found | Biz Hero</title>
{/if}
</svelte:head>
{#if loading} {#if loading}
<div class="text-center py-10"> <!-- ============================================================ -->
<p>Loading county data...</p> <!-- LOADING STATE -->
<!-- ============================================================ -->
<div class="py-6 px-2">
<!-- Skeleton breadcrumb -->
<div class="skeleton-box h-4 w-48 mb-6"></div>
<!-- Skeleton header -->
<div class="text-center pb-6">
<div class="skeleton-box h-8 w-32 mx-auto mb-4 rounded-full"></div>
<div class="skeleton-box h-10 w-64 mx-auto mb-3"></div>
<div class="skeleton-box h-5 w-80 mx-auto"></div>
</div> </div>
<!-- Skeleton table area -->
<div class="price-section mt-4">
<div class="skeleton-box h-7 w-44 mb-4"></div>
<div class="space-y-3">
{#each Array(4) as _, i}
<div class="skeleton-box h-20 stagger-{(i % 6) + 1} opacity-0 animate-fade-in"></div>
{/each}
</div>
</div>
</div>
{:else if countyData} {:else if countyData}
<!-- Breadcrumbs -->
<nav class="breadcrumb mb-6" aria-label="Breadcrumb"> <!-- ============================================================ -->
<ul class="flex space-x-2 text-sm"> <!-- BREADCRUMB -->
<li><a href="/" class="text-blue-500 hover:underline">Home</a></li> <!-- ============================================================ -->
<li class="text-gray-500">/</li> <nav class="mb-6 px-2" aria-label="Breadcrumb">
<li><a href="/{stateSlug}" class="text-blue-500 hover:underline">{getStateName(countyData.state)}</a></li> <ol class="flex items-center gap-1 text-sm">
<li class="text-gray-500">/</li> <li>
<li class="text-gray-700 font-medium">{countyData.name}</li> <a
</ul> href="/"
class="inline-flex items-center gap-1 text-primary hover:underline focus:outline-none focus:ring-2 focus:ring-primary rounded"
>
<ChevronLeft size={14} />
<span>All States</span>
</a>
</li>
<li class="text-base-content/40" aria-hidden="true">/</li>
<li>
<a
href="/{stateSlug}"
class="text-primary hover:underline focus:outline-none focus:ring-2 focus:ring-primary rounded"
>
{getStateName(countyData.state)}
</a>
</li>
<li class="text-base-content/40" aria-hidden="true">/</li>
<li class="font-medium text-base-content" aria-current="page">{countyData.name}</li>
</ol>
</nav> </nav>
<div class="text-center py-10">
<h1 class="text-3xl font-bold">{countyData.name}</h1> <!-- ============================================================ -->
<a href="/{stateSlug}" class="btn btn-primary mt-6">Back to {getStateName(countyData.state)}</a> <!-- COUNTY HEADER -->
<!-- ============================================================ -->
{#if headerVisible}
<section class="text-center pb-4 md:pb-6 px-2" in:fly={{ y: 24, duration: 500 }}>
<!-- Accent badge -->
<div class="flex justify-center mb-4">
<div class="accent-badge">
<Flame size={18} class="text-oil-orange-500" />
<span>Heating Oil Prices</span>
</div>
</div> </div>
<!-- County name -->
<h1 class="text-3xl sm:text-4xl md:text-5xl font-bold leading-tight text-base-content mb-2 px-2">
{countyData.name}
</h1>
<!-- State context -->
<p class="text-lg sm:text-xl text-base-content/70 max-w-xl mx-auto leading-relaxed px-4 mb-1">
{getStateName(countyData.state)}
</p>
<!-- Subtitle -->
<p class="text-base text-base-content/50 max-w-xl mx-auto leading-relaxed px-4">
Compare heating oil prices from local dealers
</p>
</section>
{/if}
<!-- ============================================================ -->
<!-- LISTINGS CONTENT -->
<!-- ============================================================ -->
{#if listingsLoading} {#if listingsLoading}
<div class="flex justify-center mt-8"> <!-- Skeleton loading for listings -->
<span class="loading loading-spinner loading-lg"></span> <div class="px-2 mt-4">
<div class="price-section">
<div class="skeleton-box h-7 w-44 mb-4"></div>
<div class="space-y-3">
{#each Array(3) as _, i}
<div class="skeleton-box h-24 stagger-{(i % 6) + 1} opacity-0 animate-fade-in"></div>
{/each}
</div> </div>
</div>
</div>
{:else if listingsError} {:else if listingsError}
<div class="alert alert-error mt-8"> <!-- Error state -->
<span>{listingsError}</span> <div class="max-w-lg mx-auto px-2 mt-4">
<div class="alert alert-error shadow-sm">
<AlertCircle size={20} />
<div>
<h3 class="font-bold">Could not load dealer prices</h3>
<p class="text-sm">{listingsError}</p>
</div> </div>
</div>
</div>
{:else} {:else}
<!-- Premium Dealers Section -->
<div class="mt-8"> <!-- ============================================================ -->
<h2 class="text-2xl font-bold mb-4">Premium Dealers</h2> <!-- PREMIUM DEALERS SECTION -->
<!-- ============================================================ -->
{#if premiumVisible}
<section class="px-2 mt-4" in:fly={{ y: 20, duration: 400 }}>
<div class="price-section">
<!-- Section header -->
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 mb-4">
<div>
<h2 class="text-2xl sm:text-3xl font-bold text-base-content flex items-center gap-2">
<div class="value-icon !w-9 !h-9 sm:!w-10 sm:!h-10 flex-shrink-0">
<DollarSign size={20} />
</div>
Premium Dealers
</h2>
<p class="text-base text-base-content/50 mt-1">
Verified local dealers with current pricing
</p>
</div>
{#if listings.length > 0}
<div class="text-sm text-base-content/40">
{listings.length} dealer{listings.length !== 1 ? 's' : ''} listed
</div>
{/if}
</div>
{#if listings.length === 0} {#if listings.length === 0}
<div class="text-center py-6"> <!-- Empty state -->
<p class="text-gray-600">No premium dealers listed for this county yet.</p> <div class="text-center py-10">
<div class="value-icon mx-auto mb-4">
<Flame size={28} />
</div>
<p class="text-lg font-semibold text-base-content mb-1">No premium dealers listed yet</p>
<p class="text-base text-base-content/50">Check back soon for local dealer pricing.</p>
</div> </div>
{:else} {:else}
<!-- Sort Controls -->
<div class="mb-4 flex flex-wrap gap-2"> <!-- ======================== -->
<select class="select select-bordered select-sm" bind:value={sortColumn} on:change={sortListings}> <!-- DESKTOP TABLE -->
<option value="company_name">Company</option> <!-- ======================== -->
<div class="hidden lg:block">
<div class="price-table-wrap">
<table class="w-full">
<thead>
<tr class="border-b border-base-300 bg-base-200/50">
<th class="text-left px-4 py-3">
<button
class="sort-header inline-flex items-center gap-1"
class:is-active={sortColumn === 'company_name'}
on:click={() => handleSort('company_name')}
>
Company
{#if sortColumn === 'company_name'}
{#if sortDirection === 'asc'}
<ChevronUp size={14} />
{:else}
<ChevronDown size={14} />
{/if}
{/if}
</button>
</th>
<th class="text-left px-4 py-3">
<button
class="sort-header inline-flex items-center gap-1"
class:is-active={sortColumn === 'town'}
on:click={() => handleSort('town')}
>
Town
{#if sortColumn === 'town'}
{#if sortDirection === 'asc'}
<ChevronUp size={14} />
{:else}
<ChevronDown size={14} />
{/if}
{/if}
</button>
</th>
<th class="text-left px-4 py-3">
<button
class="sort-header inline-flex items-center gap-1"
class:is-active={sortColumn === 'price_per_gallon'}
on:click={() => handleSort('price_per_gallon')}
>
Price / Gal
{#if sortColumn === 'price_per_gallon'}
{#if sortDirection === 'asc'}
<ChevronUp size={14} />
{:else}
<ChevronDown size={14} />
{/if}
{/if}
</button>
</th>
<th class="text-left px-4 py-3">
<button
class="sort-header inline-flex items-center gap-1"
class:is-active={sortColumn === 'bio_percent'}
on:click={() => handleSort('bio_percent')}
>
Bio %
{#if sortColumn === 'bio_percent'}
{#if sortDirection === 'asc'}
<ChevronUp size={14} />
{:else}
<ChevronDown size={14} />
{/if}
{/if}
</button>
</th>
<th class="text-left px-4 py-3">
<button
class="sort-header inline-flex items-center gap-1"
class:is-active={sortColumn === 'service'}
on:click={() => handleSort('service')}
>
Service
{#if sortColumn === 'service'}
{#if sortDirection === 'asc'}
<ChevronUp size={14} />
{:else}
<ChevronDown size={14} />
{/if}
{/if}
</button>
</th>
<th class="text-left px-4 py-3">
<button
class="sort-header inline-flex items-center gap-1"
class:is-active={sortColumn === 'phone'}
on:click={() => handleSort('phone')}
>
Contact
{#if sortColumn === 'phone'}
{#if sortDirection === 'asc'}
<ChevronUp size={14} />
{:else}
<ChevronDown size={14} />
{/if}
{/if}
</button>
</th>
<th class="text-left px-4 py-3">
<button
class="sort-header inline-flex items-center gap-1"
class:is-active={sortColumn === 'last_edited'}
on:click={() => handleSort('last_edited')}
>
Updated
{#if sortColumn === 'last_edited'}
{#if sortDirection === 'asc'}
<ChevronUp size={14} />
{:else}
<ChevronDown size={14} />
{/if}
{/if}
</button>
</th>
</tr>
</thead>
<tbody>
{#each listings as listing, i}
<tr
class="border-b border-base-300/50 last:border-b-0
{i % 2 === 1 ? 'bg-base-200/30' : ''}
hover:bg-primary/5 transition-colors duration-100"
>
<!-- Company name -->
<td class="px-4 py-4">
<span class="text-base font-semibold text-base-content">
{listing.company_name}
</span>
</td>
<!-- Town -->
<td class="px-4 py-4">
<span class="text-sm text-base-content/70">
{listing.town || '--'}
</span>
</td>
<!-- Price (THE HERO) -->
<td class="px-4 py-4">
<div class="price-hero">
${listing.price_per_gallon.toFixed(2)}
</div>
{#if listing.price_per_gallon_cash}
<div class="price-secondary mt-0.5">
Cash: ${listing.price_per_gallon_cash.toFixed(2)}
</div>
{/if}
</td>
<!-- Bio % -->
<td class="px-4 py-4">
<div class="inline-flex items-center gap-1 text-sm text-base-content/70">
<Droplets size={14} class="text-primary/60" />
{listing.bio_percent}%
</div>
</td>
<!-- Service -->
<td class="px-4 py-4">
{#if listing.service}
<span class="inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-xs font-semibold bg-success/15 text-success">
<Wrench size={12} />
Yes
</span>
{:else}
<span class="inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-xs font-semibold bg-base-300/50 text-base-content/40">
No
</span>
{/if}
</td>
<!-- Contact -->
<td class="px-4 py-4">
<div class="space-y-1">
{#if listing.phone}
<a
href="tel:{listing.phone}"
class="inline-flex items-center gap-1 text-sm text-primary hover:underline font-medium"
>
<Phone size={13} />
{listing.phone}
</a>
{:else}
<span class="text-sm text-base-content/40">No phone</span>
{/if}
<div class="text-xs text-base-content/40 flex items-center gap-1">
<Globe size={11} />
{formatOnlineOrdering(listing.online_ordering)}
</div>
</div>
</td>
<!-- Last Updated -->
<td class="px-4 py-4">
<span class="text-sm text-base-content/50 flex items-center gap-1">
<Clock size={13} />
{formatDate(listing.last_edited)}
</span>
</td>
</tr>
{/each}
</tbody>
</table>
</div>
</div>
<!-- ======================== -->
<!-- MOBILE SORT CONTROLS -->
<!-- ======================== -->
<div class="lg:hidden mb-4 flex items-center gap-2">
<label for="mobile-sort" class="text-sm font-medium text-base-content/60 flex-shrink-0">Sort by:</label>
<select
id="mobile-sort"
class="select select-bordered select-sm flex-1 bg-base-100 text-base-content text-sm"
bind:value={sortColumn}
on:change={sortListings}
>
<option value="price_per_gallon">Price (Low to High)</option>
<option value="company_name">Company Name</option>
<option value="town">Town</option> <option value="town">Town</option>
<option value="price_per_gallon">Price per Gallon</option>
<option value="bio_percent">Bio %</option> <option value="bio_percent">Bio %</option>
<option value="service">Service</option> <option value="service">Service Available</option>
<option value="phone">Contact</option>
<option value="last_edited">Last Updated</option> <option value="last_edited">Last Updated</option>
</select> </select>
<button class="btn btn-sm" on:click={() => { sortDirection = sortDirection === 'asc' ? 'desc' : 'asc'; sortListings(); }}> <button
{sortDirection === 'asc' ? '↑' : '↓'} class="btn btn-sm btn-square btn-ghost border border-base-300"
on:click={() => { sortDirection = sortDirection === 'asc' ? 'desc' : 'asc'; sortListings(); }}
aria-label="Toggle sort direction"
>
{#if sortDirection === 'asc'}
<ChevronUp size={16} />
{:else}
<ChevronDown size={16} />
{/if}
</button> </button>
</div> </div>
<!-- Desktop Table View --> <!-- ======================== -->
<div class="hidden md:block overflow-x-auto"> <!-- MOBILE CARDS -->
<table class="table table-zebra w-full"> <!-- ======================== -->
<thead> <div class="lg:hidden space-y-3">
<tr> {#each listings as listing, i}
<th class="cursor-pointer hover:bg-base-200" on:click={() => handleSort('company_name')}> <div class="listing-card stagger-{(i % 6) + 1} opacity-0 animate-fade-in-up">
Company <!-- Top row: Company + Price -->
{#if sortColumn === 'company_name'} <div class="flex items-start justify-between gap-3 mb-3">
{sortDirection === 'asc' ? '↑' : '↓'} <div class="min-w-0 flex-1">
{/if} <h3 class="text-lg font-bold text-base-content leading-tight truncate">
</th>
<th class="cursor-pointer hover:bg-base-200" on:click={() => handleSort('town')}>
Town
{#if sortColumn === 'town'}
{sortDirection === 'asc' ? '↑' : '↓'}
{/if}
</th>
<th class="cursor-pointer hover:bg-base-200" on:click={() => handleSort('price_per_gallon')}>
Price per Gallon
{#if sortColumn === 'price_per_gallon'}
{sortDirection === 'asc' ? '↑' : '↓'}
{/if}
</th>
<th class="cursor-pointer hover:bg-base-200" on:click={() => handleSort('bio_percent')}>
Bio %
{#if sortColumn === 'bio_percent'}
{sortDirection === 'asc' ? '↑' : '↓'}
{/if}
</th>
<th class="cursor-pointer hover:bg-base-200" on:click={() => handleSort('service')}>
Service
{#if sortColumn === 'service'}
{sortDirection === 'asc' ? '↑' : '↓'}
{/if}
</th>
<th class="cursor-pointer hover:bg-base-200" on:click={() => handleSort('phone')}>
Contact
{#if sortColumn === 'phone'}
{sortDirection === 'asc' ? '↑' : '↓'}
{/if}
</th>
<th class="cursor-pointer hover:bg-base-200" on:click={() => handleSort('last_edited')}>
Last Updated
{#if sortColumn === 'last_edited'}
{sortDirection === 'asc' ? '↑' : '↓'}
{/if}
</th>
</tr>
</thead>
<tbody>
{#each listings as listing}
<tr>
<td>{listing.company_name}</td>
<td>{listing.town || 'N/A'}</td>
<td>
<div class="text-sm">
<div><strong>Card:</strong> ${listing.price_per_gallon.toFixed(2)}</div>
<div><strong>Cash:</strong> {listing.price_per_gallon_cash ? `$${listing.price_per_gallon_cash.toFixed(2)}` : 'N/A'}</div>
</div>
</td>
<td>{listing.bio_percent}%</td>
<td>
{#if listing.service}
<span class="badge badge-success">Yes</span>
{:else}
<span class="badge badge-neutral">No</span>
{/if}
</td>
<td>
<div class="text-sm">
{#if listing.phone}
<div><strong>Phone:</strong> <a href="tel:{listing.phone}" class="text-blue-600 hover:underline">{listing.phone}</a></div>
{:else}
<div><strong>Phone:</strong> N/A</div>
{/if}
<div>
<strong>Online:</strong>
{#if listing.online_ordering === 'none'}
No
{:else if listing.online_ordering === 'online_only'}
Online Only
{:else if listing.online_ordering === 'both'}
Both
{/if}
</div>
</div>
</td>
<td>{listing.last_edited ? new Date(listing.last_edited).toLocaleDateString() : 'N/A'}</td>
</tr>
{/each}
</tbody>
</table>
</div>
<!-- Mobile Card View -->
<div class="block md:hidden space-y-4">
{#each listings as listing}
<div class="card bg-base-100 shadow-lg">
<div class="card-body p-4">
<h3 class="card-title text-lg font-bold">
{listing.company_name} {listing.company_name}
{#if listing.town}
<br><small class="text-gray-500 font-normal">{listing.town}</small>
{/if}
</h3> </h3>
<div class="grid grid-cols-2 gap-2 text-sm"> {#if listing.town}
<div> <p class="text-sm text-base-content/50 flex items-center gap-1 mt-0.5">
<span class="font-semibold">Card Price:</span><br> <MapPin size={13} />
{listing.town}
</p>
{/if}
</div>
<div class="text-right flex-shrink-0">
<div class="price-hero !text-2xl">
${listing.price_per_gallon.toFixed(2)} ${listing.price_per_gallon.toFixed(2)}
</div> </div>
<div> <div class="text-xs text-base-content/40 mt-0.5">per gallon</div>
<span class="font-semibold">Cash Price:</span><br>
{listing.price_per_gallon_cash ? `$${listing.price_per_gallon_cash.toFixed(2)}` : 'N/A'}
</div> </div>
<div>
<span class="font-semibold">Bio %:</span><br>
{listing.bio_percent}%
</div> </div>
<div>
<span class="font-semibold">Service:</span><br> <!-- Cash price callout (if different) -->
{#if listing.price_per_gallon_cash}
<div class="flex items-center gap-2 mb-3 px-3 py-2 rounded-lg bg-success/8 border border-success/15">
<DollarSign size={15} class="text-success flex-shrink-0" />
<span class="text-sm font-semibold text-base-content">
Cash Price: ${listing.price_per_gallon_cash.toFixed(2)}/gal
</span>
</div>
{/if}
<!-- Details grid -->
<div class="grid grid-cols-2 gap-x-4 gap-y-2 text-sm border-t border-base-300/50 pt-3">
<!-- Bio % -->
<div class="flex items-center gap-1.5">
<Droplets size={14} class="text-primary/60 flex-shrink-0" />
<span class="text-base-content/60">Bio:</span>
<span class="font-medium text-base-content">{listing.bio_percent}%</span>
</div>
<!-- Service -->
<div class="flex items-center gap-1.5">
<Wrench size={14} class="text-base-content/40 flex-shrink-0" />
<span class="text-base-content/60">Service:</span>
{#if listing.service} {#if listing.service}
<span class="badge badge-success badge-sm">Yes</span> <span class="font-medium text-success">Yes</span>
{:else} {:else}
<span class="badge badge-neutral badge-sm">No</span> <span class="text-base-content/40">No</span>
{/if} {/if}
</div> </div>
<div>
<span class="font-semibold">Contact:</span><br> <!-- Online ordering -->
<div class="flex items-center gap-1.5">
<Globe size={14} class="text-base-content/40 flex-shrink-0" />
<span class="text-base-content/60">Order:</span>
<span class="font-medium text-base-content">{formatOnlineOrdering(listing.online_ordering)}</span>
</div>
<!-- Last updated -->
<div class="flex items-center gap-1.5">
<Clock size={14} class="text-base-content/40 flex-shrink-0" />
<span class="text-base-content/60">{formatDate(listing.last_edited)}</span>
</div>
</div>
<!-- Phone CTA -->
{#if listing.phone} {#if listing.phone}
<a href="tel:{listing.phone}" class="text-blue-600 hover:underline text-sm">{listing.phone}</a><br> <div class="mt-3 pt-3 border-t border-base-300/50">
{:else} <a
N/A<br> href="tel:{listing.phone}"
class="inline-flex items-center gap-2 px-4 py-2.5 rounded-lg
bg-primary/10 text-primary font-semibold text-sm
hover:bg-primary/20 active:bg-primary/30
transition-colors duration-150 w-full justify-center sm:w-auto"
>
<Phone size={16} />
{listing.phone}
</a>
</div>
{/if} {/if}
<small>
Online:
{#if listing.online_ordering === 'none'}
No
{:else if listing.online_ordering === 'online_only'}
Online Only
{:else if listing.online_ordering === 'both'}
Both
{/if}
</small>
</div>
<div>
<span class="font-semibold">Last Updated:</span><br>
<small>{listing.last_edited ? new Date(listing.last_edited).toLocaleDateString() : 'N/A'}</small>
</div>
</div>
</div>
</div> </div>
{/each} {/each}
</div> </div>
{/if} {/if}
</div> </div>
</section>
{/if}
<!-- Market Prices Section (scraped oil prices) -->
{#if oilPrices.length > 0}
<div class="mt-12">
<h2 class="text-2xl font-bold mb-4">Market Prices</h2>
<!-- Desktop Table View --> <!-- ============================================================ -->
<div class="hidden md:block overflow-x-auto"> <!-- MARKET PRICES SECTION (scraped data) -->
<table class="table w-full"> <!-- ============================================================ -->
{#if marketVisible && oilPrices.length > 0}
<section class="px-2 mt-6 sm:mt-8" in:fly={{ y: 20, duration: 400 }}>
<div class="price-section">
<!-- Section header -->
<div class="mb-4">
<h2 class="text-2xl sm:text-3xl font-bold text-base-content flex items-center gap-2">
<div class="value-icon !w-9 !h-9 sm:!w-10 sm:!h-10 flex-shrink-0">
<Flame size={20} />
</div>
Market Prices
</h2>
<div class="info-note mt-2">
<Info size={14} class="flex-shrink-0" />
<span>Market prices collected from public sources</span>
</div>
</div>
<!-- Desktop table -->
<div class="hidden md:block">
<div class="price-table-wrap">
<table class="w-full">
<thead> <thead>
<tr> <tr class="border-b border-base-300 bg-base-200/50">
<th>Company Name</th> <th class="text-left px-4 py-3">
<th>Price</th> <span class="sort-header">Company</span>
<th>Date Posted</th> </th>
<th class="text-left px-4 py-3">
<span class="sort-header">Price / Gal</span>
</th>
<th class="text-left px-4 py-3">
<span class="sort-header">Date</span>
</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{#each oilPrices as op} {#each oilPrices as op, i}
<tr> <tr
<td>{op.name || 'Unknown'}</td> class="border-b border-base-300/50 last:border-b-0
<td>{op.price != null ? `$${op.price.toFixed(2)}` : 'N/A'}</td> {i % 2 === 1 ? 'bg-base-200/30' : ''}
<td>{op.date || 'N/A'}</td> hover:bg-primary/5 transition-colors duration-100"
>
<td class="px-4 py-3">
<span class="text-base font-semibold text-base-content">
{op.name || 'Unknown'}
</span>
</td>
<td class="px-4 py-3">
<span class="price-hero !text-xl">
{op.price != null ? `$${op.price.toFixed(2)}` : 'N/A'}
</span>
</td>
<td class="px-4 py-3">
<span class="text-sm text-base-content/50 flex items-center gap-1">
<Clock size={13} />
{op.date || 'N/A'}
</span>
</td>
</tr> </tr>
{/each} {/each}
</tbody> </tbody>
</table> </table>
</div> </div>
<!-- Mobile Card View -->
<div class="block md:hidden space-y-3">
{#each oilPrices as op}
<div class="card bg-base-100 shadow">
<div class="card-body p-3">
<div class="flex justify-between items-center">
<span class="font-semibold">{op.name || 'Unknown'}</span>
<span class="text-lg font-bold">{op.price != null ? `$${op.price.toFixed(2)}` : 'N/A'}</span>
</div> </div>
<div class="text-sm text-gray-500">
Posted: {op.date || 'N/A'} <!-- Mobile cards -->
<div class="md:hidden space-y-3">
{#each oilPrices as op, i}
<div class="listing-card stagger-{(i % 6) + 1} opacity-0 animate-fade-in-up">
<div class="flex items-center justify-between gap-3">
<div class="min-w-0 flex-1">
<span class="text-base font-semibold text-base-content block truncate">
{op.name || 'Unknown'}
</span>
<span class="text-xs text-base-content/40 flex items-center gap-1 mt-0.5">
<Clock size={11} />
{op.date || 'N/A'}
</span>
</div>
<div class="price-hero !text-2xl flex-shrink-0">
{op.price != null ? `$${op.price.toFixed(2)}` : 'N/A'}
</div> </div>
</div> </div>
</div> </div>
{/each} {/each}
</div> </div>
</div> </div>
</section>
{/if} {/if}
<!-- Empty state when both sections are empty -->
{#if listings.length === 0 && oilPrices.length === 0} <!-- ============================================================ -->
<div class="text-center py-8 mt-4"> <!-- EMPTY STATE (when both sections are empty) -->
<p class="text-lg text-gray-600">No pricing data available for this county yet.</p> <!-- ============================================================ -->
{#if listings.length === 0 && oilPrices.length === 0 && premiumVisible}
<section class="text-center py-12 px-2" in:fade={{ duration: 300 }}>
<div class="value-icon mx-auto mb-4">
<DollarSign size={28} />
</div> </div>
<p class="text-xl font-semibold text-base-content mb-2">No pricing data available yet</p>
<p class="text-base text-base-content/50 max-w-sm mx-auto">
We are working on gathering pricing information for {countyData.name}. Check back soon!
</p>
</section>
{/if} {/if}
{/if} {/if}
<!-- ============================================================ -->
<!-- BACK NAVIGATION (subtle, bottom) -->
<!-- ============================================================ -->
<section class="pb-8 pt-6 text-center px-2">
<a
href="/{stateSlug}"
class="inline-flex items-center gap-1 text-sm text-base-content/50 hover:text-primary transition-colors focus:outline-none focus:ring-2 focus:ring-primary rounded px-2 py-1"
>
<ChevronLeft size={14} />
<span>Back to {getStateName(countyData.state)}</span>
</a>
</section>
{:else if error} {:else if error}
<div class="text-center py-10"> <!-- ============================================================ -->
<h1 class="text-3xl font-bold text-error">County Not Found</h1> <!-- ERROR STATE — County Not Found -->
<p class="mt-4">{error}</p> <!-- ============================================================ -->
<a href="/" class="btn btn-primary mt-6">Go Back to Map</a> <div class="text-center py-16 px-2">
<div class="mb-6">
<div class="value-icon mx-auto mb-4">
<AlertCircle size={28} />
</div>
<h1 class="text-3xl font-bold text-error mb-3">County Not Found</h1>
<p class="text-base-content/60 text-lg max-w-md mx-auto">
{error}
</p>
</div>
<a href="/{stateSlug}" class="inline-flex items-center gap-1 text-primary hover:underline font-medium">
<ChevronLeft size={16} />
Back to state
</a>
</div> </div>
{/if} {/if}

View File

@@ -51,21 +51,58 @@ const config = {
theme: { theme: {
screens: { screens: {
'sm': '640px', 'sm': '640px',
// => @media (min-width: 640px) { ... }
'md': '768px', 'md': '768px',
// => @media (min-width: 768px) { ... }
'lg': '1024px', 'lg': '1024px',
// => @media (min-width: 1024px) { ... }
'xl': '1280px', 'xl': '1280px',
// => @media (min-width: 1280px) { ... }
'2xl': '1536px', '2xl': '1536px',
// => @media (min-width: 1536px) { ... }
}, },
extend: {
colors: {
'oil-orange': {
50: '#fff7ed',
100: '#ffedd5',
200: '#fed7aa',
300: '#fdba74',
400: '#fb923c',
500: '#ff6600',
600: '#e55a00',
700: '#c2410c',
800: '#9a3412',
900: '#7c2d12',
},
'oil-blue': {
50: '#eff6ff',
100: '#dbeafe',
200: '#bfdbfe',
300: '#93c5fd',
400: '#60a5fa',
500: '#0256bf',
600: '#0248a3',
700: '#1d4ed8',
800: '#14368f',
900: '#1e3a5f',
},
},
animation: {
'fade-in-up': 'fadeInUp 0.6s ease-out forwards',
'fade-in': 'fadeIn 0.5s ease-out forwards',
'float': 'float 6s ease-in-out infinite',
},
keyframes: {
fadeInUp: {
'0%': { opacity: '0', transform: 'translateY(24px)' },
'100%': { opacity: '1', transform: 'translateY(0)' },
},
fadeIn: {
'0%': { opacity: '0' },
'100%': { opacity: '1' },
},
float: {
'0%, 100%': { transform: 'translateY(0)' },
'50%': { transform: 'translateY(-8px)' },
},
},
},
}, },
}; };