Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# The landing page's copy is data, one file per stack, the same in both: a stub is
# copied into the app for its stack alone, so the two can't share one file.
sonar.cpd.exclusions=stubs/resources/js/react/components/landing/content.ts
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ A Saucebase template: an AI chat product with free and paid plans. The chat itse
| Free | €0 | 50 | 5 |
| Pro | €12 a month, or €120 a year | 2,000 | 100 |

The landing page quotes these plans: change `database/seeders/DatabaseSeeder.php` and `stubs/resources/js/vue/components/landing/content.ts` together.
The landing page quotes these plans: change `database/seeders/DatabaseSeeder.php` and both copies of `stubs/resources/js/{vue,react}/components/landing/content.ts` together.

## Install

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
},
"saucebase": {
"frameworks": [
"vue"
"vue",
"react"
]
},
"branch-alias": {
Expand Down
3 changes: 2 additions & 1 deletion resources/boost/skills/saucebase-chat-development/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
25 changes: 25 additions & 0 deletions resources/js/react/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// import { registerIcon } from '@/lib/navigation';
// import IconExample from '~icons/lucide/example';

// Custom styles: create resources/css/style.css in this module and uncomment.
// import '@modules/chat/resources/css/style.css';

/**
* Chat module setup
* Called before the first render, on the server too: register things here,
* and leave anything that needs window or document to afterMount()
*/
export function setup() {
console.debug('Chat module loaded');

// Register icons for navigation items defined in routes/navigation.php
// registerIcon('chat', IconExample);
}

/**
* Chat module after mount logic
* Called in the browser after the app has mounted
*/
export function afterMount() {
console.debug('Chat module after mount logic executed');
}
45 changes: 45 additions & 0 deletions stubs/resources/js/react/components/Footer.stories.tsx
Original file line number Diff line number Diff line change
@@ -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' },
},
},
},
});
198 changes: 198 additions & 0 deletions stubs/resources/js/react/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<footer
className="dark bg-background text-foreground relative mt-auto w-full overflow-hidden"
data-testid="site-footer"
>
<div className="mx-auto w-[min(100%-48px,1280px)] pt-16 md:w-[min(100%-160px,1280px)]">
{/* the signature: the logo at a third of the page, in its artwork for dark grounds */}
<img
className="mb-16 block h-auto w-full select-none sm:w-1/2 md:w-1/3"
src={brandAssetUrl(settings.general, 'site_logo_on_dark')}
alt={name}
width="210"
height="64"
loading="lazy"
data-testid="footer-logo"
/>

<div className="[display:grid] grid-cols-2 gap-10 text-[15px] sm:grid-cols-3 md:grid-cols-12">
<p
className="text-muted-foreground col-span-2 max-w-xs sm:col-span-3 md:col-span-5"
data-testid="footer-tagline"
>
{t(
'An assistant that answers as it writes, searches the web, draws images and knows your account.',
)}
</p>
<nav
className="flex flex-col gap-4 md:col-span-2 md:col-start-7"
aria-label={t('Product')}
>
<p className={heading}>{t('Product')}</p>
<ul className="flex flex-col gap-3">
{product.map((item) => (
<li key={item.href}>
<a className={link} href={item.href}>
{t(item.label)}
</a>
</li>
))}
</ul>
</nav>
<nav
className="flex flex-col gap-4 md:col-span-2"
aria-label={t('Account')}
>
<p className={heading}>{t('Account')}</p>
<ul className="flex flex-col gap-3">
{route().has('login') && !user && (
<li>
<a
className={link}
href={route('login')}
onClick={login}
>
{t('Sign in')}
</a>
</li>
)}
{route().has('ai-chat.index') && !!user && (
<li>
<Link
className={link}
href={route('ai-chat.index')}
>
{t('Open chat')}
</Link>
</li>
)}
{route().has('logout') && !!user && (
<li>
{/* The action, not a plain post: logging out is confirmed the same way here as in the app. */}
<button
type="button"
className={cn(link, 'cursor-pointer')}
data-testid="logout-button"
onClick={(event) =>
handleAction(
'logout',
event.nativeEvent,
)
}
>
{t('Log out')}
</button>
</li>
)}
</ul>
</nav>
<nav
className="flex flex-col gap-4 md:col-span-2"
aria-label={t('More')}
>
<p className={heading}>{t('More')}</p>
<ul className="flex flex-col gap-3">
{pages.map((item) => {
const PageLink = item.external ? 'a' : Link;

return (
<li key={item.slug}>
<PageLink
className={link}
href={item.url}
target={
item.newPage
? '_blank'
: undefined
}
>
{t(item.title)}
</PageLink>
</li>
);
})}
<li>
<Link className={link} href={route('privacy')}>
{t('Privacy')}
</Link>
</li>
<li>
<Link className={link} href={route('terms')}>
{t('Terms')}
</Link>
</li>
</ul>
</nav>
</div>

<div className="border-border text-muted-foreground mt-12 flex flex-col items-center justify-between gap-4 border-t py-6 text-sm sm:flex-row">
<span className="flex flex-wrap items-center justify-center gap-x-2">
<span data-testid="footer-app-name">
© {new Date().getFullYear()} {name}
</span>
<span aria-hidden="true">·</span>
{/* the template's credit; delete it freely */}
<a
className="hover:text-foreground inline-flex items-center gap-1.5 transition-colors"
href="https://saucebase.dev/?utm_source=chat-template&utm_medium=footer"
data-testid="footer-credit"
>
{t('Cooked with')}
<img
className="size-4"
src="/images/saucebase-mark.svg"
alt=""
/>
<b className="text-foreground/85 font-medium">
Saucebase
</b>
</a>
</span>
<div className="flex items-center gap-2">
<LanguageSelector mode="standalone" />
<ThemeSelector mode="standalone" />
</div>
</div>
</div>
</footer>
);
}
Loading
Loading