blob: fc6586fb4632697acb9c1a5852ede435cc5e172a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
<script lang="ts">
import { isSome } from '@jet/environment';
import {
type AnnotationItem,
type Action,
isFlowAction,
} from '@jet-app/app-store/api/models';
import LinkWrapper from '~/components/LinkWrapper.svelte';
export let items: AnnotationItem[];
export let linkAction: Action | undefined;
const shouldRenderAsDefinitionList = (items: AnnotationItem[]) =>
!!items[0]?.heading;
const shouldRenderAsOrderedList = (items: AnnotationItem[]) =>
!!items[0]?.textPairs;
const shouldRenderAsUnorderedList = (items: AnnotationItem[]) =>
!items[0]?.text;
const shouldRenderAsDefinitionListWithHeading = (items: AnnotationItem[]) =>
items[0]?.text && items[1]?.heading;
</script>
{#if shouldRenderAsDefinitionList(items)}
<dl class="secondary-definition-list">
{#each items as annotationItem}
<dt>{annotationItem.heading}</dt>
<dd>{annotationItem.text}</dd>
{/each}
</dl>
{:else if shouldRenderAsOrderedList(items)}
<ol>
{#each items as annotationItem}
{#if annotationItem.textPairs}
{#each annotationItem.textPairs as [text, subtext]}
<li>
<span class="text">{text}</span>
<span class="subtext">{subtext}</span>
</li>
{/each}
{:else}
<li>{annotationItem.text}</li>
{/if}
{/each}
</ol>
{:else if shouldRenderAsUnorderedList(items)}
<ul>
{#each items as annotationItem}
<li>
<span class="text">
{annotationItem.text}
</span>
</li>
{/each}
</ul>
{:else if shouldRenderAsDefinitionListWithHeading(items)}
{@const [heading, ...remainingItems] = items}
<dd>
<p class="secondary-definition-list-heading">{heading.text}</p>
<dl class="secondary-definition-list">
{#each remainingItems as annotationItem}
<dt>{annotationItem.heading}</dt>
<dd>{annotationItem.text}</dd>
{/each}
</dl>
</dd>
{:else}
<dd>
<ul>
{#each items as annotationItem}
<li>{annotationItem.text}</li>
{/each}
</ul>
{#if isSome(linkAction) && isFlowAction(linkAction)}
<LinkWrapper action={linkAction}>
{linkAction.title}
</LinkWrapper>
{/if}
</dd>
{/if}
<style>
dt {
color: var(--systemSecondary);
font: var(--body-tall);
}
dd {
white-space: pre-line;
font: var(--body-tall);
}
ol {
counter-reset: section;
}
ol li {
display: table-row;
font: var(--body-tall);
}
ol li::before {
counter-increment: section;
content: counter(section) '.';
display: table-cell;
padding-inline-end: 6px;
}
ol li .text {
display: table-cell;
width: 100%;
}
ol li .subtext {
display: table-cell;
}
.secondary-definition-list-heading {
margin-bottom: 16px;
}
.secondary-definition-list dt {
color: var(--systemPrimary);
font: var(--body-emphasized);
}
.secondary-definition-list dd:not(:last-of-type) {
margin-bottom: 16px;
}
dd li:not(:last-of-type) {
margin-bottom: 16px;
}
dd :global(a) {
color: var(--keyColor);
text-decoration: none;
}
dd :global(a:hover) {
text-decoration: underline;
}
</style>
|