From d34b82a3b78d3ed49629ec7deaaefb2fcf833287 Mon Sep 17 00:00:00 2001 From: roble Date: Mon, 30 Nov 2026 20:56:59 +0000 Subject: [PATCH 1/4] feat: React stack The template's pages, layouts and content for React, mirroring the Vue stubs, with the React app view. composer.json lists both frameworks. Co-Authored-By: Claude Opus 5.5 --- composer.json | 3 +- .../saucebase-chat-development/SKILL.md | 3 +- .../js/react/components/Footer.stories.tsx | 45 +++ .../resources/js/react/components/Footer.tsx | 198 +++++++++++++ .../js/react/components/Header.stories.tsx | 127 ++++++++ .../resources/js/react/components/Header.tsx | 270 ++++++++++++++++++ .../js/react/components/landing/AppWindow.tsx | 171 +++++++++++ .../landing/ChatInAction.stories.tsx | 23 ++ .../react/components/landing/ChatInAction.tsx | 216 ++++++++++++++ .../components/landing/ClosingCta.stories.tsx | 22 ++ .../react/components/landing/ClosingCta.tsx | 45 +++ .../react/components/landing/FeatureCell.tsx | 64 +++++ .../landing/FeatureGrid.stories.tsx | 23 ++ .../react/components/landing/FeatureGrid.tsx | 55 ++++ .../landing/HeroSection.stories.tsx | 41 +++ .../react/components/landing/HeroSection.tsx | 55 ++++ .../react/components/landing/HeroStream.tsx | 90 ++++++ .../landing/PricingSection.stories.tsx | 31 ++ .../components/landing/PricingSection.tsx | 152 ++++++++++ .../js/react/components/landing/StepGlyph.tsx | 42 +++ .../components/landing/art/ChatHistory.tsx | 77 +++++ .../components/landing/art/ImageCard.tsx | 39 +++ .../components/landing/art/ModelPicker.tsx | 89 ++++++ .../components/landing/art/ReplyStream.tsx | 38 +++ .../components/landing/art/ToolPills.tsx | 43 +++ .../js/react/components/landing/content.ts | 260 +++++++++++++++++ .../js/react/hooks/useStartChatting.ts | 28 ++ stubs/resources/js/react/pages/Index.tsx | 92 ++++++ stubs/resources/views/react/app.blade.php | 55 ++++ 29 files changed, 2395 insertions(+), 2 deletions(-) create mode 100644 stubs/resources/js/react/components/Footer.stories.tsx create mode 100644 stubs/resources/js/react/components/Footer.tsx create mode 100644 stubs/resources/js/react/components/Header.stories.tsx create mode 100644 stubs/resources/js/react/components/Header.tsx create mode 100644 stubs/resources/js/react/components/landing/AppWindow.tsx create mode 100644 stubs/resources/js/react/components/landing/ChatInAction.stories.tsx create mode 100644 stubs/resources/js/react/components/landing/ChatInAction.tsx create mode 100644 stubs/resources/js/react/components/landing/ClosingCta.stories.tsx create mode 100644 stubs/resources/js/react/components/landing/ClosingCta.tsx create mode 100644 stubs/resources/js/react/components/landing/FeatureCell.tsx create mode 100644 stubs/resources/js/react/components/landing/FeatureGrid.stories.tsx create mode 100644 stubs/resources/js/react/components/landing/FeatureGrid.tsx create mode 100644 stubs/resources/js/react/components/landing/HeroSection.stories.tsx create mode 100644 stubs/resources/js/react/components/landing/HeroSection.tsx create mode 100644 stubs/resources/js/react/components/landing/HeroStream.tsx create mode 100644 stubs/resources/js/react/components/landing/PricingSection.stories.tsx create mode 100644 stubs/resources/js/react/components/landing/PricingSection.tsx create mode 100644 stubs/resources/js/react/components/landing/StepGlyph.tsx create mode 100644 stubs/resources/js/react/components/landing/art/ChatHistory.tsx create mode 100644 stubs/resources/js/react/components/landing/art/ImageCard.tsx create mode 100644 stubs/resources/js/react/components/landing/art/ModelPicker.tsx create mode 100644 stubs/resources/js/react/components/landing/art/ReplyStream.tsx create mode 100644 stubs/resources/js/react/components/landing/art/ToolPills.tsx create mode 100644 stubs/resources/js/react/components/landing/content.ts create mode 100644 stubs/resources/js/react/hooks/useStartChatting.ts create mode 100644 stubs/resources/js/react/pages/Index.tsx create mode 100644 stubs/resources/views/react/app.blade.php diff --git a/composer.json b/composer.json index 42259b2..97872a3 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,8 @@ }, "saucebase": { "frameworks": [ - "vue" + "vue", + "react" ] }, "branch-alias": { diff --git a/resources/boost/skills/saucebase-chat-development/SKILL.md b/resources/boost/skills/saucebase-chat-development/SKILL.md index 37f4eb1..7fb75db 100644 --- a/resources/boost/skills/saucebase-chat-development/SKILL.md +++ b/resources/boost/skills/saucebase-chat-development/SKILL.md @@ -12,7 +12,8 @@ Paths are relative to `modules/chat/` unless they say otherwise. Commands run fr ## Rules -- The landing page quotes the plans (`stubs/resources/js/vue/components/landing/content.ts`): change the seeder and the copy together. +- The landing page quotes the plans (`stubs/resources/js/{vue,react}/components/landing/content.ts`, one copy per stack): change the seeder and both copies together. +- Vue and React stubs mirror each other (same test ids, words and classes). `Header` and `Footer` stay default exports on React: core's `SiteLayout` imports them that way. - The template adds no routes of its own: `/chat` belongs to ai-chat. - `ChatServiceProvider` sets `ai-chat.sessions` to `sidebar`: the chat list is the app sidebar (no "Chat" item, no second panel). ai-chat's default (`page`) is for apps where the chat is one feature among others. diff --git a/stubs/resources/js/react/components/Footer.stories.tsx b/stubs/resources/js/react/components/Footer.stories.tsx new file mode 100644 index 0000000..e2be644 --- /dev/null +++ b/stubs/resources/js/react/components/Footer.stories.tsx @@ -0,0 +1,45 @@ +import preview from '@/.storybook/preview'; +import { expect } from 'storybook/test'; +import Footer from './Footer'; + +/** + * The public site's footer, dark in both themes: the logo for dark grounds, the landing + * page's sections, sign-in or the chat, the legal pages, and the year and site name. + * + * The name comes from the brand settings (`settings.general.site_name`). + */ +const meta = preview.meta({ + title: 'Layout/Footer', + component: Footer, + parameters: { + // In its own frame: the logo is sized from the window's width, which inline would + // be the whole docs page's. + docs: { story: { inline: false, iframeHeight: '400px' } }, + layout: 'fullscreen', + }, +}); +export default meta; + +/** With the default site name. */ +export const Default = meta.story({ + play: async ({ canvas }) => { + await expect(canvas.getByTestId('footer-app-name')).toHaveTextContent( + 'Saucebase', + ); + await expect( + canvas.getByRole('link', { name: 'Privacy' }), + ).toBeVisible(); + }, +}); + +/** A long site name, in the copyright line. */ +export const LongName = meta.story({ + parameters: { + inertia: { + settings: { + sections: [], + general: { site_name: 'Northwind Analytics' }, + }, + }, + }, +}); diff --git a/stubs/resources/js/react/components/Footer.tsx b/stubs/resources/js/react/components/Footer.tsx new file mode 100644 index 0000000..8339618 --- /dev/null +++ b/stubs/resources/js/react/components/Footer.tsx @@ -0,0 +1,198 @@ +/* + * The site's footer, the same on the landing page, the sign-in pages and the legal pages: the + * product's links on the page's dark band, opened by the logo at a third of the page's width. + * It is dark in both themes; the `dark` class gives everything inside the dark tokens. + */ +import { sections } from '@/components/landing/content'; +import LanguageSelector from '@/components/LanguageSelector'; +import ThemeSelector from '@/components/ThemeSelector'; +import { cn } from '@/lib/utils'; +import { Link, usePage } from '@inertiajs/react'; +import { brandAssetUrl } from '@saucebase/core/lib/settings'; +import type { MenuItem } from '@saucebase/core/types'; +import { useAuth } from '@saucebase/react/hooks/useAuth'; +import { useSettings } from '@saucebase/react/hooks/useSettings'; +import { useT } from '@saucebase/react/i18n'; +import { handleAction } from '@saucebase/react/lib/navigation'; + +// The landing page's sections, from any page: the bar's, after the features. +const product = [{ label: 'Features', href: '/#features' }, ...sections]; + +const link = 'text-foreground/85 hover:text-foreground transition-colors'; +const heading = 'text-muted-foreground text-sm font-medium'; + +// SiteLayout imports the footer as core's default export; this file replaces core's. +export default function Footer() { + const t = useT(); + const settings = useSettings(); + const page = usePage(); + const { login } = useAuth(); + + const name = settings.general.site_name; + const user = (page.props.auth as { user?: unknown } | undefined)?.user; + + // Other modules' public pages (the blog, the roadmap). + const pages = ( + (page.props.navigation as { landing?: MenuItem[] } | undefined) + ?.landing ?? [] + ).filter((item) => item.url !== route('billing.plans')); + + return ( +
+
+ {/* the signature: the logo at a third of the page, in its artwork for dark grounds */} + {name} + +
+

