@djangocfg/layouts 2.1.638 → 2.1.639
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/package.json +12 -12
- package/src/components/errors/ErrorsTracker/components/ErrorToast.tsx +0 -19
- package/src/components/errors/ErrorsTracker/utils/curl-generator.ts +3 -16
- package/src/components/errors/README.md +5 -20
- package/src/layouts/AppLayout/BaseApp.tsx +3 -0
- package/src/layouts/AppLayout/README.md +3 -1
- package/src/layouts/AppLayout/devtoolsBaseUrl.test.ts +25 -0
- package/src/layouts/AppLayout/devtoolsBaseUrl.ts +18 -0
- package/src/layouts/AppLayout/index.ts +1 -0
- package/src/layouts/AuthLayout/components/oauth/buttons/OAuthProviderButton.tsx +1 -1
- package/src/layouts/AuthLayout/styles/auth.css +16 -5
- package/src/layouts/AuthLayout/styles/oauth.css +6 -0
- package/src/layouts/PrivateLayout/PrivateLayout.tsx +2 -0
- package/src/layouts/PrivateLayout/components/PrivateContent.tsx +1 -1
- package/src/layouts/PrivateLayout/components/SidebarBrand.tsx +1 -1
- package/src/layouts/PrivateLayout/geometry.test.ts +2 -0
- package/src/layouts/PrivateLayout/geometry.ts +1 -1
- package/src/layouts/PublicLayout/footers/DefaultFooter/DefaultFooter.tsx +9 -8
- package/src/layouts/PublicLayout/footers/DefaultFooter/FooterBottom.tsx +3 -2
- package/src/layouts/PublicLayout/footers/DefaultFooter/FooterMenuSections.tsx +3 -2
- package/src/layouts/PublicLayout/footers/DefaultFooter/touch.ts +5 -0
- package/src/layouts/PublicLayout/primitives/NavBrand.tsx +1 -1
- package/src/layouts/PublicLayout/primitives/navDesktopStyles.ts +2 -2
- package/src/layouts/PublicLayout/shared/MobileDrawerShell.tsx +4 -4
- package/src/layouts/types/layout.types.ts +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/layouts",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.639",
|
|
4
4
|
"description": "Simple, straightforward layout components for Next.js - import and use with props",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"layouts",
|
|
@@ -91,11 +91,11 @@
|
|
|
91
91
|
"test": "vitest run"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
|
-
"@djangocfg/analytics": "^2.1.
|
|
95
|
-
"@djangocfg/api": "^2.1.
|
|
96
|
-
"@djangocfg/devtools": "^2.1.
|
|
97
|
-
"@djangocfg/i18n": "^2.1.
|
|
98
|
-
"@djangocfg/ui-core": "^2.1.
|
|
94
|
+
"@djangocfg/analytics": "^2.1.639",
|
|
95
|
+
"@djangocfg/api": "^2.1.639",
|
|
96
|
+
"@djangocfg/devtools": "^2.1.639",
|
|
97
|
+
"@djangocfg/i18n": "^2.1.639",
|
|
98
|
+
"@djangocfg/ui-core": "^2.1.639",
|
|
99
99
|
"@hookform/resolvers": "^5.2.2 || ^7.0.2",
|
|
100
100
|
"consola": "^3.4.2",
|
|
101
101
|
"lucide-react": "^1.68.0",
|
|
@@ -123,12 +123,12 @@
|
|
|
123
123
|
"qrcode.react": "^4.2.0"
|
|
124
124
|
},
|
|
125
125
|
"devDependencies": {
|
|
126
|
-
"@djangocfg/analytics": "^2.1.
|
|
127
|
-
"@djangocfg/api": "^2.1.
|
|
128
|
-
"@djangocfg/devtools": "^2.1.
|
|
129
|
-
"@djangocfg/i18n": "^2.1.
|
|
130
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
131
|
-
"@djangocfg/ui-core": "^2.1.
|
|
126
|
+
"@djangocfg/analytics": "^2.1.639",
|
|
127
|
+
"@djangocfg/api": "^2.1.639",
|
|
128
|
+
"@djangocfg/devtools": "^2.1.639",
|
|
129
|
+
"@djangocfg/i18n": "^2.1.639",
|
|
130
|
+
"@djangocfg/typescript-config": "^2.1.639",
|
|
131
|
+
"@djangocfg/ui-core": "^2.1.639",
|
|
132
132
|
"@storybook/react-vite": "^10.6.5",
|
|
133
133
|
"@types/node": "^25.9.5",
|
|
134
134
|
"@types/react": "19.3.0",
|
|
@@ -8,8 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
import React from 'react';
|
|
10
10
|
|
|
11
|
-
import { isDev } from '@djangocfg/ui-core/lib';
|
|
12
|
-
|
|
13
11
|
import { extractDomain, formatErrorTitle, formatZodIssues, safeZodIssues } from '../utils/formatters';
|
|
14
12
|
import { ErrorButtons } from './ErrorButtons';
|
|
15
13
|
|
|
@@ -106,17 +104,6 @@ function buildNetworkDescription(
|
|
|
106
104
|
parts.push(`Status: ${detail.statusCode}`);
|
|
107
105
|
}
|
|
108
106
|
|
|
109
|
-
// DPoP (RFC 9449) 401s are easy to mistake for a plain auth failure. In dev,
|
|
110
|
-
// add a clear hint pointing at the cause. Detected from the backend's error
|
|
111
|
-
// message (codes dpop_proof_required / dpop_proof_invalid). Dev-only so end
|
|
112
|
-
// users never see internal proof wording.
|
|
113
|
-
const looksDpop =
|
|
114
|
-
detail.statusCode === 401 && /dpop/i.test(detail.error || '');
|
|
115
|
-
const dpopHint = isDev && looksDpop
|
|
116
|
-
? 'DPoP: this token is sender-constrained — the request needs a valid DPoP proof '
|
|
117
|
-
+ 'signed by the in-browser key. A copied/replayed token will 401.'
|
|
118
|
-
: null;
|
|
119
|
-
|
|
120
107
|
return (
|
|
121
108
|
<div className="flex flex-col gap-2 text-sm">
|
|
122
109
|
{parts.length > 0 && (
|
|
@@ -127,12 +114,6 @@ function buildNetworkDescription(
|
|
|
127
114
|
|
|
128
115
|
<div className="opacity-90">{detail.error}</div>
|
|
129
116
|
|
|
130
|
-
{dpopHint && (
|
|
131
|
-
<div className="rounded-md bg-warning/10 px-2 py-1 text-xs text-warning-foreground">
|
|
132
|
-
{dpopHint}
|
|
133
|
-
</div>
|
|
134
|
-
)}
|
|
135
|
-
|
|
136
117
|
<ErrorButtons detail={detail} />
|
|
137
118
|
</div>
|
|
138
119
|
);
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Generates cURL commands from API request details with authentication token
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { auth
|
|
9
|
+
import { auth } from '@djangocfg/api';
|
|
10
10
|
import consola from 'consola';
|
|
11
11
|
|
|
12
12
|
export interface CurlOptions {
|
|
@@ -86,20 +86,7 @@ export function generateCurl(options: CurlOptions): string {
|
|
|
86
86
|
...headers,
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
let preamble = '';
|
|
91
|
-
|
|
92
|
-
if (dpop) {
|
|
93
|
-
// DPoP on → the Bearer token is non-replayable from a terminal. Offer the
|
|
94
|
-
// API-key path instead (the supported way to script the API), with a
|
|
95
|
-
// placeholder the user fills from Settings → API keys.
|
|
96
|
-
allHeaders['X-API-Key'] = '<your-api-key>';
|
|
97
|
-
preamble =
|
|
98
|
-
'# This endpoint is DPoP-protected: a copied Bearer token returns 401\n' +
|
|
99
|
-
'# (it is bound to a non-extractable in-browser key, proof expires ~60s).\n' +
|
|
100
|
-
'# For scripts, use an API key — get one at: Settings → API keys.\n';
|
|
101
|
-
} else if (token) {
|
|
102
|
-
// No DPoP → a Bearer token works in a terminal as-is.
|
|
89
|
+
if (token) {
|
|
103
90
|
allHeaders['Authorization'] = `Bearer ${token}`;
|
|
104
91
|
}
|
|
105
92
|
|
|
@@ -116,7 +103,7 @@ export function generateCurl(options: CurlOptions): string {
|
|
|
116
103
|
}
|
|
117
104
|
|
|
118
105
|
// Join with line continuation
|
|
119
|
-
return
|
|
106
|
+
return curlParts.join(' \\\n ');
|
|
120
107
|
}
|
|
121
108
|
|
|
122
109
|
/**
|
|
@@ -70,29 +70,14 @@ import { ErrorTrackingProvider } from '@djangocfg/layouts'; // (or the module pa
|
|
|
70
70
|
|
|
71
71
|
Each toast has **Copy error** (JSON to clipboard) and, for requests, **Copy cURL**.
|
|
72
72
|
|
|
73
|
-
### Copy-as-cURL
|
|
73
|
+
### Copy-as-cURL
|
|
74
74
|
|
|
75
|
-
`utils/curl-generator.ts` builds a runnable cURL from the failed request
|
|
76
|
-
|
|
77
|
-
-
|
|
78
|
-
`auth.getToken()`), so the command works as-is in a terminal.
|
|
79
|
-
- **DPoP on** (`dpopEnabled` from `@djangocfg/api`) — a copied Bearer token would
|
|
80
|
-
just `401` (it is bound to a non-extractable in-browser key and needs a fresh
|
|
81
|
-
proof that can't leave the browser). So the cURL instead emits an
|
|
82
|
-
`X-API-Key: <your-api-key>` placeholder plus a comment pointing to
|
|
83
|
-
**Settings → API keys** — the supported way to script the API (Stripe/GitHub
|
|
84
|
-
model). See `@djangocfg/nextjs/@docs/DPOP.md`.
|
|
85
|
-
|
|
86
|
-
### DPoP error hint
|
|
87
|
-
|
|
88
|
-
A `401` whose body mentions DPoP (`dpop_proof_required` / `dpop_proof_invalid`)
|
|
89
|
-
gets an extra **dev-only** hint in the toast explaining it's a sender-constraint
|
|
90
|
-
failure, so it isn't mistaken for a plain auth error. End users never see the
|
|
91
|
-
internal proof wording (gated by `isDev`).
|
|
75
|
+
`utils/curl-generator.ts` builds a runnable cURL from the failed request, with
|
|
76
|
+
`Authorization: Bearer <token>` (read live via `auth.getToken()`), so the command
|
|
77
|
+
works as-is in a terminal.
|
|
92
78
|
|
|
93
79
|
## Notes
|
|
94
80
|
|
|
95
|
-
-
|
|
96
|
-
`@djangocfg/ui-core/lib`, `dpopEnabled` from `@djangocfg/api`.
|
|
81
|
+
- The `isDev` flag comes from `@djangocfg/ui-core/lib`.
|
|
97
82
|
- Errors also flow to `@djangocfg/devtools` (backend ingest + debug panel) for
|
|
98
83
|
inspection regardless of toast visibility.
|
|
@@ -63,6 +63,7 @@ import type { BaseLayoutProps } from '../types/layout.types';
|
|
|
63
63
|
import { LayoutI18nProvider } from '../../shared/LayoutI18nProvider';
|
|
64
64
|
import { ProjectNameProvider } from '../../shared/ProjectContext';
|
|
65
65
|
import { PwaManifestCheck, PwaMetaGuard } from './pwaMeta';
|
|
66
|
+
import { resolveDevtoolsBaseUrl } from './devtoolsBaseUrl';
|
|
66
67
|
|
|
67
68
|
import React from 'react';
|
|
68
69
|
|
|
@@ -100,6 +101,7 @@ export function BaseApp({
|
|
|
100
101
|
project,
|
|
101
102
|
theme,
|
|
102
103
|
auth,
|
|
104
|
+
apiUrl,
|
|
103
105
|
analytics,
|
|
104
106
|
errorTracking,
|
|
105
107
|
errorBoundary,
|
|
@@ -122,6 +124,7 @@ export function BaseApp({
|
|
|
122
124
|
project,
|
|
123
125
|
environment: nodeEnv,
|
|
124
126
|
...devtoolsConfig,
|
|
127
|
+
baseUrl: resolveDevtoolsBaseUrl({ auth, apiUrl, devtools: devtoolsConfig }),
|
|
125
128
|
};
|
|
126
129
|
|
|
127
130
|
const content = (
|
|
@@ -23,8 +23,10 @@ export default function RootLayout({ children }) {
|
|
|
23
23
|
<BaseApp
|
|
24
24
|
project="my-app"
|
|
25
25
|
theme={{ defaultTheme: 'system', storageKey: 'myapp-theme' }}
|
|
26
|
+
// Public app with no login: auth={false} apiUrl={process.env.NEXT_PUBLIC_API_URL}
|
|
26
27
|
auth={{ apiUrl: process.env.NEXT_PUBLIC_API_URL,
|
|
27
28
|
routes: { auth: '/auth', defaultCallback: '/private' } }}
|
|
29
|
+
// devtools ingest uses auth.apiUrl, or `apiUrl` when auth={false}, as its base URL
|
|
28
30
|
// analytics / monitor / errorTracking / debug — all optional
|
|
29
31
|
>
|
|
30
32
|
{children}
|
|
@@ -76,7 +78,7 @@ interface BaseAppProps {
|
|
|
76
78
|
children: ReactNode;
|
|
77
79
|
project?: string; // monitor.project + debug panel title default
|
|
78
80
|
theme?: ThemeConfig; // defaultTheme, storageKey, style preset
|
|
79
|
-
auth?: AuthConfig | false; // false = no AuthProvider (fully public app)
|
|
81
|
+
auth?: AuthConfig | false; // false = no AuthProvider (fully public app); `{ sso: true }` = one sign-in host (auth.<apex>) for the subdomains
|
|
80
82
|
analytics?: AnalyticsConfig; // Google Analytics
|
|
81
83
|
errorTracking?: ErrorTrackingConfig;
|
|
82
84
|
errorBoundary?: ErrorBoundaryConfig; // enabled by default
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { resolveDevtoolsBaseUrl } from './devtoolsBaseUrl';
|
|
4
|
+
|
|
5
|
+
describe('resolveDevtoolsBaseUrl', () => {
|
|
6
|
+
it('takes auth.apiUrl when auth is configured', () => {
|
|
7
|
+
expect(resolveDevtoolsBaseUrl({ auth: { apiUrl: 'https://api.a.com' } })).toBe('https://api.a.com');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('takes the apiUrl prop for auth={false} apps', () => {
|
|
11
|
+
expect(resolveDevtoolsBaseUrl({ auth: false, apiUrl: 'https://api.b.com' })).toBe('https://api.b.com');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('an explicit devtools.baseUrl wins, then apiUrl, then auth.apiUrl', () => {
|
|
15
|
+
const all = { auth: { apiUrl: 'https://auth' }, apiUrl: 'https://prop', devtools: { baseUrl: 'https://dt' } };
|
|
16
|
+
expect(resolveDevtoolsBaseUrl(all)).toBe('https://dt');
|
|
17
|
+
expect(resolveDevtoolsBaseUrl({ ...all, devtools: {} })).toBe('https://prop');
|
|
18
|
+
expect(resolveDevtoolsBaseUrl({ auth: all.auth })).toBe('https://auth');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('is undefined when nothing is set, so devtools falls back to the env var and warns', () => {
|
|
22
|
+
expect(resolveDevtoolsBaseUrl({ auth: false })).toBeUndefined();
|
|
23
|
+
expect(resolveDevtoolsBaseUrl({ auth: { apiUrl: '' }, apiUrl: ' ' })).toBeUndefined();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BaseLayoutProps } from '../types/layout.types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The ingest origin for devtools: an explicit `devtools.baseUrl`, else the
|
|
5
|
+
* `apiUrl` prop (apps with `auth={false}`), else `auth.apiUrl`. Undefined when
|
|
6
|
+
* none is set, and `@djangocfg/devtools` then falls back to NEXT_PUBLIC_API_URL
|
|
7
|
+
* and warns in the console if that is empty too.
|
|
8
|
+
*/
|
|
9
|
+
export function resolveDevtoolsBaseUrl(
|
|
10
|
+
props: Pick<BaseLayoutProps, 'auth' | 'apiUrl' | 'devtools'>,
|
|
11
|
+
): string | undefined {
|
|
12
|
+
const pick = (v?: string) => (v && v.trim() ? v : undefined);
|
|
13
|
+
return (
|
|
14
|
+
pick(props.devtools?.baseUrl) ??
|
|
15
|
+
pick(props.apiUrl) ??
|
|
16
|
+
pick(props.auth === false ? undefined : props.auth?.apiUrl)
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -30,7 +30,7 @@ function OAuthProviderButtonRaw({ Icon, label, loading = false, className, ...pr
|
|
|
30
30
|
loading={loading}
|
|
31
31
|
aria-busy={loading || undefined}
|
|
32
32
|
className={cn(
|
|
33
|
-
'h-auto min-h-[var(--auth-oauth-height)] w-full gap-2.5 whitespace-normal px-4 py-2 text-center text-sm font-medium shadow-none',
|
|
33
|
+
'auth-oauth-button h-auto min-h-[var(--auth-oauth-height)] w-full gap-2.5 whitespace-normal px-4 py-2 text-center text-sm font-medium shadow-none',
|
|
34
34
|
'hover:bg-accent hover:text-accent-foreground active:bg-accent/70',
|
|
35
35
|
'focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
|
|
36
36
|
'disabled:opacity-50',
|
|
@@ -97,7 +97,8 @@
|
|
|
97
97
|
.auth-locale-trigger {
|
|
98
98
|
height: 2.75rem;
|
|
99
99
|
padding-inline: 0.75rem;
|
|
100
|
-
|
|
100
|
+
/* 14px like the "Home" link beside it; 12px read as fine print on a phone. */
|
|
101
|
+
font-size: 0.875rem;
|
|
101
102
|
color: var(--auth-muted);
|
|
102
103
|
transition: color 0.15s var(--spring-snappy);
|
|
103
104
|
}
|
|
@@ -470,7 +471,7 @@ a.auth-logo:focus-visible {
|
|
|
470
471
|
display: flex;
|
|
471
472
|
justify-content: center;
|
|
472
473
|
gap: 0.75rem;
|
|
473
|
-
font-size: 0.
|
|
474
|
+
font-size: 0.875rem;
|
|
474
475
|
color: var(--auth-muted);
|
|
475
476
|
}
|
|
476
477
|
|
|
@@ -504,7 +505,7 @@ a.auth-logo:focus-visible {
|
|
|
504
505
|
.auth-consent {
|
|
505
506
|
margin: calc(var(--auth-gap) * -0.25) 0 0;
|
|
506
507
|
text-align: center;
|
|
507
|
-
font-size: 0.
|
|
508
|
+
font-size: 0.75rem;
|
|
508
509
|
line-height: 1.5;
|
|
509
510
|
color: var(--auth-muted);
|
|
510
511
|
}
|
|
@@ -536,7 +537,7 @@ a.auth-logo:focus-visible {
|
|
|
536
537
|
align-items: flex-start;
|
|
537
538
|
gap: 0.625rem;
|
|
538
539
|
text-align: left;
|
|
539
|
-
font-size: 0.
|
|
540
|
+
font-size: 0.875rem;
|
|
540
541
|
line-height: 1.5;
|
|
541
542
|
color: var(--auth-muted);
|
|
542
543
|
cursor: pointer;
|
|
@@ -570,7 +571,7 @@ a.auth-logo:focus-visible {
|
|
|
570
571
|
justify-content: center;
|
|
571
572
|
gap: 0.375rem;
|
|
572
573
|
padding: 0.4375rem 1rem;
|
|
573
|
-
font-size: 0.
|
|
574
|
+
font-size: 0.875rem;
|
|
574
575
|
font-weight: 500;
|
|
575
576
|
letter-spacing: -0.005em;
|
|
576
577
|
color: var(--auth-muted);
|
|
@@ -739,3 +740,13 @@ a.auth-logo:focus-visible {
|
|
|
739
740
|
transition-duration: 0.01ms !important;
|
|
740
741
|
}
|
|
741
742
|
}
|
|
743
|
+
|
|
744
|
+
/* A finger gets 44px targets for the text actions of the form (inline prose links elsewhere are exempt). */
|
|
745
|
+
@media (pointer: coarse) {
|
|
746
|
+
.auth-footer a,
|
|
747
|
+
.auth-link {
|
|
748
|
+
display: inline-flex;
|
|
749
|
+
align-items: center;
|
|
750
|
+
min-height: 2.75rem;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
@@ -97,3 +97,9 @@
|
|
|
97
97
|
margin-block: -0.375rem;
|
|
98
98
|
color: var(--auth-muted);
|
|
99
99
|
}
|
|
100
|
+
|
|
101
|
+
/* Provider button label: 14px at any preset. The preset's `text-sm` is 13px (Notion) and read as fine print on the
|
|
102
|
+
48px button; the form's own fields are 15px. */
|
|
103
|
+
.auth-oauth-button {
|
|
104
|
+
font-size: 0.875rem;
|
|
105
|
+
}
|
|
@@ -126,6 +126,8 @@ export function PrivateLayout({
|
|
|
126
126
|
defaultOpen={defaultOpen}
|
|
127
127
|
style={{ ...providerStyle, ...sidebarWidth.style }}
|
|
128
128
|
className={cn(SHELL_CLASS, providerClassName)}
|
|
129
|
+
// Named for `syncScrollReset` (ui-core): the clipped shell is scrolled by focus, and put back when the keyboard closes.
|
|
130
|
+
data-app-shell=""
|
|
129
131
|
data-sidebar-resizing={sidebarWidth.dragging || undefined}
|
|
130
132
|
>
|
|
131
133
|
<SidebarWidthContext.Provider value={sidebarWidth}>
|
|
@@ -116,7 +116,7 @@ export function PrivateContent({
|
|
|
116
116
|
<Link
|
|
117
117
|
href={titleHref}
|
|
118
118
|
aria-label={typeof title === 'string' && title ? title : 'Home'}
|
|
119
|
-
className="rounded-md text-foreground no-underline outline-none ring-ring transition-opacity hover:no-underline hover:opacity-80 focus-visible:ring-2"
|
|
119
|
+
className="rounded-md text-foreground no-underline outline-none ring-ring pointer-coarse:block pointer-coarse:w-fit pointer-coarse:max-w-full pointer-coarse:truncate pointer-coarse:py-2.5 transition-opacity hover:no-underline hover:opacity-80 focus-visible:ring-2"
|
|
120
120
|
>
|
|
121
121
|
{title}
|
|
122
122
|
</Link>
|
|
@@ -17,7 +17,7 @@ import { PrivateSidebarTrigger } from './PrivateSidebarTrigger';
|
|
|
17
17
|
import { SidebarBrandSwitcher } from './SidebarBrandSwitcher';
|
|
18
18
|
|
|
19
19
|
const BRAND_LINK =
|
|
20
|
-
'flex min-w-0 items-center gap-2.5 rounded-lg py-1 text-sidebar-foreground no-underline outline-none ring-sidebar-ring transition-opacity hover:no-underline hover:opacity-80 focus-visible:ring-2';
|
|
20
|
+
'flex min-w-0 items-center gap-2.5 rounded-lg py-1 pointer-coarse:min-h-11 text-sidebar-foreground no-underline outline-none ring-sidebar-ring transition-opacity hover:no-underline hover:opacity-80 focus-visible:ring-2';
|
|
21
21
|
|
|
22
22
|
/** Brand name: semibold, one step larger on desktop (18px), 16px on a phone; one line, truncated. */
|
|
23
23
|
const BRAND_NAME = 'truncate text-base font-semibold tracking-tight md:text-sm md:font-medium';
|
|
@@ -23,6 +23,8 @@ describe('sidebar geometry', () => {
|
|
|
23
23
|
it('mobile rows are 40px with a 44px hit area (see touch-safe.css); desktop rows are 36px', () => {
|
|
24
24
|
expect(NAV_GEOMETRY.mobile.item).toMatch(/\bh-10\b/);
|
|
25
25
|
expect(NAV_GEOMETRY.desktop.item).toContain('h-(--sidebar-item-h)');
|
|
26
|
+
// A coarse pointer on a docked sidebar (tablet) still gets a 44px row.
|
|
27
|
+
expect(NAV_GEOMETRY.desktop.item).toContain('pointer-coarse:min-h-11');
|
|
26
28
|
});
|
|
27
29
|
|
|
28
30
|
it('mobile header and footer never go under the status bar or home indicator', () => {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
export const NAV_GEOMETRY = {
|
|
7
7
|
desktop: {
|
|
8
8
|
/** Row height, type size and corner come from ui-core tokens (`--sidebar-item-*`), so a preset sets them (Notion: 30px, 14px, 6px). */
|
|
9
|
-
item: 'h-(--sidebar-item-h) gap-2.5 px-2 text-(length:--sidebar-item-font) [&>svg]:size-4',
|
|
9
|
+
item: 'h-(--sidebar-item-h) pointer-coarse:min-h-11! gap-2.5 px-2 text-(length:--sidebar-item-font) [&>svg]:size-4',
|
|
10
10
|
label: 'h-7 px-2 text-xs',
|
|
11
11
|
/** Horizontal inset of groups, slots and the divider; equals the header and footer inset. */
|
|
12
12
|
inset: 'px-2',
|
|
@@ -16,6 +16,7 @@ import { ThemeModeControl } from './ThemeModeControl';
|
|
|
16
16
|
import { FooterMenuSections } from './FooterMenuSections';
|
|
17
17
|
import { FooterProjectInfo } from './FooterProjectInfo';
|
|
18
18
|
|
|
19
|
+
import { FOOTER_LINK_TOUCH } from './touch';
|
|
19
20
|
import type { DefaultFooterProps } from './types';
|
|
20
21
|
|
|
21
22
|
function DefaultFooterRaw({ config }: DefaultFooterProps) {
|
|
@@ -86,7 +87,7 @@ function DefaultFooterRaw({ config }: DefaultFooterProps) {
|
|
|
86
87
|
href={link.path}
|
|
87
88
|
target="_blank"
|
|
88
89
|
rel="noopener noreferrer"
|
|
89
|
-
className=
|
|
90
|
+
className={`text-sm text-muted-foreground hover:text-foreground transition-colors ${FOOTER_LINK_TOUCH}`}
|
|
90
91
|
>
|
|
91
92
|
{link.label}
|
|
92
93
|
</a>
|
|
@@ -94,7 +95,7 @@ function DefaultFooterRaw({ config }: DefaultFooterProps) {
|
|
|
94
95
|
<Link
|
|
95
96
|
key={link.path}
|
|
96
97
|
href={link.path}
|
|
97
|
-
className=
|
|
98
|
+
className={`text-sm text-muted-foreground hover:text-foreground transition-colors ${FOOTER_LINK_TOUCH}`}
|
|
98
99
|
>
|
|
99
100
|
{link.label}
|
|
100
101
|
</Link>
|
|
@@ -160,7 +161,7 @@ function DefaultFooterRaw({ config }: DefaultFooterProps) {
|
|
|
160
161
|
href={link.path}
|
|
161
162
|
target="_blank"
|
|
162
163
|
rel="noopener noreferrer"
|
|
163
|
-
className=
|
|
164
|
+
className={`text-xs text-muted-foreground hover:text-primary transition-colors ${FOOTER_LINK_TOUCH}`}
|
|
164
165
|
>
|
|
165
166
|
{link.label}
|
|
166
167
|
</a>
|
|
@@ -168,7 +169,7 @@ function DefaultFooterRaw({ config }: DefaultFooterProps) {
|
|
|
168
169
|
<Link
|
|
169
170
|
key={link.path}
|
|
170
171
|
href={link.path}
|
|
171
|
-
className=
|
|
172
|
+
className={`text-xs text-muted-foreground hover:text-primary transition-colors ${FOOTER_LINK_TOUCH}`}
|
|
172
173
|
>
|
|
173
174
|
{link.label}
|
|
174
175
|
</Link>
|
|
@@ -182,7 +183,7 @@ function DefaultFooterRaw({ config }: DefaultFooterProps) {
|
|
|
182
183
|
{credits && (
|
|
183
184
|
<div className="text-xs text-muted-foreground text-center">
|
|
184
185
|
{credits.url ? (
|
|
185
|
-
<a href={credits.url} target="_blank" rel="noopener noreferrer" className=
|
|
186
|
+
<a href={credits.url} target="_blank" rel="noopener noreferrer" className={`hover:text-foreground transition-colors ${FOOTER_LINK_TOUCH}`}>
|
|
186
187
|
{credits.text}
|
|
187
188
|
</a>
|
|
188
189
|
) : (
|
|
@@ -250,7 +251,7 @@ function DefaultFooterRaw({ config }: DefaultFooterProps) {
|
|
|
250
251
|
<div className="flex min-w-0 flex-wrap items-center justify-center gap-3 text-center text-xs text-muted-foreground lg:justify-self-center">
|
|
251
252
|
{credits && (
|
|
252
253
|
credits.url ? (
|
|
253
|
-
<a href={credits.url} target="_blank" rel="noopener noreferrer" className=
|
|
254
|
+
<a href={credits.url} target="_blank" rel="noopener noreferrer" className={`hover:text-foreground transition-colors whitespace-nowrap ${FOOTER_LINK_TOUCH}`}>
|
|
254
255
|
{credits.text}
|
|
255
256
|
</a>
|
|
256
257
|
) : (
|
|
@@ -264,12 +265,12 @@ function DefaultFooterRaw({ config }: DefaultFooterProps) {
|
|
|
264
265
|
href={link.path}
|
|
265
266
|
target="_blank"
|
|
266
267
|
rel="noopener noreferrer"
|
|
267
|
-
className=
|
|
268
|
+
className={`hover:text-foreground transition-colors whitespace-nowrap ${FOOTER_LINK_TOUCH}`}
|
|
268
269
|
>
|
|
269
270
|
{link.label}
|
|
270
271
|
</a>
|
|
271
272
|
) : (
|
|
272
|
-
<Link key={link.path} href={link.path} className=
|
|
273
|
+
<Link key={link.path} href={link.path} className={`hover:text-foreground transition-colors whitespace-nowrap ${FOOTER_LINK_TOUCH}`}>
|
|
273
274
|
{link.label}
|
|
274
275
|
</Link>
|
|
275
276
|
)
|
|
@@ -5,6 +5,7 @@ import React from 'react';
|
|
|
5
5
|
import { Link } from '@djangocfg/ui-core/components';
|
|
6
6
|
import { DjangoCFGLogo } from './DjangoCFGLogo';
|
|
7
7
|
|
|
8
|
+
import { FOOTER_LINK_TOUCH } from './touch';
|
|
8
9
|
import type { FooterLink } from './types';
|
|
9
10
|
|
|
10
11
|
export interface FooterBottomProps {
|
|
@@ -90,7 +91,7 @@ export function FooterBottom({
|
|
|
90
91
|
href={link.path}
|
|
91
92
|
target="_blank"
|
|
92
93
|
rel="noopener noreferrer"
|
|
93
|
-
className=
|
|
94
|
+
className={`text-xs text-muted-foreground hover:text-primary transition-colors ${FOOTER_LINK_TOUCH}`}
|
|
94
95
|
>
|
|
95
96
|
{link.label}
|
|
96
97
|
</a>
|
|
@@ -98,7 +99,7 @@ export function FooterBottom({
|
|
|
98
99
|
<Link
|
|
99
100
|
key={link.path}
|
|
100
101
|
href={link.path}
|
|
101
|
-
className=
|
|
102
|
+
className={`text-xs text-muted-foreground hover:text-primary transition-colors ${FOOTER_LINK_TOUCH}`}
|
|
102
103
|
>
|
|
103
104
|
{link.label}
|
|
104
105
|
</Link>
|
|
@@ -4,6 +4,7 @@ import React from 'react';
|
|
|
4
4
|
|
|
5
5
|
import { Link } from '@djangocfg/ui-core/components';
|
|
6
6
|
|
|
7
|
+
import { FOOTER_LINK_TOUCH } from './touch';
|
|
7
8
|
import type { FooterMenuSection } from './types';
|
|
8
9
|
|
|
9
10
|
export interface FooterMenuSectionsProps {
|
|
@@ -31,12 +32,12 @@ export function FooterMenuSections({
|
|
|
31
32
|
<h3 className="text-xs font-medium text-muted-foreground mb-3">
|
|
32
33
|
{section.title}
|
|
33
34
|
</h3>
|
|
34
|
-
<ul className="space-y-2">
|
|
35
|
+
<ul className="space-y-2 pointer-coarse:space-y-0">
|
|
35
36
|
{section.items.map((item) => (
|
|
36
37
|
<li key={item.path}>
|
|
37
38
|
<Link
|
|
38
39
|
href={item.path}
|
|
39
|
-
className=
|
|
40
|
+
className={`text-sm text-foreground/90 hover:text-foreground transition-colors ${FOOTER_LINK_TOUCH}`}
|
|
40
41
|
>
|
|
41
42
|
{item.label}
|
|
42
43
|
</Link>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Footer links are text in a row, 12-14px tall. On a coarse pointer each one becomes a 44px-tall target
|
|
3
|
+
* (`inline-flex` so a short label still gets the height); a mouse keeps the compact footer.
|
|
4
|
+
*/
|
|
5
|
+
export const FOOTER_LINK_TOUCH = 'pointer-coarse:inline-flex pointer-coarse:min-h-11 pointer-coarse:items-center';
|
|
@@ -16,7 +16,7 @@ function NavBrandRaw({ brand, brandHref = '/' }: NavBrandProps) {
|
|
|
16
16
|
return (
|
|
17
17
|
<Link
|
|
18
18
|
href={brandHref}
|
|
19
|
-
className="font-bold text-[15px] text-foreground hover:opacity-90 transition-opacity"
|
|
19
|
+
className="font-bold text-[15px] text-foreground hover:opacity-90 transition-opacity pointer-coarse:inline-flex pointer-coarse:min-h-11 pointer-coarse:items-center"
|
|
20
20
|
>
|
|
21
21
|
{brand}
|
|
22
22
|
</Link>
|
|
@@ -10,7 +10,7 @@ import { cn } from '@djangocfg/ui-core/lib';
|
|
|
10
10
|
// BUTTONS stay pills like every other button in the product. Making the rows
|
|
11
11
|
// pills too is what produced capsules floating inside a soft-cornered popover.
|
|
12
12
|
export const navItemCls = cn(
|
|
13
|
-
'inline-flex min-h-9 items-center justify-center gap-1 rounded-control border border-transparent px-4 py-1.5 text-sm !font-medium',
|
|
13
|
+
'inline-flex min-h-9 pointer-coarse:min-h-11 items-center justify-center gap-1 rounded-control border border-transparent px-4 py-1.5 text-sm !font-medium',
|
|
14
14
|
'ring-0 focus-visible:ring-0',
|
|
15
15
|
'text-foreground/90 transition-colors',
|
|
16
16
|
'surface-hover hover:text-foreground',
|
|
@@ -24,7 +24,7 @@ export const labelCls = 'min-w-0 max-w-[11rem] truncate sm:max-w-[13rem]';
|
|
|
24
24
|
|
|
25
25
|
export function subMenuLinkCls(active: boolean) {
|
|
26
26
|
return cn(
|
|
27
|
-
'flex min-h-9 min-w-0 max-w-[min(17rem,calc(100vw-5rem))] items-center rounded-control border-0 px-3 py-2 text-sm font-medium transition-colors',
|
|
27
|
+
'flex min-h-9 pointer-coarse:min-h-11 min-w-0 max-w-[min(17rem,calc(100vw-5rem))] items-center rounded-control border-0 px-3 py-2 text-sm font-medium transition-colors',
|
|
28
28
|
'surface-hover',
|
|
29
29
|
active
|
|
30
30
|
? 'border-0 bg-accent font-semibold text-foreground shadow-sm dark:bg-muted/90 dark:shadow-none'
|
|
@@ -178,9 +178,9 @@ export function MobileDrawerShell(props: MobileDrawerShellProps) {
|
|
|
178
178
|
</Link>
|
|
179
179
|
{hasChildNav && (
|
|
180
180
|
// Children stay expanded (a short scroll beats an extra
|
|
181
|
-
// tap)
|
|
182
|
-
//
|
|
183
|
-
//
|
|
181
|
+
// tap). Every row is a 44px target, children included,
|
|
182
|
+
// with smaller type and no bold to keep the parents
|
|
183
|
+
// the louder line.
|
|
184
184
|
//
|
|
185
185
|
// The rule sits at `ml-[1.125rem]` — the centre of the
|
|
186
186
|
// parent's text inset (px-3 + half a character) — so the
|
|
@@ -196,7 +196,7 @@ export function MobileDrawerShell(props: MobileDrawerShellProps) {
|
|
|
196
196
|
onClick={closeMobileMenu}
|
|
197
197
|
title={subItem.label}
|
|
198
198
|
className={cn(
|
|
199
|
-
'flex min-h-
|
|
199
|
+
'flex min-h-11 min-w-0 max-w-full items-center rounded-control border-0 px-3 text-sm font-medium transition-colors ring-0 truncate',
|
|
200
200
|
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/35',
|
|
201
201
|
subActive
|
|
202
202
|
? 'border-0 bg-accent font-semibold text-foreground shadow-sm dark:border dark:border-border dark:bg-muted/90 dark:shadow-none'
|
|
@@ -53,6 +53,13 @@ export interface BaseLayoutProps {
|
|
|
53
53
|
/** Auth configuration. Pass `false` to disable AuthProvider entirely (public apps). */
|
|
54
54
|
auth?: AuthConfig | false;
|
|
55
55
|
|
|
56
|
+
/**
|
|
57
|
+
* django-cfg API origin for apps with `auth={false}` (public apps): used as the
|
|
58
|
+
* devtools ingest `baseUrl`, so one value is enough. With auth configured the
|
|
59
|
+
* origin comes from `auth.apiUrl`. An explicit `devtools={{ baseUrl }}` wins.
|
|
60
|
+
*/
|
|
61
|
+
apiUrl?: string;
|
|
62
|
+
|
|
56
63
|
/** Analytics configuration (from snippets/Analytics) */
|
|
57
64
|
analytics?: AnalyticsConfig;
|
|
58
65
|
|