@sondor-technology/sondor-components 1.0.1-develop.13 → 1.0.1-develop.14
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/alert/alert.constants.d.ts +3 -0
- package/dist/components/alert/alert.constants.d.ts.map +1 -0
- package/dist/components/alert/alert.constants.js +2 -0
- package/dist/components/alert/alert.constants.js.map +1 -0
- package/dist/components/alert/alert.d.ts +4 -3
- package/dist/components/alert/alert.d.ts.map +1 -1
- package/dist/components/alert/alert.js +21 -11
- package/dist/components/alert/alert.js.map +1 -0
- package/dist/components/badge/badge.constants.d.ts +3 -0
- package/dist/components/badge/badge.constants.d.ts.map +1 -0
- package/dist/components/badge/badge.constants.js +2 -0
- package/dist/components/badge/badge.constants.js.map +1 -0
- package/dist/components/badge/badge.d.ts +1 -1
- package/dist/components/badge/badge.d.ts.map +1 -1
- package/dist/components/badge/badge.js +3 -2
- package/dist/components/badge/badge.js.map +1 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts.map +1 -1
- package/dist/components/breadcrumb/breadcrumb.js +2 -1
- package/dist/components/breadcrumb/breadcrumb.js.map +1 -0
- package/dist/components/button/button.constants.d.ts +7 -0
- package/dist/components/button/button.constants.d.ts.map +1 -0
- package/dist/components/button/button.constants.js +4 -0
- package/dist/components/button/button.constants.js.map +1 -0
- package/dist/components/button/button.d.ts +8 -4
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/button.js +181 -137
- package/dist/components/button/button.js.map +1 -0
- package/dist/components/button-group/button-group.d.ts +1 -0
- package/dist/components/button-group/button-group.d.ts.map +1 -1
- package/dist/components/button-group/button-group.js +17 -21
- package/dist/components/button-group/button-group.js.map +1 -0
- package/dist/components/checkbox/checkbox.constants.d.ts +3 -0
- package/dist/components/checkbox/checkbox.constants.d.ts.map +1 -0
- package/dist/components/checkbox/checkbox.constants.js +2 -0
- package/dist/components/checkbox/checkbox.constants.js.map +1 -0
- package/dist/components/checkbox/checkbox.d.ts +5 -1
- package/dist/components/checkbox/checkbox.d.ts.map +1 -1
- package/dist/components/checkbox/checkbox.js +21 -5
- package/dist/components/checkbox/checkbox.js.map +1 -0
- package/dist/components/code-block/code-block.d.ts +7 -7
- package/dist/components/code-block/code-block.d.ts.map +1 -1
- package/dist/components/code-block/code-block.js +130 -66
- package/dist/components/code-block/code-block.js.map +1 -0
- package/dist/components/content-card/content-card.d.ts.map +1 -1
- package/dist/components/content-card/content-card.js +10 -15
- package/dist/components/content-card/content-card.js.map +1 -0
- package/dist/components/divider/divider.constants.d.ts +5 -0
- package/dist/components/divider/divider.constants.d.ts.map +1 -0
- package/dist/components/divider/divider.constants.js +3 -0
- package/dist/components/divider/divider.constants.js.map +1 -0
- package/dist/components/divider/divider.d.ts +4 -2
- package/dist/components/divider/divider.d.ts.map +1 -1
- package/dist/components/divider/divider.js +18 -9
- package/dist/components/divider/divider.js.map +1 -0
- package/dist/components/drawer/drawer.d.ts +7 -4
- package/dist/components/drawer/drawer.d.ts.map +1 -1
- package/dist/components/drawer/drawer.js +73 -30
- package/dist/components/drawer/drawer.js.map +1 -0
- package/dist/components/field/field.d.ts +2 -2
- package/dist/components/field/field.d.ts.map +1 -1
- package/dist/components/field/field.js +8 -9
- package/dist/components/field/field.js.map +1 -0
- package/dist/components/footer/footer.d.ts +8 -1
- package/dist/components/footer/footer.d.ts.map +1 -1
- package/dist/components/footer/footer.js +42 -12
- package/dist/components/footer/footer.js.map +1 -0
- package/dist/components/form/form-step.js +1 -0
- package/dist/components/form/form-step.js.map +1 -0
- package/dist/components/form/form.d.ts +3 -0
- package/dist/components/form/form.d.ts.map +1 -1
- package/dist/components/form/form.js +109 -69
- package/dist/components/form/form.js.map +1 -0
- package/dist/components/grid/grid-row.d.ts +3 -3
- package/dist/components/grid/grid-row.d.ts.map +1 -1
- package/dist/components/grid/grid-row.js +36 -22
- package/dist/components/grid/grid-row.js.map +1 -0
- package/dist/components/grid/grid.d.ts +2 -2
- package/dist/components/grid/grid.d.ts.map +1 -1
- package/dist/components/grid/grid.js +5 -2
- package/dist/components/grid/grid.js.map +1 -0
- package/dist/components/icon/icon-paths.d.ts +161 -86
- package/dist/components/icon/icon-paths.d.ts.map +1 -1
- package/dist/components/icon/icon-paths.js +176 -106
- package/dist/components/icon/icon-paths.js.map +1 -0
- package/dist/components/icon/icon.d.ts +1 -1
- package/dist/components/icon/icon.d.ts.map +1 -1
- package/dist/components/icon/icon.js +6 -5
- package/dist/components/icon/icon.js.map +1 -0
- package/dist/components/input/input.d.ts +9 -0
- package/dist/components/input/input.d.ts.map +1 -1
- package/dist/components/input/input.js +30 -37
- package/dist/components/input/input.js.map +1 -0
- package/dist/components/link/link.d.ts +6 -6
- package/dist/components/link/link.d.ts.map +1 -1
- package/dist/components/link/link.js +42 -19
- package/dist/components/link/link.js.map +1 -0
- package/dist/components/metadata/metadata.d.ts +3 -3
- package/dist/components/metadata/metadata.d.ts.map +1 -1
- package/dist/components/metadata/metadata.js +23 -20
- package/dist/components/metadata/metadata.js.map +1 -0
- package/dist/components/modal/modal.d.ts +4 -16
- package/dist/components/modal/modal.d.ts.map +1 -1
- package/dist/components/modal/modal.js +99 -62
- package/dist/components/modal/modal.js.map +1 -0
- package/dist/components/page-layout/page-layout.d.ts +4 -3
- package/dist/components/page-layout/page-layout.d.ts.map +1 -1
- package/dist/components/page-layout/page-layout.js +95 -68
- package/dist/components/page-layout/page-layout.js.map +1 -0
- package/dist/components/radio/radio.d.ts +8 -0
- package/dist/components/radio/radio.d.ts.map +1 -1
- package/dist/components/radio/radio.js +8 -12
- package/dist/components/radio/radio.js.map +1 -0
- package/dist/components/radio-group/radio-group.d.ts +6 -1
- package/dist/components/radio-group/radio-group.d.ts.map +1 -1
- package/dist/components/radio-group/radio-group.js +44 -18
- package/dist/components/radio-group/radio-group.js.map +1 -0
- package/dist/components/router/router.d.ts +5 -7
- package/dist/components/router/router.d.ts.map +1 -1
- package/dist/components/router/router.js +54 -38
- package/dist/components/router/router.js.map +1 -0
- package/dist/components/select/select.d.ts +1 -3
- package/dist/components/select/select.d.ts.map +1 -1
- package/dist/components/select/select.js +14 -5
- package/dist/components/select/select.js.map +1 -0
- package/dist/components/skeleton/skeleton.d.ts +3 -2
- package/dist/components/skeleton/skeleton.d.ts.map +1 -1
- package/dist/components/skeleton/skeleton.js +10 -13
- package/dist/components/skeleton/skeleton.js.map +1 -0
- package/dist/components/switch/switch.d.ts +12 -0
- package/dist/components/switch/switch.d.ts.map +1 -1
- package/dist/components/switch/switch.js +28 -22
- package/dist/components/switch/switch.js.map +1 -0
- package/dist/components/table/data-table.d.ts +3 -25
- package/dist/components/table/data-table.d.ts.map +1 -1
- package/dist/components/table/data-table.js +211 -146
- package/dist/components/table/data-table.js.map +1 -0
- package/dist/components/table/table.d.ts +3 -3
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/table/table.js +39 -20
- package/dist/components/table/table.js.map +1 -0
- package/dist/components/tabs/tab-panel.d.ts +3 -1
- package/dist/components/tabs/tab-panel.d.ts.map +1 -1
- package/dist/components/tabs/tab-panel.js +21 -11
- package/dist/components/tabs/tab-panel.js.map +1 -0
- package/dist/components/tabs/tab.d.ts +5 -1
- package/dist/components/tabs/tab.d.ts.map +1 -1
- package/dist/components/tabs/tab.js +46 -28
- package/dist/components/tabs/tab.js.map +1 -0
- package/dist/components/tabs/tabs.d.ts +4 -0
- package/dist/components/tabs/tabs.d.ts.map +1 -1
- package/dist/components/tabs/tabs.js +76 -13
- package/dist/components/tabs/tabs.js.map +1 -0
- package/dist/components/textarea/textarea.d.ts +13 -0
- package/dist/components/textarea/textarea.d.ts.map +1 -1
- package/dist/components/textarea/textarea.js +59 -13
- package/dist/components/textarea/textarea.js.map +1 -0
- package/dist/components/theme-toggle/theme-toggle.constants.d.ts +3 -0
- package/dist/components/theme-toggle/theme-toggle.constants.d.ts.map +1 -0
- package/dist/components/theme-toggle/theme-toggle.constants.js +2 -0
- package/dist/components/theme-toggle/theme-toggle.constants.js.map +1 -0
- package/dist/components/theme-toggle/theme-toggle.d.ts +3 -2
- package/dist/components/theme-toggle/theme-toggle.d.ts.map +1 -1
- package/dist/components/theme-toggle/theme-toggle.js +46 -19
- package/dist/components/theme-toggle/theme-toggle.js.map +1 -0
- package/dist/components/vertical-nav/vertical-nav-group.d.ts +5 -2
- package/dist/components/vertical-nav/vertical-nav-group.d.ts.map +1 -1
- package/dist/components/vertical-nav/vertical-nav-group.js +50 -14
- package/dist/components/vertical-nav/vertical-nav-group.js.map +1 -0
- package/dist/components/vertical-nav/vertical-nav-item.d.ts +3 -2
- package/dist/components/vertical-nav/vertical-nav-item.d.ts.map +1 -1
- package/dist/components/vertical-nav/vertical-nav-item.js +30 -8
- package/dist/components/vertical-nav/vertical-nav-item.js.map +1 -0
- package/dist/styles/index.css +48 -17
- package/dist/styles/reset.js +1 -0
- package/dist/styles/reset.js.map +1 -0
- package/package.json +2 -1
- package/src/components/alert/alert.constants.ts +2 -0
- package/src/components/alert/alert.ts +24 -15
- package/src/components/badge/badge.constants.ts +2 -0
- package/src/components/badge/badge.ts +3 -4
- package/src/components/breadcrumb/breadcrumb.ts +2 -2
- package/src/components/button/button.constants.ts +8 -0
- package/src/components/button/button.ts +184 -144
- package/src/components/button-group/button-group.ts +18 -22
- package/src/components/checkbox/checkbox.constants.ts +2 -0
- package/src/components/checkbox/checkbox.ts +33 -18
- package/src/components/code-block/code-block.ts +151 -84
- package/src/components/content-card/content-card.ts +10 -16
- package/src/components/divider/divider.constants.ts +5 -0
- package/src/components/divider/divider.ts +22 -11
- package/src/components/drawer/drawer.ts +79 -34
- package/src/components/field/field.ts +9 -11
- package/src/components/footer/footer.ts +43 -12
- package/src/components/form/form.ts +121 -84
- package/src/components/grid/grid-row.ts +45 -32
- package/src/components/grid/grid.ts +7 -4
- package/src/components/icon/icon-paths.ts +175 -106
- package/src/components/icon/icon.ts +6 -6
- package/src/components/input/input.ts +32 -42
- package/src/components/link/link.ts +45 -21
- package/src/components/metadata/metadata.ts +26 -24
- package/src/components/modal/modal.ts +108 -74
- package/src/components/page-layout/page-layout.ts +97 -72
- package/src/components/radio/radio.ts +8 -13
- package/src/components/radio-group/radio-group.ts +45 -21
- package/src/components/router/router.ts +73 -50
- package/src/components/select/select.ts +18 -19
- package/src/components/skeleton/skeleton.ts +14 -14
- package/src/components/switch/switch.ts +31 -25
- package/src/components/table/data-table.ts +248 -177
- package/src/components/table/table.ts +52 -29
- package/src/components/tabs/tab-panel.ts +25 -13
- package/src/components/tabs/tab.ts +58 -33
- package/src/components/tabs/tabs.ts +77 -15
- package/src/components/textarea/textarea.ts +63 -15
- package/src/components/theme-toggle/theme-toggle.constants.ts +2 -0
- package/src/components/theme-toggle/theme-toggle.ts +47 -22
- package/src/components/vertical-nav/vertical-nav-group.ts +57 -18
- package/src/components/vertical-nav/vertical-nav-item.ts +35 -12
- package/src/styles/globals.css +27 -4
- package/src/styles/theme.css +38 -32
- package/tsconfig.json +2 -1
- package/dist/components/card/card.d.ts +0 -11
- package/dist/components/card/card.d.ts.map +0 -1
- package/dist/components/card/card.js +0 -54
- package/src/components/card/card.ts +0 -53
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import Prism from
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
1
|
+
import {LitElement, html, css} from "lit";
|
|
2
|
+
import {customElement, property, state, query} from "lit/decorators.js";
|
|
3
|
+
import {unsafeHTML} from "lit/directives/unsafe-html.js";
|
|
4
|
+
import {resetStyles} from "../../styles/reset.js";
|
|
5
|
+
|
|
6
|
+
import Prism from "prismjs";
|
|
7
|
+
import "prismjs/components/prism-typescript.js";
|
|
8
|
+
import "prismjs/components/prism-javascript.js";
|
|
9
|
+
import "prismjs/components/prism-css.js";
|
|
10
|
+
import "prismjs/components/prism-json.js";
|
|
11
|
+
import "prismjs/components/prism-bash.js";
|
|
12
|
+
import "prismjs/components/prism-csharp.js";
|
|
13
13
|
|
|
14
14
|
interface CodeSnippet {
|
|
15
15
|
lang: string;
|
|
@@ -18,11 +18,11 @@ interface CodeSnippet {
|
|
|
18
18
|
highlightedCode: string;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
@customElement(
|
|
21
|
+
@customElement("st-code-block")
|
|
22
22
|
export class StCodeBlock extends LitElement {
|
|
23
23
|
// Fallback language if a template doesn't provide one
|
|
24
|
-
@property({
|
|
25
|
-
|
|
24
|
+
@property({type: String}) language = "typescript";
|
|
25
|
+
|
|
26
26
|
@state() private _snippets: CodeSnippet[] = [];
|
|
27
27
|
@state() private _activeIndex = 0;
|
|
28
28
|
@state() private _copied = false;
|
|
@@ -36,7 +36,8 @@ export class StCodeBlock extends LitElement {
|
|
|
36
36
|
display: block;
|
|
37
37
|
margin: var(--st-spacing-md) 0;
|
|
38
38
|
border-radius: 8px;
|
|
39
|
-
background
|
|
39
|
+
/* 1. Lock background to a deep dark surface */
|
|
40
|
+
background-color: #161b22;
|
|
40
41
|
border: 1px solid var(--st-color-border);
|
|
41
42
|
overflow: hidden;
|
|
42
43
|
}
|
|
@@ -45,8 +46,9 @@ export class StCodeBlock extends LitElement {
|
|
|
45
46
|
display: flex;
|
|
46
47
|
justify-content: space-between;
|
|
47
48
|
align-items: center;
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
/* 2. Lock header to a slightly darker shade */
|
|
50
|
+
background-color: #0d1117;
|
|
51
|
+
border-bottom: 1px solid #30363d;
|
|
50
52
|
padding: 0 var(--st-spacing-md);
|
|
51
53
|
min-height: 2.5rem; /* 40px */
|
|
52
54
|
}
|
|
@@ -54,7 +56,7 @@ export class StCodeBlock extends LitElement {
|
|
|
54
56
|
/* Single language label */
|
|
55
57
|
.language-label {
|
|
56
58
|
font-size: var(--st-font-size-xs);
|
|
57
|
-
color:
|
|
59
|
+
color: #8b949e;
|
|
58
60
|
text-transform: uppercase;
|
|
59
61
|
letter-spacing: 0.05em;
|
|
60
62
|
font-weight: var(--st-font-weight-bold);
|
|
@@ -71,7 +73,7 @@ export class StCodeBlock extends LitElement {
|
|
|
71
73
|
background: transparent;
|
|
72
74
|
border: none;
|
|
73
75
|
border-bottom: 2px solid transparent;
|
|
74
|
-
color:
|
|
76
|
+
color: #8b949e;
|
|
75
77
|
font-size: var(--st-font-size-xs);
|
|
76
78
|
font-weight: var(--st-font-weight-medium);
|
|
77
79
|
padding: var(--st-spacing-xs) 0;
|
|
@@ -80,19 +82,20 @@ export class StCodeBlock extends LitElement {
|
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
.tab:hover {
|
|
83
|
-
color:
|
|
85
|
+
color: #c9d1d9;
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
.tab.active {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
/* 3. Hardcode the active tab to a high-contrast blue instead of dynamic primary */
|
|
90
|
+
color: #79c0ff;
|
|
91
|
+
border-bottom-color: #79c0ff;
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
/* Copy Button */
|
|
92
95
|
.copy-button {
|
|
93
96
|
background: transparent;
|
|
94
97
|
border: 1px solid transparent;
|
|
95
|
-
color:
|
|
98
|
+
color: #8b949e;
|
|
96
99
|
cursor: pointer;
|
|
97
100
|
display: flex;
|
|
98
101
|
align-items: center;
|
|
@@ -105,8 +108,8 @@ export class StCodeBlock extends LitElement {
|
|
|
105
108
|
}
|
|
106
109
|
|
|
107
110
|
.copy-button:hover {
|
|
108
|
-
color:
|
|
109
|
-
background-color: rgba(255, 255, 255, 0.
|
|
111
|
+
color: #c9d1d9;
|
|
112
|
+
background-color: rgba(255, 255, 255, 0.1);
|
|
110
113
|
}
|
|
111
114
|
|
|
112
115
|
.copy-button svg {
|
|
@@ -120,17 +123,20 @@ export class StCodeBlock extends LitElement {
|
|
|
120
123
|
}
|
|
121
124
|
|
|
122
125
|
.copy-button.copied {
|
|
123
|
-
color:
|
|
126
|
+
color: #3fb950; /* High-contrast success green */
|
|
124
127
|
}
|
|
125
128
|
|
|
126
129
|
pre {
|
|
127
130
|
margin: 0;
|
|
128
131
|
padding: var(--st-spacing-md);
|
|
129
132
|
overflow-x: auto;
|
|
130
|
-
font-family:
|
|
133
|
+
font-family:
|
|
134
|
+
ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New",
|
|
135
|
+
monospace;
|
|
131
136
|
font-size: 0.875rem;
|
|
132
137
|
line-height: 1.5;
|
|
133
|
-
|
|
138
|
+
/* 4. Ensure default text stays light */
|
|
139
|
+
color: #c9d1d9;
|
|
134
140
|
}
|
|
135
141
|
|
|
136
142
|
.raw-content {
|
|
@@ -140,76 +146,130 @@ export class StCodeBlock extends LitElement {
|
|
|
140
146
|
/* ==========================================================
|
|
141
147
|
Prism.js Theme Mapping (Space Grey / Purple Aesthetic)
|
|
142
148
|
========================================================== */
|
|
143
|
-
.token.comment,
|
|
144
|
-
.token.
|
|
145
|
-
.token.
|
|
146
|
-
.token.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
.token.
|
|
151
|
-
|
|
152
|
-
|
|
149
|
+
.token.comment,
|
|
150
|
+
.token.prolog,
|
|
151
|
+
.token.doctype,
|
|
152
|
+
.token.cdata {
|
|
153
|
+
color: #8b949e;
|
|
154
|
+
font-style: italic;
|
|
155
|
+
}
|
|
156
|
+
.token.punctuation {
|
|
157
|
+
color: #8b949e;
|
|
158
|
+
}
|
|
159
|
+
.token.namespace {
|
|
160
|
+
opacity: 0.7;
|
|
161
|
+
}
|
|
162
|
+
.token.property,
|
|
163
|
+
.token.tag,
|
|
164
|
+
.token.boolean,
|
|
165
|
+
.token.number,
|
|
166
|
+
.token.constant,
|
|
167
|
+
.token.symbol,
|
|
168
|
+
.token.deleted {
|
|
169
|
+
color: #79c0ff;
|
|
170
|
+
}
|
|
171
|
+
.token.selector,
|
|
172
|
+
.token.attr-name,
|
|
173
|
+
.token.string,
|
|
174
|
+
.token.char,
|
|
175
|
+
.token.builtin,
|
|
176
|
+
.token.inserted {
|
|
177
|
+
color: #a5d6ff;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/* Replaced var(--st-color-text) with #c9d1d9 */
|
|
181
|
+
.token.operator,
|
|
182
|
+
.token.entity,
|
|
183
|
+
.token.url,
|
|
184
|
+
.language-css .token.string,
|
|
185
|
+
.style .token.string {
|
|
186
|
+
color: #c9d1d9;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/* Replaced var(--st-color-primary) with #ff7b72 (High-contrast pink/red for keywords) */
|
|
190
|
+
.token.atrule,
|
|
191
|
+
.token.attr-value,
|
|
192
|
+
.token.keyword {
|
|
193
|
+
color: #ff7b72;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.token.function,
|
|
197
|
+
.token.class-name {
|
|
198
|
+
color: #d2a8ff;
|
|
199
|
+
}
|
|
200
|
+
.token.regex,
|
|
201
|
+
.token.important,
|
|
202
|
+
.token.variable {
|
|
203
|
+
color: #ffa657;
|
|
204
|
+
}
|
|
205
|
+
`,
|
|
153
206
|
];
|
|
154
207
|
|
|
155
208
|
private _handleSlotChange() {
|
|
156
|
-
const nodes = this._slot.assignedNodes({
|
|
157
|
-
|
|
209
|
+
const nodes = this._slot.assignedNodes({flatten: true});
|
|
210
|
+
|
|
158
211
|
// Find ALL template tags passed into the slot
|
|
159
|
-
const templates = nodes.filter(
|
|
160
|
-
|
|
212
|
+
const templates = nodes.filter(
|
|
213
|
+
(n) => n instanceof HTMLTemplateElement,
|
|
214
|
+
) as HTMLTemplateElement[];
|
|
215
|
+
|
|
161
216
|
if (templates.length > 0) {
|
|
162
217
|
// Map over every template and parse its code and attributes
|
|
163
|
-
this._snippets = templates.map(template => {
|
|
164
|
-
const lang = template.getAttribute(
|
|
165
|
-
const label = template.getAttribute(
|
|
218
|
+
this._snippets = templates.map((template) => {
|
|
219
|
+
const lang = template.getAttribute("data-lang") || this.language;
|
|
220
|
+
const label = template.getAttribute("data-label") || lang; // Fallback to lang if no label provided
|
|
166
221
|
const rawCode = this._dedent(template.innerHTML);
|
|
167
|
-
|
|
222
|
+
|
|
168
223
|
const grammar = Prism.languages[lang] || Prism.languages.javascript;
|
|
169
224
|
const highlightedCode = Prism.highlight(rawCode, grammar, lang);
|
|
170
|
-
|
|
171
|
-
return {
|
|
225
|
+
|
|
226
|
+
return {lang, label, rawCode, highlightedCode};
|
|
172
227
|
});
|
|
173
228
|
} else {
|
|
174
229
|
// Fallback: If no template is used, process raw text just like before
|
|
175
|
-
const rawText = nodes.map(n => n.textContent).join(
|
|
230
|
+
const rawText = nodes.map((n) => n.textContent).join("");
|
|
176
231
|
const rawCode = this._dedent(rawText);
|
|
177
|
-
|
|
232
|
+
|
|
178
233
|
if (rawCode) {
|
|
179
234
|
const grammar = Prism.languages[this.language] || Prism.languages.javascript;
|
|
180
235
|
const highlightedCode = Prism.highlight(rawCode, grammar, this.language);
|
|
181
|
-
this._snippets = [{
|
|
236
|
+
this._snippets = [{lang: this.language, label: this.language, rawCode, highlightedCode}];
|
|
182
237
|
}
|
|
183
238
|
}
|
|
184
|
-
|
|
239
|
+
|
|
185
240
|
// Reset to the first tab whenever new code is injected
|
|
186
241
|
this._activeIndex = 0;
|
|
187
242
|
}
|
|
188
243
|
|
|
189
244
|
private _dedent(text: string): string {
|
|
190
|
-
const lines = text.split(
|
|
245
|
+
const lines = text.split("\n");
|
|
191
246
|
const minIndent = lines
|
|
192
|
-
.filter(line => line.trim().length > 0)
|
|
247
|
+
.filter((line) => line.trim().length > 0)
|
|
193
248
|
.reduce((min, line) => {
|
|
194
249
|
const indent = line.match(/^\s*/)?.[0].length || 0;
|
|
195
250
|
return Math.min(min, indent);
|
|
196
251
|
}, Infinity);
|
|
197
252
|
|
|
198
253
|
if (minIndent === Infinity || minIndent === 0) return text.trim();
|
|
199
|
-
return lines
|
|
254
|
+
return lines
|
|
255
|
+
.map((line) => line.slice(minIndent))
|
|
256
|
+
.join("\n")
|
|
257
|
+
.trim();
|
|
200
258
|
}
|
|
201
259
|
|
|
202
260
|
private async _copyToClipboard() {
|
|
203
261
|
// Copy the code from the currently active tab
|
|
204
262
|
const activeSnippet = this._snippets[this._activeIndex];
|
|
205
263
|
if (!activeSnippet) return;
|
|
206
|
-
|
|
264
|
+
|
|
207
265
|
try {
|
|
208
266
|
await navigator.clipboard.writeText(activeSnippet.rawCode);
|
|
209
267
|
this._copied = true;
|
|
210
|
-
setTimeout(() => {
|
|
268
|
+
setTimeout(() => {
|
|
269
|
+
this._copied = false;
|
|
270
|
+
}, 2000);
|
|
211
271
|
} catch (err) {
|
|
212
|
-
console.error(
|
|
272
|
+
console.error("Failed to copy text: ", err);
|
|
213
273
|
}
|
|
214
274
|
}
|
|
215
275
|
|
|
@@ -218,37 +278,44 @@ export class StCodeBlock extends LitElement {
|
|
|
218
278
|
|
|
219
279
|
return html`
|
|
220
280
|
<div class="header">
|
|
221
|
-
${this._snippets.length > 1
|
|
281
|
+
${this._snippets.length > 1
|
|
222
282
|
? html`
|
|
223
283
|
<div class="tabs">
|
|
224
|
-
${this._snippets.map(
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
284
|
+
${this._snippets.map(
|
|
285
|
+
(snippet, index) => html`
|
|
286
|
+
<button
|
|
287
|
+
class="tab ${index === this._activeIndex ? "active" : ""}"
|
|
288
|
+
@click=${() => (this._activeIndex = index)}
|
|
289
|
+
>
|
|
290
|
+
${snippet.label}
|
|
291
|
+
</button>
|
|
292
|
+
`,
|
|
293
|
+
)}
|
|
232
294
|
</div>
|
|
233
|
-
`
|
|
234
|
-
: html`
|
|
235
|
-
<span class="language-label">${activeSnippet?.label || this.language}</span>
|
|
236
295
|
`
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
<button class="copy-button ${this._copied ?
|
|
240
|
-
${this._copied
|
|
241
|
-
? html`<svg viewBox="0 0 24 24"><polyline points="20 6 9 17 4 12"></polyline></svg>
|
|
242
|
-
|
|
243
|
-
|
|
296
|
+
: html` <span class="language-label">${activeSnippet?.label || this.language}</span> `}
|
|
297
|
+
|
|
298
|
+
<button class="copy-button ${this._copied ? "copied" : ""}" @click=${this._copyToClipboard}>
|
|
299
|
+
${this._copied
|
|
300
|
+
? html`<svg viewBox="0 0 24 24"><polyline points="20 6 9 17 4 12"></polyline></svg>
|
|
301
|
+
Copied!`
|
|
302
|
+
: html`<svg viewBox="0 0 24 24">
|
|
303
|
+
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
|
|
304
|
+
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
|
|
305
|
+
</svg>
|
|
306
|
+
Copy`}
|
|
244
307
|
</button>
|
|
245
308
|
</div>
|
|
246
|
-
|
|
309
|
+
|
|
247
310
|
<!-- Render the currently active snippet -->
|
|
248
|
-
${activeSnippet
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
311
|
+
${activeSnippet
|
|
312
|
+
? html`
|
|
313
|
+
<pre><code class="language-${activeSnippet.lang}">${unsafeHTML(
|
|
314
|
+
activeSnippet.highlightedCode,
|
|
315
|
+
)}</code></pre>
|
|
316
|
+
`
|
|
317
|
+
: ""}
|
|
318
|
+
|
|
252
319
|
<div class="raw-content">
|
|
253
320
|
<slot name="raw" @slotchange=${this._handleSlotChange}></slot>
|
|
254
321
|
</div>
|
|
@@ -260,4 +327,4 @@ declare global {
|
|
|
260
327
|
interface HTMLElementTagNameMap {
|
|
261
328
|
"st-code-block": StCodeBlock;
|
|
262
329
|
}
|
|
263
|
-
}
|
|
330
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit';
|
|
2
2
|
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
3
4
|
import { resetStyles } from '../../styles/reset.js';
|
|
4
5
|
|
|
5
6
|
@customElement('st-content-card')
|
|
6
7
|
export class StContentCard extends LitElement {
|
|
7
|
-
// Use href to align with native HTML web standards
|
|
8
8
|
@property({ type: String }) href?: string;
|
|
9
9
|
@property({ type: String }) target: '_blank' | '_self' = '_self';
|
|
10
10
|
|
|
@@ -13,7 +13,6 @@ export class StContentCard extends LitElement {
|
|
|
13
13
|
css`
|
|
14
14
|
:host {
|
|
15
15
|
display: block;
|
|
16
|
-
/* Ensures cards stretch to equal heights if placed in a flex/grid container */
|
|
17
16
|
height: 100%;
|
|
18
17
|
}
|
|
19
18
|
|
|
@@ -27,8 +26,6 @@ export class StContentCard extends LitElement {
|
|
|
27
26
|
overflow: hidden;
|
|
28
27
|
text-decoration: none;
|
|
29
28
|
color: inherit;
|
|
30
|
-
|
|
31
|
-
/* Smooth transitions for the hover effects */
|
|
32
29
|
transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
|
|
33
30
|
}
|
|
34
31
|
|
|
@@ -44,13 +41,11 @@ export class StContentCard extends LitElement {
|
|
|
44
41
|
outline: none;
|
|
45
42
|
border-color: var(--st-color-primary);
|
|
46
43
|
transform: translateY(-2px);
|
|
47
|
-
/*
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
:host-context([data-theme="dark"]) a.card:hover {
|
|
53
|
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
|
|
44
|
+
/*
|
|
45
|
+
Safari fix: WebKit ignores :host-context.
|
|
46
|
+
Set --st-card-shadow-hover in your global dark mode CSS instead!
|
|
47
|
+
*/
|
|
48
|
+
box-shadow: var(--st-card-shadow-hover, 0 4px 12px rgba(0, 0, 0, 0.05));
|
|
54
49
|
}
|
|
55
50
|
|
|
56
51
|
/* ==========================================================
|
|
@@ -66,14 +61,12 @@ export class StContentCard extends LitElement {
|
|
|
66
61
|
overflow: hidden;
|
|
67
62
|
}
|
|
68
63
|
|
|
69
|
-
/* Image formatting */
|
|
70
64
|
::slotted(img[slot="media"]) {
|
|
71
65
|
width: 100%;
|
|
72
66
|
height: 100%;
|
|
73
67
|
object-fit: cover;
|
|
74
68
|
}
|
|
75
69
|
|
|
76
|
-
/* SVG formatting (for the icons we just created) */
|
|
77
70
|
::slotted(svg[slot="media"]) {
|
|
78
71
|
width: 3rem;
|
|
79
72
|
height: 3rem;
|
|
@@ -105,7 +98,6 @@ export class StContentCard extends LitElement {
|
|
|
105
98
|
];
|
|
106
99
|
|
|
107
100
|
render() {
|
|
108
|
-
// 1. Define the inner content once to avoid duplication
|
|
109
101
|
const innerContent = html`
|
|
110
102
|
<div class="media">
|
|
111
103
|
<slot name="media"></slot>
|
|
@@ -120,9 +112,11 @@ export class StContentCard extends LitElement {
|
|
|
120
112
|
</div>
|
|
121
113
|
`;
|
|
122
114
|
|
|
123
|
-
//
|
|
115
|
+
// 🚀 THE FIX: Conditionally apply security rel if opening in a new tab
|
|
116
|
+
const secureRel = this.target === '_blank' ? 'noopener noreferrer' : undefined;
|
|
117
|
+
|
|
124
118
|
return this.href
|
|
125
|
-
? html`<a href="${this.href}" target="${this.target}" class="card">${innerContent}</a>`
|
|
119
|
+
? html`<a href="${this.href}" target="${this.target}" rel="${ifDefined(secureRel)}" class="card">${innerContent}</a>`
|
|
126
120
|
: html`<div class="card">${innerContent}</div>`;
|
|
127
121
|
}
|
|
128
122
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit';
|
|
2
2
|
import { customElement, property } from 'lit/decorators.js';
|
|
3
3
|
import { resetStyles } from '../../styles/reset.js';
|
|
4
|
+
import { DividerColor, DividerDirection } from './divider.constants.js';
|
|
4
5
|
|
|
5
6
|
@customElement('st-divider')
|
|
6
7
|
export class StDivider extends LitElement {
|
|
7
|
-
@property({ type: String, reflect: true }) direction:
|
|
8
|
+
@property({ type: String, reflect: true }) direction: DividerDirection = 'horizontal';
|
|
8
9
|
@property({ type: String }) thickness = '1px';
|
|
9
10
|
@property({ type: String }) margin = '0';
|
|
10
|
-
@property({ type: String, reflect: true }) color:
|
|
11
|
+
@property({ type: String, reflect: true }) color: DividerColor = 'border';
|
|
11
12
|
|
|
12
13
|
static styles = [
|
|
13
14
|
resetStyles,
|
|
@@ -43,22 +44,32 @@ export class StDivider extends LitElement {
|
|
|
43
44
|
`
|
|
44
45
|
];
|
|
45
46
|
|
|
47
|
+
connectedCallback() {
|
|
48
|
+
super.connectedCallback();
|
|
49
|
+
// Semantic role belongs on the host element
|
|
50
|
+
if (!this.hasAttribute('role')) {
|
|
51
|
+
this.setAttribute('role', 'separator');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
46
55
|
updated(changedProperties: Map<string, any>) {
|
|
47
56
|
super.updated(changedProperties);
|
|
48
57
|
|
|
49
58
|
// Sync properties to CSS variables for dynamic adjustment
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
if (changedProperties.has('thickness') || changedProperties.has('margin')) {
|
|
60
|
+
this.style.setProperty('--divider-thickness', this.thickness);
|
|
61
|
+
this.style.setProperty('--divider-margin', this.margin);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Keep native ARIA attributes perfectly synced with our Lit properties
|
|
65
|
+
if (changedProperties.has('direction')) {
|
|
66
|
+
this.setAttribute('aria-orientation', this.direction);
|
|
67
|
+
}
|
|
52
68
|
}
|
|
53
69
|
|
|
54
70
|
render() {
|
|
55
|
-
//
|
|
56
|
-
return html
|
|
57
|
-
<div
|
|
58
|
-
role="separator"
|
|
59
|
-
aria-orientation="${this.direction === 'horizontal' ? 'horizontal' : 'vertical'}"
|
|
60
|
-
></div>
|
|
61
|
-
`;
|
|
71
|
+
// The host element itself is the structural divider. No inner DOM bloat needed.
|
|
72
|
+
return html``;
|
|
62
73
|
}
|
|
63
74
|
}
|
|
64
75
|
|