+ {t( + 'An assistant that answers as it writes, searches the web, draws images and knows your account.', + )} +

+ + + +
+ +
+ + + © {new Date().getFullYear()} {name} + + + {/* the template's credit; delete it freely */} + + {t('Cooked with')} + + + Saucebase + + + +
+ + +
+
+
+
+ ); +} diff --git a/stubs/resources/js/react/components/Header.stories.tsx b/stubs/resources/js/react/components/Header.stories.tsx new file mode 100644 index 0000000..342ef6b --- /dev/null +++ b/stubs/resources/js/react/components/Header.stories.tsx @@ -0,0 +1,127 @@ +import { user } from '@/.storybook/page'; +import preview from '@/.storybook/preview'; +import { expect, waitFor } from 'storybook/test'; +import Header from './Header'; + +/** + * The public site's bar: the logo, the Features menu and the landing page's sections, theme, + * sign-in or the chat, and "Start chatting free" (sign-up for a guest, the chat for a member). + * + * Flat across the top of the page; out of the way while the reader scrolls down; back as a + * floating island when they scroll up. Below `lg` the links move into a menu. + */ +const meta = preview.meta({ + title: 'Layout/Header', + component: Header, + parameters: { + // Its stories differ only in page props, which one docs page shares. + docs: { story: { inline: false, iframeHeight: '480px' } }, + layout: 'fullscreen', + }, + // A page under it, tall enough to scroll, so hiding on scroll can be seen; the frame fits + // the open mobile menu. + decorators: [ + (Story) => ( + <> + +
+
+
+ {[1, 2, 3].map((n) => ( +
+ ))} +
+
+
+ + ), + ], +}); +export default meta; + +/** A visitor: sign in, the sections, and the call to action to sign up. */ +export const SignedOut = meta.story({ + parameters: { + inertia: { auth: { user: null, registration_enabled: true } }, + }, + play: async ({ canvas }) => { + // below lg it sits in the menu; the test frame is narrower than lg + await expect(canvas.getByTestId('header-sign-in')).toBeInTheDocument(); + await expect(canvas.getByTestId('header-get-started')).toHaveAttribute( + 'href', + expect.stringContaining('register'), + ); + await expect( + canvas.getByRole('link', { name: 'Pricing', hidden: true }), + ).toHaveAttribute('href', '/#pricing'); + }, +}); + +/** The Features menu: one entry per feature on the landing page. */ +export const FeaturesMenu = meta.story({ + parameters: { + inertia: { auth: { user: null, registration_enabled: true } }, + }, + play: async ({ canvas, canvasElement, userEvent }) => { + await userEvent.click(canvas.getByTestId('header-features')); + + const body = canvasElement.ownerDocument.body; + await waitFor(() => + expect(body.querySelector('a[href="/#models"]')).toBeVisible(), + ); + }, +}); + +/** A visitor while registration is closed: the call to action goes to the chat, which asks them to sign in. */ +export const RegistrationClosed = meta.story({ + parameters: { + inertia: { auth: { user: null, registration_enabled: false } }, + }, + play: async ({ canvas }) => { + await expect(canvas.getByTestId('header-get-started')).toHaveAttribute( + 'href', + expect.stringContaining('chat'), + ); + }, +}); + +/** A signed-in user: the link back to the chat. */ +export const SignedIn = meta.story({ + parameters: { inertia: { auth: { user } } }, + play: async ({ canvas }) => { + await expect( + canvas.getByRole('link', { name: 'Open chat', hidden: true }), + ).toBeInTheDocument(); + await expect(canvas.queryByTestId('header-sign-in')).toBeNull(); + }, +}); + +/** Scrolling down hides it; scrolling back up brings it back as an island. */ +export const Scrolling = meta.story({ + parameters: { + inertia: { auth: { user: null, registration_enabled: true } }, + }, + play: async ({ canvas }) => { + const header = canvas.getByTestId('site-header'); + + window.scrollTo({ top: 400, behavior: 'instant' }); + await waitFor(() => + expect(header).toHaveAttribute('data-nav', 'hidden'), + ); + + window.scrollTo({ top: 300, behavior: 'instant' }); + await waitFor(() => + expect(header).toHaveAttribute('data-nav', 'island'), + ); + + window.scrollTo({ top: 0, behavior: 'instant' }); + }, +}); + +/** On a phone: the links fold into a menu. No play function: story tests run at desktop width. */ +export const Mobile = meta.story({ + parameters: { + inertia: { auth: { user: null, registration_enabled: true } }, + }, + globals: { viewport: { value: 'mobile1' } }, +}); diff --git a/stubs/resources/js/react/components/Header.tsx b/stubs/resources/js/react/components/Header.tsx new file mode 100644 index 0000000..3c8a13f --- /dev/null +++ b/stubs/resources/js/react/components/Header.tsx @@ -0,0 +1,270 @@ +/* + * The site's bar, for every page in SiteLayout. Flat across the top of the page; out of the + * way while the reader scrolls down; back as a floating island when they scroll up. The + * island is only a ground drawn behind the bar's own content, so the logo, links and buttons + * never move: the switch is a fade. It stays while its menus are open or hold the focus. + */ +import AppLogo from '@/components/AppLogo'; +import { featureMenu, sections } from '@/components/landing/content'; +import ThemeSelector from '@/components/ThemeSelector'; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from '@/components/ui/popover'; +import { useStartChatting } from '@/hooks/useStartChatting'; +import { cn } from '@/lib/utils'; +import { Link, usePage } from '@inertiajs/react'; +import { useAuth } from '@saucebase/react/hooks/useAuth'; +import { useT } from '@saucebase/react/i18n'; +import { + ChevronDown, + ChevronRight, + History, + Image as ImageIcon, + Menu, + MessageSquareText, + SlidersHorizontal, + Wrench, + X, +} from 'lucide-react'; +import { useEffect, useRef, useState } from 'react'; + +const icons = { + stream: MessageSquareText, + tools: Wrench, + image: ImageIcon, + models: SlidersHorizontal, + history: History, +}; + +const link = + 'text-foreground/80 hover:text-foreground rounded-lg px-3 py-2 text-[15px] font-medium transition-colors'; + +// SiteLayout imports the bar as core's default export; this file replaces core's. +export default function Header() { + const t = useT(); + const page = usePage(); + const { login } = useAuth(); + const { href: startHref, start } = useStartChatting(); + const user = (page.props.auth as { user?: unknown } | undefined)?.user; + const guest = route().has('login') && !user; + const member = !!user && route().has('ai-chat.index'); + + const bar = useRef(null); + const [state, setState] = useState<'flat' | 'hidden' | 'island'>('flat'); + const [featuresOpen, setFeaturesOpen] = useState(false); + const [menuOpen, setMenuOpen] = useState(false); + const lastY = useRef(0); + + useEffect(() => { + function follow() { + const y = window.scrollY; + + if (Math.abs(y - lastY.current) < 6) { + return; + } + + const busy = + featuresOpen || + menuOpen || + !!bar.current?.matches(':focus-within'); + const down = y > lastY.current && !busy; + + lastY.current = y; + if (y < 80) { + setState('flat'); + } else { + setState(down ? 'hidden' : 'island'); + } + } + + window.addEventListener('scroll', follow, { passive: true }); + return () => window.removeEventListener('scroll', follow); + }, [featuresOpen, menuOpen]); + + return ( +
+
+ + {/* the lockup, and on a phone just the mark */} + + + + + + + + + + +
+ {/* a phone has no room beside the call to action: its menu holds the switch */} + + + + {guest ? ( + + {t('Sign in')} + + ) : ( + member && ( + + {t('Open chat')} + + ) + )} + + {t('Start chatting free')} + + + +
+ + {/* a phone's and a tablet's menu: the same entries, stacked */} + {menuOpen && ( +
+ {[...featureMenu, ...sections].map((item) => ( + setMenuOpen(false)} + > + {t(item.label)} + + ))} + {guest ? ( + { + setMenuOpen(false); + login(event); + }} + > + {t('Sign in')} + + ) : ( + member && ( + setMenuOpen(false)} + > + {t('Open chat')} + + ) + )} +
+ +
+
+ )} +
+
+ ); +} diff --git a/stubs/resources/js/react/components/landing/AppWindow.tsx b/stubs/resources/js/react/components/landing/AppWindow.tsx new file mode 100644 index 0000000..0b2061f --- /dev/null +++ b/stubs/resources/js/react/components/landing/AppWindow.tsx @@ -0,0 +1,171 @@ +/* + * The chat in one window: the chat history (drifting up, as a live list does) beside the open + * chat. It fills in after it lands: the list, the question, the step the assistant took, then the + * answer word by word, and the box for the next question. --i on each item sets its turn. + */ +import { cn } from '@/lib/utils'; +import { useT } from '@saucebase/react/i18n'; +import { ArrowUp, ChevronDown, Plus } from 'lucide-react'; +import { Fragment, type CSSProperties } from 'react'; +import { chats, transcript } from './content'; +import { StepGlyph } from './StepGlyph'; + +const rise = 'motion-safe:animate-chat-rise'; + +const listFade = + 'lg:after:to-card lg:after:pointer-events-none lg:after:absolute lg:after:inset-x-0 lg:after:bottom-0 lg:after:h-16 lg:after:bg-linear-to-b lg:after:from-transparent'; + +const meters = [ + { label: 'Messages', used: 12, of: 50 }, + { label: 'Images', used: 2, of: 5 }, +]; + +export function AppWindow({ className }: { className?: string }) { + const t = useT(); + // the answer's words, each rising in on its turn + const words = t(transcript.answer).split(' '); + + return ( +
+
+
+
+ + {t('New chat')} +
+ {/* the list twice over, drifting up; the copy is hidden from readers */} +
+
    + {[...chats, ...chats].map((chat, i) => ( +
  • = chats.length ? 'true' : undefined + } + style={{ '--i': i } as CSSProperties} + data-testid="hero-chat" + > + + {t(chat.title)} + + + {t(chat.when)} + +
  • + ))} +
