@diegopluna/narvi 0.3.3 → 0.3.4
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/components/app-shell/AppShellMain.svelte +14 -2
- package/dist/components/app-shell/AppShellPanel.svelte +77 -12
- package/dist/components/app-shell/AppShellPanel.svelte.d.ts +11 -1
- package/dist/components/app-shell/AppShellSheet.svelte +11 -1
- package/dist/components/app-shell/context.d.ts +8 -0
- package/dist/components/app-shell/context.js +7 -0
- package/dist/components/avatar/AvatarRoot.svelte +20 -7
- package/dist/components/avatar/AvatarRoot.svelte.d.ts +10 -3
- package/dist/components/button/Button.svelte +12 -1
- package/dist/components/button/Button.svelte.d.ts +7 -0
- package/dist/components/segmented/SegmentedControl.svelte +12 -1
- package/dist/components/segmented/SegmentedControl.svelte.d.ts +3 -1
- package/dist/components/select/Select.svelte +25 -4
- package/dist/components/select/Select.svelte.d.ts +7 -0
- package/dist/components/settings-row/SettingsRow.svelte +87 -37
- package/dist/components/settings-row/SettingsRow.svelte.d.ts +13 -0
- package/dist/components/split-button/SplitButton.svelte +137 -0
- package/dist/components/split-button/SplitButton.svelte.d.ts +29 -0
- package/dist/components/tab-strip/TabStrip.svelte +337 -93
- package/dist/components/tab-strip/TabStrip.svelte.d.ts +36 -1
- package/dist/components/tab-strip/drag.svelte.d.ts +31 -0
- package/dist/components/tab-strip/drag.svelte.js +148 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
- package/skills/building-ui/SKILL.md +24 -4
- package/skills/building-ui/references/components.md +21 -20
- package/skills/markdown/SKILL.md +1 -1
- package/skills/setup/SKILL.md +1 -1
- package/skills/styling/SKILL.md +1 -1
- package/skills/theming/SKILL.md +1 -1
|
@@ -11,11 +11,12 @@
|
|
|
11
11
|
import Glyph from '../../internal/Glyph.svelte';
|
|
12
12
|
import { shared } from '../../internal/shared.js';
|
|
13
13
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
14
|
-
import { colors, motion, radius, space } from '../../tokens.stylex.js';
|
|
14
|
+
import { colors, font, motion, radius, space } from '../../tokens.stylex.js';
|
|
15
15
|
import { media } from '../../media.stylex.js';
|
|
16
16
|
import { typography } from '../../typography.js';
|
|
17
17
|
import * as Tooltip from '../tooltip/index.js';
|
|
18
18
|
import { getSettingsGroupContext } from '../settings-group/context.js';
|
|
19
|
+
import '../../internal/icons.css';
|
|
19
20
|
|
|
20
21
|
export type SettingsRowControl = {
|
|
21
22
|
/** For the control's `id`, which the label's `for` names: `controlId` when it is set. */
|
|
@@ -28,6 +29,18 @@
|
|
|
28
29
|
|
|
29
30
|
export type SettingsRowProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'title'> & {
|
|
30
31
|
label: string;
|
|
32
|
+
/**
|
|
33
|
+
* Before the label and the description: a provider's mark, an icon of what the row is,
|
|
34
|
+
* an Avatar. Decoration: the label names the row.
|
|
35
|
+
*/
|
|
36
|
+
leading?: Snippet | undefined;
|
|
37
|
+
/** Sets the label in the muted ink: for something switched off, or not to be had here. */
|
|
38
|
+
dimmed?: boolean | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Sets the label in monospace, for a name that is code: an environment variable, a
|
|
41
|
+
* header, a tool, a path.
|
|
42
|
+
*/
|
|
43
|
+
mono?: boolean | undefined;
|
|
31
44
|
/**
|
|
32
45
|
* What the setting does, in a sentence or two, behind an info mark beside the label. It
|
|
33
46
|
* opens on a hover, or as the mark takes the focus.
|
|
@@ -88,9 +101,27 @@
|
|
|
88
101
|
text: { display: 'flex', flexDirection: 'column', gap: '0.125rem', minWidth: 0 },
|
|
89
102
|
// Beside the control, the text takes the room and wraps the control under it below 14rem
|
|
90
103
|
textInline: { flexGrow: 1, flexShrink: 1, flexBasis: '14rem' },
|
|
104
|
+
// The leading mark and the text beside it
|
|
105
|
+
lead: { display: 'flex', alignItems: 'center', gap: space.x3, minWidth: 0 },
|
|
106
|
+
leading: {
|
|
107
|
+
'--narvi-icon-size': '1rem',
|
|
108
|
+
display: 'grid',
|
|
109
|
+
placeItems: 'center',
|
|
110
|
+
flexShrink: 0,
|
|
111
|
+
color: colors.textMuted
|
|
112
|
+
},
|
|
113
|
+
leadText: { flexGrow: 1 },
|
|
91
114
|
// Room for the info mark's focus ring beside the label
|
|
92
115
|
title: { display: 'flex', alignItems: 'center', gap: '0.375rem', minWidth: 0 },
|
|
93
116
|
label: { color: colors.text },
|
|
117
|
+
dimmed: { color: colors.textMuted },
|
|
118
|
+
// Mono runs wider than the text's face: a step down, and no heavier than the text
|
|
119
|
+
mono: {
|
|
120
|
+
fontFamily: font.mono,
|
|
121
|
+
fontSize: font.sizeMeta,
|
|
122
|
+
fontWeight: font.weightRegular,
|
|
123
|
+
overflowWrap: 'anywhere'
|
|
124
|
+
},
|
|
94
125
|
about: {
|
|
95
126
|
position: 'relative',
|
|
96
127
|
display: 'inline-grid',
|
|
@@ -127,6 +158,9 @@
|
|
|
127
158
|
<script lang="ts">
|
|
128
159
|
let {
|
|
129
160
|
label,
|
|
161
|
+
leading,
|
|
162
|
+
dimmed = false,
|
|
163
|
+
mono = false,
|
|
130
164
|
about,
|
|
131
165
|
description,
|
|
132
166
|
stacked = false,
|
|
@@ -149,6 +183,12 @@
|
|
|
149
183
|
.filter(Boolean)
|
|
150
184
|
.join(' ') || undefined
|
|
151
185
|
);
|
|
186
|
+
const labelStyles = $derived([
|
|
187
|
+
typography.label,
|
|
188
|
+
styles.label,
|
|
189
|
+
dimmed && styles.dimmed,
|
|
190
|
+
mono && styles.mono
|
|
191
|
+
]);
|
|
152
192
|
const control = $derived({
|
|
153
193
|
id: controlId ?? `${uid}-control`,
|
|
154
194
|
labelId: `${uid}-label`,
|
|
@@ -171,43 +211,53 @@
|
|
|
171
211
|
className
|
|
172
212
|
)}
|
|
173
213
|
>
|
|
174
|
-
|
|
175
|
-
<
|
|
176
|
-
{
|
|
177
|
-
|
|
178
|
-
id={control.labelId}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
</Tooltip.
|
|
202
|
-
|
|
214
|
+
{#snippet text(sx: Sx | false)}
|
|
215
|
+
<div {...stylex.attrs(styles.text, sx)}>
|
|
216
|
+
<span {...stylex.attrs(styles.title)}>
|
|
217
|
+
{#if labelFor && children}
|
|
218
|
+
<label id={control.labelId} for={control.id} {...stylex.attrs(...labelStyles)}
|
|
219
|
+
>{label}</label
|
|
220
|
+
>
|
|
221
|
+
{:else}
|
|
222
|
+
<span id={control.labelId} {...stylex.attrs(...labelStyles)}>{label}</span>
|
|
223
|
+
{/if}
|
|
224
|
+
{#if about}
|
|
225
|
+
<Tooltip.Provider delayDuration={400}>
|
|
226
|
+
<Tooltip.Root>
|
|
227
|
+
<Tooltip.Trigger>
|
|
228
|
+
{#snippet child({ props })}
|
|
229
|
+
<button
|
|
230
|
+
{...props}
|
|
231
|
+
type="button"
|
|
232
|
+
aria-label="About {label}"
|
|
233
|
+
{...stylex.attrs(styles.about, shared.focusable)}
|
|
234
|
+
>
|
|
235
|
+
<Glyph name="info" size={14} />
|
|
236
|
+
</button>
|
|
237
|
+
{/snippet}
|
|
238
|
+
</Tooltip.Trigger>
|
|
239
|
+
<Tooltip.Content side="top">{about}</Tooltip.Content>
|
|
240
|
+
</Tooltip.Root>
|
|
241
|
+
</Tooltip.Provider>
|
|
242
|
+
{/if}
|
|
243
|
+
</span>
|
|
244
|
+
{#if description}
|
|
245
|
+
<div id="{uid}-description" {...stylex.attrs(typography.meta, styles.description)}>
|
|
246
|
+
{#if typeof description === 'string'}{description}{:else}{@render description()}{/if}
|
|
247
|
+
</div>
|
|
203
248
|
{/if}
|
|
204
|
-
</
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
249
|
+
</div>
|
|
250
|
+
{/snippet}
|
|
251
|
+
{#if leading}
|
|
252
|
+
<div {...stylex.attrs(styles.lead, !stacked && styles.textInline)}>
|
|
253
|
+
<span data-icons aria-hidden="true" {...stylex.attrs(styles.leading)}
|
|
254
|
+
>{@render leading()}</span
|
|
255
|
+
>
|
|
256
|
+
{@render text(styles.leadText)}
|
|
257
|
+
</div>
|
|
258
|
+
{:else}
|
|
259
|
+
{@render text(!stacked && styles.textInline)}
|
|
260
|
+
{/if}
|
|
211
261
|
{#if children}
|
|
212
262
|
<div {...stylex.attrs(styles.control, stacked ? styles.full : styles.controlInline)}>
|
|
213
263
|
{@render children(control)}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
3
|
import { type Sx } from '../../internal/sx.js';
|
|
4
|
+
import '../../internal/icons.css';
|
|
4
5
|
export type SettingsRowControl = {
|
|
5
6
|
/** For the control's `id`, which the label's `for` names: `controlId` when it is set. */
|
|
6
7
|
id: string;
|
|
@@ -11,6 +12,18 @@ export type SettingsRowControl = {
|
|
|
11
12
|
};
|
|
12
13
|
export type SettingsRowProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'title'> & {
|
|
13
14
|
label: string;
|
|
15
|
+
/**
|
|
16
|
+
* Before the label and the description: a provider's mark, an icon of what the row is,
|
|
17
|
+
* an Avatar. Decoration: the label names the row.
|
|
18
|
+
*/
|
|
19
|
+
leading?: Snippet | undefined;
|
|
20
|
+
/** Sets the label in the muted ink: for something switched off, or not to be had here. */
|
|
21
|
+
dimmed?: boolean | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Sets the label in monospace, for a name that is code: an environment variable, a
|
|
24
|
+
* header, a tool, a path.
|
|
25
|
+
*/
|
|
26
|
+
mono?: boolean | undefined;
|
|
14
27
|
/**
|
|
15
28
|
* What the setting does, in a sentence or two, behind an info mark beside the label. It
|
|
16
29
|
* opens on a hover, or as the mark takes the focus.
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
A button and, joined to its end, a second that opens a menu of how to do it, or
|
|
3
|
+
of what else there is to do: Merge, and the ways to merge. The two are one
|
|
4
|
+
group, disabled together. Without a menu the button stands alone, rounded at
|
|
5
|
+
both ends, so a menu that is offered only sometimes does not change the markup.
|
|
6
|
+
-->
|
|
7
|
+
<script lang="ts" module>
|
|
8
|
+
import * as stylex from '@stylexjs/stylex';
|
|
9
|
+
import type { Snippet } from 'svelte';
|
|
10
|
+
import Glyph from '../../internal/Glyph.svelte';
|
|
11
|
+
import { attrs, type Sx } from '../../internal/sx.js';
|
|
12
|
+
import Button, { type ButtonProps } from '../button/Button.svelte';
|
|
13
|
+
import * as Menu from '../menu/index.js';
|
|
14
|
+
|
|
15
|
+
export type SplitButtonProps = Omit<
|
|
16
|
+
ButtonProps,
|
|
17
|
+
'variant' | 'iconOnly' | 'href' | 'shape' | 'pressed' | 'sx'
|
|
18
|
+
> & {
|
|
19
|
+
/** `secondary`, an edge round both halves; `primary`, the one solid, with a line between them. */
|
|
20
|
+
variant?: 'primary' | 'secondary' | undefined;
|
|
21
|
+
/** Names the pair as a group, where the button's own words do not say it all: "Merge". */
|
|
22
|
+
label?: string | undefined;
|
|
23
|
+
/** Names the button that opens the menu: "Choose how to merge", "More for GitHub". */
|
|
24
|
+
menuLabel?: string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The menu: Menu.Item, Menu.RadioGroup, Menu.CheckboxItem and the rest. Without it there
|
|
27
|
+
* is no second button.
|
|
28
|
+
*/
|
|
29
|
+
menu?: Snippet | undefined;
|
|
30
|
+
/** Where the menu lines up with the pair. */
|
|
31
|
+
align?: 'start' | 'center' | 'end' | undefined;
|
|
32
|
+
/** A width of its own for the menu, such as `16rem`. */
|
|
33
|
+
menuWidth?: string | undefined;
|
|
34
|
+
/** Whether the menu is open. Bindable. */
|
|
35
|
+
open?: boolean | undefined;
|
|
36
|
+
/** On the group, which holds both halves. */
|
|
37
|
+
sx?: Sx | undefined;
|
|
38
|
+
/** The main button's label, and its icon if it has one. */
|
|
39
|
+
children?: Snippet | undefined;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const styles = stylex.create({
|
|
43
|
+
group: {
|
|
44
|
+
display: 'inline-flex',
|
|
45
|
+
alignItems: 'stretch',
|
|
46
|
+
flexShrink: 0,
|
|
47
|
+
verticalAlign: 'middle'
|
|
48
|
+
},
|
|
49
|
+
// The focused half is drawn over its neighbour, so its ring is whole
|
|
50
|
+
half: { zIndex: { default: null, ':focus-visible': 1 } },
|
|
51
|
+
main: { borderStartEndRadius: 0, borderEndEndRadius: 0 },
|
|
52
|
+
more: { borderStartStartRadius: 0, borderEndStartRadius: 0 },
|
|
53
|
+
// The edges overlap, so one hairline runs between the halves
|
|
54
|
+
moreSecondary: { marginInlineStart: '-1px' },
|
|
55
|
+
// On the solid, a line in its own ink, faint, divides them
|
|
56
|
+
morePrimary: {
|
|
57
|
+
'::before': {
|
|
58
|
+
content: '""',
|
|
59
|
+
position: 'absolute',
|
|
60
|
+
insetInlineStart: 0,
|
|
61
|
+
insetBlock: 0,
|
|
62
|
+
width: '1px',
|
|
63
|
+
backgroundColor: 'color-mix(in srgb, currentColor 28%, transparent)',
|
|
64
|
+
pointerEvents: 'none'
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
// The chevron's button is a little narrower than a square: it is the lesser half
|
|
68
|
+
moreWidth: { paddingInline: '0.375rem' }
|
|
69
|
+
});
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<script lang="ts">
|
|
73
|
+
let {
|
|
74
|
+
variant = 'secondary',
|
|
75
|
+
size = 'md',
|
|
76
|
+
label,
|
|
77
|
+
menuLabel = 'More options',
|
|
78
|
+
menu,
|
|
79
|
+
align = 'end',
|
|
80
|
+
menuWidth,
|
|
81
|
+
open = $bindable(false),
|
|
82
|
+
disabled = false,
|
|
83
|
+
loading = false,
|
|
84
|
+
sx,
|
|
85
|
+
class: className,
|
|
86
|
+
ref = $bindable(null),
|
|
87
|
+
children,
|
|
88
|
+
...rest
|
|
89
|
+
}: SplitButtonProps = $props();
|
|
90
|
+
|
|
91
|
+
const glyph = { micro: 10, xs: 12, sm: 12, md: 14, lg: 16 } as const;
|
|
92
|
+
</script>
|
|
93
|
+
|
|
94
|
+
<div
|
|
95
|
+
role="group"
|
|
96
|
+
aria-label={label}
|
|
97
|
+
data-slot="split-button"
|
|
98
|
+
{...attrs([styles.group, sx], className)}
|
|
99
|
+
>
|
|
100
|
+
<Button
|
|
101
|
+
bind:ref
|
|
102
|
+
{...rest}
|
|
103
|
+
{variant}
|
|
104
|
+
{size}
|
|
105
|
+
{disabled}
|
|
106
|
+
{loading}
|
|
107
|
+
sx={[styles.half, menu && styles.main]}
|
|
108
|
+
>
|
|
109
|
+
{@render children?.()}
|
|
110
|
+
</Button>
|
|
111
|
+
{#if menu}
|
|
112
|
+
<Menu.Root bind:open>
|
|
113
|
+
<Menu.Trigger disabled={disabled || loading}>
|
|
114
|
+
{#snippet child({ props })}
|
|
115
|
+
<Button
|
|
116
|
+
{...props}
|
|
117
|
+
{variant}
|
|
118
|
+
{size}
|
|
119
|
+
disabled={disabled || loading}
|
|
120
|
+
aria-label={menuLabel}
|
|
121
|
+
sx={[
|
|
122
|
+
styles.half,
|
|
123
|
+
styles.more,
|
|
124
|
+
styles.moreWidth,
|
|
125
|
+
variant === 'primary' ? styles.morePrimary : styles.moreSecondary
|
|
126
|
+
]}
|
|
127
|
+
>
|
|
128
|
+
<Glyph name="chevron" size={glyph[size]} />
|
|
129
|
+
</Button>
|
|
130
|
+
{/snippet}
|
|
131
|
+
</Menu.Trigger>
|
|
132
|
+
<Menu.Content {align} width={menuWidth}>
|
|
133
|
+
{@render menu()}
|
|
134
|
+
</Menu.Content>
|
|
135
|
+
</Menu.Root>
|
|
136
|
+
{/if}
|
|
137
|
+
</div>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import { type Sx } from '../../internal/sx.js';
|
|
3
|
+
import { type ButtonProps } from '../button/Button.svelte';
|
|
4
|
+
export type SplitButtonProps = Omit<ButtonProps, 'variant' | 'iconOnly' | 'href' | 'shape' | 'pressed' | 'sx'> & {
|
|
5
|
+
/** `secondary`, an edge round both halves; `primary`, the one solid, with a line between them. */
|
|
6
|
+
variant?: 'primary' | 'secondary' | undefined;
|
|
7
|
+
/** Names the pair as a group, where the button's own words do not say it all: "Merge". */
|
|
8
|
+
label?: string | undefined;
|
|
9
|
+
/** Names the button that opens the menu: "Choose how to merge", "More for GitHub". */
|
|
10
|
+
menuLabel?: string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* The menu: Menu.Item, Menu.RadioGroup, Menu.CheckboxItem and the rest. Without it there
|
|
13
|
+
* is no second button.
|
|
14
|
+
*/
|
|
15
|
+
menu?: Snippet | undefined;
|
|
16
|
+
/** Where the menu lines up with the pair. */
|
|
17
|
+
align?: 'start' | 'center' | 'end' | undefined;
|
|
18
|
+
/** A width of its own for the menu, such as `16rem`. */
|
|
19
|
+
menuWidth?: string | undefined;
|
|
20
|
+
/** Whether the menu is open. Bindable. */
|
|
21
|
+
open?: boolean | undefined;
|
|
22
|
+
/** On the group, which holds both halves. */
|
|
23
|
+
sx?: Sx | undefined;
|
|
24
|
+
/** The main button's label, and its icon if it has one. */
|
|
25
|
+
children?: Snippet | undefined;
|
|
26
|
+
};
|
|
27
|
+
declare const SplitButton: import("svelte").Component<SplitButtonProps, {}, "ref" | "open">;
|
|
28
|
+
type SplitButton = ReturnType<typeof SplitButton>;
|
|
29
|
+
export default SplitButton;
|