forked from hplush/slowreader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.svelte
More file actions
141 lines (119 loc) · 2.81 KB
/
stack.svelte
File metadata and controls
141 lines (119 loc) · 2.81 KB
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
<script lang="ts">
import type { Snippet } from 'svelte'
let {
align = 'start',
children,
controls,
gap = 'm',
height = 'auto',
justify = 'start',
role,
row = false,
width = 'stretch'
}: {
align?: 'baseline' | 'center' | 'end' | 'start'
children: Snippet
controls?: string
gap?: 'l' | 'm' | 's' | 'xl' | 'xs' | 'xxl'
height?: 'auto' | 'stretch'
justify?: 'center' | 'end' | 'space-between' | 'start'
role?: 'menu' | 'menuitem'
row?: boolean
width?: 'auto' | 'stretch'
} = $props()
</script>
<!-- We need tabindex on <div> for simpler focus to edit/delete -->
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
<div
class="stack"
class:is-align-baseline={align === 'baseline'}
class:is-align-center={align === 'center'}
class:is-align-end={align === 'end'}
class:is-align-start={align === 'start'}
class:is-gap-l={gap === 'l'}
class:is-gap-m={gap === 'm'}
class:is-gap-s={gap === 's'}
class:is-gap-xl={gap === 'xl'}
class:is-gap-xs={gap === 'xs'}
class:is-gap-xxl={gap === 'xxl'}
class:is-height-stretch={height === 'stretch'}
class:is-justify-center={justify === 'center'}
class:is-justify-end={justify === 'end'}
class:is-justify-space-between={justify === 'space-between'}
class:is-justify-start={justify === 'start'}
class:is-row={row}
class:is-width-auto={width === 'auto'}
class:is-width-stretch={width === 'stretch'}
aria-controls={controls}
{role}
tabindex={controls ? 0 : null}
>
{@render children()}
</div>
<style>
:global {
.stack {
display: flex;
flex-direction: column;
&[aria-controls] {
border-radius: var(--base-radius);
}
&.is-align-start {
align-items: flex-start;
}
&.is-align-center {
align-items: center;
}
&.is-align-end {
align-items: flex-end;
}
&.is-align-baseline {
align-items: baseline;
}
&.is-justify-center {
justify-content: center;
}
&.is-justify-end {
justify-content: flex-end;
}
&.is-justify-space-between {
justify-content: space-between;
}
&.is-justify-start {
justify-content: flex-start;
}
&.is-width-auto {
width: auto;
}
&.is-width-stretch {
width: stretch;
}
&.is-height-stretch {
flex-grow: 1;
min-height: 100%;
}
&.is-row {
flex-direction: row;
padding: 0 var(--stack-padding);
}
&.is-gap-xxl {
gap: 3rem;
}
&.is-gap-xl {
gap: 1.5rem;
}
&.is-gap-l {
gap: 1rem;
}
&.is-gap-m {
gap: 0.625rem;
}
&.is-gap-xs {
gap: 0.125rem;
}
&.is-gap-s {
gap: 0.375rem;
}
}
}
</style>