setMenuOpen(false)}
+ />
+ )}
+ >
+ );
+}
diff --git a/apps/dashboard/src/components/Layout.tsx b/apps/dashboard/src/components/Layout.tsx
index 7bdd642..7aecfde 100644
--- a/apps/dashboard/src/components/Layout.tsx
+++ b/apps/dashboard/src/components/Layout.tsx
@@ -3,25 +3,10 @@ import { NavLink } from 'react-router-dom';
import { useAuth } from '../auth/AuthContext';
import { useWorkspace } from '../state/WorkspaceContext';
-import { isDark, toggleTheme } from '../ui/theme';
+import { ThemeToggle } from '../ui/theme-toggle';
import { useToast } from '../ui/toast';
import { ErrorNote, Modal } from './ui';
-function ThemeToggle() {
- const [dark, setDark] = useState(isDark);
- return (
-
setDark(toggleTheme())}
- >
- {dark ? '☀' : '☾'}
-
- );
-}
-
function Switchers() {
const ws = useWorkspace();
const toast = useToast();
diff --git a/apps/dashboard/src/main.tsx b/apps/dashboard/src/main.tsx
index df6f805..435ab94 100644
--- a/apps/dashboard/src/main.tsx
+++ b/apps/dashboard/src/main.tsx
@@ -6,7 +6,6 @@ import { BrowserRouter } from 'react-router-dom';
import { App } from './App';
import { AuthProvider } from './auth/AuthContext';
import './theme.css';
-import './styles.css';
import { ToastProvider } from './ui/toast';
import { initTheme } from './ui/theme';
diff --git a/apps/dashboard/src/pages/GuestHomePage.tsx b/apps/dashboard/src/pages/GuestHomePage.tsx
new file mode 100644
index 0000000..276de9d
--- /dev/null
+++ b/apps/dashboard/src/pages/GuestHomePage.tsx
@@ -0,0 +1,303 @@
+import type { ReactNode } from 'react';
+import { useLocation } from 'react-router-dom';
+
+import { useAuth } from '../auth/AuthContext';
+import { GuestNav } from '../components/GuestNav';
+
+/**
+ * Public landing page — the default screen for anyone who isn't signed in.
+ * Sign-in lives in the topbar (right side) rather than on a dedicated login
+ * screen; both auth entry points carry the path the visitor asked for so a deep
+ * link survives the Keycloak round trip.
+ */
+
+const FEATURES: { title: string; body: string; glyph: string }[] = [
+ {
+ glyph: '⏻',
+ title: 'Kill switch',
+ body: 'Turn any tool off in production instantly — no redeploy. Define the fallback users see: hide it, show a notice, or run an alternate path.',
+ },
+ {
+ glyph: '◐',
+ title: 'Gradual rollouts',
+ body: 'Ship to 5%, then 25%, then everyone. Bucketing is deterministic per user, so nobody flickers between versions.',
+ },
+ {
+ glyph: '◱',
+ title: 'Targeting & segments',
+ body: 'Reusable segments by plan, region, or any trait you send. The same rule model everywhere — no invented jargon.',
+ },
+ {
+ glyph: '⚙',
+ title: 'Remote config & prompts',
+ body: 'Limits, endpoints, model params, and prompts edited live. Every change is versioned with a diff and one-click rollback.',
+ },
+ {
+ glyph: '⚡',
+ title: 'Edge delivery',
+ body: 'Reads are served from the edge and keep serving the last published ruleset even if the control plane is down.',
+ },
+ {
+ glyph: '≡',
+ title: 'Audit trail',
+ body: 'Who flipped what, when, and why — per flag and org-wide, with scoped per-environment API keys and roles.',
+ },
+];
+
+const STEPS: { step: string; title: string; body: string }[] = [
+ {
+ step: '1',
+ title: 'Register your tools',
+ body: 'Create a project and get dev, staging, and production environments with their own keys.',
+ },
+ {
+ step: '2',
+ title: 'Guard them in code',
+ body: 'The backend SDK evaluates locally from an in-memory ruleset, so a flag check costs ~0ms and survives outages.',
+ },
+ {
+ step: '3',
+ title: 'Control from the dashboard',
+ body: 'Flip a switch or edit config; connected SDKs pick the change up within seconds.',
+ },
+];
+
+// Real `@toggleflow/sdk` API (server client) — keep in step with packages/sdk-js.
+const SNIPPET = `import { createServerClient } from '@toggleflow/sdk';
+
+const flags = createServerClient({
+ edgeUrl: 'https://edge.toggleflow.dev',
+ environmentId: process.env.TF_ENV_ID,
+ serverKey: process.env.TF_SERVER_KEY,
+});
+
+app.post('/summarize', (req, res) => {
+ const flag = 'tool.summarize';
+ if (!flags.isEnabled(flag, req.user)) {
+ return res.status(503).json(flags.getFallback(flag));
+ }
+ const { model } = flags.getConfig(flag) ?? {};
+ // …run the tool
+});`;
+
+function MockRow({
+ flagKey,
+ name,
+ state,
+}: {
+ flagKey: string;
+ name: string;
+ state: 'on' | 'off' | 'rollout';
+}) {
+ const chip =
+ state === 'on' ? (
+
ON
+ ) : state === 'off' ? (
+
OFF
+ ) : (
+
25%
+ );
+ const glyph = state === 'on' ? '●' : state === 'off' ? '○' : '◐';
+ const tone = state === 'on' ? 'text-on' : state === 'off' ? 'text-off' : 'text-rollout';
+ return (
+
+
+ {glyph}
+
+
+ {flagKey}
+ {name}
+
+ {chip}
+
+ );
+}
+
+function Section({
+ id,
+ eyebrow,
+ title,
+ children,
+}: {
+ id: string;
+ eyebrow: string;
+ title: string;
+ children: ReactNode;
+}) {
+ return (
+
+
+
+ {eyebrow}
+
+
{title}
+ {children}
+
+
+ );
+}
+
+export function GuestHomePage() {
+ const { login, signup } = useAuth();
+ const location = useLocation();
+ // A visitor who landed on /tools/abc gets sent back there after signing in.
+ const returnTo = `${location.pathname}${location.search}`;
+
+ return (
+
+
+ Skip to content
+
+
+
+ {/* The nav is fixed, so the hero owns the clearance under it. */}
+
+
+
+
+
+ VeloBits Control Plane
+
+
+ A remote control plane for every tool in your app
+
+
+ Kill switches, gradual rollouts, targeting, and live configuration — changed from a
+ dashboard and delivered in seconds. No redeploy, no waiting on a release.
+
+
+ void signup(returnTo)}
+ >
+ Get started free
+
+ void login(returnTo)}>
+ Sign in
+
+
+
+ Free tier · Set up in about 15 minutes · Flat, predictable pricing
+
+
+
+
+
+
+ ●
+
+ fixmytext · production
+
+ ruleset v418
+
+
+
+
+
+
+ 254 flags · 246 on · 5 off · 3 rolling out
+
+
+
+
+
+
+
+ {FEATURES.map((feature) => (
+
+
+ {feature.glyph}
+
+ {feature.title}
+ {feature.body}
+
+ ))}
+
+
+
+
+
+
+ {STEPS.map((item) => (
+
+
+ {item.step}
+
+
+ {item.title}
+ {item.body}
+
+
+ ))}
+
+
+ {SNIPPET}
+
+
+
+
+
+
+
+
Flags that know what they control
+
+ A flag can carry its tool's route, owner, and model parameters — not just a
+ bare boolean.
+
+
+
+
Config and prompts, versioned
+
+ Prompts and model params are configuration: edit, diff, and roll back without a
+ deploy.
+
+
+
+
The read path is the promise
+
+ Evaluation runs at the edge or in your process, so your app keeps working even when
+ ours doesn't.
+
+
+
+
+
+
+ Take back control of production
+
+ Create an organization, add your first application, and flip a real flag in minutes.
+
+
+ void signup(returnTo)}
+ >
+ Get started free
+
+ void login(returnTo)}>
+ Sign in
+
+
+
+
+
+
+
+ );
+}
diff --git a/apps/dashboard/src/pages/LoginPage.tsx b/apps/dashboard/src/pages/LoginPage.tsx
deleted file mode 100644
index 4e33df3..0000000
--- a/apps/dashboard/src/pages/LoginPage.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-import { useAuth } from '../auth/AuthContext';
-
-export function LoginPage() {
- const { login, signup } = useAuth();
- return (
-
-
-
ToggleFlow
-
- Kill switches, gradual rollouts, and live configuration for every tool in your app.
-
-
- void login()}>
- Sign in
-
- void signup()}>
- Create account
-
-
-
-
- );
-}
diff --git a/apps/dashboard/src/styles.css b/apps/dashboard/src/styles.css
index 3857b66..6592261 100644
--- a/apps/dashboard/src/styles.css
+++ b/apps/dashboard/src/styles.css
@@ -363,20 +363,3 @@ tr.clickable {
height: 100vh;
gap: 12px;
}
-.login-card {
- background: var(--panel);
- border: 1px solid var(--border);
- border-radius: 12px;
- padding: 40px;
- text-align: center;
- width: 360px;
-}
-.login-card h1 {
- color: var(--accent);
-}
-.login-card .actions {
- display: flex;
- flex-direction: column;
- gap: 8px;
- margin-top: 20px;
-}
diff --git a/apps/dashboard/src/theme.css b/apps/dashboard/src/theme.css
index af2323a..a0b77dd 100644
--- a/apps/dashboard/src/theme.css
+++ b/apps/dashboard/src/theme.css
@@ -1,5 +1,14 @@
@import 'tailwindcss';
+/*
+ * The hand-written component CSS goes into Tailwind's `components` layer, so
+ * utilities (a later layer) override it without `!important` while it still
+ * beats Preflight. Unlayered, `button { border-radius; padding }` and
+ * `a { color }` would win over every utility. Imported here rather than in
+ * main.tsx — a second unlayered import would defeat this.
+ */
+@import './styles.css' layer(components);
+
/*
* VeloBits theme bridge — VSCode Dark+/Light inspired, same palette as
* fixmytext's design system (frontend/packages/design-system/theme.css +
diff --git a/apps/dashboard/src/ui/icons.tsx b/apps/dashboard/src/ui/icons.tsx
new file mode 100644
index 0000000..8f01a0f
--- /dev/null
+++ b/apps/dashboard/src/ui/icons.tsx
@@ -0,0 +1,71 @@
+import type { ReactNode, SVGProps } from 'react';
+
+export interface IconProps extends SVGProps
{
+ /** Width and height in px — icons are square. */
+ size?: number | string;
+}
+
+/**
+ * Stroke-based icon set (Feather/Lucide-style, 24×24 grid, currentColor) — the
+ * same convention as fixmytext's `@velobits/design-system` icons, copied rather
+ * than imported because that package is private and in a different workspace.
+ * Icons are decorative by default (aria-hidden); pass `aria-hidden={undefined}`
+ * plus an `aria-label` for semantic use.
+ */
+function createIcon(displayName: string, children: ReactNode) {
+ function Icon({ size = 16, ...props }: IconProps) {
+ return (
+
+ {children}
+
+ );
+ }
+ Icon.displayName = displayName;
+ return Icon;
+}
+
+export const MenuIcon = createIcon(
+ 'MenuIcon',
+ <>
+
+
+
+ >,
+);
+
+export const MoonIcon = createIcon('MoonIcon', );
+
+export const SunIcon = createIcon(
+ 'SunIcon',
+ <>
+
+
+
+
+
+
+
+
+
+ >,
+);
+
+export const XIcon = createIcon(
+ 'XIcon',
+ <>
+
+
+ >,
+);
diff --git a/apps/dashboard/src/ui/theme-toggle.tsx b/apps/dashboard/src/ui/theme-toggle.tsx
new file mode 100644
index 0000000..a1818a2
--- /dev/null
+++ b/apps/dashboard/src/ui/theme-toggle.tsx
@@ -0,0 +1,21 @@
+import { useState } from 'react';
+
+import { cn } from './cn';
+import { MoonIcon, SunIcon } from './icons';
+import { isDark, toggleTheme } from './theme';
+
+/** Light/dark switch — shared by the app shell topbar and the public guest home. */
+export function ThemeToggle({ className }: { className?: string }) {
+ const [dark, setDark] = useState(isDark);
+ return (
+ setDark(toggleTheme())}
+ >
+ {dark ? : }
+
+ );
+}
diff --git a/apps/dashboard/test/auth.test.tsx b/apps/dashboard/test/auth.test.tsx
index 1e250f4..a658f72 100644
--- a/apps/dashboard/test/auth.test.tsx
+++ b/apps/dashboard/test/auth.test.tsx
@@ -11,7 +11,6 @@ import { afterEach, describe, expect, it, vi } from 'vitest';
import { AuthProvider, getAccessToken, useAuth } from '../src/auth/AuthContext';
import { CallbackPage } from '../src/auth/CallbackPage';
import { userManager } from '../src/auth/oidc';
-import { LoginPage } from '../src/pages/LoginPage';
import { stubAuth, testUser } from './harness';
afterEach(() => {
@@ -113,8 +112,14 @@ describe('AuthProvider', () => {
renderProbe();
await waitFor(() => expect(screen.getByTestId('state').textContent).toBe('dev@velobits.test'));
+ // No argument means "land back on /" once Keycloak returns.
fireEvent.click(screen.getByText('login'));
- expect(auth.signinRedirect).toHaveBeenCalled();
+ expect(auth.signinRedirect).toHaveBeenCalledWith({ state: { returnTo: '/' } });
+
+ // signupRedirect drives a second UserManager (Keycloak's /registrations)
+ // that this module never exports, so it is only observable as "did not
+ // throw" here.
+ expect(() => fireEvent.click(screen.getByText('signup'))).not.toThrow();
fireEvent.click(screen.getByText('logout'));
expect(auth.signoutRedirect).toHaveBeenCalled();
@@ -138,23 +143,9 @@ describe('getAccessToken', () => {
});
});
-describe('LoginPage', () => {
- it('starts the sign-in and sign-up redirects', async () => {
- const auth = stubAuth({ user: null });
- render(
-
-
- ,
- );
-
- fireEvent.click(screen.getByText('Sign in'));
- expect(auth.signinRedirect).toHaveBeenCalled();
-
- // signupRedirect drives a second UserManager (Keycloak's /registrations),
- // so it is only observable as "did not throw" here.
- expect(() => fireEvent.click(screen.getByText('Create account'))).not.toThrow();
- });
-});
+// The sign-in/sign-up entry points moved to GuestHomePage when the dedicated
+// login screen was dropped; units.test.tsx covers them, including the returnTo
+// deep link that the old LoginPage had no notion of.
describe('CallbackPage', () => {
const renderCallback = () =>
diff --git a/apps/dashboard/test/units.test.tsx b/apps/dashboard/test/units.test.tsx
index 5ed93b2..e3b095b 100644
--- a/apps/dashboard/test/units.test.tsx
+++ b/apps/dashboard/test/units.test.tsx
@@ -1,12 +1,22 @@
// @vitest-environment happy-dom
import { cleanup, fireEvent, render, screen } from '@testing-library/react';
-import { afterEach, describe, expect, it, vi } from 'vitest';
+import { MemoryRouter } from 'react-router-dom';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
afterEach(cleanup);
+// The guest home only needs the auth actions; stubbing the context keeps the
+// test off the real UserManager (network + storage).
+const auth = vi.hoisted(() => ({ login: vi.fn(), signup: vi.fn() }));
+vi.mock('../src/auth/AuthContext', () => ({
+ useAuth: () => ({ user: null, loading: false, logout: vi.fn(), ...auth }),
+}));
+
import type { FlagRow } from '../src/api/client';
+import { returnToFromState, safeReturnTo } from '../src/auth/return-to';
import { diffLines } from '../src/components/diff';
import { ConfirmButton, StatusChip } from '../src/components/ui';
+import { GuestHomePage } from '../src/pages/GuestHomePage';
import { EMPTY_FILTER, filterRows } from '../src/pages/tools-filter';
describe('diffLines', () => {
@@ -101,3 +111,124 @@ describe('ConfirmButton', () => {
expect(onConfirm).toHaveBeenCalledOnce();
});
});
+
+describe('safeReturnTo', () => {
+ it('keeps in-app paths', () => {
+ expect(safeReturnTo('/tools/abc')).toBe('/tools/abc');
+ expect(safeReturnTo('/audit?actor=ns')).toBe('/audit?actor=ns');
+ });
+
+ it('rejects external, non-path, and callback targets', () => {
+ expect(safeReturnTo('//evil.example.com')).toBe('/');
+ expect(safeReturnTo('/\\evil.example.com')).toBe('/');
+ expect(safeReturnTo('https://evil.example.com')).toBe('/');
+ expect(safeReturnTo('tools/abc')).toBe('/');
+ expect(safeReturnTo(undefined)).toBe('/');
+ expect(safeReturnTo('/auth/callback')).toBe('/');
+ });
+
+ it('reads the path out of the oidc state', () => {
+ expect(returnToFromState({ returnTo: '/segments' })).toBe('/segments');
+ expect(returnToFromState({})).toBe('/');
+ expect(returnToFromState(null)).toBe('/');
+ });
+});
+
+describe('GuestHomePage', () => {
+ beforeEach(() => {
+ auth.login.mockClear();
+ auth.signup.mockClear();
+ // happy-dom keeps one document per file, so scroll offset and the fragment
+ // would leak between cases.
+ window.scroll({ top: 0 });
+ window.history.replaceState(null, '', '/');
+ });
+
+ const renderAt = (path: string) =>
+ render(
+
+
+ ,
+ );
+
+ it('is the landing page and offers sign-in without a login screen', () => {
+ renderAt('/');
+ expect(screen.getByRole('heading', { level: 1 }).textContent).toContain('control plane');
+ fireEvent.click(screen.getAllByText('Sign in')[0]!);
+ expect(auth.login).toHaveBeenCalledWith('/');
+ fireEvent.click(screen.getAllByText('Get started free')[0]!);
+ expect(auth.signup).toHaveBeenCalledWith('/');
+ });
+
+ it('carries the requested path into sign-in so deep links survive', () => {
+ renderAt('/tools/abc?env=prod');
+ fireEvent.click(screen.getAllByText('Sign in')[0]!);
+ expect(auth.login).toHaveBeenCalledWith('/tools/abc?env=prod');
+ });
+
+ it('weights the nav island past 40px of scroll', () => {
+ renderAt('/');
+ const island = document.getElementById('site-nav')!;
+ expect(island.getAttribute('data-scrolled')).toBe('false');
+ window.scroll({ top: 120 });
+ fireEvent.scroll(window);
+ expect(island.getAttribute('data-scrolled')).toBe('true');
+ window.scroll({ top: 10 });
+ fireEvent.scroll(window);
+ expect(island.getAttribute('data-scrolled')).toBe('false');
+ });
+
+ it('opens the mobile menu, then closes it on Escape and restores focus', () => {
+ renderAt('/');
+ const toggle = screen.getByRole('button', { name: 'Open navigation menu' });
+ expect(toggle.getAttribute('aria-expanded')).toBe('false');
+ expect(toggle.getAttribute('aria-controls')).toBe('mobile-menu');
+ expect(document.getElementById('mobile-menu')).toBeNull();
+
+ fireEvent.click(toggle);
+ const menu = document.getElementById('mobile-menu')!;
+ expect(toggle.getAttribute('aria-expanded')).toBe('true');
+ expect(toggle.getAttribute('aria-label')).toBe('Close navigation menu');
+ expect([...menu.querySelectorAll('a')].map((link) => link.getAttribute('href'))).toEqual([
+ '#features',
+ '#how',
+ '#why',
+ ]);
+
+ fireEvent.keyDown(document, { key: 'Escape' });
+ expect(document.getElementById('mobile-menu')).toBeNull();
+ expect(document.activeElement).toBe(toggle);
+ });
+
+ it('closes the mobile menu on an outside mousedown but not an inside one', () => {
+ renderAt('/');
+ fireEvent.click(screen.getByRole('button', { name: 'Open navigation menu' }));
+ fireEvent.mouseDown(document.getElementById('mobile-menu')!);
+ expect(document.getElementById('mobile-menu')).toBeTruthy();
+ fireEvent.mouseDown(document.body);
+ expect(document.getElementById('mobile-menu')).toBeNull();
+ });
+
+ it('carries the requested path from inside the mobile menu', () => {
+ renderAt('/tools/abc?env=prod');
+ fireEvent.click(screen.getByRole('button', { name: 'Open navigation menu' }));
+ const menu = document.getElementById('mobile-menu')!;
+ const getStarted = [...menu.querySelectorAll('button')].find(
+ (button) => button.textContent === 'Get started free',
+ )!;
+ fireEvent.click(getStarted);
+ expect(auth.signup).toHaveBeenCalledWith('/tools/abc?env=prod');
+ expect(document.getElementById('mobile-menu')).toBeNull();
+ });
+
+ it('marks the section the visitor jumped to with aria-current', () => {
+ renderAt('/');
+ const island = document.getElementById('site-nav')!;
+ const features = island.querySelector('a[href="#features"]')!;
+ const how = island.querySelector('a[href="#how"]')!;
+ expect(features.getAttribute('aria-current')).toBeNull();
+ fireEvent.click(features);
+ expect(features.getAttribute('aria-current')).toBe('location');
+ expect(how.getAttribute('aria-current')).toBeNull();
+ });
+});