@estiva-app/ui 0.109.0 → 0.110.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@estiva-app/ui",
3
- "version": "0.109.0",
3
+ "version": "0.110.0",
4
4
  "description": "Estiva's design tokens (the contract) and a small set of primitives (a convenience) for every Estiva app.",
5
5
  "type": "module",
6
6
  "license": "MIT",
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.109.0",
7
+ "packageVersion": "0.110.0",
8
8
  "exports": 251,
9
9
  "typeExports": 260,
10
10
  "files": null
@@ -8916,6 +8916,18 @@
8916
8916
  "takes": "text",
8917
8917
  "required": false,
8918
8918
  "note": "A part with no words, a picture or a whole block: what it is, in the app's words (\"Picture: plan.png\")."
8919
+ },
8920
+ {
8921
+ "name": "href",
8922
+ "takes": "text",
8923
+ "required": false,
8924
+ "note": "Where the words are in their file, when the reader is not looking at it: the words open it there."
8925
+ },
8926
+ {
8927
+ "name": "external",
8928
+ "takes": "true/false",
8929
+ "required": false,
8930
+ "note": "`href` is another app's: it opens in a new tab."
8919
8931
  }
8920
8932
  ],
8921
8933
  "variants": [
@@ -35,6 +35,9 @@ import { ConversationCard, QuotedLine } from '@estiva-app/ui'
35
35
  - Two lines at most; the whole words are in the tooltip.
36
36
  - A part with no words, a picture or a block: `label`, its name in your words, on the grey: the yellow is only for words still in the page.
37
37
  - Made for the card's `about`: the card puts it under the name, where the words start.
38
+ - Read away from the page it quotes (another app, a list of comments from several pages): `href`, where the words are in that page, and the words are a **Link** (`quiet`) that opens it there, in place through the app's `navigate`, or in a new tab when `external`; a press on it never opens the card's thread around it. Beside the page itself, none.
39
+
40
+ <Canvas of={Stories.Linked} />
38
41
 
39
42
  ## What it owns
40
43
 
@@ -23,6 +23,9 @@ export const Reworded: Story = { name: 'Words changed', args: { state: 'reworded
23
23
  /** The part was deleted from the page: the words struck through, and "Deleted from the page". */
24
24
  export const Gone: Story = { name: 'Part deleted', args: { state: 'gone' } }
25
25
 
26
+ /** Read away from the page it quotes: the words open that page where they are. */
27
+ export const Linked: Story = { name: 'Words that open the page', args: { href: 'https://example.com/page#block-1' } }
28
+
26
29
  /** On a part with no words of its own, a picture: its name, in the app's words. */
27
30
  export const Part: Story = { name: 'No words', args: { words: undefined, label: 'Picture: plan-sketch.png' } }
28
31
 
@@ -40,4 +40,17 @@ describe('QuotedLine', () => {
40
40
  expect(mark.className).toMatch(/\bbg-bg-inset\b/)
41
41
  expect(mark.className).not.toMatch(/\bline-through\b/)
42
42
  })
43
+
44
+ // A reader in another app reaches the sentence in one click, as the part card's link did (Miky, 10 November).
45
+ it('makes the words the link to where they are in their file, when given one', () => {
46
+ render(<QuotedLine words="brass fitting" href="https://ship.example/issue/x#block-b1" external />)
47
+ const link = screen.getByRole('link', { name: 'brass fitting' })
48
+ expect(link.getAttribute('href')).toBe('https://ship.example/issue/x#block-b1')
49
+ expect(link.getAttribute('target')).toBe('_blank')
50
+ })
51
+
52
+ it('draws the words as no link where the file is beside them', () => {
53
+ render(<QuotedLine words="brass fitting" />)
54
+ expect(screen.queryByRole('link')).toBeNull()
55
+ })
43
56
  })
@@ -1,4 +1,5 @@
1
1
  import { cn } from './cn'
2
+ import { Link } from './Link'
2
3
  import { WithTooltip } from './Tooltip'
3
4
 
4
5
  export interface QuotedLineProps {
@@ -8,6 +9,13 @@ export interface QuotedLineProps {
8
9
  state?: 'here' | 'reworded' | 'gone'
9
10
  /** A part with no words, a picture or a whole block: what it is, in the app's words ("Picture: plan.png"). */
10
11
  label?: string
12
+ /**
13
+ * Where the words are in their file, when the reader is not looking at it: the words open it there. The page that
14
+ * shows the file beside its comments gives none. Navigation is yours, as for every `Link`.
15
+ */
16
+ href?: string
17
+ /** `href` is another app's: it opens in a new tab. */
18
+ external?: boolean
11
19
  }
12
20
 
13
21
  const SINCE = { reworded: 'Changed since', gone: 'Deleted from the page' } as const
@@ -16,17 +24,25 @@ const SINCE = { reworded: 'Changed since', gone: 'Deleted from the page' } as co
16
24
  * What a comment on a part of the page is on: its words, two lines at most, in the page's own highlight, so the two
17
25
  * read as one. ConversationCard puts it under the name, above the comment's words ("above the message, not above the
18
26
  * person": Katerina, 1 November). Words changed since or deleted lose the highlight and say so; a part with no words
19
- * gives its name, on the grey: it is not words of the page.
27
+ * gives its name, on the grey: it is not words of the page. With `href`, the words are the way to them in their file
28
+ * (Miky, 10 November: a reader in another app reaches the sentence in one click, as the part card's link did).
20
29
  */
21
- export function QuotedLine({ words, state = 'here', label }: QuotedLineProps) {
30
+ export function QuotedLine({ words, state = 'here', label, href, external }: QuotedLineProps) {
22
31
  const shown = words ?? label ?? ''
23
32
  // The page's yellow only for words still in it; a part's name is not words of the page, so it takes the grey (Katerina, 3 November).
24
33
  const inThePage = !!words && state === 'here'
34
+ const mark = <mark className={cn('rounded-sm px-0.5 text-text-primary [box-decoration-break:clone]', inThePage ? 'bg-warning-muted' : 'bg-bg-inset text-text-secondary', state === 'gone' && 'line-through')}>{shown}</mark>
25
35
  return (
26
36
  <div data-quoted={words ? state : 'part'} className="flex w-full min-w-0 flex-col gap-0.5">
27
37
  <WithTooltip label={shown} wrapperClassName="flex min-w-0">
28
38
  <p className="line-clamp-2 text-caption text-text-secondary">
29
- <mark className={cn('rounded-sm px-0.5 text-text-primary [box-decoration-break:clone]', inThePage ? 'bg-warning-muted' : 'bg-bg-inset text-text-secondary', state === 'gone' && 'line-through')}>{shown}</mark>
39
+ {href ? (
40
+ <Link href={href} variant="quiet" external={external}>
41
+ {mark}
42
+ </Link>
43
+ ) : (
44
+ mark
45
+ )}
30
46
  </p>
31
47
  </WithTooltip>
32
48
  {state !== 'here' && <span className="text-caption italic text-text-muted">{SINCE[state]}</span>}