+
+
+
+ +
+
+ + {t(chats[0].title)} + + {/* the model picker: the models the admin offers */} + + {t('Balanced')} + + +
+ +
+

+ {t(transcript.question)} +

+

+ + {t(transcript.step)} +

+

+ {words.map((word, i) => ( + + + {word} + {' '} + + ))} +

+ {/* what the answer read: this month's use against the plan */} +
+ {meters.map((meter) => ( + + + + {t(meter.label)} + + + {meter.used} / {meter.of} + + + + + + + ))} +
+
+ +
+
+ + {t('Ask anything')} + + + + +
+
+
+
+ ); +} diff --git a/stubs/resources/js/react/components/landing/ChatInAction.stories.tsx b/stubs/resources/js/react/components/landing/ChatInAction.stories.tsx new file mode 100644 index 0000000..7a0c469 --- /dev/null +++ b/stubs/resources/js/react/components/landing/ChatInAction.stories.tsx @@ -0,0 +1,23 @@ +import preview from '@/.storybook/preview'; +import { expect } from 'storybook/test'; +import { ChatInAction } from './ChatInAction'; + +/** + * The chat at work: questions about the account in turn over this month's use, and a browser + * agent's WebMCP calls drifting up. + */ +const meta = preview.meta({ + component: ChatInAction, + parameters: { layout: 'padded' }, +}); +export default meta; + +/** Both cells, with the question deck and the agent's log. */ +export const Default = meta.story({ + play: async ({ canvas }) => { + await expect(canvas.getAllByTestId('action-cell')).toHaveLength(2); + await expect(canvas.getByTestId('agent-log')).toHaveTextContent( + 'ask_this_assistant', + ); + }, +}); diff --git a/stubs/resources/js/react/components/landing/ChatInAction.tsx b/stubs/resources/js/react/components/landing/ChatInAction.tsx new file mode 100644 index 0000000..25c3470 --- /dev/null +++ b/stubs/resources/js/react/components/landing/ChatInAction.tsx @@ -0,0 +1,216 @@ +/* + * The chat at work, in two ruled cells: the latest question (a new one every few seconds, the + * front card going to the back of the stack) over this month's use and a reply streaming in; + * and a browser agent's WebMCP calls filling in at its foot. Both move as transforms only. + */ +import { cn } from '@/lib/utils'; +import { useT } from '@saucebase/react/i18n'; +import type { CSSProperties } from 'react'; +import { agentLog, asks, readings } from './content'; +import { FeatureCell } from './FeatureCell'; +import { StepGlyph } from './StepGlyph'; + +// the streaming reply in the middle card: lines of words, drawn twice over to slide +const LOOP = 64; +const values = readings(30, 5); +let k = 0; +const words = [20, 50, 80].flatMap((top) => { + const line: { x: number; y: number; w: number }[] = []; + let x = 0; + + while (true) { + const w = 3 + Math.round(values[k++ % values.length] * 8); + + if (x + w > LOOP - 2) { + break; + } + line.push({ x, y: top, w }); + x += w + 2; + } + + return [...line, ...line.map((word) => ({ ...word, x: word.x + LOOP }))]; +}); + +const meters = [ + { label: 'Messages this month', used: 12, of: 50, place: 'justify-self-end' }, + { label: 'Images this month', used: 2, of: 5, place: 'justify-self-start' }, +]; + +const tag = { + done: 'text-done', + failed: 'text-failed bg-failed/12', + tool: 'text-tool', + note: 'text-muted-foreground', +}; + +// the stack held still (reduced motion): first in front, then second and third behind, fourth away +const still: CSSProperties[] = [ + { zIndex: 4 }, + { zIndex: 2, transform: 'translateY(-10px) scale(0.95)' }, + { zIndex: 1, transform: 'translateY(-20px) scale(0.9)' }, + { zIndex: 0, opacity: 0 }, +]; + +// a card running into the cell's foot: no bottom border or corners, cut like the others +const card = + 'border-border bg-background flex flex-col gap-2.5 rounded-t-xl border border-b-0 px-4 pt-3.5'; +// a side card: as wide as the middle one, faded, for the cell's edge to cut +const side = 'w-[360px] max-w-none opacity-45 max-sm:hidden'; +const ruled = + 'overflow-hidden bg-[repeating-linear-gradient(to_right,transparent_0_31px,color-mix(in_oklab,var(--foreground)_7%,transparent)_31px_32px)]'; + +export function ChatInAction() { + const t = useT(); + + return ( +
+ +
+ {/* the questions as a stack: the front one goes to the back every 4 s */} +
+ {asks.map((ask, i) => ( +
+ + + + {t(ask.title)} + + + {t(ask.text)} + + +
+ ))} +
+
+ {/* the cards beside it are whole cards, cut by the cell's edges like slides */} + {meters.map((meter, m) => ( +
+ + + {t(meter.label)} + + + {meter.used} / {meter.of} + + + + + + + {t('Free plan · resets on the 1st')} + +
+ ))} +
+ + + {t('Reply · streaming')} + + + + {t('Looked up your account')} + + + + + +
+
+
+
+ + +
+ {/* the log twice over, drifting up as new rows arrive at its foot */} +
    + {[...agentLog, ...agentLog].map((row, i) => ( +
  1. = agentLog.length ? 'true' : undefined + } + > + + + {row.tag} + + {row.text} +
  2. + ))} +
