@estiva-app/ui 0.94.0 → 0.95.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/LinkRow.d.ts.map +1 -1
- package/dist/PartCard.d.ts +4 -7
- package/dist/PartCard.d.ts.map +1 -1
- package/dist/ShowMore.d.ts +1 -7
- package/dist/ShowMore.d.ts.map +1 -1
- package/dist/index.js +6 -12
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
- package/registry.json +1 -13
- package/src/LinkCard.test.tsx +5 -2
- package/src/LinkRow.mdx +1 -1
- package/src/LinkRow.tsx +10 -5
- 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/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/package.json
CHANGED
package/registry.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"kind": "package",
|
|
5
5
|
"repo": "estiva-ui",
|
|
6
6
|
"package": "@estiva-app/ui",
|
|
7
|
-
"packageVersion": "0.
|
|
7
|
+
"packageVersion": "0.95.0",
|
|
8
8
|
"exports": 210,
|
|
9
9
|
"typeExports": 213,
|
|
10
10
|
"files": null
|
|
@@ -6323,12 +6323,6 @@
|
|
|
6323
6323
|
"required": false,
|
|
6324
6324
|
"note": "The part's blocks, drawn by the app."
|
|
6325
6325
|
},
|
|
6326
|
-
{
|
|
6327
|
-
"name": "action",
|
|
6328
|
-
"takes": "anything",
|
|
6329
|
-
"required": false,
|
|
6330
|
-
"note": "The way out to where the part lives: a small `Button` with a leading icon (\"Open in Leaf\")."
|
|
6331
|
-
},
|
|
6332
6326
|
{
|
|
6333
6327
|
"name": "maxHeight",
|
|
6334
6328
|
"takes": "number",
|
|
@@ -8308,12 +8302,6 @@
|
|
|
8308
8302
|
"required": false,
|
|
8309
8303
|
"note": "inset card and a selected message included."
|
|
8310
8304
|
},
|
|
8311
|
-
{
|
|
8312
|
-
"name": "action",
|
|
8313
|
-
"takes": "anything",
|
|
8314
|
-
"required": false,
|
|
8315
|
-
"note": "A small muted `Button` with a leading icon, at the right of the toggle's row: the way out to where the content lives."
|
|
8316
|
-
},
|
|
8317
8305
|
{
|
|
8318
8306
|
"name": "contentClassName",
|
|
8319
8307
|
"takes": "text",
|
package/src/LinkCard.test.tsx
CHANGED
|
@@ -122,9 +122,12 @@ describe('LinkCard', () => {
|
|
|
122
122
|
expect(screen.queryByRole('link')).toBeNull()
|
|
123
123
|
})
|
|
124
124
|
|
|
125
|
-
it('says it is not available, and where it may still open', () => {
|
|
125
|
+
it('says it is not available, and where it may still open: an "Open" button that links there, in a new tab', () => {
|
|
126
126
|
render(<LinkCard link={UNAVAILABLE} />)
|
|
127
127
|
expect(screen.getByText('Issue not available')).toBeTruthy()
|
|
128
|
-
|
|
128
|
+
const open = screen.getByRole('link', { name: 'Open in App one' })
|
|
129
|
+
expect(open.getAttribute('href')).toBe('#elsewhere')
|
|
130
|
+
expect(open.getAttribute('target')).toBe('_blank')
|
|
131
|
+
expect(open.textContent).toBe('Open')
|
|
129
132
|
})
|
|
130
133
|
})
|
package/src/LinkRow.mdx
CHANGED
|
@@ -17,7 +17,7 @@ A link alone on its line: its kind in a file's tile, the title and its key under
|
|
|
17
17
|
- **width** — at most 480px, in a box being written in too.
|
|
18
18
|
- **unread** — the count is brighter, with its dot.
|
|
19
19
|
- **loading** — the row in bars, in the row's own shape.
|
|
20
|
-
- **unavailable** — a row's shape, "Issue not available", with where it may still open (`openIn`). This is also what a card draws when it is not available: **LinkUnavailable**, from this file.
|
|
20
|
+
- **unavailable** — a row's shape, "Issue not available", with where it may still open (`openIn`): a small `Button` "Open" with an open-out icon, a link to a new tab, the app in its name and tooltip ("Open in Ship"), as Peek's file header has it. It is the one way there: the words are not a link. This is also what a card draws when it is not available: **LinkUnavailable**, from this file.
|
|
21
21
|
- **deleted** — `deleted` on the state, when a trusted deletion names it (SPEC §13.6.1): the same row, "Issue deleted", and no way out.
|
|
22
22
|
- **written as a URL** — `url` on the state: the URL as it was written, a plain link in the row's place, deleted or not available alike (SPEC §13.1).
|
|
23
23
|
|
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/PartCard.mdx
CHANGED
|
@@ -12,7 +12,7 @@ A part of something longer, shared live: its blocks as they are now, under the t
|
|
|
12
12
|
## When
|
|
13
13
|
|
|
14
14
|
- **ready** — what it is part of, as a card starts: its kind in a file's 36px tile, its title as the link, and "A part of ABC-2" under it; then the blocks the app draws as `children`, behind a quote bar that starts where the tile does. The apps draw the blocks with **RichText** `size="small"`.
|
|
15
|
-
- **
|
|
15
|
+
- **long** — with `maxHeight`, a long part is cut behind Show more, under the quote bar. Its title is the way to it, in the app it lives in: there is no "Open in …" button (Katerina, 31 Oct).
|
|
16
16
|
- **loading** — at a card's height.
|
|
17
17
|
- **unavailable** — one row: "A part of this issue not available", in the app's word for it, else its kind's. Not the reader's to see.
|
|
18
18
|
- **deleted** — what it is part of was deleted, as a trusted deletion naming it says (SPEC §13.6.1): the same row, "A part of this issue deleted".
|
package/src/PartCard.stories.tsx
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
-
import { IconExternalLink } from '@tabler/icons-react'
|
|
3
|
-
import { Button } from './Button'
|
|
4
2
|
import { PartCard } from './PartCard'
|
|
5
3
|
import { RichText, type RichTextBlock } from './RichText'
|
|
6
4
|
|
|
@@ -38,19 +36,14 @@ const LONG_BLOCKS: RichTextBlock[] = [
|
|
|
38
36
|
...Array.from({ length: 6 }, (_, i): RichTextBlock => ({ type: 'paragraph', inline: [{ text: `Paragraph ${i + 1} of the part, long enough to fill a line of the card and go on to a second one.`, marks: [] }] })),
|
|
39
37
|
]
|
|
40
38
|
|
|
41
|
-
/** As an app quotes a long part: cut behind Show more,
|
|
42
|
-
export const
|
|
39
|
+
/** As an app quotes a long part: cut behind Show more, under the quote bar. Its title is the way to it, in its own app. */
|
|
40
|
+
export const Long: Story = {
|
|
43
41
|
args: {
|
|
44
42
|
state: 'ready',
|
|
45
43
|
kind: 'page',
|
|
46
44
|
heading: 'Document one',
|
|
47
45
|
href: '#part',
|
|
48
46
|
maxHeight: 160,
|
|
49
|
-
action: (
|
|
50
|
-
<Button size="small" leadingIcon={<IconExternalLink stroke={1.5} className="size-3.5" />} onClick={() => {}}>
|
|
51
|
-
Open in App one
|
|
52
|
-
</Button>
|
|
53
|
-
),
|
|
54
47
|
children: <RichText blocks={LONG_BLOCKS} size="small" />,
|
|
55
48
|
},
|
|
56
49
|
}
|
package/src/PartCard.test.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @vitest-environment jsdom
|
|
2
2
|
/** What the PartCard page claims, pinned: the header opens what it is part of, the blocks draw, and the states say so. */
|
|
3
3
|
import { cleanup, render, screen } from '@testing-library/react'
|
|
4
|
-
import { afterEach, describe, expect, it } from 'vitest'
|
|
4
|
+
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
5
5
|
import { PartCard } from './PartCard'
|
|
6
6
|
|
|
7
7
|
afterEach(cleanup)
|
|
@@ -19,6 +19,18 @@ describe('PartCard', () => {
|
|
|
19
19
|
expect(screen.getByText('The blocks')).toBeTruthy()
|
|
20
20
|
})
|
|
21
21
|
|
|
22
|
+
it('a long part is cut behind Show more, its title the only way to it (Katerina, 31 Oct: no "Open in" beside it)', () => {
|
|
23
|
+
const tall = vi.spyOn(HTMLElement.prototype, 'scrollHeight', 'get').mockReturnValue(300)
|
|
24
|
+
render(
|
|
25
|
+
<PartCard kind="page" heading="Document one" href="#part" maxHeight={160}>
|
|
26
|
+
<p>The blocks</p>
|
|
27
|
+
</PartCard>,
|
|
28
|
+
)
|
|
29
|
+
expect(screen.getAllByRole('button').map((b) => b.textContent)).toEqual(['Show more'])
|
|
30
|
+
expect(screen.getAllByRole('link').map((a) => a.textContent)).toEqual(['Document one'])
|
|
31
|
+
tall.mockRestore()
|
|
32
|
+
})
|
|
33
|
+
|
|
22
34
|
it('says a part is not available in words', () => {
|
|
23
35
|
render(<PartCard state="unavailable" kind="issue" noun="Issue" />)
|
|
24
36
|
expect(screen.getByText('A part of this issue not available')).toBeTruthy()
|
package/src/PartCard.tsx
CHANGED
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
* Look C (Katerina, 29 Oct): what it is part of as a card starts, its kind in a
|
|
9
9
|
* file's 36px tile, its title and "A part of ABC-2" under it; then the blocks
|
|
10
10
|
* behind a quote bar that starts where the tile does.
|
|
11
|
+
*
|
|
12
|
+
* The title is the way to it, in the app it lives in: no "Open in …" button
|
|
13
|
+
* beside the blocks (Katerina, 31 Oct: it said again what the title does).
|
|
11
14
|
*/
|
|
12
15
|
import { useContext, type ReactNode } from 'react'
|
|
13
16
|
import { Card } from './Card'
|
|
@@ -45,17 +48,11 @@ export interface PartCardProps {
|
|
|
45
48
|
openIn?: { app: string; href: string }
|
|
46
49
|
/** The part's blocks, drawn by the app. */
|
|
47
50
|
children?: ReactNode
|
|
48
|
-
/**
|
|
49
|
-
* The way out to where the part lives: a small `Button` with a leading icon ("Open in Leaf"). Drawn under the
|
|
50
|
-
* blocks at the right, level with Show more, outside the quote bar (Katerina, 30 Oct: "the vertical line should not
|
|
51
|
-
* be covering the button"). Peek and Ship put it in ShowMore's row inside the blocks before.
|
|
52
|
-
*/
|
|
53
|
-
action?: ReactNode
|
|
54
51
|
/** Cut the blocks at this height, in px, behind ShowMore's fade and its Show more. Absent, they are drawn whole. */
|
|
55
52
|
maxHeight?: number
|
|
56
53
|
}
|
|
57
54
|
|
|
58
|
-
export function PartCard({ state = 'ready', kind, heading, href, partKey, noun, openIn, children,
|
|
55
|
+
export function PartCard({ state = 'ready', kind, heading, href, partKey, noun, openIn, children, maxHeight }: PartCardProps) {
|
|
59
56
|
const word = noun ?? kindNounOf({ kind }) ?? 'File'
|
|
60
57
|
const boxed = useContext(inTheBox)
|
|
61
58
|
if (state === 'loading') return <LinkCardLoading kind={kind} shape={{ summary: true, rows: 0, footer: 'none' }} />
|
|
@@ -85,8 +82,8 @@ export function PartCard({ state = 'ready', kind, heading, href, partKey, noun,
|
|
|
85
82
|
</span>
|
|
86
83
|
</div>
|
|
87
84
|
{/* The quote bar starts where the tile above it starts (Katerina, 29 Oct), and runs beside the blocks only. */}
|
|
88
|
-
{
|
|
89
|
-
<ShowMore maxHeight={maxHeight
|
|
85
|
+
{maxHeight !== undefined ? (
|
|
86
|
+
<ShowMore maxHeight={maxHeight} contentClassName={QUOTE_BAR_CLASSES}>
|
|
90
87
|
{children}
|
|
91
88
|
</ShowMore>
|
|
92
89
|
) : (
|
package/src/ShowMore.mdx
CHANGED
|
@@ -44,11 +44,8 @@ import { ShowMore } from '@estiva-app/ui'
|
|
|
44
44
|
- `maxHeight` is in px, 96 by default.
|
|
45
45
|
- The toggle is a small outlined `Button` with a chevron: down on "Show more",
|
|
46
46
|
up on "Show less". Its edge starts where the content does.
|
|
47
|
-
-
|
|
48
|
-
|
|
49
|
-
row is drawn for it even when the content fits and there is no toggle.
|
|
50
|
-
|
|
51
|
-
<Canvas of={ShowMoreStories.WithAnAction} />
|
|
47
|
+
- Nothing else goes on the toggle's row. The way to where the content lives is
|
|
48
|
+
its title, above it.
|
|
52
49
|
|
|
53
50
|
<Canvas of={ShowMoreStories.InACard} />
|
|
54
51
|
|
package/src/ShowMore.stories.tsx
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
-
import { IconExternalLink } from '@tabler/icons-react'
|
|
3
|
-
import { Button } from './Button'
|
|
4
2
|
import { Card } from './Card'
|
|
5
3
|
import { ShowMore } from './ShowMore'
|
|
6
4
|
|
|
@@ -39,15 +37,3 @@ export const InACard: Story = {
|
|
|
39
37
|
</Card>
|
|
40
38
|
),
|
|
41
39
|
}
|
|
42
|
-
|
|
43
|
-
/** `action`: one more small button, level with Show more at the right of its row. */
|
|
44
|
-
export const WithAnAction: Story = {
|
|
45
|
-
args: { surface: 'inset', action: <Button size="small" leadingIcon={<IconExternalLink stroke={1.5} className="size-3.5" />}>Open in Estiva Ship</Button> },
|
|
46
|
-
render: InACard.render,
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** Short content with an action: no toggle, and the action keeps its place at the right. */
|
|
50
|
-
export const ShortWithAnAction: Story = {
|
|
51
|
-
args: { ...WithAnAction.args, children: <p className="text-caption text-text-secondary">One line of description.</p> },
|
|
52
|
-
render: InACard.render,
|
|
53
|
-
}
|
package/src/ShowMore.test.tsx
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
7
7
|
import { cleanup, render, screen } from '@testing-library/react'
|
|
8
8
|
import userEvent from '@testing-library/user-event'
|
|
9
|
-
import { Button } from './Button'
|
|
10
9
|
import { ShowMore } from './ShowMore'
|
|
11
10
|
|
|
12
11
|
afterEach(() => {
|
|
@@ -42,19 +41,4 @@ describe('ShowMore', () => {
|
|
|
42
41
|
expect(screen.queryByRole('button')).toBeNull()
|
|
43
42
|
expect(screen.getByText('Short').parentElement!.style.maxHeight).toBe('')
|
|
44
43
|
})
|
|
45
|
-
|
|
46
|
-
it('puts an action level with the toggle, at the right of its row', () => {
|
|
47
|
-
contentHeight(300)
|
|
48
|
-
render(<ShowMore maxHeight={96} action={<Button>Open</Button>}><p>Long</p></ShowMore>)
|
|
49
|
-
const row = screen.getByRole('button', { name: 'Show more' }).parentElement!
|
|
50
|
-
expect(row.contains(screen.getByRole('button', { name: 'Open' }))).toBe(true)
|
|
51
|
-
expect(row.className).toMatch(/justify-between/)
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it('keeps the action when the content fits, with no toggle', () => {
|
|
55
|
-
contentHeight(40)
|
|
56
|
-
render(<ShowMore maxHeight={96} action={<Button>Open</Button>}><p>Short</p></ShowMore>)
|
|
57
|
-
expect(screen.queryByRole('button', { name: /Show/ })).toBeNull()
|
|
58
|
-
expect(screen.getByRole('button', { name: 'Open' })).toBeTruthy()
|
|
59
|
-
})
|
|
60
44
|
})
|
package/src/ShowMore.tsx
CHANGED
|
@@ -18,10 +18,6 @@ import { cn } from './cn'
|
|
|
18
18
|
*
|
|
19
19
|
* Focus arriving inside the cut content opens it: a field or a link there,
|
|
20
20
|
* reached by Tab or a click, is never worked on out of sight.
|
|
21
|
-
*
|
|
22
|
-
* `action` is one more small button on the toggle's row, at its right
|
|
23
|
-
* (Katerina, 8 October: Peek's block card puts "Open in Estiva Ship" level with
|
|
24
|
-
* Show more). The row is drawn for it whether or not the content is cut.
|
|
25
21
|
*/
|
|
26
22
|
export interface ShowMoreProps {
|
|
27
23
|
children: ReactNode
|
|
@@ -32,8 +28,6 @@ export interface ShowMoreProps {
|
|
|
32
28
|
* inset card and a selected message included. Accepted, and ignored.
|
|
33
29
|
*/
|
|
34
30
|
surface?: 'surface' | 'inset' | 'elevated'
|
|
35
|
-
/** A small muted `Button` with a leading icon, at the right of the toggle's row: the way out to where the content lives. Its words end where the content does. */
|
|
36
|
-
action?: ReactNode
|
|
37
31
|
/** On the content alone, not the toggle's row under it: PartCard's quote bar runs beside the blocks only. */
|
|
38
32
|
contentClassName?: string
|
|
39
33
|
className?: string
|
|
@@ -42,7 +36,7 @@ export interface ShowMoreProps {
|
|
|
42
36
|
/** The last 40px of cut content fade out: a mask on the content, not a fill over it, so it ends in whatever is behind. */
|
|
43
37
|
const FADE = 'linear-gradient(to top, transparent, black 40px)'
|
|
44
38
|
|
|
45
|
-
export function ShowMore({ children, maxHeight = 96,
|
|
39
|
+
export function ShowMore({ children, maxHeight = 96, contentClassName, className }: ShowMoreProps) {
|
|
46
40
|
const box = useRef<HTMLDivElement>(null)
|
|
47
41
|
const [open, setOpen] = useState(false)
|
|
48
42
|
const [overflows, setOverflows] = useState(false)
|
|
@@ -64,15 +58,7 @@ export function ShowMore({ children, maxHeight = 96, action, contentClassName, c
|
|
|
64
58
|
<div ref={box} className={cn('relative w-full', cut && 'overflow-hidden', contentClassName)} style={cut ? { maxHeight, maskImage: FADE, WebkitMaskImage: FADE } : undefined} onFocus={cut ? () => setOpen(true) : undefined}>
|
|
65
59
|
{children}
|
|
66
60
|
</div>
|
|
67
|
-
{
|
|
68
|
-
<div className={cn('mt-1 flex w-full items-center gap-2', overflows ? 'justify-between' : 'justify-end')}>
|
|
69
|
-
{overflows && <Toggle open={open} onToggle={() => setOpen((o) => !o)} />}
|
|
70
|
-
{/* `-mr-2`: a small button's 8px right inset beside a leading icon, so its words end where the content's do. */}
|
|
71
|
-
<div className="-mr-2 flex shrink-0">{action}</div>
|
|
72
|
-
</div>
|
|
73
|
-
) : (
|
|
74
|
-
overflows && <Toggle open={open} onToggle={() => setOpen((o) => !o)} className="mt-1" />
|
|
75
|
-
)}
|
|
61
|
+
{overflows && <Toggle open={open} onToggle={() => setOpen((o) => !o)} className="mt-1" />}
|
|
76
62
|
</div>
|
|
77
63
|
)
|
|
78
64
|
}
|