@vettvangur/design-system 2.0.13 → 2.0.15
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/index.js +83 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2128,10 +2128,13 @@ function renderColorsCshtml(colors, projectName) {
|
|
|
2128
2128
|
const items = Object.entries(group || {}).filter(([, token]) => token?.type === 'COLOR').map(([tokenKey]) => {
|
|
2129
2129
|
const colorTitle = titleizeColor(categoryKey, tokenKey);
|
|
2130
2130
|
|
|
2131
|
-
//
|
|
2131
|
+
// CSS variable name
|
|
2132
2132
|
const colorKey = `color-${categoryKey}-${tokenKey}`;
|
|
2133
|
+
|
|
2134
|
+
// Tailwind utility name (maps to --color-*)
|
|
2135
|
+
const swatchKey = `${categoryKey}-${tokenKey}`;
|
|
2133
2136
|
return ` <div class="ds-color">
|
|
2134
|
-
<div class="ds-color__swatch bg-${
|
|
2137
|
+
<div class="ds-color__swatch bg-${swatchKey}"></div>
|
|
2135
2138
|
<div class="ds-color__meta">
|
|
2136
2139
|
<div class="ds-color__name">${colorTitle}</div>
|
|
2137
2140
|
<div class="ds-color__var">--${colorKey}</div>
|
|
@@ -2179,8 +2182,8 @@ async function generateColors(colors, config, outpath, projectName) {
|
|
|
2179
2182
|
message('finished generating colors');
|
|
2180
2183
|
}
|
|
2181
2184
|
|
|
2182
|
-
/* ---------------------------------------------
|
|
2183
|
-
* helpers
|
|
2185
|
+
/* ---------------------------------------------
|
|
2186
|
+
* helpers
|
|
2184
2187
|
* ------------------------------------------- */
|
|
2185
2188
|
|
|
2186
2189
|
function titleCase(str) {
|
|
@@ -2188,6 +2191,7 @@ function titleCase(str) {
|
|
|
2188
2191
|
}
|
|
2189
2192
|
function extractKey(prefix, key) {
|
|
2190
2193
|
// font-size-headline-1 -> headline-1
|
|
2194
|
+
|
|
2191
2195
|
return key.replace(prefix, '');
|
|
2192
2196
|
}
|
|
2193
2197
|
function getValue(values, mode) {
|
|
@@ -2197,8 +2201,8 @@ function isHeadline(id) {
|
|
|
2197
2201
|
return id.startsWith('headline-');
|
|
2198
2202
|
}
|
|
2199
2203
|
|
|
2200
|
-
/* ---------------------------------------------
|
|
2201
|
-
* normalize typography into semantic entries
|
|
2204
|
+
/* ---------------------------------------------
|
|
2205
|
+
* normalize typography into semantic entries
|
|
2202
2206
|
* ------------------------------------------- */
|
|
2203
2207
|
|
|
2204
2208
|
function buildEntries({
|
|
@@ -2228,8 +2232,8 @@ function buildEntries({
|
|
|
2228
2232
|
return map;
|
|
2229
2233
|
}
|
|
2230
2234
|
|
|
2231
|
-
/* ---------------------------------------------
|
|
2232
|
-
* category resolution
|
|
2235
|
+
/* ---------------------------------------------
|
|
2236
|
+
* category resolution
|
|
2233
2237
|
* ------------------------------------------- */
|
|
2234
2238
|
|
|
2235
2239
|
function resolveCategory(id) {
|
|
@@ -2242,28 +2246,37 @@ function resolveCategory(id) {
|
|
|
2242
2246
|
return null;
|
|
2243
2247
|
}
|
|
2244
2248
|
|
|
2245
|
-
/* ---------------------------------------------
|
|
2246
|
-
* preview render
|
|
2249
|
+
/* ---------------------------------------------
|
|
2250
|
+
* preview render
|
|
2247
2251
|
* ------------------------------------------- */
|
|
2248
2252
|
|
|
2249
2253
|
function renderPreview(id, title) {
|
|
2250
2254
|
if (isHeadline(id)) {
|
|
2251
2255
|
return `
|
|
2256
|
+
|
|
2252
2257
|
<vv-headline
|
|
2258
|
+
|
|
2253
2259
|
identifier="ds-preview-headline"
|
|
2260
|
+
|
|
2254
2261
|
text="${title}"
|
|
2262
|
+
|
|
2255
2263
|
size="@HeadlineSize.H2"
|
|
2264
|
+
|
|
2256
2265
|
modifier="${id}"
|
|
2266
|
+
|
|
2257
2267
|
/>`;
|
|
2258
2268
|
}
|
|
2259
2269
|
return `
|
|
2270
|
+
|
|
2260
2271
|
<p class="${id}">
|
|
2272
|
+
|
|
2261
2273
|
${title}
|
|
2274
|
+
|
|
2262
2275
|
</p>`;
|
|
2263
2276
|
}
|
|
2264
2277
|
|
|
2265
|
-
/* ---------------------------------------------
|
|
2266
|
-
* entry render
|
|
2278
|
+
/* ---------------------------------------------
|
|
2279
|
+
* entry render
|
|
2267
2280
|
* ------------------------------------------- */
|
|
2268
2281
|
|
|
2269
2282
|
function renderEntry(id, entry) {
|
|
@@ -2274,6 +2287,23 @@ function renderEntry(id, entry) {
|
|
|
2274
2287
|
const mSize = getValue(entry.size, 'Mobile');
|
|
2275
2288
|
const mLine = getValue(entry.lineHeight, 'Mobile');
|
|
2276
2289
|
const mFamily = getValue(entry.family, 'Mobile');
|
|
2290
|
+
const hasDesktopVariant = dSize != null && dLine != null && dFamily != null && (dSize !== mSize || dLine !== mLine || dFamily !== mFamily);
|
|
2291
|
+
const defaultSize = hasDesktopVariant ? dSize : mSize;
|
|
2292
|
+
const defaultLine = hasDesktopVariant ? dLine : mLine;
|
|
2293
|
+
const defaultFamily = hasDesktopVariant ? dFamily : mFamily;
|
|
2294
|
+
const renderMeta = (family, size, line) => {
|
|
2295
|
+
const lines = [];
|
|
2296
|
+
if (family != null) {
|
|
2297
|
+
lines.push(`<div><strong>Font</strong> ${family}</div>`);
|
|
2298
|
+
}
|
|
2299
|
+
if (size != null) {
|
|
2300
|
+
lines.push(`<div><strong>Size</strong> ${size}px</div>`);
|
|
2301
|
+
}
|
|
2302
|
+
if (line != null) {
|
|
2303
|
+
lines.push(`<div><strong>Line height</strong> ${line}px</div>`);
|
|
2304
|
+
}
|
|
2305
|
+
return lines.join('\n ');
|
|
2306
|
+
};
|
|
2277
2307
|
return `
|
|
2278
2308
|
<div class="ds-type-card">
|
|
2279
2309
|
<div class="ds-type-preview">
|
|
@@ -2281,42 +2311,48 @@ ${renderPreview(id, title)}
|
|
|
2281
2311
|
</div>
|
|
2282
2312
|
|
|
2283
2313
|
<div class="ds-type-meta">
|
|
2284
|
-
|
|
2285
|
-
<div><strong>Size</strong> ${dSize}px</div>
|
|
2286
|
-
<div><strong>Line height</strong> ${dLine}px</div>
|
|
2314
|
+
${renderMeta(defaultFamily, defaultSize, defaultLine)}
|
|
2287
2315
|
</div>
|
|
2288
2316
|
|
|
2317
|
+
${hasDesktopVariant ? `
|
|
2289
2318
|
<div class="ds-type-mobile">
|
|
2290
2319
|
<div class="ds-type-preview">
|
|
2291
|
-
${renderPreview(id, title)}
|
|
2320
|
+
${renderPreview(id, title)}
|
|
2292
2321
|
</div>
|
|
2293
2322
|
|
|
2294
2323
|
<div class="ds-type-meta">
|
|
2295
|
-
<div
|
|
2296
|
-
|
|
2297
|
-
|
|
2324
|
+
<div class="ds-type-meta__info">
|
|
2325
|
+
${renderMeta(mFamily, mSize, mLine)}
|
|
2326
|
+
</div>
|
|
2298
2327
|
</div>
|
|
2299
|
-
</div
|
|
2328
|
+
</div>` : ''}
|
|
2300
2329
|
</div>`;
|
|
2301
2330
|
}
|
|
2302
2331
|
|
|
2303
|
-
/* ---------------------------------------------
|
|
2304
|
-
* category render
|
|
2332
|
+
/* ---------------------------------------------
|
|
2333
|
+
* category render
|
|
2305
2334
|
* ------------------------------------------- */
|
|
2306
2335
|
|
|
2307
2336
|
function renderCategory(title, entries) {
|
|
2308
2337
|
return `
|
|
2338
|
+
|
|
2309
2339
|
<section class="ds-type-category">
|
|
2340
|
+
|
|
2310
2341
|
<vv-headline text="${title}" size="@HeadlineSize.H2" modifier="headline-2" />
|
|
2311
2342
|
|
|
2343
|
+
|
|
2344
|
+
|
|
2312
2345
|
<div class="ds-type-grid">
|
|
2346
|
+
|
|
2313
2347
|
${entries.join('\n')}
|
|
2348
|
+
|
|
2314
2349
|
</div>
|
|
2350
|
+
|
|
2315
2351
|
</section>`;
|
|
2316
2352
|
}
|
|
2317
2353
|
|
|
2318
|
-
/* ---------------------------------------------
|
|
2319
|
-
* main render
|
|
2354
|
+
/* ---------------------------------------------
|
|
2355
|
+
* main render
|
|
2320
2356
|
* ------------------------------------------- */
|
|
2321
2357
|
|
|
2322
2358
|
function renderTypographyCshtml(data, projectName) {
|
|
@@ -2333,31 +2369,52 @@ function renderTypographyCshtml(data, projectName) {
|
|
|
2333
2369
|
const sections = Object.entries(categories).map(([title, items]) => renderCategory(title, items)).join('\n');
|
|
2334
2370
|
|
|
2335
2371
|
// @{
|
|
2372
|
+
|
|
2336
2373
|
// Layout = "Master.cshtml";
|
|
2374
|
+
|
|
2337
2375
|
// }
|
|
2376
|
+
|
|
2338
2377
|
return `@* AUTO-GENERATED - DO NOT EDIT BY HAND *@
|
|
2339
2378
|
|
|
2379
|
+
|
|
2380
|
+
|
|
2340
2381
|
<section class="ds-typography">
|
|
2382
|
+
|
|
2341
2383
|
<div class="ds__left">
|
|
2384
|
+
|
|
2342
2385
|
<partial name="${projectName}/DesignSystem/DSNavigation" />
|
|
2386
|
+
|
|
2343
2387
|
</div>
|
|
2344
2388
|
|
|
2389
|
+
|
|
2390
|
+
|
|
2345
2391
|
<div class="ds__right">
|
|
2392
|
+
|
|
2346
2393
|
<vv-headline
|
|
2394
|
+
|
|
2347
2395
|
identifier="ds-title"
|
|
2396
|
+
|
|
2348
2397
|
modifier="headline-1"
|
|
2398
|
+
|
|
2349
2399
|
size="@HeadlineSize.H2"
|
|
2400
|
+
|
|
2350
2401
|
text="Typography"
|
|
2402
|
+
|
|
2351
2403
|
/>
|
|
2352
2404
|
|
|
2405
|
+
|
|
2406
|
+
|
|
2353
2407
|
${sections}
|
|
2354
2408
|
|
|
2409
|
+
|
|
2410
|
+
|
|
2355
2411
|
</div>
|
|
2412
|
+
|
|
2356
2413
|
</section>`;
|
|
2357
2414
|
}
|
|
2358
2415
|
|
|
2359
|
-
/* ---------------------------------------------
|
|
2360
|
-
* public API
|
|
2416
|
+
/* ---------------------------------------------
|
|
2417
|
+
* public API
|
|
2361
2418
|
* ------------------------------------------- */
|
|
2362
2419
|
|
|
2363
2420
|
async function generateTypography(typography, config, outpath, projectName) {
|