@haneinfo/frontend-shell
v1.8.0
Published
Readme
Frontend shell
Shared dashboard layout, navigation, UI primitives, preferences, and application i18n support. See sidebar navigation and preferences for integration details.
Button hover
Buttons keep their resting backgrounds on hover and use a current-color border or inset shadow; destructive and link hover text also moves toward the theme foreground. Rest, dimensions and keyboard focus styles stay unchanged. See button hover contrast for the theme contract and known resting-color limitations, and the P7 validation report.
Shell control labels
ThemeSwitcher, Sheet close, Breadcrumb (including More), and ListPagination use shell-owned
zh-TW/en text from I18nProvider, following useSidebarLabels. No new App catalog keys are
needed; without a provider these controls use zh-TW. Theme names include the current light,
dark, or system mode. App text takes precedence: ThemeSwitcher accepts aria-label,
SheetContent accepts closeLabel, Breadcrumb accepts aria-label, BreadcrumbEllipsis accepts
children, and ListPagination keeps previousText, nextText, and infoText.
ListPagination remains usable from server components with function-valued link builders;
only its default text leaves read the client i18n context.
SidebarTrigger, LocaleSwitcher, ThemeSwitcher, and NotificationBell are 44×44px below the
sm breakpoint (max-sm, 640px). Desktop/tablet sizes stay 28px for the sidebar trigger
and 32px for the other controls. The existing 48px DashboardShell header accommodates them.
Mobile action grouping and search layout belong to the consuming App/template (follow-up T1).
Closing a mobile sidebar opened with SidebarTrigger restores focus to that trigger.
ListPagination links and disabled buttons have a minimum 44px height and width at max-sm;
the desktop sm button variant remains 28px high. Disabled buttons explicitly use type="button".
See the P3 validation report for measurements, default axe scans, desktop pixel comparison, keyboard checks, and screenshot review.
Server API requests
createApiFetch shares the API origin, access-token lookup and cache: 'no-store' between
JSON requests and binary downloads. Pass getBaseUrl to override NEXT_PUBLIC_API_URL.
Without an access token it does not add Authorization. Caller headers can override the bearer token.
Use the default mode for JSON endpoints. Its existing signature and behavior are unchanged:
it sends Content-Type: application/json, parses successful JSON, returns undefined for 204,
and throws ApiError with the existing backend error fields.
import { createApiFetch } from '@haneinfo/frontend-shell';
const apiFetch = createApiFetch({ getAccessToken });
const report = await apiFetch<{ code: string }>('/reports/example');Use responseType: 'binary' for PDF, PNG, CSV, XLSX or other responses that must stream.
This overload returns (path: string, init?: RequestInit) => Promise<Response>.
Successful responses are returned unchanged, with their status, headers and unread body;
even 204 returns a Response. There is no default Content-Type in this mode. When sending
JSON, set the request header explicitly; strings and byte buffers both pass through unchanged.
All standard HeadersInit forms are supported without mutating the caller's headers.
import { ApiError, createApiFetch } from '@haneinfo/frontend-shell';
const apiBinaryFetch = createApiFetch({ getAccessToken, responseType: 'binary' });
try {
const upstream = await apiBinaryFetch('/reports/example/run', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ format: 'pdf', parameters: {} }),
signal: request.signal,
});
const headers = new Headers({
'Cache-Control': 'no-store',
'X-Content-Type-Options': 'nosniff',
});
for (const name of ['Content-Type', 'Content-Disposition', 'Content-Length']) {
const value = upstream.headers.get(name);
if (value) headers.set(name, value);
}
return new Response(upstream.body, { status: upstream.status, headers });
} catch (error) {
if (!(error instanceof ApiError)) throw error;
return Response.json({ error: error.code ?? 'REPORT_EXECUTION_FAILED' }, {
status: error.statusCode,
});
}Only failed HTTP responses are parsed as JSON in binary mode. ApiError.statusCode comes from
the HTTP response, even if its JSON body says otherwise. code is the first string in code,
then message, matching /^[A-Z][A-Z0-9_]+$/. The error's message is that code, or HTTP <status>
when no code is valid; details is undefined and traceId is empty. Backend prose, status text,
stacks and other diagnostics are discarded. Apps still map allowed codes to their own messages.
Network, token-provider and cancellation failures propagate to the caller; cancellation remains
effective while the returned body streams. A proxy owns its response header allowlist and permissions.
The existing wildcard export already exposes this overload and CreateApiBinaryFetchOptions.
See the P2 validation report for the
four reports route-handler migration drafts. Reports adoption follows the G2 release in R5.
Sidebar accessibility
DashboardShell exposes one main landmark. Desktop/tablet sidebars, including icon mode
and collapsible="none", contain brand, navigation, page slot, user menu, and resize handle
in a named region. NavMain exposes a named nav in both desktop and mobile branches.
The mobile Sheet keeps its named modal dialog, with no nested complementary landmark.
When closed, the Sheet and its navigation are absent; when open, Radix hides the background
from the accessibility tree.
Sidebar labels follow I18nProvider (zh-TW or en) using shell-owned text, like other
shell-owned controls. Apps do not need to add catalog keys. Standalone sidebar primitives
without a provider use zh-TW. Existing props, exports, types, classes, and data-slot /
data-sidebar attributes remain compatible; explicit desktop ARIA props still override defaults.
See the validation report for the landmark outline, component/default axe coverage, screenshot comparison, and limitations.
