ds-one 0.2.0-alpha.1 → 0.2.0-alpha.2
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/DS1/1-root/one.css +1 -1
- package/DS1/2-core/{article-v1.ts → ds-article.ts} +5 -4
- package/DS1/2-core/{attributes-v1.ts → ds-attributes.ts} +4 -3
- package/DS1/2-core/{cycle-v1.ts → ds-cycle.ts} +11 -10
- package/DS1/2-core/{downloadcv-v1.ts → ds-downloadcv.ts} +9 -8
- package/DS1/2-core/{header-v1.ts → ds-header.ts} +4 -3
- package/DS1/2-core/{home-v1.ts → ds-home.ts} +3 -2
- package/DS1/2-core/{icon-v1.ts → ds-icon.ts} +2 -2
- package/DS1/2-core/{link-v1.ts → ds-link.ts} +5 -5
- package/DS1/2-core/{markdown-v1.ts → ds-markdown.ts} +3 -2
- package/DS1/2-core/{price-v1.ts → ds-price.ts} +4 -3
- package/DS1/2-core/{squarecircle-v1.ts → ds-squarecircle.ts} +4 -3
- package/DS1/2-core/{title-v1.ts → ds-title.ts} +5 -4
- package/DS1/2-core/{tooltip-v1.ts → ds-tooltip.ts} +4 -3
- package/DS1/2-core/{viewtoggle-v1.ts → ds-viewtoggle.ts} +4 -3
- package/DS1/2-core/{year-v1.ts → ds-year.ts} +4 -3
- package/DS1/3-unit/{doublenav-v1.ts → ds-doublenav.ts} +9 -8
- package/DS1/3-unit/{list-v1.ts → ds-list.ts} +3 -2
- package/DS1/3-unit/{panel-v1.ts → ds-panel.ts} +3 -2
- package/DS1/3-unit/{row-v1.ts → ds-row.ts} +3 -2
- package/DS1/3-unit/{singlenav-v1.ts → ds-singlenav.ts} +5 -4
- package/DS1/index.ts +20 -20
- package/README.md +4 -4
- package/dist/2-core/ds-article.d.ts +129 -0
- package/dist/2-core/ds-article.d.ts.map +1 -0
- package/dist/2-core/ds-article.js +361 -0
- package/dist/2-core/ds-attributes.d.ts +47 -0
- package/dist/2-core/ds-attributes.d.ts.map +1 -0
- package/dist/2-core/ds-attributes.js +128 -0
- package/dist/2-core/ds-cycle.d.ts +66 -0
- package/dist/2-core/ds-cycle.d.ts.map +1 -0
- package/dist/2-core/ds-cycle.js +586 -0
- package/dist/2-core/ds-downloadcv.d.ts +58 -0
- package/dist/2-core/ds-downloadcv.d.ts.map +1 -0
- package/dist/2-core/ds-downloadcv.js +119 -0
- package/dist/2-core/ds-header.d.ts +28 -0
- package/dist/2-core/ds-header.d.ts.map +1 -0
- package/dist/2-core/ds-header.js +66 -0
- package/dist/2-core/ds-home.d.ts +26 -0
- package/dist/2-core/ds-home.d.ts.map +1 -0
- package/dist/2-core/ds-home.js +148 -0
- package/dist/2-core/ds-icon.d.ts +28 -0
- package/dist/2-core/ds-icon.d.ts.map +1 -0
- package/dist/2-core/ds-icon.js +297 -0
- package/dist/2-core/ds-link.d.ts +35 -0
- package/dist/2-core/ds-link.d.ts.map +1 -0
- package/dist/2-core/ds-link.js +85 -0
- package/dist/2-core/ds-markdown.d.ts +7 -0
- package/dist/2-core/ds-markdown.d.ts.map +1 -0
- package/dist/2-core/ds-markdown.js +240 -0
- package/dist/2-core/ds-price.d.ts +46 -0
- package/dist/2-core/ds-price.d.ts.map +1 -0
- package/dist/2-core/ds-price.js +72 -0
- package/dist/2-core/ds-squarecircle.d.ts +50 -0
- package/dist/2-core/ds-squarecircle.d.ts.map +1 -0
- package/dist/2-core/ds-squarecircle.js +133 -0
- package/dist/2-core/ds-title.d.ts +50 -0
- package/dist/2-core/ds-title.d.ts.map +1 -0
- package/dist/2-core/ds-title.js +103 -0
- package/dist/2-core/ds-tooltip.d.ts +39 -0
- package/dist/2-core/ds-tooltip.d.ts.map +1 -0
- package/dist/2-core/ds-tooltip.js +145 -0
- package/dist/2-core/ds-viewtoggle.d.ts +27 -0
- package/dist/2-core/ds-viewtoggle.d.ts.map +1 -0
- package/dist/2-core/ds-viewtoggle.js +49 -0
- package/dist/2-core/ds-year.d.ts +16 -0
- package/dist/2-core/ds-year.d.ts.map +1 -0
- package/dist/2-core/ds-year.js +21 -0
- package/dist/3-unit/ds-doublenav.d.ts +51 -0
- package/dist/3-unit/ds-doublenav.d.ts.map +1 -0
- package/dist/3-unit/ds-doublenav.js +88 -0
- package/dist/3-unit/ds-list.d.ts +11 -0
- package/dist/3-unit/ds-list.d.ts.map +1 -0
- package/dist/3-unit/ds-list.js +15 -0
- package/dist/3-unit/ds-panel.d.ts +11 -0
- package/dist/3-unit/ds-panel.d.ts.map +1 -0
- package/dist/3-unit/ds-panel.js +16 -0
- package/dist/3-unit/ds-row.d.ts +25 -0
- package/dist/3-unit/ds-row.d.ts.map +1 -0
- package/dist/3-unit/ds-row.js +32 -0
- package/dist/3-unit/ds-singlenav.d.ts +32 -0
- package/dist/3-unit/ds-singlenav.d.ts.map +1 -0
- package/dist/3-unit/ds-singlenav.js +62 -0
- package/dist/ds-one.bundle.js +63 -63
- package/dist/ds-one.bundle.js.map +2 -2
- package/dist/ds-one.bundle.min.js +27 -27
- package/dist/ds-one.bundle.min.js.map +2 -2
- package/dist/index.d.ts +20 -20
- package/dist/index.js +20 -20
- package/package.json +2 -2
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { LitElement, html, css } from "lit";
|
|
2
|
+
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
3
|
+
export class Icon extends LitElement {
|
|
4
|
+
get type() {
|
|
5
|
+
return this._type;
|
|
6
|
+
}
|
|
7
|
+
set type(val) {
|
|
8
|
+
const oldVal = this._type;
|
|
9
|
+
this._type = val;
|
|
10
|
+
this.requestUpdate("type", oldVal);
|
|
11
|
+
}
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
this._type = "";
|
|
15
|
+
this.size = "1em";
|
|
16
|
+
this.color = "currentColor";
|
|
17
|
+
this.background = "transparent";
|
|
18
|
+
console.log("Icon constructor", this._type);
|
|
19
|
+
}
|
|
20
|
+
connectedCallback() {
|
|
21
|
+
super.connectedCallback();
|
|
22
|
+
console.log("Icon connected", this._type);
|
|
23
|
+
}
|
|
24
|
+
renderIcon() {
|
|
25
|
+
console.log("renderIcon called with type:", this._type);
|
|
26
|
+
if (!this._type || this._type === "") {
|
|
27
|
+
console.log("No type specified, rendering default slot");
|
|
28
|
+
return html `<div class="icon-container"><slot></slot></div>`;
|
|
29
|
+
}
|
|
30
|
+
// First, try to render an SVG whose file name matches `type`
|
|
31
|
+
const svgFromSet = Icon.iconNameToSvgMap[this._type.toLowerCase()];
|
|
32
|
+
if (svgFromSet) {
|
|
33
|
+
return html `<div class="icon-container">${unsafeHTML(svgFromSet)}</div>`;
|
|
34
|
+
}
|
|
35
|
+
switch (this._type.toLowerCase()) {
|
|
36
|
+
case "close":
|
|
37
|
+
console.log("Rendering close icon");
|
|
38
|
+
return html `
|
|
39
|
+
<div class="icon-container">
|
|
40
|
+
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
41
|
+
<path
|
|
42
|
+
d="M18.3 5.71a.996.996 0 00-1.41 0L12 10.59 7.11 5.7A.996.996 0 105.7 7.11L10.59 12 5.7 16.89a.996.996 0 101.41 1.41L12 13.41l4.89 4.89a.996.996 0 101.41-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4z"
|
|
43
|
+
/>
|
|
44
|
+
</svg>
|
|
45
|
+
</div>
|
|
46
|
+
`;
|
|
47
|
+
case "page":
|
|
48
|
+
console.log("Rendering page icon");
|
|
49
|
+
return html `
|
|
50
|
+
<div class="icon-container">
|
|
51
|
+
<svg viewBox="0 0 17 17" xmlns="http://www.w3.org/2000/svg">
|
|
52
|
+
<rect
|
|
53
|
+
width="16"
|
|
54
|
+
height="16"
|
|
55
|
+
transform="translate(0.799988 0.678772)"
|
|
56
|
+
fill="var(--accent-color)"
|
|
57
|
+
/>
|
|
58
|
+
<path
|
|
59
|
+
d="M13.7956 2.38385V14.9737H3.80438V2.38385H13.7956ZM4.7243 14.0538H12.8757V3.30377H4.7243V14.0538ZM8.67841 8.53619V9.45612H5.92938V8.53619H8.67841ZM10.8259 6.60455V7.52448H5.92938V6.60455H10.8259ZM10.8259 4.67194V5.59283H5.92938V4.67194H10.8259Z"
|
|
60
|
+
fill="#2A2A2A"
|
|
61
|
+
/>
|
|
62
|
+
</svg>
|
|
63
|
+
</div>
|
|
64
|
+
`;
|
|
65
|
+
case "note":
|
|
66
|
+
console.log("Rendering note icon");
|
|
67
|
+
return html `
|
|
68
|
+
<div class="icon-container">
|
|
69
|
+
<svg viewBox="0 0 17 17" xmlns="http://www.w3.org/2000/svg">
|
|
70
|
+
<rect
|
|
71
|
+
width="16"
|
|
72
|
+
height="16"
|
|
73
|
+
transform="translate(0.799988 0.678772)"
|
|
74
|
+
fill="var(--accent-color, #CCFF4D)"
|
|
75
|
+
/>
|
|
76
|
+
<path
|
|
77
|
+
d="M14.7653 3.99225V13.3653H2.83466V3.99225H14.7653ZM3.83466 12.3653H13.7653V4.99225H3.83466V12.3653Z"
|
|
78
|
+
fill="#2A2A2A"
|
|
79
|
+
/>
|
|
80
|
+
<path
|
|
81
|
+
d="M8.8064 7.75881V8.67873H4.51343V7.75881H8.8064ZM10.7527 5.75881V6.67873H4.51343V5.75881H10.7527Z"
|
|
82
|
+
fill="#2A2A2A"
|
|
83
|
+
/>
|
|
84
|
+
</svg>
|
|
85
|
+
</div>
|
|
86
|
+
`;
|
|
87
|
+
case "default":
|
|
88
|
+
console.log("Rendering default icon");
|
|
89
|
+
return html `
|
|
90
|
+
<div class="icon-container">
|
|
91
|
+
<svg
|
|
92
|
+
width="17"
|
|
93
|
+
height="16"
|
|
94
|
+
viewBox="0 0 17 16"
|
|
95
|
+
fill="none"
|
|
96
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
97
|
+
>
|
|
98
|
+
<rect
|
|
99
|
+
width="16"
|
|
100
|
+
height="16"
|
|
101
|
+
transform="translate(0.799988)"
|
|
102
|
+
fill="var(--accent-color, #CCFF4D)"
|
|
103
|
+
/>
|
|
104
|
+
<path
|
|
105
|
+
d="M9.95899 15V6.81H7.05999V5.77H14.093V6.81H11.194V15H9.95899Z"
|
|
106
|
+
fill="#2A2A2A"
|
|
107
|
+
/>
|
|
108
|
+
<path
|
|
109
|
+
fill-rule="evenodd"
|
|
110
|
+
clip-rule="evenodd"
|
|
111
|
+
d="M5.89999 0V5.10001H0.799988V0H5.89999Z"
|
|
112
|
+
fill="#2A2A2A"
|
|
113
|
+
/>
|
|
114
|
+
</svg>
|
|
115
|
+
</div>
|
|
116
|
+
`;
|
|
117
|
+
case "big":
|
|
118
|
+
console.log("Rendering big icon");
|
|
119
|
+
return html `
|
|
120
|
+
<div class="icon-container">
|
|
121
|
+
<svg
|
|
122
|
+
width="17"
|
|
123
|
+
height="16"
|
|
124
|
+
viewBox="0 0 17 16"
|
|
125
|
+
fill="none"
|
|
126
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
127
|
+
>
|
|
128
|
+
<g clip-path="url(#clip0_3141_3351)">
|
|
129
|
+
<rect
|
|
130
|
+
width="16"
|
|
131
|
+
height="16"
|
|
132
|
+
transform="translate(0.799988)"
|
|
133
|
+
fill="var(--accent-color, #CCFF4D)"
|
|
134
|
+
/>
|
|
135
|
+
<path
|
|
136
|
+
d="M13.959 12.615V4.425H11.06V3.385H16.802V4.425H15.194V12.615H13.959Z"
|
|
137
|
+
fill="#2A2A2A"
|
|
138
|
+
/>
|
|
139
|
+
<path
|
|
140
|
+
fill-rule="evenodd"
|
|
141
|
+
clip-rule="evenodd"
|
|
142
|
+
d="M9.79999 3.5V12.5H0.799988V3.5H9.79999Z"
|
|
143
|
+
fill="#2A2A2A"
|
|
144
|
+
/>
|
|
145
|
+
</g>
|
|
146
|
+
<defs>
|
|
147
|
+
<clipPath id="clip0_3141_3351">
|
|
148
|
+
<rect
|
|
149
|
+
width="16"
|
|
150
|
+
height="16"
|
|
151
|
+
fill="white"
|
|
152
|
+
transform="translate(0.799988)"
|
|
153
|
+
/>
|
|
154
|
+
</clipPath>
|
|
155
|
+
</defs>
|
|
156
|
+
</svg>
|
|
157
|
+
</div>
|
|
158
|
+
`;
|
|
159
|
+
case "gallery":
|
|
160
|
+
console.log("Rendering gallery icon");
|
|
161
|
+
return html `
|
|
162
|
+
<div class="icon-container">
|
|
163
|
+
<svg
|
|
164
|
+
width="17"
|
|
165
|
+
height="16"
|
|
166
|
+
viewBox="0 0 17 16"
|
|
167
|
+
fill="none"
|
|
168
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
169
|
+
>
|
|
170
|
+
<g clip-path="url(#clip0_3144_2504)">
|
|
171
|
+
<rect
|
|
172
|
+
width="16"
|
|
173
|
+
height="16"
|
|
174
|
+
transform="translate(0.799988)"
|
|
175
|
+
fill="var(--accent-color, #CCFF4D)"
|
|
176
|
+
/>
|
|
177
|
+
<path
|
|
178
|
+
fill-rule="evenodd"
|
|
179
|
+
clip-rule="evenodd"
|
|
180
|
+
d="M0.799988 16V0H16.8L0.799988 16ZM1.50604 0.769531V1.80957H4.40546V10H5.63983V1.80957H8.53925V0.769531H1.50604Z"
|
|
181
|
+
fill="#2A2A2A"
|
|
182
|
+
/>
|
|
183
|
+
</g>
|
|
184
|
+
<defs>
|
|
185
|
+
<clipPath id="clip0_3144_2504">
|
|
186
|
+
<rect
|
|
187
|
+
width="16"
|
|
188
|
+
height="16"
|
|
189
|
+
fill="white"
|
|
190
|
+
transform="translate(0.799988)"
|
|
191
|
+
/>
|
|
192
|
+
</clipPath>
|
|
193
|
+
</defs>
|
|
194
|
+
</svg>
|
|
195
|
+
</div>
|
|
196
|
+
`;
|
|
197
|
+
case "check":
|
|
198
|
+
console.log("Rendering check icon");
|
|
199
|
+
return html `
|
|
200
|
+
<div class="icon-container">
|
|
201
|
+
<svg
|
|
202
|
+
viewBox="0 0 17 17"
|
|
203
|
+
fill="none"
|
|
204
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
205
|
+
>
|
|
206
|
+
<rect
|
|
207
|
+
width="16"
|
|
208
|
+
height="16"
|
|
209
|
+
transform="translate(0.799988 0.678772)"
|
|
210
|
+
fill="var(--accent-color)"
|
|
211
|
+
/>
|
|
212
|
+
<path
|
|
213
|
+
d="M7.48658 11.8747L13.2431 6.12674L12.5361 5.41788L7.48845 10.4734L5.06409 8.04082L4.35706 8.73597L7.48658 11.8747Z"
|
|
214
|
+
fill="#2A2A2A"
|
|
215
|
+
/>
|
|
216
|
+
</svg>
|
|
217
|
+
</div>
|
|
218
|
+
`;
|
|
219
|
+
default:
|
|
220
|
+
console.log(`Unknown icon type: ${this._type}, rendering default slot`);
|
|
221
|
+
return html `<div class="icon-container"><slot></slot></div>`;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
updated(changedProperties) {
|
|
225
|
+
console.log("Icon updated", changedProperties);
|
|
226
|
+
this.style.setProperty("--icon-size", this.size);
|
|
227
|
+
this.style.setProperty("--icon-color", this.color);
|
|
228
|
+
this.style.setProperty("--icon-background", this.background);
|
|
229
|
+
}
|
|
230
|
+
render() {
|
|
231
|
+
console.log("Icon render", this._type);
|
|
232
|
+
return this.renderIcon();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
Icon.properties = {
|
|
236
|
+
type: { type: String, reflect: true },
|
|
237
|
+
};
|
|
238
|
+
Icon.styles = css `
|
|
239
|
+
:host {
|
|
240
|
+
display: inline-flex;
|
|
241
|
+
justify-content: center;
|
|
242
|
+
align-items: center;
|
|
243
|
+
width: calc(16px * var(--scaling-factor));
|
|
244
|
+
height: calc(16px * var(--scaling-factor));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
svg {
|
|
248
|
+
width: 100%;
|
|
249
|
+
height: 100%;
|
|
250
|
+
fill: var(--icon-color, currentColor);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
path {
|
|
254
|
+
fill: var(--icon-color, currentColor);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.icon-container {
|
|
258
|
+
display: flex;
|
|
259
|
+
justify-content: center;
|
|
260
|
+
align-items: center;
|
|
261
|
+
width: calc(16px * var(--scaling-factor));
|
|
262
|
+
height: calc(16px * var(--scaling-factor));
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/* Notes style color variable for future implementation */
|
|
266
|
+
:host {
|
|
267
|
+
--notes-style-color: #ffb6b9;
|
|
268
|
+
}
|
|
269
|
+
`;
|
|
270
|
+
// Load all SVGs from `x Icon/` as raw strings at build time (Vite)
|
|
271
|
+
// The keys will be the file base names (without extension), lowercased.
|
|
272
|
+
Icon.iconNameToSvgMap = (() => {
|
|
273
|
+
try {
|
|
274
|
+
// Note: folder name contains a space, keep it exact.
|
|
275
|
+
const modules = import.meta.glob("../x Icon/*.svg", {
|
|
276
|
+
as: "raw",
|
|
277
|
+
eager: true,
|
|
278
|
+
});
|
|
279
|
+
const map = {};
|
|
280
|
+
for (const [path, content] of Object.entries(modules)) {
|
|
281
|
+
const fileName = path.split("/").pop() ?? "";
|
|
282
|
+
const baseName = fileName.replace(/\.svg$/i, "").toLowerCase();
|
|
283
|
+
if (baseName) {
|
|
284
|
+
map[baseName] = content;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return map;
|
|
288
|
+
}
|
|
289
|
+
catch (err) {
|
|
290
|
+
// If not running under Vite (or during tests), gracefully degrade.
|
|
291
|
+
console.warn("Icon: failed to glob SVGs from x Icon/; falling back only to inline switch icons.", err);
|
|
292
|
+
return {};
|
|
293
|
+
}
|
|
294
|
+
})();
|
|
295
|
+
customElements.define("ds-icon", Icon);
|
|
296
|
+
// Add this line to help with debugging
|
|
297
|
+
console.log("Icon component registered with custom elements registry");
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
/**
|
|
3
|
+
* A component for creating localized links that open in new tabs
|
|
4
|
+
*
|
|
5
|
+
* @element ds-link
|
|
6
|
+
* @prop {string} href - The URL to link to
|
|
7
|
+
*/
|
|
8
|
+
export declare class Link extends LitElement {
|
|
9
|
+
static get properties(): {
|
|
10
|
+
href: {
|
|
11
|
+
type: StringConstructor;
|
|
12
|
+
reflect: boolean;
|
|
13
|
+
};
|
|
14
|
+
_text: {
|
|
15
|
+
type: StringConstructor;
|
|
16
|
+
state: boolean;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
href: string;
|
|
20
|
+
_text: string;
|
|
21
|
+
private boundHandlers;
|
|
22
|
+
constructor();
|
|
23
|
+
static styles: import("lit").CSSResult;
|
|
24
|
+
connectedCallback(): void;
|
|
25
|
+
disconnectedCallback(): void;
|
|
26
|
+
updated(changedProperties: Map<string, unknown>): void;
|
|
27
|
+
_loadText(): void;
|
|
28
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
29
|
+
}
|
|
30
|
+
declare global {
|
|
31
|
+
interface HTMLElementTagNameMap {
|
|
32
|
+
"ds-link": Link;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=ds-link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ds-link.d.ts","sourceRoot":"","sources":["../../DS1/2-core/ds-link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAG5C;;;;;GAKG;AACH,qBAAa,IAAK,SAAQ,UAAU;IAClC,MAAM,KAAK,UAAU;;;;;;;;;MAKpB;IAEO,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IAEtB,OAAO,CAAC,aAAa,CAAqC;;IAe1D,MAAM,CAAC,MAAM,0BAeX;IAEF,iBAAiB;IAiBjB,oBAAoB;IAYpB,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAQ/C,SAAS;IAWT,MAAM;CAYP;AAID,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,SAAS,EAAE,IAAI,CAAC;KACjB;CACF"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { LitElement, html, css } from "lit";
|
|
2
|
+
import { getText } from "../utils/language";
|
|
3
|
+
/**
|
|
4
|
+
* A component for creating localized links that open in new tabs
|
|
5
|
+
*
|
|
6
|
+
* @element ds-link
|
|
7
|
+
* @prop {string} href - The URL to link to
|
|
8
|
+
*/
|
|
9
|
+
export class Link extends LitElement {
|
|
10
|
+
static get properties() {
|
|
11
|
+
return {
|
|
12
|
+
href: { type: String, reflect: true },
|
|
13
|
+
_text: { type: String, state: true },
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
this.href = "";
|
|
19
|
+
this._text = "";
|
|
20
|
+
// Create bound event handlers for proper cleanup
|
|
21
|
+
this.boundHandlers = {
|
|
22
|
+
languageChanged: (() => {
|
|
23
|
+
this._loadText();
|
|
24
|
+
}),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
connectedCallback() {
|
|
28
|
+
super.connectedCallback();
|
|
29
|
+
this._loadText();
|
|
30
|
+
// Listen for language changes
|
|
31
|
+
window.addEventListener("language-changed", this.boundHandlers.languageChanged);
|
|
32
|
+
// Also listen for translations loaded event
|
|
33
|
+
window.addEventListener("translations-loaded", this.boundHandlers.languageChanged);
|
|
34
|
+
}
|
|
35
|
+
disconnectedCallback() {
|
|
36
|
+
super.disconnectedCallback();
|
|
37
|
+
window.removeEventListener("language-changed", this.boundHandlers.languageChanged);
|
|
38
|
+
window.removeEventListener("translations-loaded", this.boundHandlers.languageChanged);
|
|
39
|
+
}
|
|
40
|
+
updated(changedProperties) {
|
|
41
|
+
super.updated(changedProperties);
|
|
42
|
+
if (changedProperties.has("href")) {
|
|
43
|
+
this._loadText();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
_loadText() {
|
|
47
|
+
try {
|
|
48
|
+
const text = getText("link");
|
|
49
|
+
this._text = text || "Link";
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error("Error loading text for key 'link':", error);
|
|
53
|
+
this._text = "Link";
|
|
54
|
+
}
|
|
55
|
+
this.requestUpdate();
|
|
56
|
+
}
|
|
57
|
+
render() {
|
|
58
|
+
if (!this.href) {
|
|
59
|
+
return html `<span>${this._text}</span>`;
|
|
60
|
+
}
|
|
61
|
+
return html `
|
|
62
|
+
<a href="${this.href}" target="_blank" rel="noopener noreferrer">
|
|
63
|
+
${this._text}
|
|
64
|
+
<ds-icon type="open"></ds-icon>
|
|
65
|
+
</a>
|
|
66
|
+
`;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
Link.styles = css `
|
|
70
|
+
:host {
|
|
71
|
+
display: inline;
|
|
72
|
+
font-family: var(--typeface);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
a {
|
|
76
|
+
color: inherit;
|
|
77
|
+
text-decoration: none;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
ds-icon {
|
|
81
|
+
display: inline-block;
|
|
82
|
+
vertical-align: middle;
|
|
83
|
+
}
|
|
84
|
+
`;
|
|
85
|
+
customElements.define("ds-link", Link);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ds-markdown.d.ts","sourceRoot":"","sources":["../../DS1/2-core/ds-markdown.ts"],"names":[],"mappings":"AAsPA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,GAAG,CAAC;KACpB;CACF"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { LitElement, html, css } from "lit";
|
|
3
|
+
customElements.define("ds-markdown", (_a = class Markdown extends LitElement {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.content = "";
|
|
7
|
+
this.title = "";
|
|
8
|
+
this.language = "";
|
|
9
|
+
this.guideId = "";
|
|
10
|
+
}
|
|
11
|
+
render() {
|
|
12
|
+
if (!this.content) {
|
|
13
|
+
return html `<div class="markdown-container">
|
|
14
|
+
<p>No content available</p>
|
|
15
|
+
</div>`;
|
|
16
|
+
}
|
|
17
|
+
return html `
|
|
18
|
+
<div class="markdown-container">
|
|
19
|
+
${this.title
|
|
20
|
+
? html `
|
|
21
|
+
<div class="markdown-header">
|
|
22
|
+
<h1 class="markdown-title">${this.title}</h1>
|
|
23
|
+
<div class="markdown-meta">
|
|
24
|
+
${this.language
|
|
25
|
+
? html `
|
|
26
|
+
<span class="markdown-category"
|
|
27
|
+
>${this.language}</span
|
|
28
|
+
>
|
|
29
|
+
`
|
|
30
|
+
: ""}
|
|
31
|
+
${this.guideId
|
|
32
|
+
? html `
|
|
33
|
+
<span class="markdown-tag"
|
|
34
|
+
>Guide ID: ${this.guideId}</span
|
|
35
|
+
>
|
|
36
|
+
`
|
|
37
|
+
: ""}
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
`
|
|
41
|
+
: ""}
|
|
42
|
+
<div class="markdown-content">
|
|
43
|
+
${this.renderMarkdown(this.content)}
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
renderMarkdown(markdown) {
|
|
49
|
+
// Simple markdown rendering - you might want to use a proper markdown parser
|
|
50
|
+
let htmlContent = markdown
|
|
51
|
+
// Headers
|
|
52
|
+
.replace(/^### (.*$)/gim, "<h3>$1</h3>")
|
|
53
|
+
.replace(/^## (.*$)/gim, "<h2>$1</h2>")
|
|
54
|
+
.replace(/^# (.*$)/gim, "<h1>$1</h1>")
|
|
55
|
+
// Bold
|
|
56
|
+
.replace(/\*\*(.*?)\*\*/g, "<strong>$1</strong>")
|
|
57
|
+
// Italic
|
|
58
|
+
.replace(/\*(.*?)\*/g, "<em>$1</em>")
|
|
59
|
+
// Code blocks
|
|
60
|
+
.replace(/```([\s\S]*?)```/g, "<pre><code>$1</code></pre>")
|
|
61
|
+
// Inline code
|
|
62
|
+
.replace(/`(.*?)`/g, "<code>$1</code>")
|
|
63
|
+
// Links
|
|
64
|
+
.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2">$1</a>')
|
|
65
|
+
// Line breaks
|
|
66
|
+
.replace(/\n/g, "<br>");
|
|
67
|
+
return html `${htmlContent}`;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
_a.properties = {
|
|
71
|
+
content: { type: String },
|
|
72
|
+
title: { type: String },
|
|
73
|
+
language: { type: String },
|
|
74
|
+
guideId: { type: String },
|
|
75
|
+
},
|
|
76
|
+
_a.styles = css `
|
|
77
|
+
:host {
|
|
78
|
+
display: block;
|
|
79
|
+
font-family:
|
|
80
|
+
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
|
|
81
|
+
Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
|
|
82
|
+
line-height: 1.6;
|
|
83
|
+
color: #333;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.markdown-container {
|
|
87
|
+
max-width: 800px;
|
|
88
|
+
margin: 0 auto;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.markdown-header {
|
|
92
|
+
padding-bottom: 1rem;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.markdown-title {
|
|
96
|
+
font-weight: 700;
|
|
97
|
+
margin: 0 0 0.5rem 0;
|
|
98
|
+
color: #2c3e50;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.markdown-meta {
|
|
102
|
+
display: flex;
|
|
103
|
+
gap: 1rem;
|
|
104
|
+
font-size: 0.9rem;
|
|
105
|
+
color: #666;
|
|
106
|
+
flex-wrap: wrap;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.markdown-category {
|
|
110
|
+
background: #e3f2fd;
|
|
111
|
+
color: #1976d2;
|
|
112
|
+
padding: 0.25rem 0.5rem;
|
|
113
|
+
border-radius: 4px;
|
|
114
|
+
font-weight: 500;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.markdown-tags {
|
|
118
|
+
display: flex;
|
|
119
|
+
gap: 0.5rem;
|
|
120
|
+
flex-wrap: wrap;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.markdown-tag {
|
|
124
|
+
background: #f5f5f5;
|
|
125
|
+
color: #666;
|
|
126
|
+
padding: 0.25rem 0.5rem;
|
|
127
|
+
border-radius: 4px;
|
|
128
|
+
font-size: 0.8rem;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.markdown-content {
|
|
132
|
+
font-size: 1rem;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.markdown-content h1,
|
|
136
|
+
.markdown-content h2,
|
|
137
|
+
.markdown-content h3,
|
|
138
|
+
.markdown-content h4,
|
|
139
|
+
.markdown-content h5,
|
|
140
|
+
.markdown-content h6 {
|
|
141
|
+
margin-bottom: 1rem;
|
|
142
|
+
font-weight: 600;
|
|
143
|
+
line-height: 1.3;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.markdown-content h1 {
|
|
147
|
+
font-size: 1.8rem;
|
|
148
|
+
color: #2c3e50;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.markdown-content h2 {
|
|
152
|
+
font-size: 1.5rem;
|
|
153
|
+
color: #34495e;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.markdown-content h3 {
|
|
157
|
+
font-size: 1.3rem;
|
|
158
|
+
color: #2c3e50;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.markdown-content h4 {
|
|
162
|
+
font-size: 1.1rem;
|
|
163
|
+
color: #34495e;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.markdown-content p {
|
|
167
|
+
margin-bottom: 1rem;
|
|
168
|
+
line-height: 1.7;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.markdown-content ul,
|
|
172
|
+
.markdown-content ol {
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.markdown-content li {
|
|
176
|
+
margin-bottom: 0.5rem;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.markdown-content blockquote {
|
|
180
|
+
border-left: 4px solid #3498db;
|
|
181
|
+
padding-left: 1rem;
|
|
182
|
+
margin: 1.5rem 0;
|
|
183
|
+
font-style: italic;
|
|
184
|
+
color: #555;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.markdown-content code {
|
|
188
|
+
background: #f8f9fa;
|
|
189
|
+
padding: 0.2rem 0.4rem;
|
|
190
|
+
border-radius: 3px;
|
|
191
|
+
font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
|
|
192
|
+
font-size: 0.9em;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.markdown-content pre {
|
|
196
|
+
background: #f8f9fa;
|
|
197
|
+
padding: 1rem;
|
|
198
|
+
border-radius: 5px;
|
|
199
|
+
overflow-x: auto;
|
|
200
|
+
margin: 1.5rem 0;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.markdown-content pre code {
|
|
204
|
+
background: none;
|
|
205
|
+
padding: 0;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.markdown-content table {
|
|
209
|
+
width: 100%;
|
|
210
|
+
border-collapse: collapse;
|
|
211
|
+
margin: 1.5rem 0;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.markdown-content th,
|
|
215
|
+
.markdown-content td {
|
|
216
|
+
padding: 0.75rem;
|
|
217
|
+
text-align: left;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.markdown-content th {
|
|
221
|
+
background: #f8f9fa;
|
|
222
|
+
font-weight: 600;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.markdown-content a {
|
|
226
|
+
color: #3498db;
|
|
227
|
+
text-decoration: none;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.markdown-content a:hover {
|
|
231
|
+
text-decoration: underline;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.markdown-content img {
|
|
235
|
+
max-width: 100%;
|
|
236
|
+
height: auto;
|
|
237
|
+
margin: 1rem 0;
|
|
238
|
+
}
|
|
239
|
+
`,
|
|
240
|
+
_a));
|