OpenStock is an open-source alternative to expensive market platforms. Track real-time prices, set personalized alerts, and explore detailed company insights — built openly, for everyone, forever free.
fix(ui): accessible tabs, honest live labels, review polish
ravixalgorithm968a3fee7a4c
diff --git a/README.md b/README.mdindex 0b310bb..17f790d 100644--- a/README.md+++ b/README.md@@ -284,6 +284,8 @@ GEMINI_API_KEY=your_gemini_api_key# Inngest Signing Key (required for Vercel deployment)# Get this from your Inngest dashboard: https://app.inngest.com/env/settings/keysINNGEST_SIGNING_KEY=your_inngest_signing_key+# Required in production so sign-up can send the welcome-email event+INNGEST_EVENT_KEY=your_inngest_event_key# Market data (optional)# Several free Finnhub keys, rotated per request: each adds 60 requests/min.@@ -293,10 +295,11 @@ INNGEST_SIGNING_KEY=your_inngest_signing_key# Social sign-in (optional; each provider is hidden server-side until set)# Callback URLs: <BETTER_AUTH_URL>/api/auth/callback/google and /api/auth/callback/github-GOOGLE_CLIENT_ID=your_google_client_id-GOOGLE_CLIENT_SECRET=your_google_client_secret-GITHUB_CLIENT_ID=your_github_client_id-GITHUB_CLIENT_SECRET=your_github_client_secret+# Leave these commented out until you have real credentials: any value turns the provider on+# GOOGLE_CLIENT_ID=your_google_client_id+# GOOGLE_CLIENT_SECRET=your_google_client_secret+# GITHUB_CLIENT_ID=your_github_client_id+# GITHUB_CLIENT_SECRET=your_github_client_secret# Email (optional; Nodemailer via Gmail, consider App Passwords if 2FA)@@ -338,6 +341,8 @@ GEMINI_API_KEY=your_gemini_api_key# Inngest Signing Key (required for Vercel deployment)# Get this from your Inngest dashboard: https://app.inngest.com/env/settings/keysINNGEST_SIGNING_KEY=your_inngest_signing_key+# Required in production so sign-up can send the welcome-email event+INNGEST_EVENT_KEY=your_inngest_event_key# Market data (optional)# Several free Finnhub keys, rotated per request: each adds 60 requests/min.@@ -347,10 +352,11 @@ INNGEST_SIGNING_KEY=your_inngest_signing_key# Social sign-in (optional; each provider is hidden server-side until set)# Callback URLs: <BETTER_AUTH_URL>/api/auth/callback/google and /api/auth/callback/github-GOOGLE_CLIENT_ID=your_google_client_id-GOOGLE_CLIENT_SECRET=your_google_client_secret-GITHUB_CLIENT_ID=your_github_client_id-GITHUB_CLIENT_SECRET=your_github_client_secret+# Leave these commented out until you have real credentials: any value turns the provider on+# GOOGLE_CLIENT_ID=your_google_client_id+# GOOGLE_CLIENT_SECRET=your_google_client_secret+# GITHUB_CLIENT_ID=your_github_client_id+# GITHUB_CLIENT_SECRET=your_github_client_secret# Email (optional; Nodemailer via Gmail, consider App Passwords if 2FA)diff --git a/app/(marketing)/sponsor/page.tsx b/app/(marketing)/sponsor/page.tsxindex 54e518b..d37add9 100644--- a/app/(marketing)/sponsor/page.tsx+++ b/app/(marketing)/sponsor/page.tsx@@ -167,7 +167,11 @@ export default async function SponsorPage() {</div></div>{fundingTotal > 0 && (- <p className="num mt-4 text-muted-foreground">Running OpenStock costs about <b className="text-foreground">${fundingTotal} a month</b>.</p>+ <p className="num mt-4 text-muted-foreground">+ {FUNDING_USES.every((use) => use.monthly)+ ? <>Running OpenStock costs about <b className="text-foreground">${fundingTotal} a month</b>.</>+ : <>Known costs so far: <b className="text-foreground">${fundingTotal} a month</b>.</>}+ </p>)}</section>diff --git a/components/DataFreshness.tsx b/components/DataFreshness.tsxindex d2854c1..9651c7f 100644--- a/components/DataFreshness.tsx+++ b/components/DataFreshness.tsx@@ -1,13 +1,22 @@+'use client';++import { useEffect, useState } from "react";import { isRealtime } from "@/lib/market-data";// Honest label for how old a number is: "Live" in realtime mode, otherwise the time of the last trade.+// The time is formatted after mount, in the viewer's own time zone, so server and browser never disagree.const DataFreshness = ({ tradeTime }: { tradeTime?: number }) => {+ const [asOf, setAsOf] = useState<string | null>(null);++ useEffect(() => {+ setAsOf(tradeTime+ ? new Date(tradeTime * 1000).toLocaleString('en-US', { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' })+ : null);+ }, [tradeTime]);+if (isRealtime) {return <span className="inline-flex items-center gap-1.5 text-[12px] text-faint"><span className="live-dot" /> Live · 15s</span>;}- const asOf = tradeTime- ? new Date(tradeTime * 1000).toLocaleString('en-US', { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' })- : null;return <span className="text-[12px] text-faint">{asOf ? `As of ${asOf}` : 'Delayed'} · refreshed hourly</span>;};diff --git a/components/IndexPulse.tsx b/components/IndexPulse.tsxindex 0ef9990..ada2c94 100644--- a/components/IndexPulse.tsx+++ b/components/IndexPulse.tsx@@ -1,6 +1,4 @@-import Link from "next/link";-import { LineChart } from "lucide-react";-import ChangePill from "@/components/ChangePill";+import PulseTile from "@/components/PulseTile";import TradingViewWidget from "@/components/TradingViewWidget";import { getLiveQuotes } from "@/lib/actions/finnhub.actions";import { singleQuoteConfig } from "@/lib/constants";@@ -8,9 +6,6 @@ import { getMarket, type Market } from "@/lib/markets";const SINGLE_QUOTE = 'https://s3.tradingview.com/external-embedding/embed-widget-single-quote.js';-const formatAmount = (value: number) =>- value.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: value < 1 ? 4 : 2 });-// Four headline tiles for a market. Markets Finnhub can price get native tiles from our shared quote cache;// the rest use TradingView's quote tile, which is free for those exchanges.export default async function IndexPulse({ market = getMarket('us') }: { market?: Market }) {@@ -27,32 +22,7 @@ export default async function IndexPulse({ market = getMarket('us') }: { market?</div>);}- const quote = quotes[tile.finnhub];- const isCrypto = tile.finnhub.startsWith('BINANCE:');- return (- <Link key={tile.symbol} href={`/stocks/${encodeURIComponent(tile.finnhub)}`} className="bento-tile transition-colors hover:bg-hover/60">- <div className="bento-head">- <span className="bento-ico"><LineChart /></span>- <span className="truncate">{tile.label}</span>- <span className="mono ml-auto text-xs text-faint">{tile.finnhub.replace('BINANCE:', '')}</span>- </div>- <p className="bento-value">- {quote?.c ? (- isCrypto ? <>{formatAmount(quote.c)}<small> USDT</small></> : <><small>$</small>{formatAmount(quote.c)}</>- ) : '—'}- </p>- <div className="bento-foot">- {quote?.c ? (- <>- <ChangePill value={quote.dp} />- <span className="num truncate">{(quote.d ?? 0) > 0 ? '+' : ''}{formatAmount(quote.d ?? 0)} vs prev close</span>- </>- ) : (- <span>Quote unavailable</span>- )}- </div>- </Link>- );+ return <PulseTile key={tile.symbol} symbol={tile.finnhub} label={tile.label} initial={quotes[tile.finnhub]} />;})}</div>);diff --git a/components/PulseTile.tsx b/components/PulseTile.tsxnew file mode 100644index 0000000..5663e8e--- /dev/null+++ b/components/PulseTile.tsx@@ -0,0 +1,43 @@+'use client';++import Link from "next/link";+import { LineChart } from "lucide-react";+import ChangePill from "@/components/ChangePill";+import PriceFlash from "@/components/PriceFlash";+import { useLiveQuotes, type LiveQuote } from "@/hooks/useLiveQuotes";++const formatAmount = (value: number) =>+ value.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: value < 1 ? 4 : 2 });++// A pulse tile priced from our own quote cache. In realtime mode it refreshes on screen,+// so the "Live · 15s" label is true; in cached mode it shows the server-rendered quote.+export default function PulseTile({ symbol, label, initial }: { symbol: string; label: string; initial: LiveQuote | null }) {+ const live = useLiveQuotes([symbol]);+ const quote = live[symbol] ?? initial;+ const isCrypto = symbol.startsWith('BINANCE:');++ return (+ <Link href={`/stocks/${encodeURIComponent(symbol)}`} className="bento-tile transition-colors hover:bg-hover/60">+ <div className="bento-head">+ <span className="bento-ico"><LineChart /></span>+ <span className="truncate">{label}</span>+ <span className="mono ml-auto text-xs text-faint">{symbol.replace('BINANCE:', '')}</span>+ </div>+ <PriceFlash value={quote?.c} className="bento-value self-start">+ {quote?.c ? (+ isCrypto ? <>{formatAmount(quote.c)}<small> USDT</small></> : <><small>$</small>{formatAmount(quote.c)}</>+ ) : '—'}+ </PriceFlash>+ <div className="bento-foot">+ {quote?.c ? (+ <>+ <ChangePill value={quote.dp} />+ <span className="num truncate">{(quote.d ?? 0) > 0 ? '+' : ''}{formatAmount(quote.d ?? 0)} vs prev close</span>+ </>+ ) : (+ <span>Quote unavailable</span>+ )}+ </div>+ </Link>+ );+}diff --git a/components/forms/SocialAuthButtons.tsx b/components/forms/SocialAuthButtons.tsxindex b40cd72..767dad0 100644--- a/components/forms/SocialAuthButtons.tsx+++ b/components/forms/SocialAuthButtons.tsx@@ -36,13 +36,18 @@ const SocialAuthButtons = () => {const onClick = async (provider: 'google' | 'github') => {setPending(provider);- const result = await signInWithSocial(provider);- if (result.success && result.url) {- window.location.href = result.url;- return;+ try {+ const result = await signInWithSocial(provider);+ if (result.success && result.url) {+ window.location.href = result.url;+ return;+ }+ toast.error('Sign in failed', { description: result.error });+ } catch {+ // Network failure or a stale action after a deploy+ toast.error('Sign in failed', { description: 'Check your connection and try again.' });}setPending(null);- toast.error('Sign in failed', { description: result.error });}if (providers.length === 0) return null;diff --git a/components/shell/TabBar.tsx b/components/shell/TabBar.tsxindex 607a76d..c8b4ce9 100644--- a/components/shell/TabBar.tsx+++ b/components/shell/TabBar.tsx@@ -35,7 +35,7 @@ const TabBar = ({ onMenu }: { onMenu: () => void }) => {const pathname = usePathname();const router = useRouter();const [tabs, setTabs] = useState(() => withTab(PINNED, pathname));- const tabRefs = useRef(new Map<string, HTMLAnchorElement>());+ const tabRefs = useRef(new Map<string, HTMLDivElement>());const [glider, setGlider] = useState<{ x: number; w: number } | null>(null);// Restore tabs from the last visit (per-browser convenience only)@@ -90,28 +90,28 @@ const TabBar = ({ onMenu }: { onMenu: () => void }) => {const isStock = path.startsWith('/stocks/');const active = path === pathname;return (- <Link+ <divkey={path}- href={path}ref={(el) => { if (el) tabRefs.current.set(path, el); else tabRefs.current.delete(path); }}className={cn('tab', active && 'is-active', pinned && 'pr-4')}- aria-current={active ? 'page' : undefined}>- {path === '/dashboard' && <LayoutDashboard />}- {path === '/watchlist' && <Star />}- <span className={cn('tab-label', isStock && 'mono text-[13px]')}>{tabLabel(path)}</span>+ {/* Stretched link: the whole tab navigates, while the close button stays a real, focusable button */}+ <Link href={path} aria-current={active ? 'page' : undefined} className="flex min-w-0 flex-1 items-center gap-2 before:absolute before:inset-0 before:content-['']">+ {path === '/dashboard' && <LayoutDashboard />}+ {path === '/watchlist' && <Star />}+ <span className={cn('tab-label', isStock && 'mono text-[13px]')}>{tabLabel(path)}</span>+ </Link>{!pinned && (- <span- role="button"- tabIndex={-1}+ <button+ type="button"aria-label={`Close ${tabLabel(path)}`}- className="tab-close"- onClick={(e) => { e.preventDefault(); e.stopPropagation(); closeTab(path); }}+ className="tab-close relative z-10"+ onClick={() => closeTab(path)}><X />- </span>+ </button>)}- </Link>+ </div>);})}</div>diff --git a/components/sponsors/SponsorsBand.tsx b/components/sponsors/SponsorsBand.tsxindex ff5720b..418efe4 100644--- a/components/sponsors/SponsorsBand.tsx+++ b/components/sponsors/SponsorsBand.tsx@@ -30,6 +30,8 @@ const OpenSlot = ({ tier }: { tier: string }) => ();export default function SponsorsBand() {+ // Only Company and Partner tiers include a footer logo (see the placements on /sponsor)+ const logoSponsors = ACTIVE_SPONSORS.filter((s) => s.tier === 'company' || s.tier === 'partner');const openTiers = SPONSOR_TIERS.filter((t) => t.id === 'company' || t.id === 'partner').filter((t) => !t.slots || ACTIVE_SPONSORS.filter((s) => s.tier === t.id).length < t.slots);@@ -46,7 +48,7 @@ export default function SponsorsBand() {<div className="flex flex-col gap-2"><p className="kicker">Current sponsors</p><div className="flex flex-wrap gap-2">- {ACTIVE_SPONSORS.map((s) => <SponsorMark key={s.name} sponsor={s} />)}+ {logoSponsors.map((s) => <SponsorMark key={s.name} sponsor={s} />)}{openTiers.map((t) => <OpenSlot key={t.id} tier={t.name} />)}</div></div>diff --git a/components/watchlist/AlertsPanel.tsx b/components/watchlist/AlertsPanel.tsxindex 42d9a47..58139e4 100644--- a/components/watchlist/AlertsPanel.tsx+++ b/components/watchlist/AlertsPanel.tsx@@ -1,6 +1,7 @@"use client";import React, { useState } from "react";+import { useRouter } from "next/navigation";import { BellRing, Trash2 } from "lucide-react";import { toast } from "sonner";import { deleteAlert } from "@/lib/actions/alert.actions";@@ -24,6 +25,7 @@ const statusOf = (alert: AlertRow) => {};export default function AlertsPanel({ alerts }: { alerts: AlertRow[] }) {+ const router = useRouter();const [pendingId, setPendingId] = useState<string | null>(null);const handleDelete = async (alert: AlertRow) => {@@ -31,6 +33,7 @@ export default function AlertsPanel({ alerts }: { alerts: AlertRow[] }) {try {await deleteAlert(alert._id);toast.success(`Alert for ${alert.symbol} removed`);+ router.refresh();} catch {toast.error("Couldn’t remove the alert");} finally {diff --git a/scripts/check-env.mjs b/scripts/check-env.mjsindex e1378e7..e77f90d 100644--- a/scripts/check-env.mjs+++ b/scripts/check-env.mjs@@ -34,6 +34,7 @@ const requiredVars = {// Inngest (Background jobs, cron, AI)'INNGEST_SIGNING_KEY': 'Inngest signing key (required for Vercel deployment; get from Inngest dashboard)',+ 'INNGEST_EVENT_KEY': 'Inngest event key (required in production: sign-up sends the welcome-email event with it)',};