contain-css-svelte 1.2.2 → 1.3.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/Card.svelte +12 -0
- package/dist/controls/Button.svelte +12 -0
- package/dist/controls/ButtonLink.svelte +12 -0
- package/dist/controls/Checkbox.svelte +12 -0
- package/dist/controls/CircleButton.svelte +12 -0
- package/dist/controls/Input.svelte +12 -0
- package/dist/controls/RadioButton.svelte +12 -0
- package/dist/controls/Select.svelte +12 -0
- package/dist/controls/Slider.svelte +12 -0
- package/dist/controls/TabItem.svelte +12 -0
- package/dist/controls/Toggle.svelte +12 -0
- package/dist/dropdowns/DropdownMenu.svelte +12 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/layout/Accordion.svelte +12 -0
- package/dist/layout/Bar.svelte +12 -0
- package/dist/layout/ColumnContainer.svelte +12 -0
- package/dist/layout/Columns.svelte +12 -0
- package/dist/layout/Container.svelte +12 -0
- package/dist/layout/DataList.svelte +12 -0
- package/dist/layout/DataListItem.svelte +12 -0
- package/dist/layout/Fieldset.svelte +12 -0
- package/dist/layout/Form.svelte +12 -0
- package/dist/layout/FormItem.svelte +12 -0
- package/dist/layout/GridLayout.svelte +12 -0
- package/dist/layout/Hero.svelte +12 -0
- package/dist/layout/Inline.svelte +12 -0
- package/dist/layout/MenuList.svelte +12 -0
- package/dist/layout/Page.svelte +17 -1
- package/dist/layout/RowContainer.svelte +12 -0
- package/dist/layout/Sidebar.svelte +516 -57
- package/dist/layout/Sidebar.svelte.d.ts +24 -1
- package/dist/layout/SidebarContainer.svelte +172 -0
- package/dist/layout/SidebarContainer.svelte.d.ts +20 -0
- package/dist/layout/SplitPane.svelte +12 -0
- package/dist/layout/Stack.svelte +12 -0
- package/dist/layout/TabBar.svelte +12 -0
- package/dist/layout/Table.svelte +233 -151
- package/dist/layout/Tile.svelte +12 -0
- package/dist/misc/CodeInner.svelte +12 -0
- package/dist/misc/Progress.svelte +12 -0
- package/dist/misc/Tag.svelte +12 -0
- package/dist/overlays/Dialog.svelte +12 -0
- package/dist/overlays/Tooltip.svelte +20 -2
- package/dist/overlays/Tooltip.svelte.d.ts +1 -0
- package/dist/sass/_responsive.scss +15 -0
- package/dist/typography/TextLayout.svelte +12 -0
- package/package.json +1 -1
|
@@ -6,6 +6,29 @@ declare const Sidebar: import("svelte").Component<ContainProps<HTMLAttributes<HT
|
|
|
6
6
|
left?: boolean;
|
|
7
7
|
right?: boolean;
|
|
8
8
|
children?: Snippet;
|
|
9
|
+
/**
|
|
10
|
+
* Float the panel *over* the page content at every width instead of
|
|
11
|
+
* widening the aside and pushing the content aside. Narrow/compact
|
|
12
|
+
* screens already overlay, so this only changes the wide layout.
|
|
13
|
+
*
|
|
14
|
+
* An overlay sidebar also takes the compact layout's affordance: a
|
|
15
|
+
* button that opens a sheet, starting shut. The grab-bar rail is for a
|
|
16
|
+
* panel that lives in the layout -- floating one over the content and
|
|
17
|
+
* asking someone to grab it is strange, and a panel that starts open on
|
|
18
|
+
* top of the content is worse.
|
|
19
|
+
*/
|
|
20
|
+
overlay?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the sidebar is showing its panel. Bindable, so a caller can
|
|
23
|
+
* drive the sidebar from a button of their own:
|
|
24
|
+
* `<Sidebar bind:open />`.
|
|
25
|
+
*
|
|
26
|
+
* Left `undefined` (the default) the sidebar keeps its per-layout
|
|
27
|
+
* defaults -- the wide rail starts open, the compact sheet starts
|
|
28
|
+
* closed -- and the built-in toggles set it from there. Once it holds a
|
|
29
|
+
* boolean, that boolean wins in both layouts.
|
|
30
|
+
*/
|
|
31
|
+
open?: boolean | undefined;
|
|
9
32
|
/**
|
|
10
33
|
* Accessible name for the button that opens the sidebar on narrow
|
|
11
34
|
* screens, and for the one that collapses it once open. What the sidebar
|
|
@@ -14,6 +37,6 @@ declare const Sidebar: import("svelte").Component<ContainProps<HTMLAttributes<HT
|
|
|
14
37
|
*/
|
|
15
38
|
expandLabel?: string;
|
|
16
39
|
collapseLabel?: string;
|
|
17
|
-
}, SidebarStyleProps & StyleProps<readonly ["bg", "fg", "fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "textAlign", "textTransform", "textDecoration", "fontVariant"]>>, {}, "">;
|
|
40
|
+
}, SidebarStyleProps & StyleProps<readonly ["bg", "fg", "fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "textAlign", "textTransform", "textDecoration", "fontVariant"]>>, {}, "open">;
|
|
18
41
|
type Sidebar = ReturnType<typeof Sidebar>;
|
|
19
42
|
export default Sidebar;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
<script lang="ts">import { elementProps } from "../util";
|
|
2
|
+
import { COLOR_VARS, PADDING_VARS, RADIUS_VARS, } from "../styleProps";
|
|
3
|
+
let { right = false, children, class: className, ...restProps } = $props();
|
|
4
|
+
const SIDEBAR_CONTAINER_VARS = [
|
|
5
|
+
...COLOR_VARS,
|
|
6
|
+
...PADDING_VARS,
|
|
7
|
+
...RADIUS_VARS,
|
|
8
|
+
];
|
|
9
|
+
const el = $derived(elementProps(restProps, "sidebar-container", [
|
|
10
|
+
...SIDEBAR_CONTAINER_VARS,
|
|
11
|
+
"width",
|
|
12
|
+
"height",
|
|
13
|
+
"gap",
|
|
14
|
+
]));
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<div class={["sidebar-container", className]} class:right {...el}>
|
|
18
|
+
{@render children?.()}
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<style>/* Logical, not top/bottom/left/right: margin-block/margin-inline already take
|
|
22
|
+
one value (both sides equal) or two (start end), so there is no separate
|
|
23
|
+
"which side" prop to remember and no 4-value shorthand order to get wrong.
|
|
24
|
+
Defaults to 0 on purpose -- unlike padding-props above, a margin that
|
|
25
|
+
appeared by default on every consumer would be a silent layout change the
|
|
26
|
+
day this mixin got added to a new component. Callers opt in with an actual
|
|
27
|
+
value. (Container does not use this mixin: it wants --gap/auto as its
|
|
28
|
+
defaults, which do not fit the "0 unless asked" contract here.) */
|
|
29
|
+
/* The width at or below which a Sidebar swaps its grab-bar rail for the sheet
|
|
30
|
+
affordance -- a floating button that opens a panel over the content.
|
|
31
|
+
|
|
32
|
+
Page has to agree with Sidebar about this, because Page is what floats the
|
|
33
|
+
aside out of flow and reserves the strip of padding the sheet button sits
|
|
34
|
+
in. They used to disagree: Sidebar switched at 512px and Page at 600px,
|
|
35
|
+
which left a band between 513 and 600 where Page had already lifted the
|
|
36
|
+
aside out of the layout while the Sidebar inside it was still showing a
|
|
37
|
+
rail -- a grab bar floating on top of the content, which is the affordance
|
|
38
|
+
we deliberately avoid everywhere else.
|
|
39
|
+
|
|
40
|
+
One definition, used by both, so they cannot drift again. */
|
|
41
|
+
/* Warning: because we define a fallback
|
|
42
|
+
media query, the media query can override the container
|
|
43
|
+
if we stack a bunch of these in a row and aren't thoughtful about the order.
|
|
44
|
+
Put min-width queries *after* max-width queries so that smaller
|
|
45
|
+
container queries don't get their styles overridden by large media queries.
|
|
46
|
+
*/
|
|
47
|
+
/* Convenience groupings */
|
|
48
|
+
.sidebar-container {
|
|
49
|
+
--link-bg: var(--sidebar-container-link-bg, var(--surface-link-bg, inherit));
|
|
50
|
+
--link-fg: var(--sidebar-container-link-fg, var(--surface-link-fg, inherit));
|
|
51
|
+
--_bg-mix-color: var(--sidebar-container-bg-mix-color, var(--surface-bg-mix-color, var(--bg-mix-color, transparent)));
|
|
52
|
+
--_bg-mix-amount: var(--sidebar-container-bg-mix-amount, var(--surface-bg-mix-amount, var(--bg-mix-amount, 0%)));
|
|
53
|
+
--_fg-mix-color: var(--sidebar-container-fg-mix-color, var(--surface-fg-mix-color, var(--fg-mix-color, transparent)));
|
|
54
|
+
--_fg-mix-amount: var(--sidebar-container-fg-mix-amount, var(--surface-fg-mix-amount, var(--fg-mix-amount, 0%)));
|
|
55
|
+
--_bg-base: var(--sidebar-container-bg, var(--surface-bg, var(--bg, unset)));
|
|
56
|
+
--_fg-base: var(--sidebar-container-fg, var(--surface-fg, var(--fg, unset)));
|
|
57
|
+
--_background-color: color-mix(
|
|
58
|
+
in srgb,
|
|
59
|
+
var(--_bg-base),
|
|
60
|
+
var(--_bg-mix-color) var(--_bg-mix-amount)
|
|
61
|
+
);
|
|
62
|
+
--_color: color-mix(
|
|
63
|
+
in srgb,
|
|
64
|
+
var(--_fg-base),
|
|
65
|
+
var(--_fg-mix-color) var(--_fg-mix-amount)
|
|
66
|
+
);
|
|
67
|
+
--muted-color: var(--muted-color-override, var(--_background-color));
|
|
68
|
+
--primary-text-fg: var(
|
|
69
|
+
--primary-text-fg-override,
|
|
70
|
+
color-mix(
|
|
71
|
+
in srgb,
|
|
72
|
+
var(--_color),
|
|
73
|
+
var(--primary-color)
|
|
74
|
+
var(--primary-text-amount, var(--text-amount, 50%))
|
|
75
|
+
)
|
|
76
|
+
);
|
|
77
|
+
--secondary-text-fg: var(
|
|
78
|
+
--secondary-text-fg-override,
|
|
79
|
+
color-mix(
|
|
80
|
+
in srgb,
|
|
81
|
+
var(--_color),
|
|
82
|
+
var(--secondary-color)
|
|
83
|
+
var(--secondary-text-amount, var(--text-amount, 50%))
|
|
84
|
+
)
|
|
85
|
+
);
|
|
86
|
+
--info-text-fg: var(
|
|
87
|
+
--info-text-fg-override,
|
|
88
|
+
color-mix(
|
|
89
|
+
in srgb,
|
|
90
|
+
var(--_color),
|
|
91
|
+
var(--info-color)
|
|
92
|
+
var(--info-text-amount, var(--text-amount, 50%))
|
|
93
|
+
)
|
|
94
|
+
);
|
|
95
|
+
--success-text-fg: var(
|
|
96
|
+
--success-text-fg-override,
|
|
97
|
+
color-mix(
|
|
98
|
+
in srgb,
|
|
99
|
+
var(--_color),
|
|
100
|
+
var(--success-color)
|
|
101
|
+
var(--success-text-amount, var(--text-amount, 50%))
|
|
102
|
+
)
|
|
103
|
+
);
|
|
104
|
+
--warning-text-fg: var(
|
|
105
|
+
--warning-text-fg-override,
|
|
106
|
+
color-mix(
|
|
107
|
+
in srgb,
|
|
108
|
+
var(--_color),
|
|
109
|
+
var(--warning-color)
|
|
110
|
+
var(--warning-text-amount, var(--text-amount, 50%))
|
|
111
|
+
)
|
|
112
|
+
);
|
|
113
|
+
--danger-text-fg: var(
|
|
114
|
+
--danger-text-fg-override,
|
|
115
|
+
color-mix(
|
|
116
|
+
in srgb,
|
|
117
|
+
var(--_color),
|
|
118
|
+
var(--danger-color)
|
|
119
|
+
var(--danger-text-amount, var(--text-amount, 50%))
|
|
120
|
+
)
|
|
121
|
+
);
|
|
122
|
+
--muted-text-fg: var(
|
|
123
|
+
--muted-text-fg-override,
|
|
124
|
+
color-mix(
|
|
125
|
+
in srgb,
|
|
126
|
+
var(--_color),
|
|
127
|
+
var(--muted-color)
|
|
128
|
+
var(--muted-text-amount, var(--text-amount, 50%))
|
|
129
|
+
)
|
|
130
|
+
);
|
|
131
|
+
background-color: var(--_background-color);
|
|
132
|
+
color: var(--_color);
|
|
133
|
+
box-sizing: border-box;
|
|
134
|
+
--_padding: var(--sidebar-container-padding, var(--padding, 4px));
|
|
135
|
+
padding: var(--_padding);
|
|
136
|
+
border: var(--sidebar-container-border, var(--border, inherit));
|
|
137
|
+
border-width: var(--sidebar-container-border-width, var(--__missing-border-width));
|
|
138
|
+
border-style: var(--sidebar-container-border-style, var(--__missing-border-style));
|
|
139
|
+
border-color: var(--sidebar-container-border-color, var(--__missing-border-color));
|
|
140
|
+
border-top: var(--sidebar-container-border-top, var(--border-top, var(--sidebar-container-border, var(--border, none))));
|
|
141
|
+
border-right: var(--sidebar-container-border-right, var(--border-right, var(--sidebar-container-border, var(--border, none))));
|
|
142
|
+
border-bottom: var(--sidebar-container-border-bottom, var(--border-bottom, var(--sidebar-container-border, var(--border, none))));
|
|
143
|
+
border-left: var(--sidebar-container-border-left, var(--border-left, var(--sidebar-container-border, var(--border, none))));
|
|
144
|
+
border-radius: var(--sidebar-container-border-radius, var(--border-radius, none));
|
|
145
|
+
/* (1) so the Sidebar's container queries have something to measure */
|
|
146
|
+
container-type: inline-size;
|
|
147
|
+
/* (3) so the content sits beside the sidebar, not under it */
|
|
148
|
+
display: flex;
|
|
149
|
+
gap: var(--sidebar-container-gap, 0);
|
|
150
|
+
/* so an overlay sheet anchors here rather than escaping up the tree */
|
|
151
|
+
position: relative;
|
|
152
|
+
box-sizing: border-box;
|
|
153
|
+
width: var(--sidebar-container-width, 100%);
|
|
154
|
+
/* (2) a height to fill. `auto` would collapse, because a collapsed
|
|
155
|
+
sidebar has no in-flow content of its own. */
|
|
156
|
+
height: var(--sidebar-container-height, 100%);
|
|
157
|
+
min-height: var(--sidebar-container-min-height, 0);
|
|
158
|
+
/* Deliberately NOT `overflow: hidden`: that is what makes an overlay
|
|
159
|
+
sheet vanish inside a <Container>. */
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.sidebar-container.right {
|
|
163
|
+
flex-direction: row-reverse;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/* The content beside the sidebar takes the remaining width and scrolls on
|
|
167
|
+
its own, so a long page does not stretch the sidebar past the viewport. */
|
|
168
|
+
.sidebar-container > :global(:not(aside)) {
|
|
169
|
+
flex: 1 1 auto;
|
|
170
|
+
min-width: 0;
|
|
171
|
+
overflow: auto;
|
|
172
|
+
}</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
import type { ContainProps } from "../types";
|
|
4
|
+
import { type StyleProps } from "../styleProps";
|
|
5
|
+
declare const SidebarContainer: import("svelte").Component<ContainProps<HTMLAttributes<HTMLDivElement>, {
|
|
6
|
+
/** Put the sidebar after the content in the flex row. Pair with
|
|
7
|
+
* `<Sidebar right />`, which is what draws its border and rail on the
|
|
8
|
+
* correct edge. */
|
|
9
|
+
right?: boolean;
|
|
10
|
+
children?: Snippet;
|
|
11
|
+
}, StyleProps<readonly ["bg", "fg", "padding", "borderRadius"]> & {
|
|
12
|
+
/** Shorthands for --sidebar-container-{width,height,gap}. Height
|
|
13
|
+
* matters: a collapsed sidebar has no in-flow content, so an auto
|
|
14
|
+
* height collapses to nothing. */
|
|
15
|
+
width?: string | null;
|
|
16
|
+
height?: string | null;
|
|
17
|
+
gap?: string | null;
|
|
18
|
+
}>, {}, "">;
|
|
19
|
+
type SidebarContainer = ReturnType<typeof SidebarContainer>;
|
|
20
|
+
export default SidebarContainer;
|
|
@@ -124,6 +124,18 @@ onMount(() => {
|
|
|
124
124
|
day this mixin got added to a new component. Callers opt in with an actual
|
|
125
125
|
value. (Container does not use this mixin: it wants --gap/auto as its
|
|
126
126
|
defaults, which do not fit the "0 unless asked" contract here.) */
|
|
127
|
+
/* The width at or below which a Sidebar swaps its grab-bar rail for the sheet
|
|
128
|
+
affordance -- a floating button that opens a panel over the content.
|
|
129
|
+
|
|
130
|
+
Page has to agree with Sidebar about this, because Page is what floats the
|
|
131
|
+
aside out of flow and reserves the strip of padding the sheet button sits
|
|
132
|
+
in. They used to disagree: Sidebar switched at 512px and Page at 600px,
|
|
133
|
+
which left a band between 513 and 600 where Page had already lifted the
|
|
134
|
+
aside out of the layout while the Sidebar inside it was still showing a
|
|
135
|
+
rail -- a grab bar floating on top of the content, which is the affordance
|
|
136
|
+
we deliberately avoid everywhere else.
|
|
137
|
+
|
|
138
|
+
One definition, used by both, so they cannot drift again. */
|
|
127
139
|
/* Warning: because we define a fallback
|
|
128
140
|
media query, the media query can override the container
|
|
129
141
|
if we stack a bunch of these in a row and aren't thoughtful about the order.
|
package/dist/layout/Stack.svelte
CHANGED
|
@@ -40,6 +40,18 @@ const el = $derived(elementProps({ justify, align: resolvedAlign, gap, ...restPr
|
|
|
40
40
|
day this mixin got added to a new component. Callers opt in with an actual
|
|
41
41
|
value. (Container does not use this mixin: it wants --gap/auto as its
|
|
42
42
|
defaults, which do not fit the "0 unless asked" contract here.) */
|
|
43
|
+
/* The width at or below which a Sidebar swaps its grab-bar rail for the sheet
|
|
44
|
+
affordance -- a floating button that opens a panel over the content.
|
|
45
|
+
|
|
46
|
+
Page has to agree with Sidebar about this, because Page is what floats the
|
|
47
|
+
aside out of flow and reserves the strip of padding the sheet button sits
|
|
48
|
+
in. They used to disagree: Sidebar switched at 512px and Page at 600px,
|
|
49
|
+
which left a band between 513 and 600 where Page had already lifted the
|
|
50
|
+
aside out of the layout while the Sidebar inside it was still showing a
|
|
51
|
+
rail -- a grab bar floating on top of the content, which is the affordance
|
|
52
|
+
we deliberately avoid everywhere else.
|
|
53
|
+
|
|
54
|
+
One definition, used by both, so they cannot drift again. */
|
|
43
55
|
/* Warning: because we define a fallback
|
|
44
56
|
media query, the media query can override the container
|
|
45
57
|
if we stack a bunch of these in a row and aren't thoughtful about the order.
|
|
@@ -54,6 +54,18 @@ let lastActive = $state(active);
|
|
|
54
54
|
day this mixin got added to a new component. Callers opt in with an actual
|
|
55
55
|
value. (Container does not use this mixin: it wants --gap/auto as its
|
|
56
56
|
defaults, which do not fit the "0 unless asked" contract here.) */
|
|
57
|
+
/* The width at or below which a Sidebar swaps its grab-bar rail for the sheet
|
|
58
|
+
affordance -- a floating button that opens a panel over the content.
|
|
59
|
+
|
|
60
|
+
Page has to agree with Sidebar about this, because Page is what floats the
|
|
61
|
+
aside out of flow and reserves the strip of padding the sheet button sits
|
|
62
|
+
in. They used to disagree: Sidebar switched at 512px and Page at 600px,
|
|
63
|
+
which left a band between 513 and 600 where Page had already lifted the
|
|
64
|
+
aside out of the layout while the Sidebar inside it was still showing a
|
|
65
|
+
rail -- a grab bar floating on top of the content, which is the affordance
|
|
66
|
+
we deliberately avoid everywhere else.
|
|
67
|
+
|
|
68
|
+
One definition, used by both, so they cannot drift again. */
|
|
57
69
|
/* Warning: because we define a fallback
|
|
58
70
|
media query, the media query can override the container
|
|
59
71
|
if we stack a bunch of these in a row and aren't thoughtful about the order.
|