@tryghost/shade 0.1.0-alpha.5 → 0.1.0-alpha.6
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/README.md
CHANGED
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
# Shade
|
|
2
2
|
|
|
3
|
-
Ghost
|
|
3
|
+
Shade is Ghost's design system for React apps: the tokens, layout primitives,
|
|
4
|
+
components, patterns and page templates that Ghost Admin is built with.
|
|
4
5
|
|
|
5
|
-
##
|
|
6
|
+
## Install in an app
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
`@tryghost/shade/styles.css` or add another `ShadeApp` wrapper. Import
|
|
10
|
-
components from their layer-specific subpaths:
|
|
8
|
+
These steps are for a standalone surface: an app that owns its page, rather
|
|
9
|
+
than one bundled into Ghost Admin.
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import {Button} from '@tryghost/shade/components';
|
|
16
|
-
|
|
17
|
-
export function Example() {
|
|
18
|
-
return <Button>Continue</Button>;
|
|
19
|
-
}
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## Usage in standalone surfaces
|
|
11
|
+
Building a Ghost app, which runs framed inside Admin? Follow
|
|
12
|
+
[Using Shade in a Ghost app](https://github.com/TryGhost/Ghost/blob/main/apps/shade/src/docs/ghost-apps.mdx)
|
|
13
|
+
instead: it also covers fonts, Admin's theme and the page frame.
|
|
23
14
|
|
|
24
15
|
Shade requires React 18 and Tailwind CSS 4.1+. The app compiles Shade's
|
|
25
16
|
`styles.css` together with its own styles using Tailwind's Vite or PostCSS
|
|
@@ -85,59 +76,34 @@ createRoot(document.getElementById('root')!).render(
|
|
|
85
76
|
`.dark` to `document.documentElement` and pass the same state to `ShadeApp` so
|
|
86
77
|
portalled menus and dialogs receive the theme too.
|
|
87
78
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
Admin's stylesheet and application wrapper instead.
|
|
79
|
+
Import from the layer subpaths, such as `@tryghost/shade/components` and
|
|
80
|
+
`@tryghost/shade/primitives`, never the root `@tryghost/shade`.
|
|
91
81
|
|
|
92
|
-
##
|
|
82
|
+
## Inside Ghost Admin
|
|
93
83
|
|
|
94
|
-
|
|
84
|
+
Shade is already set up. Ghost Admin provides Shade's CSS and the `ShadeApp`
|
|
85
|
+
wrapper centrally, so embedded Admin apps, including `apps/admin` and
|
|
86
|
+
`apps/activitypub`, must not import `@tryghost/shade/styles.css` or add another
|
|
87
|
+
`ShadeApp`. They only import components:
|
|
95
88
|
|
|
96
|
-
|
|
97
|
-
|
|
89
|
+
```tsx
|
|
90
|
+
import {Button} from '@tryghost/shade/components';
|
|
98
91
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
92
|
+
export function Example() {
|
|
93
|
+
return <Button>Continue</Button>;
|
|
94
|
+
}
|
|
102
95
|
```
|
|
103
96
|
|
|
104
|
-
|
|
105
|
-
`pnpm --filter @tryghost/shade <command>`.
|
|
106
|
-
|
|
107
|
-
Local docs with Storybook:
|
|
108
|
-
|
|
109
|
-
- `pnpm storybook` — run Storybook and view docs under `src/docs/`
|
|
110
|
-
- `pnpm build-storybook` — build a static export
|
|
111
|
-
- `pnpm build` — build the JavaScript and type declarations
|
|
112
|
-
|
|
113
|
-
### Source exports
|
|
114
|
-
|
|
115
|
-
Admin’s Vite development, production and test configurations select the `source`
|
|
116
|
-
export condition to load this package directly from `src/`. Changes reach Vite
|
|
117
|
-
without waiting for the library build. Consumers without that condition keep
|
|
118
|
-
using the compiled exports; TypeScript continues using the generated declarations.
|
|
119
|
-
The library build remains required for those consumers. Published exports only
|
|
120
|
-
refer to compiled modules and declarations; the workspace-only `source`
|
|
121
|
-
conditions are removed when packing.
|
|
122
|
-
|
|
123
|
-
## Test
|
|
124
|
-
|
|
125
|
-
- `pnpm test` — type-checks and runs Vitest with coverage
|
|
126
|
-
- `pnpm test:unit` — runs Vitest
|
|
127
|
-
- `pnpm test:types` — TypeScript only
|
|
128
|
-
- `pnpm lint` — ESLint for `src/` and `test/`
|
|
129
|
-
|
|
130
|
-
## Publishing
|
|
97
|
+
## Docs
|
|
131
98
|
|
|
132
|
-
Shade
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
`
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
release gates and the unchanged-package check.
|
|
99
|
+
Shade's docs are its Storybook: how to use tokens, primitives, components,
|
|
100
|
+
patterns and page templates, with live examples. It isn't hosted yet. Read the
|
|
101
|
+
sources in
|
|
102
|
+
[`src/docs/`](https://github.com/TryGhost/Ghost/tree/main/apps/shade/src/docs)
|
|
103
|
+
on GitHub, or run it from a Ghost checkout with `pnpm storybook` in
|
|
104
|
+
`apps/shade`.
|
|
139
105
|
|
|
140
|
-
##
|
|
106
|
+
## Working on Shade?
|
|
141
107
|
|
|
142
|
-
|
|
143
|
-
|
|
108
|
+
See [CONTRIBUTING.md](https://github.com/TryGhost/Ghost/blob/main/apps/shade/CONTRIBUTING.md)
|
|
109
|
+
for development, layers, conventions, tests and publishing.
|
|
@@ -90,7 +90,8 @@ function ListPageBody({ className, children, ...rest }) {
|
|
|
90
90
|
* Composition:
|
|
91
91
|
* - `<ListPage.Header>` — sticky, blurred, full-bleed chrome band. Place
|
|
92
92
|
* `PageHeader`, `ViewBar`, and/or `FilterBar` directly inside as siblings.
|
|
93
|
-
* `FilterBar`
|
|
93
|
+
* `FilterBar` hides itself only when it has no children, so mount it
|
|
94
|
+
* while filters are active (`hasFilters && <FilterBar>…</FilterBar>`).
|
|
94
95
|
* - `<ListPage.Body>` — grows to fill remaining space. Use `flex-1 flex items-center justify-center`
|
|
95
96
|
* on the immediate child to vertically center empty/loading states.
|
|
96
97
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-page.js","names":[],"sources":["../../../src/components/page-templates/list-page.tsx"],"sourcesContent":["import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport { Stack } from '@/components/primitives/stack';\nimport { PageHeaderLargeTitleContext } from '@/components/patterns/page-header-large-title';\nimport { cn } from '@/lib/utils';\nimport {\n LARGE_TITLE_HANDOVER,\n LARGE_TITLE_HEADER_OVERLAP,\n useLargeTitleCondense,\n usePageChrome,\n useScrolledPast,\n} from './large-page-title';\n\ntype ListPageProps = React.ComponentPropsWithoutRef<'div'>;\n\n/** The list page's large title, for its header: on, and whether the header has stuck. */\nconst ListPageLargeTitleState = createContext<{\n active: boolean;\n condensed: boolean;\n headerRef?: (element: HTMLElement | null) => void;\n}>({ active: false, condensed: false });\n\n// Under a large title, the header is see-through until the title has handed\n// over, then solid (a layer the handover fades in), with its padding set by\n// LARGE_TITLE_HEADER_OVERLAP; overriding Admin's page chrome, hence important\nconst LARGE_TITLE_HEADER_CLASS_NAME =\n 'bg-none! pt-4! pb-0! backdrop-blur-none! before:pointer-events-none before:absolute before:inset-0 before:-z-10 before:bg-background';\n\n/**\n * Where a list page's title shows large (PageHeader.Title renders into it),\n * with the space above it and the markers its handover to the header is\n * measured by: one spanning the handover, one where the header sticks.\n */\nfunction ListPageLargeTitleSlot({\n hidden,\n slotRef,\n handoverMarkerRef,\n stickMarkerRef,\n}: {\n hidden: boolean;\n slotRef: (element: HTMLElement | null) => void;\n handoverMarkerRef: (element: HTMLElement | null) => void;\n stickMarkerRef: (element: HTMLElement | null) => void;\n}) {\n return (\n <div\n className=\"relative\"\n data-list-page=\"large-title\"\n hidden={hidden}\n style={{ paddingTop: 'var(--large-title-space)' }}\n >\n <div ref={slotRef} />\n <div\n ref={hidden ? undefined : handoverMarkerRef}\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-x-0\"\n data-large-title-marker=\"\"\n style={{\n bottom: `calc(${LARGE_TITLE_HEADER_OVERLAP} - ${LARGE_TITLE_HANDOVER / 2}px)`,\n height: LARGE_TITLE_HANDOVER,\n }}\n />\n <div\n ref={hidden ? undefined : stickMarkerRef}\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-x-0 h-px\"\n style={{ bottom: LARGE_TITLE_HEADER_OVERLAP }}\n />\n </div>\n );\n}\n\n/**\n * Sticky, full-bleed header stack. Place `PageHeader`, `ViewBar`, and/or\n * `FilterBar` directly inside — they stack with a consistent gap.\n *\n * Full-bleed is achieved by negating the parent's horizontal padding\n * (`-mx-4 lg:-mx-8`) and re-applying it (`px-4 lg:px-8`), so the blurred\n * background spans edge-to-edge while content stays aligned with the body.\n *\n * Pass `sticky={false} blurredBackground={false}` to `PageHeader` when using\n * it here — stickiness and blur are handled by `ListPage.Header` instead.\n */\nfunction ListPageHeader({ className, children, style, ...rest }: ListPageProps) {\n const { active, condensed, headerRef } = useContext(ListPageLargeTitleState);\n\n return (\n <Stack\n ref={headerRef}\n className={cn(\n '-mx-4 px-4 lg:-mx-5 lg:px-5',\n 'sticky top-0 z-50',\n 'bg-gradient-to-b from-background via-background/70 to-background/70 backdrop-blur-md',\n 'py-5',\n className,\n active && LARGE_TITLE_HEADER_CLASS_NAME,\n )}\n data-condensed={active && condensed ? '' : undefined}\n data-large-title-header={active ? '' : undefined}\n data-list-page=\"header\"\n gap=\"lg\"\n // Pulled up beside the large title\n style={active ? { marginTop: `calc(-1 * ${LARGE_TITLE_HEADER_OVERLAP})`, ...style } : style}\n {...rest}\n >\n {children}\n </Stack>\n );\n}\n\nfunction ListPageBody({ className, children, ...rest }: ListPageProps) {\n return (\n <Stack\n className={cn('min-h-0 min-w-0 grow pb-4 lg:pb-8', className)}\n data-list-page=\"body\"\n gap=\"none\"\n {...rest}\n >\n {children}\n </Stack>\n );\n}\n\ntype ListPageComponent = React.FC<ListPageProps> & {\n Header: React.FC<ListPageProps>;\n Body: React.FC<ListPageProps>;\n};\n\n/**\n * ListPage is the canonical recipe for the **List page** type — the recurring\n * structure used by Members, Tags, Comments, Automations, etc.\n *\n * It is intentionally thin: a vertical Stack with horizontal padding\n * that grows to fill its flex parent. Drop the named slots in as direct children.\n *\n * Composition:\n * - `<ListPage.Header>` — sticky, blurred, full-bleed chrome band. Place\n * `PageHeader`, `ViewBar`, and/or `FilterBar` directly inside as siblings.\n * `FilterBar` auto-collapses when it has no active filters.\n * - `<ListPage.Body>` — grows to fill remaining space. Use `flex-1 flex items-center justify-center`\n * on the immediate child to vertically center empty/loading states.\n *\n * With large titles on (PageChromeProvider), the header's PageHeader.Title\n * also shows large above the header, with generous space above it. The\n * header is pulled up beside it, see-through, and as the page scrolls the\n * large title fades out, the header turns solid and sticks, and its own small\n * title fades in. A separator sits under the header's first row, unless a\n * FilterBar follows it, which takes its place. A page without a\n * PageHeader.Title keeps the usual header.\n */\nconst ListPage: ListPageComponent = Object.assign(\n function ListPage({ className, children, style, ...rest }: ListPageProps) {\n const { largeTitles } = usePageChrome();\n const [slot, setSlot] = useState<HTMLElement | null>(null);\n const [titles, setTitles] = useState(0);\n const registerTitle = useCallback(() => {\n setTitles((count) => count + 1);\n return () => setTitles((count) => count - 1);\n }, []);\n const active = largeTitles && titles > 0;\n const { markerRef: handoverMarkerRef } = useLargeTitleCondense();\n const { scrolledPast, markerRef: stickMarkerRef } = useScrolledPast();\n\n const largeTitle = useMemo(\n () => (largeTitles ? { slot, registerTitle } : null),\n [largeTitles, slot, registerTitle],\n );\n // The header's height (it doesn't change under a large title), for the\n // body's table labels to stick beneath it (styles.css). Only large titles\n // stick them, so it's left unset otherwise\n const [host, setHost] = useState<HTMLElement | null>(null);\n const [header, setHeader] = useState<HTMLElement | null>(null);\n useEffect(() => {\n if (!largeTitles || !host || !header || typeof ResizeObserver === 'undefined') {\n return;\n }\n const update = () =>\n host.style.setProperty('--list-page-header-height', `${header.offsetHeight}px`);\n update();\n const observer = new ResizeObserver(update);\n observer.observe(header);\n return () => {\n observer.disconnect();\n host.style.removeProperty('--list-page-header-height');\n };\n }, [largeTitles, host, header]);\n\n const state = useMemo(\n () => ({ active, condensed: scrolledPast, headerRef: setHeader }),\n [active, scrolledPast],\n );\n\n return (\n <PageHeaderLargeTitleContext.Provider value={largeTitle}>\n <ListPageLargeTitleState.Provider value={state}>\n <Stack\n ref={setHost}\n className={cn('h-full min-h-0 grow px-4 lg:px-6', className)}\n data-large-title-host={largeTitles ? '' : undefined}\n data-list-page=\"list-page\"\n gap=\"none\"\n style={style}\n {...rest}\n >\n {largeTitles && (\n <ListPageLargeTitleSlot\n handoverMarkerRef={handoverMarkerRef}\n hidden={!active}\n slotRef={setSlot}\n stickMarkerRef={stickMarkerRef}\n />\n )}\n {children}\n </Stack>\n </ListPageLargeTitleState.Provider>\n </PageHeaderLargeTitleContext.Provider>\n );\n },\n {\n Header: ListPageHeader,\n Body: ListPageBody,\n },\n);\n\nexport { ListPage, ListPageHeader, ListPageBody };\n"],"mappings":";;;;;;;;AAeA,IAAM,0BAA0B,cAI7B;CAAE,QAAQ;CAAO,WAAW;AAAM,CAAC;AAKtC,IAAM,gCACJ;;;;;;AAOF,SAAS,uBAAuB,EAC9B,QACA,SACA,mBACA,kBAMC;CACD,OACE,qBAAC,OAAD;EACE,WAAU;EACV,kBAAe;EACP;EACR,OAAO,EAAE,YAAY,2BAA2B;YAJlD;GAME,oBAAC,OAAD,EAAK,KAAK,QAAU,CAAA;GACpB,oBAAC,OAAD;IACE,KAAK,SAAS,KAAA,IAAY;IAC1B,eAAY;IACZ,WAAU;IACV,2BAAwB;IACxB,OAAO;KACL,QAAQ,QAAQ,2BAA2B,KAAA,KAA4B,EAAE;KACzE,QAAA;IACF;GACD,CAAA;GACD,oBAAC,OAAD;IACE,KAAK,SAAS,KAAA,IAAY;IAC1B,eAAY;IACZ,WAAU;IACV,OAAO,EAAE,QAAQ,2BAA2B;GAC7C,CAAA;EACE;;AAET;;;;;;;;;;;;AAaA,SAAS,eAAe,EAAE,WAAW,UAAU,OAAO,GAAG,QAAuB;CAC9E,MAAM,EAAE,QAAQ,WAAW,cAAc,WAAW,uBAAuB;CAE3E,OACE,oBAAC,OAAD;EACE,KAAK;EACL,WAAW,GACT,+BACA,qBACA,wFACA,QACA,WACA,UAAU,6BACZ;EACA,kBAAgB,UAAU,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GACX,SAAS,WAAW;GACpB,KAAK,MAAM,eAAe,2BAA2B;EACvD;CACF,GAAG;EAAC;EAAa;EAAM;CAAM,CAAC;CAE9B,MAAM,QAAQ,eACL;EAAE;EAAQ,WAAW;EAAc,WAAW;CAAU,IAC/D,CAAC,QAAQ,YAAY,CACvB;CAEA,OACE,oBAAC,4BAA4B,UAA7B;EAAsC,OAAO;YAC3C,oBAAC,wBAAwB,UAAzB;GAAkC,OAAO;aACvC,qBAAC,OAAD;IACE,KAAK;IACL,WAAW,GAAG,oCAAoC,SAAS;IAC3D,yBAAuB,cAAc,KAAK,KAAA;IAC1C,kBAAe;IACf,KAAI;IACG;IACP,GAAI;cAPN,CASG,eACC,oBAAC,wBAAD;KACqB;KACnB,QAAQ,CAAC;KACT,SAAS;KACO;IACjB,CAAA,GAEF,QACI;;EACyB,CAAA;CACE,CAAA;AAE1C,GACA;CACE,QAAQ;CACR,MAAM;AACR,CACF"}
|
|
1
|
+
{"version":3,"file":"list-page.js","names":[],"sources":["../../../src/components/page-templates/list-page.tsx"],"sourcesContent":["import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport { Stack } from '@/components/primitives/stack';\nimport { PageHeaderLargeTitleContext } from '@/components/patterns/page-header-large-title';\nimport { cn } from '@/lib/utils';\nimport {\n LARGE_TITLE_HANDOVER,\n LARGE_TITLE_HEADER_OVERLAP,\n useLargeTitleCondense,\n usePageChrome,\n useScrolledPast,\n} from './large-page-title';\n\ntype ListPageProps = React.ComponentPropsWithoutRef<'div'>;\n\n/** The list page's large title, for its header: on, and whether the header has stuck. */\nconst ListPageLargeTitleState = createContext<{\n active: boolean;\n condensed: boolean;\n headerRef?: (element: HTMLElement | null) => void;\n}>({ active: false, condensed: false });\n\n// Under a large title, the header is see-through until the title has handed\n// over, then solid (a layer the handover fades in), with its padding set by\n// LARGE_TITLE_HEADER_OVERLAP; overriding Admin's page chrome, hence important\nconst LARGE_TITLE_HEADER_CLASS_NAME =\n 'bg-none! pt-4! pb-0! backdrop-blur-none! before:pointer-events-none before:absolute before:inset-0 before:-z-10 before:bg-background';\n\n/**\n * Where a list page's title shows large (PageHeader.Title renders into it),\n * with the space above it and the markers its handover to the header is\n * measured by: one spanning the handover, one where the header sticks.\n */\nfunction ListPageLargeTitleSlot({\n hidden,\n slotRef,\n handoverMarkerRef,\n stickMarkerRef,\n}: {\n hidden: boolean;\n slotRef: (element: HTMLElement | null) => void;\n handoverMarkerRef: (element: HTMLElement | null) => void;\n stickMarkerRef: (element: HTMLElement | null) => void;\n}) {\n return (\n <div\n className=\"relative\"\n data-list-page=\"large-title\"\n hidden={hidden}\n style={{ paddingTop: 'var(--large-title-space)' }}\n >\n <div ref={slotRef} />\n <div\n ref={hidden ? undefined : handoverMarkerRef}\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-x-0\"\n data-large-title-marker=\"\"\n style={{\n bottom: `calc(${LARGE_TITLE_HEADER_OVERLAP} - ${LARGE_TITLE_HANDOVER / 2}px)`,\n height: LARGE_TITLE_HANDOVER,\n }}\n />\n <div\n ref={hidden ? undefined : stickMarkerRef}\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-x-0 h-px\"\n style={{ bottom: LARGE_TITLE_HEADER_OVERLAP }}\n />\n </div>\n );\n}\n\n/**\n * Sticky, full-bleed header stack. Place `PageHeader`, `ViewBar`, and/or\n * `FilterBar` directly inside — they stack with a consistent gap.\n *\n * Full-bleed is achieved by negating the parent's horizontal padding\n * (`-mx-4 lg:-mx-8`) and re-applying it (`px-4 lg:px-8`), so the blurred\n * background spans edge-to-edge while content stays aligned with the body.\n *\n * Pass `sticky={false} blurredBackground={false}` to `PageHeader` when using\n * it here — stickiness and blur are handled by `ListPage.Header` instead.\n */\nfunction ListPageHeader({ className, children, style, ...rest }: ListPageProps) {\n const { active, condensed, headerRef } = useContext(ListPageLargeTitleState);\n\n return (\n <Stack\n ref={headerRef}\n className={cn(\n '-mx-4 px-4 lg:-mx-5 lg:px-5',\n 'sticky top-0 z-50',\n 'bg-gradient-to-b from-background via-background/70 to-background/70 backdrop-blur-md',\n 'py-5',\n className,\n active && LARGE_TITLE_HEADER_CLASS_NAME,\n )}\n data-condensed={active && condensed ? '' : undefined}\n data-large-title-header={active ? '' : undefined}\n data-list-page=\"header\"\n gap=\"lg\"\n // Pulled up beside the large title\n style={active ? { marginTop: `calc(-1 * ${LARGE_TITLE_HEADER_OVERLAP})`, ...style } : style}\n {...rest}\n >\n {children}\n </Stack>\n );\n}\n\nfunction ListPageBody({ className, children, ...rest }: ListPageProps) {\n return (\n <Stack\n className={cn('min-h-0 min-w-0 grow pb-4 lg:pb-8', className)}\n data-list-page=\"body\"\n gap=\"none\"\n {...rest}\n >\n {children}\n </Stack>\n );\n}\n\ntype ListPageComponent = React.FC<ListPageProps> & {\n Header: React.FC<ListPageProps>;\n Body: React.FC<ListPageProps>;\n};\n\n/**\n * ListPage is the canonical recipe for the **List page** type — the recurring\n * structure used by Members, Tags, Comments, Automations, etc.\n *\n * It is intentionally thin: a vertical Stack with horizontal padding\n * that grows to fill its flex parent. Drop the named slots in as direct children.\n *\n * Composition:\n * - `<ListPage.Header>` — sticky, blurred, full-bleed chrome band. Place\n * `PageHeader`, `ViewBar`, and/or `FilterBar` directly inside as siblings.\n * `FilterBar` hides itself only when it has no children, so mount it\n * while filters are active (`hasFilters && <FilterBar>…</FilterBar>`).\n * - `<ListPage.Body>` — grows to fill remaining space. Use `flex-1 flex items-center justify-center`\n * on the immediate child to vertically center empty/loading states.\n *\n * With large titles on (PageChromeProvider), the header's PageHeader.Title\n * also shows large above the header, with generous space above it. The\n * header is pulled up beside it, see-through, and as the page scrolls the\n * large title fades out, the header turns solid and sticks, and its own small\n * title fades in. A separator sits under the header's first row, unless a\n * FilterBar follows it, which takes its place. A page without a\n * PageHeader.Title keeps the usual header.\n */\nconst ListPage: ListPageComponent = Object.assign(\n function ListPage({ className, children, style, ...rest }: ListPageProps) {\n const { largeTitles } = usePageChrome();\n const [slot, setSlot] = useState<HTMLElement | null>(null);\n const [titles, setTitles] = useState(0);\n const registerTitle = useCallback(() => {\n setTitles((count) => count + 1);\n return () => setTitles((count) => count - 1);\n }, []);\n const active = largeTitles && titles > 0;\n const { markerRef: handoverMarkerRef } = useLargeTitleCondense();\n const { scrolledPast, markerRef: stickMarkerRef } = useScrolledPast();\n\n const largeTitle = useMemo(\n () => (largeTitles ? { slot, registerTitle } : null),\n [largeTitles, slot, registerTitle],\n );\n // The header's height (it doesn't change under a large title), for the\n // body's table labels to stick beneath it (styles.css). Only large titles\n // stick them, so it's left unset otherwise\n const [host, setHost] = useState<HTMLElement | null>(null);\n const [header, setHeader] = useState<HTMLElement | null>(null);\n useEffect(() => {\n if (!largeTitles || !host || !header || typeof ResizeObserver === 'undefined') {\n return;\n }\n const update = () =>\n host.style.setProperty('--list-page-header-height', `${header.offsetHeight}px`);\n update();\n const observer = new ResizeObserver(update);\n observer.observe(header);\n return () => {\n observer.disconnect();\n host.style.removeProperty('--list-page-header-height');\n };\n }, [largeTitles, host, header]);\n\n const state = useMemo(\n () => ({ active, condensed: scrolledPast, headerRef: setHeader }),\n [active, scrolledPast],\n );\n\n return (\n <PageHeaderLargeTitleContext.Provider value={largeTitle}>\n <ListPageLargeTitleState.Provider value={state}>\n <Stack\n ref={setHost}\n className={cn('h-full min-h-0 grow px-4 lg:px-6', className)}\n data-large-title-host={largeTitles ? '' : undefined}\n data-list-page=\"list-page\"\n gap=\"none\"\n style={style}\n {...rest}\n >\n {largeTitles && (\n <ListPageLargeTitleSlot\n handoverMarkerRef={handoverMarkerRef}\n hidden={!active}\n slotRef={setSlot}\n stickMarkerRef={stickMarkerRef}\n />\n )}\n {children}\n </Stack>\n </ListPageLargeTitleState.Provider>\n </PageHeaderLargeTitleContext.Provider>\n );\n },\n {\n Header: ListPageHeader,\n Body: ListPageBody,\n },\n);\n\nexport { ListPage, ListPageHeader, ListPageBody };\n"],"mappings":";;;;;;;;AAeA,IAAM,0BAA0B,cAI7B;CAAE,QAAQ;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Q,CAAC;KACT,SAAS;KACO;IACjB,CAAA,GAEF,QACI;;EACyB,CAAA;CACE,CAAA;AAE1C,GACA;CACE,QAAQ;CACR,MAAM;AACR,CACF"}
|
package/package.json
CHANGED
|
@@ -27,7 +27,8 @@ type ListPageComponent = React.FC<ListPageProps> & {
|
|
|
27
27
|
* Composition:
|
|
28
28
|
* - `<ListPage.Header>` — sticky, blurred, full-bleed chrome band. Place
|
|
29
29
|
* `PageHeader`, `ViewBar`, and/or `FilterBar` directly inside as siblings.
|
|
30
|
-
* `FilterBar`
|
|
30
|
+
* `FilterBar` hides itself only when it has no children, so mount it
|
|
31
|
+
* while filters are active (`hasFilters && <FilterBar>…</FilterBar>`).
|
|
31
32
|
* - `<ListPage.Body>` — grows to fill remaining space. Use `flex-1 flex items-center justify-center`
|
|
32
33
|
* on the immediate child to vertically center empty/loading states.
|
|
33
34
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-page.d.ts","sourceRoot":"","sources":["../../../src/components/page-templates/list-page.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+E,MAAM,OAAO,CAAC;AAYpG,KAAK,aAAa,GAAG,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC;AA2D3D;;;;;;;;;;GAUG;AACH,iBAAS,cAAc,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE,aAAa,qBAyB7E;AAED,iBAAS,YAAY,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,aAAa,qBAWpE;AAED,KAAK,iBAAiB,GAAG,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,GAAG;IACjD,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;IAChC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;CAC/B,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"list-page.d.ts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