@beatzball/create-litro 0.2.1 → 0.4.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/CHANGELOG.md +33 -0
- package/dist/recipes/starlight/template/app.ts +14 -0
- package/dist/recipes/starlight/template/nitro.config.ts +2 -0
- package/dist/recipes/starlight/template/package.json +2 -0
- package/dist/recipes/starlight/template/pages/docs/[slug].ts +75 -2
- package/dist/recipes/starlight/template/pages/index.ts +6 -6
- package/dist/recipes/starlight/template/public/styles/highlight.css +108 -0
- package/dist/recipes/starlight/template/public/styles/starlight.css +58 -19
- package/dist/recipes/starlight/template/src/components/{sl-aside.ts → litro-aside.ts} +5 -5
- package/{recipes/starlight/template/src/components/sl-badge.ts → dist/recipes/starlight/template/src/components/litro-badge.ts} +5 -5
- package/{recipes/starlight/template/src/components/sl-card-grid.ts → dist/recipes/starlight/template/src/components/litro-card-grid.ts} +7 -7
- package/{recipes/starlight/template/src/components/sl-card.ts → dist/recipes/starlight/template/src/components/litro-card.ts} +36 -12
- package/dist/recipes/starlight/template/src/components/{sl-tab-item.ts → litro-tab-item.ts} +6 -6
- package/{recipes/starlight/template/src/components/sl-tabs.ts → dist/recipes/starlight/template/src/components/litro-tabs.ts} +12 -12
- package/dist/recipes/starlight/template/src/components/starlight-header.ts +128 -32
- package/dist/recipes/starlight/template/src/components/starlight-page.ts +53 -5
- package/dist/recipes/starlight/template/src/highlight.ts +40 -0
- package/dist/recipes/starlight/template/src/route-meta.ts +4 -1
- package/dist/recipes/starlight/template/vite.config.ts +1 -1
- package/dist/src/scaffold.test.js +6 -6
- package/dist/src/scaffold.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/recipes/starlight/template/app.ts +14 -0
- package/recipes/starlight/template/nitro.config.ts +2 -0
- package/recipes/starlight/template/package.json +2 -0
- package/recipes/starlight/template/pages/docs/[slug].ts +75 -2
- package/recipes/starlight/template/pages/index.ts +6 -6
- package/recipes/starlight/template/public/styles/highlight.css +108 -0
- package/recipes/starlight/template/public/styles/starlight.css +58 -19
- package/recipes/starlight/template/src/components/{sl-aside.ts → litro-aside.ts} +5 -5
- package/{dist/recipes/starlight/template/src/components/sl-badge.ts → recipes/starlight/template/src/components/litro-badge.ts} +5 -5
- package/{dist/recipes/starlight/template/src/components/sl-card-grid.ts → recipes/starlight/template/src/components/litro-card-grid.ts} +7 -7
- package/{dist/recipes/starlight/template/src/components/sl-card.ts → recipes/starlight/template/src/components/litro-card.ts} +36 -12
- package/recipes/starlight/template/src/components/{sl-tab-item.ts → litro-tab-item.ts} +6 -6
- package/{dist/recipes/starlight/template/src/components/sl-tabs.ts → recipes/starlight/template/src/components/litro-tabs.ts} +12 -12
- package/recipes/starlight/template/src/components/starlight-header.ts +128 -32
- package/recipes/starlight/template/src/components/starlight-page.ts +53 -5
- package/recipes/starlight/template/src/highlight.ts +40 -0
- package/recipes/starlight/template/src/route-meta.ts +4 -1
- package/recipes/starlight/template/vite.config.ts +1 -1
- package/src/scaffold.test.ts +6 -6
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/* highlight.js — fire theme (always dark background) */
|
|
2
|
+
|
|
3
|
+
pre:has(.hljs) {
|
|
4
|
+
background-color: #0d0d10;
|
|
5
|
+
color: #cbd5e1;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
[data-theme="dark"] pre:has(.hljs) {
|
|
9
|
+
background-color: #0d0d10;
|
|
10
|
+
color: #cbd5e1;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.hljs {
|
|
14
|
+
color: #cbd5e1;
|
|
15
|
+
background: transparent;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* Keywords: const, let, if, class, return … */
|
|
19
|
+
.hljs-keyword,
|
|
20
|
+
.hljs-selector-tag,
|
|
21
|
+
.hljs-tag {
|
|
22
|
+
color: #f97316;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* Strings and attribute values */
|
|
26
|
+
.hljs-string,
|
|
27
|
+
.hljs-attr,
|
|
28
|
+
.hljs-attribute {
|
|
29
|
+
color: #38bdf8;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Numbers and boolean literals */
|
|
33
|
+
.hljs-number,
|
|
34
|
+
.hljs-literal {
|
|
35
|
+
color: #fbbf24;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* Function/class names, built-ins */
|
|
39
|
+
.hljs-title,
|
|
40
|
+
.hljs-title.class_,
|
|
41
|
+
.hljs-title.function_,
|
|
42
|
+
.hljs-built_in {
|
|
43
|
+
color: #fb923c;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Comments */
|
|
47
|
+
.hljs-comment {
|
|
48
|
+
color: #6b7280;
|
|
49
|
+
font-style: italic;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* Variables and parameters */
|
|
53
|
+
.hljs-variable,
|
|
54
|
+
.hljs-params {
|
|
55
|
+
color: #cbd5e1;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* Operators and punctuation */
|
|
59
|
+
.hljs-operator,
|
|
60
|
+
.hljs-punctuation {
|
|
61
|
+
color: #94a3b8;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* Meta / imports / decorators */
|
|
65
|
+
.hljs-meta,
|
|
66
|
+
.hljs-meta .hljs-keyword {
|
|
67
|
+
color: #38bdf8;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* Type annotations */
|
|
71
|
+
.hljs-type {
|
|
72
|
+
color: #fb923c;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* Diff deletions */
|
|
76
|
+
.hljs-deletion {
|
|
77
|
+
color: #f87171;
|
|
78
|
+
background: rgba(248, 113, 113, 0.1);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* Diff additions */
|
|
82
|
+
.hljs-addition {
|
|
83
|
+
color: #4ade80;
|
|
84
|
+
background: rgba(74, 222, 128, 0.1);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* Section / selector */
|
|
88
|
+
.hljs-section,
|
|
89
|
+
.hljs-selector-class,
|
|
90
|
+
.hljs-selector-id {
|
|
91
|
+
color: #fb923c;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* Symbol / bullet */
|
|
95
|
+
.hljs-symbol,
|
|
96
|
+
.hljs-bullet,
|
|
97
|
+
.hljs-link {
|
|
98
|
+
color: #38bdf8;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* Emphasis */
|
|
102
|
+
.hljs-emphasis {
|
|
103
|
+
font-style: italic;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.hljs-strong {
|
|
107
|
+
font-weight: bold;
|
|
108
|
+
}
|
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
/* FOUCE - https://www.abeautifulsite.net/posts/flash-of-undefined-custom-elements/ */
|
|
2
|
+
:not(:defined) {
|
|
3
|
+
visibility: hidden;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/* Shoelace theme bridge — map sl-color-primary-* to Litro's accent palette */
|
|
7
|
+
:root {
|
|
8
|
+
--sl-color-primary-50: #f5f3ff;
|
|
9
|
+
--sl-color-primary-100: #ede9fe;
|
|
10
|
+
--sl-color-primary-200: #ddd6fe;
|
|
11
|
+
--sl-color-primary-300: #c4b5fd;
|
|
12
|
+
--sl-color-primary-400: #a78bfa;
|
|
13
|
+
--sl-color-primary-500: #8b5cf6;
|
|
14
|
+
--sl-color-primary-600: #7c3aed;
|
|
15
|
+
--sl-color-primary-700: #6d28d9;
|
|
16
|
+
--sl-color-primary-800: #5b21b6;
|
|
17
|
+
--sl-color-primary-900: #4c1d95;
|
|
18
|
+
--sl-color-primary-950: #2e1065;
|
|
19
|
+
}
|
|
20
|
+
|
|
1
21
|
/* Starlight design tokens — light mode defaults */
|
|
2
22
|
:root {
|
|
3
23
|
--sl-color-white: #fff;
|
|
@@ -30,14 +50,14 @@
|
|
|
30
50
|
--sl-font-sans: ui-sans-serif, system-ui, -apple-system, sans-serif;
|
|
31
51
|
--sl-font-mono: ui-monospace, "Cascadia Code", "Fira Code", monospace;
|
|
32
52
|
|
|
33
|
-
--sl-text-xs:
|
|
34
|
-
--sl-text-sm:
|
|
53
|
+
--sl-text-xs: 0.75rem;
|
|
54
|
+
--sl-text-sm: 0.875rem;
|
|
35
55
|
--sl-text-base: 1rem;
|
|
36
|
-
--sl-text-lg:
|
|
37
|
-
--sl-text-xl:
|
|
38
|
-
--sl-text-2xl:
|
|
39
|
-
--sl-text-3xl:
|
|
40
|
-
--sl-text-4xl:
|
|
56
|
+
--sl-text-lg: 1.125rem;
|
|
57
|
+
--sl-text-xl: 1.25rem;
|
|
58
|
+
--sl-text-2xl: 1.5rem;
|
|
59
|
+
--sl-text-3xl: 1.875rem;
|
|
60
|
+
--sl-text-4xl: 2.25rem;
|
|
41
61
|
|
|
42
62
|
--sl-nav-height: 3.5rem;
|
|
43
63
|
--sl-sidebar-width: 16rem;
|
|
@@ -54,7 +74,7 @@
|
|
|
54
74
|
}
|
|
55
75
|
|
|
56
76
|
/* Dark mode overrides */
|
|
57
|
-
[data-theme=
|
|
77
|
+
[data-theme="dark"] {
|
|
58
78
|
--sl-color-text: #f0f0f0;
|
|
59
79
|
--sl-color-bg: #17181c;
|
|
60
80
|
--sl-color-bg-sidebar: #1e1f24;
|
|
@@ -80,7 +100,9 @@
|
|
|
80
100
|
}
|
|
81
101
|
|
|
82
102
|
/* Base reset */
|
|
83
|
-
*,
|
|
103
|
+
*,
|
|
104
|
+
*::before,
|
|
105
|
+
*::after {
|
|
84
106
|
box-sizing: border-box;
|
|
85
107
|
}
|
|
86
108
|
|
|
@@ -99,7 +121,12 @@ body {
|
|
|
99
121
|
}
|
|
100
122
|
|
|
101
123
|
/* Typography reset for content areas */
|
|
102
|
-
h1,
|
|
124
|
+
h1,
|
|
125
|
+
h2,
|
|
126
|
+
h3,
|
|
127
|
+
h4,
|
|
128
|
+
h5,
|
|
129
|
+
h6 {
|
|
103
130
|
margin-top: 1.5em;
|
|
104
131
|
margin-bottom: 0.5em;
|
|
105
132
|
font-weight: 600;
|
|
@@ -107,10 +134,20 @@ h1, h2, h3, h4, h5, h6 {
|
|
|
107
134
|
color: var(--sl-color-text);
|
|
108
135
|
}
|
|
109
136
|
|
|
110
|
-
h1 {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
137
|
+
h1 {
|
|
138
|
+
font-size: var(--sl-text-4xl);
|
|
139
|
+
}
|
|
140
|
+
h2 {
|
|
141
|
+
font-size: var(--sl-text-2xl);
|
|
142
|
+
border-bottom: 1px solid var(--sl-color-border);
|
|
143
|
+
padding-bottom: 0.25em;
|
|
144
|
+
}
|
|
145
|
+
h3 {
|
|
146
|
+
font-size: var(--sl-text-xl);
|
|
147
|
+
}
|
|
148
|
+
h4 {
|
|
149
|
+
font-size: var(--sl-text-lg);
|
|
150
|
+
}
|
|
114
151
|
|
|
115
152
|
p {
|
|
116
153
|
margin-top: 0;
|
|
@@ -147,7 +184,7 @@ pre {
|
|
|
147
184
|
line-height: 1.6;
|
|
148
185
|
}
|
|
149
186
|
|
|
150
|
-
[data-theme=
|
|
187
|
+
[data-theme="dark"] pre {
|
|
151
188
|
background-color: #0d0e11;
|
|
152
189
|
color: #e2e4e9;
|
|
153
190
|
}
|
|
@@ -166,7 +203,8 @@ table {
|
|
|
166
203
|
font-size: var(--sl-text-sm);
|
|
167
204
|
}
|
|
168
205
|
|
|
169
|
-
th,
|
|
206
|
+
th,
|
|
207
|
+
td {
|
|
170
208
|
border: 1px solid var(--sl-color-border);
|
|
171
209
|
padding: 0.5rem 0.75rem;
|
|
172
210
|
text-align: left;
|
|
@@ -177,11 +215,12 @@ th {
|
|
|
177
215
|
font-weight: 600;
|
|
178
216
|
}
|
|
179
217
|
|
|
180
|
-
[data-theme=
|
|
218
|
+
[data-theme="dark"] th {
|
|
181
219
|
background-color: var(--sl-color-gray-1);
|
|
182
220
|
}
|
|
183
221
|
|
|
184
|
-
ul,
|
|
222
|
+
ul,
|
|
223
|
+
ol {
|
|
185
224
|
padding-left: 1.5rem;
|
|
186
225
|
margin: 0 0 1rem;
|
|
187
226
|
}
|
|
@@ -199,7 +238,7 @@ blockquote {
|
|
|
199
238
|
border-radius: 0 var(--sl-border-radius) var(--sl-border-radius) 0;
|
|
200
239
|
}
|
|
201
240
|
|
|
202
|
-
[data-theme=
|
|
241
|
+
[data-theme="dark"] blockquote {
|
|
203
242
|
background-color: var(--sl-color-accent-low);
|
|
204
243
|
}
|
|
205
244
|
|
|
@@ -18,13 +18,13 @@ const LABELS: Record<AsideType, string> = {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* <
|
|
21
|
+
* <litro-aside type="tip" title="Custom Title">
|
|
22
22
|
* Callout box with an icon and colored left border.
|
|
23
23
|
* Slot content is the body.
|
|
24
|
-
* </
|
|
24
|
+
* </litro-aside>
|
|
25
25
|
*/
|
|
26
|
-
@customElement('
|
|
27
|
-
export class
|
|
26
|
+
@customElement('litro-aside')
|
|
27
|
+
export class LitroAside extends LitElement {
|
|
28
28
|
static override properties = {
|
|
29
29
|
type: { type: String },
|
|
30
30
|
title: { type: String },
|
|
@@ -88,4 +88,4 @@ export class SlAside extends LitElement {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
export default
|
|
91
|
+
export default LitroAside;
|
|
@@ -4,12 +4,12 @@ import { customElement } from 'lit/decorators.js';
|
|
|
4
4
|
type BadgeVariant = 'note' | 'tip' | 'caution' | 'danger' | 'default';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* <
|
|
7
|
+
* <litro-badge variant="tip" text="New">
|
|
8
8
|
* Inline color-coded chip. Use `text` attribute or slot content.
|
|
9
|
-
* </
|
|
9
|
+
* </litro-badge>
|
|
10
10
|
*/
|
|
11
|
-
@customElement('
|
|
12
|
-
export class
|
|
11
|
+
@customElement('litro-badge')
|
|
12
|
+
export class LitroBadge extends LitElement {
|
|
13
13
|
static override properties = {
|
|
14
14
|
variant: { type: String },
|
|
15
15
|
text: { type: String },
|
|
@@ -73,4 +73,4 @@ export class SlBadge extends LitElement {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
export default
|
|
76
|
+
export default LitroBadge;
|
|
@@ -2,13 +2,13 @@ import { LitElement, html, css } from 'lit';
|
|
|
2
2
|
import { customElement } from 'lit/decorators.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* <
|
|
6
|
-
* Responsive auto-fit grid for <
|
|
7
|
-
* Single slot — place <
|
|
8
|
-
* </
|
|
5
|
+
* <litro-card-grid>
|
|
6
|
+
* Responsive auto-fit grid for <litro-card> elements.
|
|
7
|
+
* Single slot — place <litro-card> elements directly inside.
|
|
8
|
+
* </litro-card-grid>
|
|
9
9
|
*/
|
|
10
|
-
@customElement('
|
|
11
|
-
export class
|
|
10
|
+
@customElement('litro-card-grid')
|
|
11
|
+
export class LitroCardGrid extends LitElement {
|
|
12
12
|
static override styles = css`
|
|
13
13
|
:host {
|
|
14
14
|
display: block;
|
|
@@ -31,4 +31,4 @@ export class SlCardGrid extends LitElement {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export default
|
|
34
|
+
export default LitroCardGrid;
|
|
@@ -2,28 +2,32 @@ import { LitElement, html, css } from 'lit';
|
|
|
2
2
|
import { customElement } from 'lit/decorators.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* <
|
|
5
|
+
* <litro-card title="Feature" description="Short desc" href="/docs/feature">
|
|
6
6
|
* Renders as an <a> when `href` is set, otherwise a <div>.
|
|
7
7
|
* Rotating accent color per nth-card via CSS counter.
|
|
8
|
-
* </
|
|
8
|
+
* </litro-card>
|
|
9
9
|
*/
|
|
10
|
-
@customElement('
|
|
11
|
-
export class
|
|
10
|
+
@customElement('litro-card')
|
|
11
|
+
export class LitroCard extends LitElement {
|
|
12
12
|
static override properties = {
|
|
13
13
|
title: { type: String },
|
|
14
14
|
description: { type: String },
|
|
15
15
|
icon: { type: String },
|
|
16
|
+
iconSrc: { type: String },
|
|
16
17
|
href: { type: String },
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
static override styles = css`
|
|
20
21
|
:host {
|
|
21
|
-
display:
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: column;
|
|
22
24
|
counter-increment: card;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
.card {
|
|
26
|
-
display:
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
flex: 1;
|
|
27
31
|
padding: 1.25rem 1.5rem;
|
|
28
32
|
border: 1px solid var(--sl-color-border, #e8e8e8);
|
|
29
33
|
border-radius: var(--sl-border-radius, 0.375rem);
|
|
@@ -45,16 +49,31 @@ export class SlCard extends LitElement {
|
|
|
45
49
|
transform: translateY(-2px);
|
|
46
50
|
}
|
|
47
51
|
|
|
52
|
+
.card-header {
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
gap: 0.6rem;
|
|
56
|
+
margin-bottom: 0.4rem;
|
|
57
|
+
}
|
|
58
|
+
|
|
48
59
|
.card-icon {
|
|
49
|
-
font-size: 1.
|
|
50
|
-
|
|
60
|
+
font-size: 1.5rem;
|
|
61
|
+
flex-shrink: 0;
|
|
62
|
+
line-height: 1;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.card-icon-img {
|
|
66
|
+
width: 1.5rem;
|
|
67
|
+
height: 1.5rem;
|
|
68
|
+
object-fit: contain;
|
|
69
|
+
flex-shrink: 0;
|
|
51
70
|
}
|
|
52
71
|
|
|
53
72
|
.card-title {
|
|
54
73
|
font-size: var(--sl-text-lg, 1.125rem);
|
|
55
74
|
font-weight: 600;
|
|
56
75
|
color: var(--sl-color-text, #23262f);
|
|
57
|
-
margin: 0
|
|
76
|
+
margin: 0;
|
|
58
77
|
}
|
|
59
78
|
|
|
60
79
|
.card-desc {
|
|
@@ -72,12 +91,17 @@ export class SlCard extends LitElement {
|
|
|
72
91
|
title = '';
|
|
73
92
|
description = '';
|
|
74
93
|
icon = '';
|
|
94
|
+
iconSrc = '';
|
|
75
95
|
href = '';
|
|
76
96
|
|
|
77
97
|
override render() {
|
|
78
98
|
const inner = html`
|
|
79
|
-
|
|
80
|
-
|
|
99
|
+
<div class="card-header">
|
|
100
|
+
${this.iconSrc
|
|
101
|
+
? html`<img class="card-icon-img" src="${this.iconSrc}" alt="" aria-hidden="true" />`
|
|
102
|
+
: this.icon ? html`<span class="card-icon">${this.icon}</span>` : ''}
|
|
103
|
+
<p class="card-title">${this.title}</p>
|
|
104
|
+
</div>
|
|
81
105
|
${this.description ? html`<p class="card-desc">${this.description}</p>` : ''}
|
|
82
106
|
<div class="card-slot"><slot></slot></div>
|
|
83
107
|
`;
|
|
@@ -88,4 +112,4 @@ export class SlCard extends LitElement {
|
|
|
88
112
|
}
|
|
89
113
|
}
|
|
90
114
|
|
|
91
|
-
export default
|
|
115
|
+
export default LitroCard;
|
|
@@ -2,13 +2,13 @@ import { LitElement, html, css } from 'lit';
|
|
|
2
2
|
import { customElement } from 'lit/decorators.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* <
|
|
6
|
-
* A single tab panel managed by a parent <
|
|
5
|
+
* <litro-tab-item label="Tab Label">
|
|
6
|
+
* A single tab panel managed by a parent <litro-tabs> element.
|
|
7
7
|
* Hidden automatically when not selected.
|
|
8
|
-
* </
|
|
8
|
+
* </litro-tab-item>
|
|
9
9
|
*/
|
|
10
|
-
@customElement('
|
|
11
|
-
export class
|
|
10
|
+
@customElement('litro-tab-item')
|
|
11
|
+
export class LitroTabItem extends LitElement {
|
|
12
12
|
static override properties = {
|
|
13
13
|
label: { type: String },
|
|
14
14
|
selected: { type: Boolean, reflect: true },
|
|
@@ -32,4 +32,4 @@ export class SlTabItem extends LitElement {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export default
|
|
35
|
+
export default LitroTabItem;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit';
|
|
2
2
|
import { customElement } from 'lit/decorators.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { LitroTabItem } from './litro-tab-item.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* <
|
|
7
|
-
* <
|
|
8
|
-
* <
|
|
9
|
-
* </
|
|
6
|
+
* <litro-tabs>
|
|
7
|
+
* <litro-tab-item label="First">Content A</litro-tab-item>
|
|
8
|
+
* <litro-tab-item label="Second">Content B</litro-tab-item>
|
|
9
|
+
* </litro-tabs>
|
|
10
10
|
*
|
|
11
|
-
* Reads slotted <
|
|
11
|
+
* Reads slotted <litro-tab-item> elements via the slotchange event.
|
|
12
12
|
* Renders a tab bar in Shadow DOM; clicking selects the tab.
|
|
13
13
|
*/
|
|
14
|
-
@customElement('
|
|
15
|
-
export class
|
|
14
|
+
@customElement('litro-tabs')
|
|
15
|
+
export class LitroTabs extends LitElement {
|
|
16
16
|
static override properties = {
|
|
17
17
|
_labels: { type: Array, state: true },
|
|
18
18
|
_selectedIndex: { type: Number, state: true },
|
|
@@ -64,11 +64,11 @@ export class SlTabs extends LitElement {
|
|
|
64
64
|
_labels: string[] = [];
|
|
65
65
|
_selectedIndex = 0;
|
|
66
66
|
|
|
67
|
-
private _items():
|
|
67
|
+
private _items(): LitroTabItem[] {
|
|
68
68
|
const slot = this.shadowRoot?.querySelector('slot');
|
|
69
69
|
if (!slot) return [];
|
|
70
70
|
return slot.assignedElements().filter(
|
|
71
|
-
(el): el is
|
|
71
|
+
(el): el is LitroTabItem => el.tagName.toLowerCase() === 'litro-tab-item',
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -78,7 +78,7 @@ export class SlTabs extends LitElement {
|
|
|
78
78
|
this._selectIndex(this._selectedIndex < items.length ? this._selectedIndex : 0, items);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
private _selectIndex(index: number, items?:
|
|
81
|
+
private _selectIndex(index: number, items?: LitroTabItem[]) {
|
|
82
82
|
const all = items ?? this._items();
|
|
83
83
|
this._selectedIndex = index;
|
|
84
84
|
all.forEach((item, i) => {
|
|
@@ -105,4 +105,4 @@ export class SlTabs extends LitElement {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
export default
|
|
108
|
+
export default LitroTabs;
|