+
+
+
+ ); +} diff --git a/stubs/resources/js/react/components/landing/ClosingCta.stories.tsx b/stubs/resources/js/react/components/landing/ClosingCta.stories.tsx new file mode 100644 index 0000000..a0b9a27 --- /dev/null +++ b/stubs/resources/js/react/components/landing/ClosingCta.stories.tsx @@ -0,0 +1,22 @@ +import preview from '@/.storybook/preview'; +import { expect } from 'storybook/test'; +import { ClosingCta } from './ClosingCta'; + +/** The last call to action, on the dark band above the footer. */ +const meta = preview.meta({ + component: ClosingCta, + parameters: { + layout: 'fullscreen', + inertia: { auth: { user: null, registration_enabled: true } }, + }, +}); +export default meta; + +/** A visitor: the button signs them up. */ +export const Default = meta.story({ + play: async ({ canvas }) => { + await expect( + canvas.getByRole('link', { name: /Start chatting free/ }), + ).toHaveAttribute('href', expect.stringContaining('register')); + }, +}); diff --git a/stubs/resources/js/react/components/landing/ClosingCta.tsx b/stubs/resources/js/react/components/landing/ClosingCta.tsx new file mode 100644 index 0000000..c7f4806 --- /dev/null +++ b/stubs/resources/js/react/components/landing/ClosingCta.tsx @@ -0,0 +1,45 @@ +// The last call to action, on the dark band above the footer. +import { buttonVariants } from '@/components/ui/button'; +import { useStartChatting } from '@/hooks/useStartChatting'; +import { cn } from '@/lib/utils'; +import { useT } from '@saucebase/react/i18n'; +import { ChevronRight } from 'lucide-react'; + +export function ClosingCta() { + const t = useT(); + const { href, start } = useStartChatting(); + + return ( +
+
+
+

