@estiva-app/ui 0.94.0 → 0.96.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/dist/AppShell.d.ts +25 -7
- package/dist/AppShell.d.ts.map +1 -1
- package/dist/ArchivedNotice.d.ts +28 -0
- package/dist/ArchivedNotice.d.ts.map +1 -0
- package/dist/Button.d.ts +4 -3
- package/dist/Button.d.ts.map +1 -1
- package/dist/Card.d.ts.map +1 -1
- package/dist/CommentBox.d.ts.map +1 -1
- package/dist/ConversationActions.d.ts +24 -0
- package/dist/ConversationActions.d.ts.map +1 -0
- package/dist/ConversationCard.d.ts +88 -0
- package/dist/ConversationCard.d.ts.map +1 -0
- package/dist/ConversationLayout.d.ts +50 -0
- package/dist/ConversationLayout.d.ts.map +1 -0
- package/dist/ConversationMenu.d.ts +24 -0
- package/dist/ConversationMenu.d.ts.map +1 -0
- package/dist/Divider.d.ts +23 -4
- package/dist/Divider.d.ts.map +1 -1
- package/dist/EditedMarker.d.ts +11 -0
- package/dist/EditedMarker.d.ts.map +1 -0
- package/dist/IconButton.d.ts +3 -3
- package/dist/IconButton.d.ts.map +1 -1
- package/dist/LinkParts.d.ts +3 -1
- package/dist/LinkParts.d.ts.map +1 -1
- package/dist/LinkRow.d.ts.map +1 -1
- package/dist/ListColumn.d.ts +3 -1
- package/dist/ListColumn.d.ts.map +1 -1
- package/dist/MetaText.d.ts +22 -0
- package/dist/MetaText.d.ts.map +1 -0
- package/dist/NavItem.d.ts.map +1 -1
- package/dist/PageHeader.d.ts +50 -0
- package/dist/PageHeader.d.ts.map +1 -0
- package/dist/Panel.d.ts +6 -0
- package/dist/Panel.d.ts.map +1 -1
- package/dist/PartCard.d.ts +4 -7
- package/dist/PartCard.d.ts.map +1 -1
- package/dist/PinnedComment.d.ts +17 -0
- package/dist/PinnedComment.d.ts.map +1 -0
- package/dist/QuotedLine.d.ts +16 -0
- package/dist/QuotedLine.d.ts.map +1 -0
- package/dist/ReactionHorizon.d.ts +14 -0
- package/dist/ReactionHorizon.d.ts.map +1 -0
- package/dist/RepliesRow.d.ts +26 -0
- package/dist/RepliesRow.d.ts.map +1 -0
- package/dist/ResolveDialog.d.ts +13 -0
- package/dist/ResolveDialog.d.ts.map +1 -0
- package/dist/Select.d.ts +1 -1
- package/dist/Select.d.ts.map +1 -1
- package/dist/ShowMore.d.ts +1 -7
- package/dist/ShowMore.d.ts.map +1 -1
- package/dist/Skeleton.d.ts +8 -4
- package/dist/Skeleton.d.ts.map +1 -1
- package/dist/Thread.d.ts +38 -0
- package/dist/Thread.d.ts.map +1 -0
- package/dist/TopBar.d.ts +3 -2
- package/dist/TopBar.d.ts.map +1 -1
- package/dist/UrgentMark.d.ts +6 -0
- package/dist/UrgentMark.d.ts.map +1 -0
- package/dist/commentBoxFrame.d.ts +3 -1
- package/dist/commentBoxFrame.d.ts.map +1 -1
- package/dist/conversation.examples.d.ts +52 -0
- package/dist/conversation.examples.d.ts.map +1 -0
- package/dist/editor.js +32 -24
- package/dist/editor.js.map +2 -2
- package/dist/eslint/index.js +2 -1
- package/dist/eslint/index.js.map +2 -2
- package/dist/eslint/no-native-title.d.ts +1 -1
- package/dist/eslint/no-native-title.d.ts.map +1 -1
- package/dist/eslint/no-restyled-part.d.ts.map +1 -1
- package/dist/index.d.ts +18 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1379 -442
- package/dist/index.js.map +4 -4
- package/dist/looks.d.ts +13 -1
- package/dist/looks.d.ts.map +1 -1
- package/dist/threadCard.d.ts +46 -0
- package/dist/threadCard.d.ts.map +1 -0
- package/package.json +1 -1
- package/registry.json +1872 -557
- package/src/AppShell.mdx +24 -10
- package/src/AppShell.stories.tsx +65 -31
- package/src/AppShell.test.tsx +92 -10
- package/src/AppShell.tsx +108 -18
- package/src/ArchivedNotice.mdx +46 -0
- package/src/ArchivedNotice.stories.tsx +52 -0
- package/src/ArchivedNotice.test.tsx +42 -0
- package/src/ArchivedNotice.tsx +71 -0
- package/src/Button.mdx +2 -2
- package/src/Button.tsx +8 -6
- package/src/Card.test.tsx +4 -4
- package/src/Card.tsx +6 -2
- package/src/CommentBox.test.tsx +2 -1
- package/src/CommentBox.tsx +14 -7
- package/src/ConfirmDialog.stories.tsx +12 -0
- package/src/ConversationActions.mdx +47 -0
- package/src/ConversationActions.stories.tsx +39 -0
- package/src/ConversationActions.tsx +96 -0
- package/src/ConversationCard.mdx +72 -0
- package/src/ConversationCard.states.test.tsx +330 -0
- package/src/ConversationCard.stories.tsx +135 -0
- package/src/ConversationCard.test.tsx +159 -0
- package/src/ConversationCard.tsx +522 -0
- package/src/ConversationLayout.mdx +61 -0
- package/src/ConversationLayout.stories.tsx +161 -0
- package/src/ConversationLayout.test.tsx +240 -0
- package/src/ConversationLayout.tsx +233 -0
- package/src/ConversationMenu.mdx +47 -0
- package/src/ConversationMenu.stories.tsx +42 -0
- package/src/ConversationMenu.test.tsx +47 -0
- package/src/ConversationMenu.tsx +57 -0
- package/src/Divider.mdx +36 -1
- package/src/Divider.stories.tsx +57 -0
- package/src/Divider.test.tsx +24 -1
- package/src/Divider.tsx +49 -9
- package/src/EditedMarker.mdx +36 -0
- package/src/EditedMarker.stories.tsx +24 -0
- package/src/EditedMarker.tsx +20 -0
- package/src/IconButton.mdx +2 -1
- package/src/IconButton.tsx +8 -5
- package/src/LinkCard.test.tsx +5 -2
- package/src/LinkParts.mdx +4 -0
- package/src/LinkParts.stories.tsx +10 -0
- package/src/LinkParts.tsx +5 -1
- package/src/LinkRow.mdx +1 -1
- package/src/LinkRow.tsx +10 -5
- package/src/ListColumn.tsx +9 -3
- package/src/MetaText.mdx +41 -0
- package/src/MetaText.stories.tsx +29 -0
- package/src/MetaText.tsx +38 -0
- package/src/NavItem.tsx +2 -11
- package/src/PageHeader.mdx +123 -0
- package/src/PageHeader.stories.tsx +174 -0
- package/src/PageHeader.test.tsx +99 -0
- package/src/PageHeader.tsx +105 -0
- package/src/Panel.mdx +12 -0
- package/src/Panel.stories.tsx +47 -5
- package/src/Panel.test.tsx +40 -0
- package/src/Panel.tsx +8 -2
- package/src/PartCard.mdx +1 -1
- package/src/PartCard.stories.tsx +2 -9
- package/src/PartCard.test.tsx +13 -1
- package/src/PartCard.tsx +6 -9
- package/src/PinnedComment.mdx +40 -0
- package/src/PinnedComment.stories.tsx +21 -0
- package/src/PinnedComment.tsx +40 -0
- package/src/QuotedLine.mdx +44 -0
- package/src/QuotedLine.stories.tsx +30 -0
- package/src/QuotedLine.test.tsx +34 -0
- package/src/QuotedLine.tsx +33 -0
- package/src/ReactionHorizon.mdx +36 -0
- package/src/ReactionHorizon.stories.tsx +27 -0
- package/src/ReactionHorizon.tsx +27 -0
- package/src/RepliesRow.mdx +45 -0
- package/src/RepliesRow.stories.tsx +33 -0
- package/src/RepliesRow.test.tsx +47 -0
- package/src/RepliesRow.tsx +86 -0
- package/src/ReplyCard.mdx +50 -0
- package/src/ReplyCard.stories.tsx +68 -0
- package/src/ResolveDialog.mdx +44 -0
- package/src/ResolveDialog.stories.tsx +23 -0
- package/src/ResolveDialog.test.tsx +53 -0
- package/src/ResolveDialog.tsx +58 -0
- package/src/Select.tsx +12 -2
- package/src/ShowMore.mdx +2 -5
- package/src/ShowMore.stories.tsx +0 -14
- package/src/ShowMore.test.tsx +0 -16
- package/src/ShowMore.tsx +2 -16
- package/src/Skeleton.stories.tsx +4 -1
- package/src/Skeleton.tsx +33 -4
- package/src/Thread.mdx +53 -0
- package/src/Thread.stories.tsx +167 -0
- package/src/Thread.test.tsx +83 -0
- package/src/Thread.tsx +113 -0
- package/src/TopBar.mdx +8 -6
- package/src/TopBar.stories.tsx +4 -3
- package/src/TopBar.tsx +8 -3
- package/src/UrgentMark.mdx +37 -0
- package/src/UrgentMark.stories.tsx +27 -0
- package/src/UrgentMark.tsx +15 -0
- package/src/commentBoxFrame.tsx +8 -4
- package/src/conversation.examples.tsx +135 -0
- package/src/eslint/no-native-title.ts +1 -1
- package/src/eslint/no-restyled-part.ts +1 -0
- package/src/index.ts +19 -2
- package/src/looks.ts +18 -2
- package/src/registry/registry.test.ts +7 -6
- package/src/threadCard.ts +84 -0
- package/stories/Choosing.mdx +21 -1
- package/tokens.css +14 -10
package/src/LinkRow.tsx
CHANGED
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
* At most 480px wide, as a card is, in a box being written in too.
|
|
10
10
|
*/
|
|
11
11
|
import { useContext } from 'react'
|
|
12
|
+
import { IconExternalLink } from '@tabler/icons-react'
|
|
12
13
|
import { Avatar } from './Avatar'
|
|
13
14
|
import { AvatarGroup } from './AvatarGroup'
|
|
15
|
+
import { Button } from './Button'
|
|
14
16
|
import { Card } from './Card'
|
|
15
17
|
import { cn } from './cn'
|
|
16
18
|
import { Link } from './Link'
|
|
@@ -19,6 +21,7 @@ import { CommentCount, kindNounOf, LinkedIcon, LinkTile, ProgressRing, StatusMar
|
|
|
19
21
|
import { LinkPreview } from './LinkPreview'
|
|
20
22
|
import { TIME_CLASSES, TYPE_TILE_CLASSES } from './looks'
|
|
21
23
|
import { SkeletonBar } from './Skeleton'
|
|
24
|
+
import { WithTooltip } from './Tooltip'
|
|
22
25
|
|
|
23
26
|
export interface LinkUnavailableProps {
|
|
24
27
|
kind: LinkedKind
|
|
@@ -63,12 +66,14 @@ export function UnavailableRow({ kind, words, href, openIn, card = false }: { ki
|
|
|
63
66
|
words
|
|
64
67
|
)}
|
|
65
68
|
</span>
|
|
69
|
+
{/* The kit's Button as a link, as Peek's file header has it (Katerina, 31 Oct): "Open", the app in its name and
|
|
70
|
+
tooltip, in place of a text link with a typed arrow. */}
|
|
66
71
|
{openIn && (
|
|
67
|
-
<
|
|
68
|
-
<
|
|
69
|
-
Open
|
|
70
|
-
</
|
|
71
|
-
</
|
|
72
|
+
<WithTooltip label={`Open in ${openIn.app}`}>
|
|
73
|
+
<Button href={openIn.href} external size="small" className="shrink-0" leadingIcon={<IconExternalLink stroke={1.5} className="size-3.5" />} aria-label={`Open in ${openIn.app}`}>
|
|
74
|
+
Open
|
|
75
|
+
</Button>
|
|
76
|
+
</WithTooltip>
|
|
72
77
|
)}
|
|
73
78
|
</Card>
|
|
74
79
|
)
|
package/src/ListColumn.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import type { ReactNode } from 'react'
|
|
|
2
2
|
import { cn } from './cn'
|
|
3
3
|
import { ContainerHeader } from './ContainerHeader'
|
|
4
4
|
import { ErrorBoundary } from './ErrorBoundary'
|
|
5
|
+
import { FOLDED_CLASSES, FOLD_MOTION_CLASSES, UNFOLDED_CLASSES } from './looks'
|
|
5
6
|
import { ScrollArea } from './ScrollArea'
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -25,7 +26,9 @@ import { ScrollArea } from './ScrollArea'
|
|
|
25
26
|
* in the middle of the room the list had, and the rest of the page keeps working.
|
|
26
27
|
*
|
|
27
28
|
* `collapsed` closes it with the rail, as Peek's did: it narrows to nothing
|
|
28
|
-
* and fades, in 300ms
|
|
29
|
+
* and fades, in 300ms, as `AppShell`'s fold does, and nothing in it can be
|
|
30
|
+
* reached. The fold that closes it is the frame's; whether it is closed is
|
|
31
|
+
* the app's to hand on.
|
|
29
32
|
*/
|
|
30
33
|
export interface ListColumnProps {
|
|
31
34
|
/** The column's name, in its header. A node for a title that is more than words. */
|
|
@@ -51,11 +54,14 @@ function Column({ title, chevron = false, titleMenu, actions, above, collapsed =
|
|
|
51
54
|
<div
|
|
52
55
|
className={cn(
|
|
53
56
|
// `shrink-0`: the column keeps its 290px beside a main area that grows.
|
|
54
|
-
'flex shrink-0 flex-col overflow-hidden border-r border-border-subtle transition-[width,opacity]
|
|
55
|
-
|
|
57
|
+
'flex shrink-0 flex-col overflow-hidden border-r border-border-subtle transition-[width,opacity,visibility]',
|
|
58
|
+
FOLD_MOTION_CLASSES,
|
|
59
|
+
collapsed ? cn('w-0 border-r-0', FOLDED_CLASSES) : cn('w-[290px]', UNFOLDED_CLASSES),
|
|
56
60
|
className,
|
|
57
61
|
)}
|
|
58
62
|
data-collapsed={collapsed || undefined}
|
|
63
|
+
// Closed, nothing in it can be reached: inert at once, hidden once it has faded, as AppShell's folded navigation.
|
|
64
|
+
inert={collapsed}
|
|
59
65
|
>
|
|
60
66
|
<ContainerHeader title={title} chevron={chevron} titleMenu={titleMenu} actions={actions} />
|
|
61
67
|
{above}
|
package/src/MetaText.mdx
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks'
|
|
2
|
+
import * as Stories from './MetaText.stories'
|
|
3
|
+
|
|
4
|
+
<Meta of={Stories} />
|
|
5
|
+
|
|
6
|
+
# MetaText
|
|
7
|
+
|
|
8
|
+
The small figure beside a name: a time, a resolve line's time, a count. In Signal the mono micro-type with even digits.
|
|
9
|
+
|
|
10
|
+
<Canvas of={Stories.Time} />
|
|
11
|
+
|
|
12
|
+
## When
|
|
13
|
+
|
|
14
|
+
- A time beside a name.
|
|
15
|
+
- `tone="secondary"` and `tone="success"` for counts of open and resolved.
|
|
16
|
+
- `size="chip"` beside a small name.
|
|
17
|
+
|
|
18
|
+
<Canvas of={Stories.Counts} />
|
|
19
|
+
|
|
20
|
+
## When not
|
|
21
|
+
|
|
22
|
+
- Words a person reads as a sentence → plain text in the caption size.
|
|
23
|
+
- A status → **Chip**.
|
|
24
|
+
|
|
25
|
+
## How
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { MetaText } from '@estiva-app/ui'
|
|
29
|
+
|
|
30
|
+
<MetaText>11:08 AM</MetaText>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- It never wraps.
|
|
34
|
+
|
|
35
|
+
## What it owns
|
|
36
|
+
|
|
37
|
+
Nothing. It only draws. Clicks and keys are yours.
|
|
38
|
+
|
|
39
|
+
## Props
|
|
40
|
+
|
|
41
|
+
<Controls />
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
+
import { MetaText } from './MetaText'
|
|
3
|
+
|
|
4
|
+
/** The small figure beside a name. In Signal the mono micro-type; in the other themes the caption. */
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'Conversation/MetaText',
|
|
7
|
+
component: MetaText,
|
|
8
|
+
parameters: { layout: 'padded' },
|
|
9
|
+
args: { children: '11:08 AM' },
|
|
10
|
+
} satisfies Meta<typeof MetaText>
|
|
11
|
+
|
|
12
|
+
export default meta
|
|
13
|
+
type Story = StoryObj<typeof meta>
|
|
14
|
+
|
|
15
|
+
/** A time. */
|
|
16
|
+
export const Time: Story = {}
|
|
17
|
+
|
|
18
|
+
/** Counts, of open and of resolved. */
|
|
19
|
+
export const Counts: Story = {
|
|
20
|
+
render: () => (
|
|
21
|
+
<span className="flex items-center gap-2">
|
|
22
|
+
<MetaText tone="secondary">6 open</MetaText>
|
|
23
|
+
<MetaText tone="success">2 resolved</MetaText>
|
|
24
|
+
</span>
|
|
25
|
+
),
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The smaller size, beside a small name. */
|
|
29
|
+
export const Small: Story = { args: { size: 'chip' } }
|
package/src/MetaText.tsx
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
import { cn } from './cn'
|
|
3
|
+
import { TIME_CLASSES } from './looks'
|
|
4
|
+
|
|
5
|
+
const TONE_CLASSES = {
|
|
6
|
+
muted: 'text-text-muted',
|
|
7
|
+
secondary: 'text-text-secondary',
|
|
8
|
+
success: 'text-success-default',
|
|
9
|
+
} as const
|
|
10
|
+
|
|
11
|
+
export interface MetaTextProps {
|
|
12
|
+
children: ReactNode
|
|
13
|
+
/** `muted` for a time; `secondary` and `success` for counts of open and resolved. */
|
|
14
|
+
tone?: keyof typeof TONE_CLASSES
|
|
15
|
+
/** `chip` beside a small name, as in a thread's resolve line. */
|
|
16
|
+
size?: 'caption' | 'chip'
|
|
17
|
+
/** Placement only: `shrink-0`, `contents`. */
|
|
18
|
+
className?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The small figure beside a name: a comment's time, a resolve line's time, a count. One line; in Signal the mono
|
|
23
|
+
* micro-type with even digits. Peek's, moved with the conversation (Katerina, 31 October: Peek's way in every app).
|
|
24
|
+
*/
|
|
25
|
+
export function MetaText({ children, tone = 'muted', size = 'caption', className }: MetaTextProps) {
|
|
26
|
+
return (
|
|
27
|
+
<span
|
|
28
|
+
className={cn(
|
|
29
|
+
size === 'chip' ? 'text-chip font-normal' : 'text-caption',
|
|
30
|
+
TONE_CLASSES[tone],
|
|
31
|
+
TIME_CLASSES,
|
|
32
|
+
className,
|
|
33
|
+
)}
|
|
34
|
+
>
|
|
35
|
+
{children}
|
|
36
|
+
</span>
|
|
37
|
+
)
|
|
38
|
+
}
|
package/src/NavItem.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useId, useState, type ComponentPropsWithoutRef, type ReactNode } from 'react'
|
|
2
2
|
import { Collapsible } from '@base-ui/react/collapsible'
|
|
3
|
-
import {
|
|
3
|
+
import { IconChevronRight, IconDotsVertical } from '@tabler/icons-react'
|
|
4
|
+
import { UrgentMark } from './UrgentMark'
|
|
4
5
|
import { useInAppClick } from './AppProvider'
|
|
5
6
|
import { cn } from './cn'
|
|
6
7
|
import { useOpenFor } from './CollapsibleSection'
|
|
@@ -296,13 +297,3 @@ export function NavItem({
|
|
|
296
297
|
)
|
|
297
298
|
}
|
|
298
299
|
|
|
299
|
-
/** Urgent and unread: a 12px warning mark on its tint, in the dot's 24px slot. */
|
|
300
|
-
function UrgentMark() {
|
|
301
|
-
return (
|
|
302
|
-
<div className="flex h-6 w-6 shrink-0 items-center justify-center" data-urgent>
|
|
303
|
-
<div className="flex items-center rounded-full bg-warning-muted p-0.5 signal:shadow-glow-warning">
|
|
304
|
-
<IconAlertSquareRounded size={12} stroke={2.5} className="text-warning-default" />
|
|
305
|
-
</div>
|
|
306
|
-
</div>
|
|
307
|
-
)
|
|
308
|
-
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks'
|
|
2
|
+
import * as PageHeaderStories from './PageHeader.stories'
|
|
3
|
+
|
|
4
|
+
<Meta of={PageHeaderStories} />
|
|
5
|
+
|
|
6
|
+
# PageHeader
|
|
7
|
+
|
|
8
|
+
The bar at the top of a page: what the page is, and what acts on all of it, each in its own place.
|
|
9
|
+
|
|
10
|
+
<Canvas of={PageHeaderStories.Everything} />
|
|
11
|
+
|
|
12
|
+
It is ContainerHeader's bar — 48px, a hairline under it, 16px in at each
|
|
13
|
+
end — with a place for each thing a page's bar holds. At the left, 8px
|
|
14
|
+
apart: an icon or a face, a lock, the title, something right after it. At the
|
|
15
|
+
right, 12px apart: quiet counts, when it last changed, the members, then the
|
|
16
|
+
page's buttons, 4px apart.
|
|
17
|
+
|
|
18
|
+
## When
|
|
19
|
+
|
|
20
|
+
- **The top of any page**: a page of one thing, opened from a list, with its
|
|
21
|
+
name and the buttons that act on the whole of it.
|
|
22
|
+
- `leading`: what kind of page it is, or its state, as a 16px icon; a face
|
|
23
|
+
for a page that is one person's.
|
|
24
|
+
|
|
25
|
+
<Canvas of={PageHeaderStories.WithAFace} />
|
|
26
|
+
|
|
27
|
+
- `private`: a lock before the title, when only its members can open it.
|
|
28
|
+
- `after`: something that belongs to the title, right after it — a small
|
|
29
|
+
`Button` that opens it elsewhere, a `Chip`.
|
|
30
|
+
|
|
31
|
+
<Canvas of={PageHeaderStories.AfterTheTitle} />
|
|
32
|
+
|
|
33
|
+
- `meta`: quiet counts at the right, a dot between them; `done: true`
|
|
34
|
+
for words about what is finished.
|
|
35
|
+
|
|
36
|
+
<Canvas of={PageHeaderStories.Counts} />
|
|
37
|
+
|
|
38
|
+
- `time`: when it last changed, in words, 12px italic; the exact time is in
|
|
39
|
+
a tooltip.
|
|
40
|
+
|
|
41
|
+
<Canvas of={PageHeaderStories.EditedTime} />
|
|
42
|
+
|
|
43
|
+
- `members`: who is in it — a **MembersPill**.
|
|
44
|
+
- `actions`: the page's own buttons — a **Toolbar** of `ToolbarButton`s,
|
|
45
|
+
`surface={false}`. A button that shows and hides the right column is
|
|
46
|
+
one of them, its icon filled while the column is open.
|
|
47
|
+
|
|
48
|
+
<Canvas of={PageHeaderStories.ColumnToggle} />
|
|
49
|
+
|
|
50
|
+
- A **Breadcrumb** in the title's place, for a page reached down a trail.
|
|
51
|
+
|
|
52
|
+
<Canvas of={PageHeaderStories.Breadcrumb} />
|
|
53
|
+
|
|
54
|
+
## When not
|
|
55
|
+
|
|
56
|
+
- The bar of a side column — details, a thread → **Panel**, which draws its
|
|
57
|
+
own bar from `title` and `actions`.
|
|
58
|
+
- The bar of a list beside the page → **ListColumn**.
|
|
59
|
+
- The bar across the whole frame, with the logo and the search field →
|
|
60
|
+
**TopBar**.
|
|
61
|
+
- A heading for one part of the page → **SectionHeader**.
|
|
62
|
+
|
|
63
|
+
## How
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
import { MembersPill, PageHeader, Toolbar, ToolbarButton } from '@estiva-app/ui'
|
|
67
|
+
|
|
68
|
+
<PageHeader
|
|
69
|
+
leading={<IconSquareRounded size={16} stroke={1.5} />}
|
|
70
|
+
title="Item one"
|
|
71
|
+
meta={['6 open', { label: '2 done', done: true }]}
|
|
72
|
+
time={{ label: 'Edited 2 minutes ago', exact: '31 October 2026, 14:02' }}
|
|
73
|
+
members={<MembersPill members={members} onClick={openMembers} />}
|
|
74
|
+
actions={
|
|
75
|
+
<Toolbar aria-label="Page actions" surface={false}>
|
|
76
|
+
<ToolbarButton tooltip="More" aria-label="More">
|
|
77
|
+
<IconDotsVertical size={16} stroke={1.5} />
|
|
78
|
+
</ToolbarButton>
|
|
79
|
+
</Toolbar>
|
|
80
|
+
}
|
|
81
|
+
/>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
- **It is the bar, and nothing under it.** The page under it is yours: a
|
|
85
|
+
`ScrollArea` that takes the rest of the column (`min-h-0 flex-1`), or a
|
|
86
|
+
**Panel** that takes it in `header`, in place of its own bar.
|
|
87
|
+
- A string `title` is one line and is cut short with an ellipsis when the
|
|
88
|
+
room runs out; everything at the right keeps its size. A node — a
|
|
89
|
+
`Breadcrumb`, an `InlineText` — is drawn as given, and cuts itself short.
|
|
90
|
+
|
|
91
|
+
<Canvas of={PageHeaderStories.LongTitle} />
|
|
92
|
+
|
|
93
|
+
- `leading` is 16px. A bare icon takes the secondary text colour; a face is
|
|
94
|
+
an `Avatar` at `size={16}`.
|
|
95
|
+
- **The tooltips are under the pointer only.** The lock is named "Private"
|
|
96
|
+
to assistive technology as well; the exact time is not, and Tab does not
|
|
97
|
+
stop on the words. That is a known gap.
|
|
98
|
+
- The quiet things keep 12px clear of the buttons by themselves: write no
|
|
99
|
+
padding between them.
|
|
100
|
+
|
|
101
|
+
## What it owns
|
|
102
|
+
|
|
103
|
+
It does these by itself. Write none of them around it.
|
|
104
|
+
|
|
105
|
+
| It does | So you never write | Refused when written by hand |
|
|
106
|
+
|---|---|---|
|
|
107
|
+
| Draws ContainerHeader's bar: 48px, the hairline under it, 16px in at each end | a header row of your own | ContainerHeader used on its own in an app |
|
|
108
|
+
| Keeps the counts, the time and the members 12px apart, and 12px clear of the buttons | `gap-3`, `pr-2` of your own around them | |
|
|
109
|
+
| Cuts a long string title short and keeps everything else whole | `truncate`, `min-w-0`, `shrink-0` | |
|
|
110
|
+
| Draws the counts in `MetaText`, a dot between them | a dot or a count style of your own | |
|
|
111
|
+
| Draws the time 12px italic, with the exact time in a tooltip | `text-caption italic` and a `WithTooltip` of your own | |
|
|
112
|
+
| Names the lock "Private", in a tooltip and to assistive technology | an `aria-label` and a tooltip on an icon | |
|
|
113
|
+
|
|
114
|
+
## Keys
|
|
115
|
+
|
|
116
|
+
| Key | What it does |
|
|
117
|
+
|---|---|
|
|
118
|
+
| Tab | Moves through the bar in reading order: what is after the title, the members, then the buttons |
|
|
119
|
+
| Arrow keys | Move along the `Toolbar` of buttons, which is one Tab stop — the Toolbar's own keys |
|
|
120
|
+
|
|
121
|
+
## Props
|
|
122
|
+
|
|
123
|
+
<Controls of={PageHeaderStories.Title} />
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import type { Decorator, Meta, StoryObj } from '@storybook/react-vite'
|
|
3
|
+
import { IconBox, IconDotsVertical, IconLayoutSidebarRight, IconLayoutSidebarRightFilled, IconSquareRounded } from '@tabler/icons-react'
|
|
4
|
+
import { Avatar } from './Avatar'
|
|
5
|
+
import { Breadcrumb as Trail } from './Breadcrumb'
|
|
6
|
+
import { Button } from './Button'
|
|
7
|
+
import { MembersPill } from './MembersPill'
|
|
8
|
+
import { Menu, MenuItem } from './Menu'
|
|
9
|
+
import { PageHeader } from './PageHeader'
|
|
10
|
+
import { ScrollArea } from './ScrollArea'
|
|
11
|
+
import { Toolbar, ToolbarButton } from './Toolbar'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The page under the bar: a stand-in body that scrolls, so the bar is seen
|
|
15
|
+
* against content and its hairline against the page.
|
|
16
|
+
*/
|
|
17
|
+
const onAPage: Decorator = (Story) => (
|
|
18
|
+
<div className="flex h-screen w-full flex-col bg-bg-surface">
|
|
19
|
+
{Story()}
|
|
20
|
+
<ScrollArea className="min-h-0 flex-1" contentClassName="flex flex-col gap-3 px-4 pt-3 pb-4">
|
|
21
|
+
{Array.from({ length: 3 }, (_, i) => (
|
|
22
|
+
<p key={i} className="max-w-2xl text-body-2 text-text-secondary">
|
|
23
|
+
Paragraph {i + 1}. The page under the bar: what it holds, written out in full the way a real one is, so the bar is seen
|
|
24
|
+
against what it heads.
|
|
25
|
+
</p>
|
|
26
|
+
))}
|
|
27
|
+
</ScrollArea>
|
|
28
|
+
</div>
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
const meta = {
|
|
32
|
+
title: 'Page structure/PageHeader',
|
|
33
|
+
component: PageHeader,
|
|
34
|
+
// On the page each canvas is its own frame, the bar and a few lines of the page under it; the story alone is full height.
|
|
35
|
+
parameters: { layout: 'fullscreen', docs: { story: { inline: false, height: '200px' } } },
|
|
36
|
+
args: { title: 'Item one' },
|
|
37
|
+
argTypes: {
|
|
38
|
+
leading: { control: false },
|
|
39
|
+
after: { control: false },
|
|
40
|
+
members: { control: false },
|
|
41
|
+
actions: { control: false },
|
|
42
|
+
},
|
|
43
|
+
decorators: [onAPage],
|
|
44
|
+
} satisfies Meta<typeof PageHeader>
|
|
45
|
+
|
|
46
|
+
export default meta
|
|
47
|
+
type Story = StoryObj<typeof meta>
|
|
48
|
+
|
|
49
|
+
const icon = <IconSquareRounded size={16} stroke={1.5} />
|
|
50
|
+
const members = <MembersPill members={[{ name: 'Ana Duarte' }, { name: 'Ravi Mehta' }, { name: 'Marta Silva' }]} count={4} onClick={() => {}} />
|
|
51
|
+
const more = (
|
|
52
|
+
<Menu
|
|
53
|
+
align="right"
|
|
54
|
+
trigger={
|
|
55
|
+
<ToolbarButton tooltip="More" aria-label="More">
|
|
56
|
+
<IconDotsVertical size={16} stroke={1.5} />
|
|
57
|
+
</ToolbarButton>
|
|
58
|
+
}
|
|
59
|
+
>
|
|
60
|
+
<MenuItem label="Item one" />
|
|
61
|
+
<MenuItem label="Item two" />
|
|
62
|
+
</Menu>
|
|
63
|
+
)
|
|
64
|
+
const actions = (
|
|
65
|
+
<Toolbar aria-label="Page actions" surface={false}>
|
|
66
|
+
<ToolbarButton tooltip="Action" aria-label="Action">
|
|
67
|
+
<IconSquareRounded size={16} stroke={1.5} />
|
|
68
|
+
</ToolbarButton>
|
|
69
|
+
{more}
|
|
70
|
+
</Toolbar>
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
/** The title alone: one line in body-2-strong. */
|
|
74
|
+
export const Title: Story = {}
|
|
75
|
+
|
|
76
|
+
/** An icon before the title, 16px, 8px from it: what kind of page this is, or its state. */
|
|
77
|
+
export const WithAnIcon: Story = { args: { leading: icon } }
|
|
78
|
+
|
|
79
|
+
/** A face before the title: a page that is one person's. */
|
|
80
|
+
export const WithAFace: Story = { args: { title: 'Ana Duarte', leading: <Avatar size={16} name="Ana Duarte" /> } }
|
|
81
|
+
|
|
82
|
+
/** A lock before the title: only its members can open it. Point at the lock for its name. */
|
|
83
|
+
export const Private: Story = { args: { private: true } }
|
|
84
|
+
|
|
85
|
+
/** Something right after the title, never cut short: a small button. */
|
|
86
|
+
export const AfterTheTitle: Story = {
|
|
87
|
+
args: {
|
|
88
|
+
after: (
|
|
89
|
+
<Button size="small" href="https://example.com" external leadingIcon={<IconSquareRounded size={14} stroke={1.5} />}>
|
|
90
|
+
Open
|
|
91
|
+
</Button>
|
|
92
|
+
),
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Quiet counts at the right, a dot between them; words about what is finished in the success colour. */
|
|
97
|
+
export const Counts: Story = { args: { leading: icon, meta: ['6 open', { label: '2 done', done: true }] } }
|
|
98
|
+
|
|
99
|
+
/** When it last changed, 12px italic. Point at it for the exact time. */
|
|
100
|
+
export const EditedTime: Story = { args: { time: { label: 'Edited 2 minutes ago', exact: '31 October 2026, 14:02' } } }
|
|
101
|
+
|
|
102
|
+
/** Who is in it: the members pill, which opens the list. */
|
|
103
|
+
export const Members: Story = { args: { members } }
|
|
104
|
+
|
|
105
|
+
/** The page's buttons at the right edge: a toolbar, 4px apart, the last one a menu. */
|
|
106
|
+
export const Actions: Story = { args: { actions } }
|
|
107
|
+
|
|
108
|
+
function WithAToggle() {
|
|
109
|
+
const [open, setOpen] = useState(true)
|
|
110
|
+
return (
|
|
111
|
+
<PageHeader
|
|
112
|
+
title="Item one"
|
|
113
|
+
members={members}
|
|
114
|
+
actions={
|
|
115
|
+
<Toolbar aria-label="Page actions" surface={false}>
|
|
116
|
+
<ToolbarButton tooltip={open ? 'Hide column' : 'Show column'} aria-label={open ? 'Hide column' : 'Show column'} onClick={() => setOpen(!open)}>
|
|
117
|
+
{open ? <IconLayoutSidebarRightFilled size={16} stroke={1.5} /> : <IconLayoutSidebarRight size={16} stroke={1.5} />}
|
|
118
|
+
</ToolbarButton>
|
|
119
|
+
{more}
|
|
120
|
+
</Toolbar>
|
|
121
|
+
}
|
|
122
|
+
/>
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** A button that shows and hides the right column: its icon filled while the column is open. Press it. */
|
|
127
|
+
export const ColumnToggle: Story = {
|
|
128
|
+
render: () => <WithAToggle />,
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** A trail in the title's place: where this page sits, the last crumb where you are. */
|
|
132
|
+
export const Breadcrumb: Story = {
|
|
133
|
+
args: {
|
|
134
|
+
title: (
|
|
135
|
+
<Trail
|
|
136
|
+
items={[
|
|
137
|
+
{ label: 'Items', href: '#' },
|
|
138
|
+
{ label: 'Group one', icon: <IconBox size={16} stroke={1.5} />, href: '#' },
|
|
139
|
+
{ label: 'ITM-12', mono: true },
|
|
140
|
+
]}
|
|
141
|
+
/>
|
|
142
|
+
),
|
|
143
|
+
members,
|
|
144
|
+
},
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** A title longer than its room: it is cut short with an ellipsis, and nothing at the right moves. */
|
|
148
|
+
export const LongTitle: Story = {
|
|
149
|
+
decorators: [(Story) => <div className="flex w-full max-w-xl flex-col">{Story()}</div>],
|
|
150
|
+
args: {
|
|
151
|
+
leading: icon,
|
|
152
|
+
title: 'Item one, with a name long enough to run out of room well before the buttons at the right',
|
|
153
|
+
meta: ['6 open', { label: '2 done', done: true }],
|
|
154
|
+
members,
|
|
155
|
+
actions,
|
|
156
|
+
},
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Everything at once, in its order: icon, lock, title, button; counts, time, members, buttons. */
|
|
160
|
+
export const Everything: Story = {
|
|
161
|
+
args: {
|
|
162
|
+
leading: icon,
|
|
163
|
+
private: true,
|
|
164
|
+
after: (
|
|
165
|
+
<Button size="small" href="https://example.com" external leadingIcon={<IconSquareRounded size={14} stroke={1.5} />}>
|
|
166
|
+
Open
|
|
167
|
+
</Button>
|
|
168
|
+
),
|
|
169
|
+
meta: ['6 open', { label: '2 done', done: true }],
|
|
170
|
+
time: { label: 'Edited 2 minutes ago', exact: '31 October 2026, 14:02' },
|
|
171
|
+
members,
|
|
172
|
+
actions,
|
|
173
|
+
},
|
|
174
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
/** What the PageHeader page claims, pinned: what a person sees and reaches in the bar, slot by slot. */
|
|
3
|
+
import { afterEach, describe, expect, it } from 'vitest'
|
|
4
|
+
import { cleanup, render, screen, within } from '@testing-library/react'
|
|
5
|
+
import userEvent from '@testing-library/user-event'
|
|
6
|
+
import { IconDotsVertical, IconSquareRounded } from '@tabler/icons-react'
|
|
7
|
+
import { Breadcrumb } from './Breadcrumb'
|
|
8
|
+
import { Button } from './Button'
|
|
9
|
+
import { MembersPill } from './MembersPill'
|
|
10
|
+
import { PageHeader } from './PageHeader'
|
|
11
|
+
import { Toolbar, ToolbarButton } from './Toolbar'
|
|
12
|
+
|
|
13
|
+
afterEach(cleanup)
|
|
14
|
+
|
|
15
|
+
const toolbar = (
|
|
16
|
+
<Toolbar aria-label="Page actions" surface={false}>
|
|
17
|
+
<ToolbarButton tooltip="Action" aria-label="Action">
|
|
18
|
+
<IconSquareRounded size={16} stroke={1.5} />
|
|
19
|
+
</ToolbarButton>
|
|
20
|
+
<ToolbarButton tooltip="More" aria-label="More">
|
|
21
|
+
<IconDotsVertical size={16} stroke={1.5} />
|
|
22
|
+
</ToolbarButton>
|
|
23
|
+
</Toolbar>
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
describe('PageHeader', () => {
|
|
27
|
+
it('shows the title, and nothing else when given nothing else', () => {
|
|
28
|
+
const { container } = render(<PageHeader title="Item one" />)
|
|
29
|
+
expect(container.textContent).toBe('Item one')
|
|
30
|
+
expect(screen.queryByRole('button')).toBeNull()
|
|
31
|
+
expect(screen.queryByRole('img', { name: 'Private' })).toBeNull()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('a private page has a lock named "Private" before its title', () => {
|
|
35
|
+
const { container } = render(<PageHeader title="Item one" private />)
|
|
36
|
+
const lock = screen.getByRole('img', { name: 'Private' })
|
|
37
|
+
// Before the title in reading order.
|
|
38
|
+
expect(lock.compareDocumentPosition(screen.getByText('Item one')) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy()
|
|
39
|
+
expect(container.textContent).toBe('Item one')
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('names the lock in a tooltip when the pointer is on it', async () => {
|
|
43
|
+
const user = userEvent.setup()
|
|
44
|
+
render(<PageHeader title="Item one" private />)
|
|
45
|
+
await user.hover(screen.getByRole('img', { name: 'Private' }))
|
|
46
|
+
expect((await screen.findByRole('tooltip')).textContent).toBe('Private')
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('draws the counts in the order given, as words', () => {
|
|
50
|
+
render(<PageHeader title="Item one" meta={['6 open', { label: '2 done', done: true }]} />)
|
|
51
|
+
const open = screen.getByText('6 open')
|
|
52
|
+
const done = screen.getByText('2 done')
|
|
53
|
+
expect(open.compareDocumentPosition(done) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy()
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('shows when it last changed, and the exact time in a tooltip under the pointer', async () => {
|
|
57
|
+
const user = userEvent.setup()
|
|
58
|
+
render(<PageHeader title="Item one" time={{ label: 'Edited 2 minutes ago', exact: '31 October 2026, 14:02' }} />)
|
|
59
|
+
const when = screen.getByText('Edited 2 minutes ago')
|
|
60
|
+
expect(screen.queryByRole('tooltip')).toBeNull()
|
|
61
|
+
await user.hover(when)
|
|
62
|
+
expect((await screen.findByRole('tooltip')).textContent).toBe('31 October 2026, 14:02')
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('the members pill is a button that opens the list', async () => {
|
|
66
|
+
const user = userEvent.setup()
|
|
67
|
+
let opened = 0
|
|
68
|
+
render(<PageHeader title="Item one" members={<MembersPill members={[{ name: 'Ana Duarte' }, { name: 'Ravi Mehta' }]} onClick={() => opened++} />} />)
|
|
69
|
+
await user.click(screen.getByRole('button', { name: '2 members' }))
|
|
70
|
+
expect(opened).toBe(1)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it('the buttons come after everything else, in reading order and in the Tab order', async () => {
|
|
74
|
+
const user = userEvent.setup()
|
|
75
|
+
render(
|
|
76
|
+
<PageHeader
|
|
77
|
+
title="Item one"
|
|
78
|
+
after={<Button size="small">Open</Button>}
|
|
79
|
+
meta={['6 open']}
|
|
80
|
+
members={<MembersPill members={[{ name: 'Ana Duarte' }]} onClick={() => {}} />}
|
|
81
|
+
actions={toolbar}
|
|
82
|
+
/>,
|
|
83
|
+
)
|
|
84
|
+
await user.tab()
|
|
85
|
+
expect(document.activeElement).toBe(screen.getByRole('button', { name: 'Open' }))
|
|
86
|
+
await user.tab()
|
|
87
|
+
expect(document.activeElement).toBe(screen.getByRole('button', { name: '1 member' }))
|
|
88
|
+
await user.tab()
|
|
89
|
+
// The toolbar is one stop; its first button takes it.
|
|
90
|
+
expect(document.activeElement).toBe(within(screen.getByRole('toolbar', { name: 'Page actions' })).getByRole('button', { name: 'Action' }))
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('a title that is not a string is drawn as given: a breadcrumb trail stays a trail', () => {
|
|
94
|
+
render(<PageHeader title={<Breadcrumb items={[{ label: 'Items', href: '#' }, { label: 'ITM-12', mono: true }]} />} />)
|
|
95
|
+
const trail = screen.getByRole('navigation', { name: 'Breadcrumb' })
|
|
96
|
+
expect(within(trail).getByRole('link', { name: 'Items' })).toBeTruthy()
|
|
97
|
+
expect(within(trail).getByText('ITM-12').getAttribute('aria-current')).toBe('page')
|
|
98
|
+
})
|
|
99
|
+
})
|