@poadio/starter-next 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +18 -0
- package/.env.example +8 -0
- package/Dockerfile +45 -0
- package/Dockerfile.dockerignore +18 -0
- package/README.md +197 -2
- package/bun.lock +156 -0
- package/gitignore +37 -0
- package/next.config.ts +14 -0
- package/package.json +72 -4
- package/public/logo.svg +1 -0
- package/public/providers/google.svg +1 -0
- package/public/providers/keycloak.svg +1 -0
- package/scripts/dev.mjs +92 -0
- package/scripts/env.mjs +160 -0
- package/scripts/env.test.mjs +93 -0
- package/src/app/(auth)/login/login-form.tsx +258 -0
- package/src/app/(auth)/login/page.tsx +16 -0
- package/src/app/(auth)/mfa/mfa-form.tsx +55 -0
- package/src/app/(auth)/mfa/page.tsx +16 -0
- package/src/app/(auth)/reset/page.tsx +16 -0
- package/src/app/(auth)/reset/reset-form.tsx +51 -0
- package/src/app/app/account/account.css +36 -0
- package/src/app/app/account/account.tsx +476 -0
- package/src/app/app/account/page.tsx +18 -0
- package/src/app/app/dashboard.tsx +58 -0
- package/src/app/app/hello/[name]/page.tsx +38 -0
- package/src/app/app/layout.tsx +12 -0
- package/src/app/app/page.tsx +18 -0
- package/src/app/app/public/page.tsx +15 -0
- package/src/app/app/public/public-content.tsx +31 -0
- package/src/app/globals.css +271 -0
- package/src/app/home.css +186 -0
- package/src/app/home.tsx +92 -0
- package/src/app/icon.svg +1 -0
- package/src/app/layout.tsx +59 -0
- package/src/app/not-found.tsx +6 -0
- package/src/app/page.tsx +6 -0
- package/src/app/providers.tsx +24 -0
- package/src/app/setup/page.tsx +39 -0
- package/src/app/shell.css +752 -0
- package/src/app.meta.ts +41 -0
- package/src/components/brand.tsx +15 -0
- package/src/components/captcha.tsx +93 -0
- package/src/components/link-button.tsx +9 -0
- package/src/components/rich.tsx +14 -0
- package/src/components/shell/app-menu.tsx +127 -0
- package/src/components/shell/app-shell.tsx +268 -0
- package/src/components/shell/page-title.tsx +29 -0
- package/src/components/shell/switches.tsx +35 -0
- package/src/components/shell/use-layout.ts +123 -0
- package/src/core/auth.tsx +228 -0
- package/src/core/env.server.ts +83 -0
- package/src/core/env.tsx +48 -0
- package/src/core/guards.tsx +74 -0
- package/src/core/messages.ts +18 -0
- package/src/core/providers.ts +32 -0
- package/src/core/theme-script.ts +7 -0
- package/src/core/theme.tsx +37 -0
- package/src/i18n/client.tsx +47 -0
- package/src/i18n/en.ts +228 -0
- package/src/i18n/fr.ts +251 -0
- package/src/i18n/index.ts +38 -0
- package/src/i18n/server.ts +19 -0
- package/tsconfig.json +21 -0
package/src/app/home.tsx
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import Link from 'next/link';
|
|
3
|
+
import { PoadIcon } from '@poadio/ui-react';
|
|
4
|
+
import { APP } from '@/app.meta';
|
|
5
|
+
import { Brand } from '@/components/brand';
|
|
6
|
+
import { LocaleSwitch } from '@/components/shell/switches';
|
|
7
|
+
import { useAuth } from '@/core/auth';
|
|
8
|
+
import { useTheme } from '@/core/theme';
|
|
9
|
+
import { useT } from '@/i18n/client';
|
|
10
|
+
import './home.css';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Page de démarrage, hors du cadre de l'application. Écrite sur les tokens
|
|
14
|
+
* --poad-* : elle suit le thème clair/sombre. Les portes d'entrée disent où
|
|
15
|
+
* elles mènent et ce qu'elles démontrent ; à remplacer par celles de l'application.
|
|
16
|
+
*/
|
|
17
|
+
export function Home() {
|
|
18
|
+
const theme = useTheme();
|
|
19
|
+
const auth = useAuth();
|
|
20
|
+
const t = useT();
|
|
21
|
+
|
|
22
|
+
const doors = [
|
|
23
|
+
auth.session
|
|
24
|
+
? { icon: 'layout-dashboard', title: t('home.open'), text: t('home.openText', { name: auth.displayName }), link: '/app' }
|
|
25
|
+
: { icon: 'log-in', title: t('home.signIn'), text: t('home.signInText'), link: '/login' },
|
|
26
|
+
{ icon: 'globe', title: t('home.public'), text: t('home.publicText'), link: '/app/public' },
|
|
27
|
+
{ icon: 'book-open', title: t('home.docs'), text: t('home.docsText'), href: 'https://github.com/poadio' },
|
|
28
|
+
];
|
|
29
|
+
const facts = [
|
|
30
|
+
{ value: '1', label: t('home.fact1') },
|
|
31
|
+
{ value: 'OAuth', label: t('home.fact2') },
|
|
32
|
+
{ value: 'MFA', label: t('home.fact3') },
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div className="start">
|
|
37
|
+
<div className="start-grid" aria-hidden="true" />
|
|
38
|
+
|
|
39
|
+
<div className="start-tools">
|
|
40
|
+
<LocaleSwitch />
|
|
41
|
+
<button type="button" className="start-theme" aria-label={theme.dark ? t('common.toLight') : t('common.toDark')} onClick={theme.toggle}>
|
|
42
|
+
<PoadIcon name={theme.dark ? 'sun' : 'moon'} size={15} />
|
|
43
|
+
</button>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<main className="start-main">
|
|
47
|
+
<Brand className="start-brand" size={36} version />
|
|
48
|
+
|
|
49
|
+
<h1>
|
|
50
|
+
{t('home.title')}
|
|
51
|
+
<em>{t('home.titleAccent')}</em>
|
|
52
|
+
</h1>
|
|
53
|
+
<p className="start-lead">{t('home.lead', { description: APP.description })}</p>
|
|
54
|
+
|
|
55
|
+
<nav className="doors">
|
|
56
|
+
{doors.map((d) => {
|
|
57
|
+
const inner = (
|
|
58
|
+
<>
|
|
59
|
+
<span className="dicon">
|
|
60
|
+
<PoadIcon name={d.icon} size={17} />
|
|
61
|
+
</span>
|
|
62
|
+
<span className="dtxt">
|
|
63
|
+
<span className="dtitle">{d.title}</span>
|
|
64
|
+
<span className="dtext">{d.text}</span>
|
|
65
|
+
</span>
|
|
66
|
+
<PoadIcon className="darrow" name={d.href ? 'arrow-up-right' : 'arrow-right'} size={15} />
|
|
67
|
+
</>
|
|
68
|
+
);
|
|
69
|
+
return d.href ? (
|
|
70
|
+
<a key={d.title} className="door" href={d.href} target="_blank" rel="noopener">
|
|
71
|
+
{inner}
|
|
72
|
+
</a>
|
|
73
|
+
) : (
|
|
74
|
+
<Link key={d.title} className="door" href={d.link!}>
|
|
75
|
+
{inner}
|
|
76
|
+
</Link>
|
|
77
|
+
);
|
|
78
|
+
})}
|
|
79
|
+
</nav>
|
|
80
|
+
|
|
81
|
+
<dl className="facts">
|
|
82
|
+
{facts.map((f) => (
|
|
83
|
+
<div key={f.label}>
|
|
84
|
+
<dt>{f.value}</dt>
|
|
85
|
+
<dd>{f.label}</dd>
|
|
86
|
+
</div>
|
|
87
|
+
))}
|
|
88
|
+
</dl>
|
|
89
|
+
</main>
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
|
+
}
|
package/src/app/icon.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="8" fill="#4f46e5"/><rect x="9.4" y="7" width="3.2" height="19" rx="1.6" fill="#fff"/><circle cx="17" cy="13" r="4.9" fill="none" stroke="#fff" stroke-width="3.2"/><circle cx="17" cy="13" r="1.5" fill="#fff"/></svg>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Composants des pages : feuilles de @poadio/ui-core, une fois pour toute l'application
|
|
2
|
+
import '@poadio/ui-core/tokens.css';
|
|
3
|
+
import '@poadio/ui-core/base.css';
|
|
4
|
+
import '@poadio/ui-core/icon.css';
|
|
5
|
+
import '@poadio/ui-core/button.css';
|
|
6
|
+
import '@poadio/ui-core/field.css';
|
|
7
|
+
import '@poadio/ui-core/password.css';
|
|
8
|
+
import '@poadio/ui-core/meter.css';
|
|
9
|
+
import '@poadio/ui-core/select.css';
|
|
10
|
+
import '@poadio/ui-core/option-list.css';
|
|
11
|
+
import '@poadio/ui-core/floating.css';
|
|
12
|
+
import '@poadio/ui-core/sheet.css';
|
|
13
|
+
import '@poadio/ui-core/tooltip.css';
|
|
14
|
+
import '@poadio/ui-core/popover.css';
|
|
15
|
+
import '@poadio/ui-core/menu.css';
|
|
16
|
+
import '@poadio/ui-core/tabs.css';
|
|
17
|
+
import '@poadio/ui-core/tag.css';
|
|
18
|
+
import '@poadio/ui-core/message.css';
|
|
19
|
+
import '@poadio/ui-core/divider.css';
|
|
20
|
+
import '@poadio/ui-core/progress.css';
|
|
21
|
+
import '@poadio/ui-core/toast.css';
|
|
22
|
+
import '@poadio/ui-core/card.css';
|
|
23
|
+
import './globals.css';
|
|
24
|
+
import './shell.css';
|
|
25
|
+
import type { Metadata } from 'next';
|
|
26
|
+
import type { ReactNode } from 'react';
|
|
27
|
+
import { APP } from '@/app.meta';
|
|
28
|
+
import { publicEnv } from '@/core/env.server';
|
|
29
|
+
import { THEME_SCRIPT } from '@/core/theme-script';
|
|
30
|
+
import { getLocale } from '@/i18n/server';
|
|
31
|
+
import { Providers } from './providers';
|
|
32
|
+
|
|
33
|
+
export const metadata: Metadata = {
|
|
34
|
+
title: { default: APP.name, template: `%s · ${APP.name}` },
|
|
35
|
+
description: APP.description,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Racine, rendue par le serveur À CHAQUE REQUÊTE (la langue lit les cookies) :
|
|
40
|
+
* les variables publiques (POAD_URL, POAD_ANON_KEY, PUBLIC_*) sont lues dans
|
|
41
|
+
* l'environnement du serveur et dans le projet poad (variables de cette
|
|
42
|
+
* application) à ce moment-là, jamais compilées dans le code.
|
|
43
|
+
* L'image Docker est donc construite une fois et configurée au démarrage.
|
|
44
|
+
*/
|
|
45
|
+
export default async function RootLayout({ children }: { children: ReactNode }) {
|
|
46
|
+
const locale = await getLocale();
|
|
47
|
+
return (
|
|
48
|
+
<html lang={locale} suppressHydrationWarning>
|
|
49
|
+
<head>
|
|
50
|
+
<script dangerouslySetInnerHTML={{ __html: THEME_SCRIPT }} />
|
|
51
|
+
</head>
|
|
52
|
+
<body>
|
|
53
|
+
<Providers env={await publicEnv()} locale={locale}>
|
|
54
|
+
{children}
|
|
55
|
+
</Providers>
|
|
56
|
+
</body>
|
|
57
|
+
</html>
|
|
58
|
+
);
|
|
59
|
+
}
|
package/src/app/page.tsx
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import { PoadToast } from '@poadio/ui-react';
|
|
4
|
+
import { AuthProvider } from '@/core/auth';
|
|
5
|
+
import { EnvProvider } from '@/core/env';
|
|
6
|
+
import { ThemeProvider } from '@/core/theme';
|
|
7
|
+
import { I18nProvider } from '@/i18n/client';
|
|
8
|
+
import type { Locale } from '@/i18n';
|
|
9
|
+
|
|
10
|
+
/** Fournisseurs de toute l'application : variables, langue, thème, session, toasts */
|
|
11
|
+
export function Providers({ env, locale, children }: { env: Record<string, string>; locale: Locale; children: ReactNode }) {
|
|
12
|
+
return (
|
|
13
|
+
<EnvProvider values={env}>
|
|
14
|
+
<I18nProvider locale={locale}>
|
|
15
|
+
<ThemeProvider>
|
|
16
|
+
<AuthProvider>
|
|
17
|
+
{children}
|
|
18
|
+
<PoadToast position="bottom-right" />
|
|
19
|
+
</AuthProvider>
|
|
20
|
+
</ThemeProvider>
|
|
21
|
+
</I18nProvider>
|
|
22
|
+
</EnvProvider>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import Link from 'next/link';
|
|
2
|
+
import { PoadCard, PoadMessage } from '@poadio/ui-react';
|
|
3
|
+
import { Brand } from '@/components/brand';
|
|
4
|
+
import { Rich } from '@/components/rich';
|
|
5
|
+
import { getT, titled } from '@/i18n/server';
|
|
6
|
+
|
|
7
|
+
export const generateMetadata = titled('title.setup');
|
|
8
|
+
|
|
9
|
+
const SAMPLE = 'docker run -p 8080:3000 \\\n -e POAD_URL=https://mon-projet.example.com \\\n -e POAD_ANON_KEY=eyJ… mon-app';
|
|
10
|
+
|
|
11
|
+
/** Affichée tant que POAD_URL et POAD_ANON_KEY manquent : comment brancher l'application sur poad */
|
|
12
|
+
export default async function SetupPage() {
|
|
13
|
+
const t = await getT();
|
|
14
|
+
return (
|
|
15
|
+
<div className="screen screen-top">
|
|
16
|
+
<section className="page setup" style={{ width: '100%', maxWidth: 620 }}>
|
|
17
|
+
<Link href="/" className="home-link">
|
|
18
|
+
<Brand size={32} />
|
|
19
|
+
</Link>
|
|
20
|
+
<h1>{t('setup.title')}</h1>
|
|
21
|
+
<PoadMessage severity="warning" variant="soft">
|
|
22
|
+
<Rich text={t('setup.missing')} />
|
|
23
|
+
</PoadMessage>
|
|
24
|
+
<PoadCard>
|
|
25
|
+
<ol>
|
|
26
|
+
<li>
|
|
27
|
+
<Rich text={t('setup.local')} />
|
|
28
|
+
</li>
|
|
29
|
+
<li>
|
|
30
|
+
<Rich text={t('setup.dotenv')} />
|
|
31
|
+
</li>
|
|
32
|
+
</ol>
|
|
33
|
+
<p className="muted">{t('setup.docker')}</p>
|
|
34
|
+
<pre className="json">{SAMPLE}</pre>
|
|
35
|
+
</PoadCard>
|
|
36
|
+
</section>
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
}
|