+ {t('Ask your first question today')} +

+

+ {t( + 'Free for 50 messages and 5 images a month. No card needed.', + )} +

+
+ + {t('Start chatting free')} + + +
+
+ ); +} diff --git a/stubs/resources/js/react/components/landing/FeatureCell.tsx b/stubs/resources/js/react/components/landing/FeatureCell.tsx new file mode 100644 index 0000000..49a6b63 --- /dev/null +++ b/stubs/resources/js/react/components/landing/FeatureCell.tsx @@ -0,0 +1,64 @@ +/* + * One cell of a ruled grid (FeatureGrid, ChatInAction): its words, then its drawing running to + * the cell's foot. The grid draws the outer top and left rules; each cell its right and bottom. + * `lead` sets the words as one line, the claim in the ink and the rest muted. + */ +import { cn } from '@/lib/utils'; +import { useT } from '@saucebase/react/i18n'; +import type { ComponentProps } from 'react'; + +export function FeatureCell({ + title, + text, + wide = false, + lead = false, + children, + className, + ...rest +}: ComponentProps<'article'> & { + title: string; + text: string; + wide?: boolean; + lead?: boolean; +}) { + const t = useT(); + + return ( +
+ {lead ? ( +

+ {t(title)}{' '} + {t(text)} +

+ ) : ( +
+

{t(title)}

+

{t(text)}

+
+ )} +
+ {/* the floor every drawing stands on: a soft shade squashed to the isometric 2:1, lighter on the light ground */} +