@vettvangur/design-system 2.0.12 → 2.0.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.
Files changed (2) hide show
  1. package/dist/index.js +54 -34
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2062,7 +2062,7 @@ function renderButtonsCshtml(buttons, projectName) {
2062
2062
  const key = b.key;
2063
2063
  const title = titleizeButton(key);
2064
2064
  return ` <div class="ds-button-wrap">
2065
- <vv-headline text="${title}" size="2" modifier="headline-2" />
2065
+ <vv-headline text="${title}" size="@HeadlineSize.H2" modifier="headline-2" />
2066
2066
  <vv-button
2067
2067
  identifier="ds__button"
2068
2068
  modifier="${key}"
@@ -2091,7 +2091,7 @@ function renderButtonsCshtml(buttons, projectName) {
2091
2091
  <vv-headline
2092
2092
  identifier="ds-title"
2093
2093
  modifier="headline-2"
2094
- size="2"
2094
+ size="@HeadlineSize.H2"
2095
2095
  text="Buttons"
2096
2096
  />
2097
2097
 
@@ -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
- // Tailwind utility name (maps to --color-*)
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-${colorKey}"></div>
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>
@@ -2139,7 +2142,7 @@ function renderColorsCshtml(colors, projectName) {
2139
2142
  </div>`;
2140
2143
  }).join('\n');
2141
2144
  return ` <section class="ds-color-group">
2142
- <vv-headline text="${categoryTitle}" size="2" modifier="headline-2" />
2145
+ <vv-headline text="${categoryTitle}" size="@HeadlineSize.H2" modifier="headline-2" />
2143
2146
  <div class="ds-color-grid">
2144
2147
  ${items}
2145
2148
  </div>
@@ -2158,7 +2161,7 @@ ${items}
2158
2161
  <vv-headline
2159
2162
  identifier="ds-title"
2160
2163
  modifier="headline-2"
2161
- size="2"
2164
+ size="@HeadlineSize.H2"
2162
2165
  text="Colors"
2163
2166
  />
2164
2167
 
@@ -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) {
@@ -2197,8 +2200,8 @@ function isHeadline(id) {
2197
2200
  return id.startsWith('headline-');
2198
2201
  }
2199
2202
 
2200
- /* ---------------------------------------------
2201
- * normalize typography into semantic entries
2203
+ /* ---------------------------------------------
2204
+ * normalize typography into semantic entries
2202
2205
  * ------------------------------------------- */
2203
2206
 
2204
2207
  function buildEntries({
@@ -2228,8 +2231,8 @@ function buildEntries({
2228
2231
  return map;
2229
2232
  }
2230
2233
 
2231
- /* ---------------------------------------------
2232
- * category resolution
2234
+ /* ---------------------------------------------
2235
+ * category resolution
2233
2236
  * ------------------------------------------- */
2234
2237
 
2235
2238
  function resolveCategory(id) {
@@ -2242,8 +2245,8 @@ function resolveCategory(id) {
2242
2245
  return null;
2243
2246
  }
2244
2247
 
2245
- /* ---------------------------------------------
2246
- * preview render
2248
+ /* ---------------------------------------------
2249
+ * preview render
2247
2250
  * ------------------------------------------- */
2248
2251
 
2249
2252
  function renderPreview(id, title) {
@@ -2252,7 +2255,7 @@ function renderPreview(id, title) {
2252
2255
  <vv-headline
2253
2256
  identifier="ds-preview-headline"
2254
2257
  text="${title}"
2255
- size="2"
2258
+ size="@HeadlineSize.H2"
2256
2259
  modifier="${id}"
2257
2260
  />`;
2258
2261
  }
@@ -2262,8 +2265,8 @@ function renderPreview(id, title) {
2262
2265
  </p>`;
2263
2266
  }
2264
2267
 
2265
- /* ---------------------------------------------
2266
- * entry render
2268
+ /* ---------------------------------------------
2269
+ * entry render
2267
2270
  * ------------------------------------------- */
2268
2271
 
2269
2272
  function renderEntry(id, entry) {
@@ -2274,6 +2277,23 @@ function renderEntry(id, entry) {
2274
2277
  const mSize = getValue(entry.size, 'Mobile');
2275
2278
  const mLine = getValue(entry.lineHeight, 'Mobile');
2276
2279
  const mFamily = getValue(entry.family, 'Mobile');
2280
+ const hasDesktopVariant = dSize != null && dLine != null && dFamily != null && (dSize !== mSize || dLine !== mLine || dFamily !== mFamily);
2281
+ const defaultSize = hasDesktopVariant ? dSize : mSize;
2282
+ const defaultLine = hasDesktopVariant ? dLine : mLine;
2283
+ const defaultFamily = hasDesktopVariant ? dFamily : mFamily;
2284
+ const renderMeta = (family, size, line) => {
2285
+ const lines = [];
2286
+ if (family != null) {
2287
+ lines.push(`<div><strong>Font</strong> ${family}</div>`);
2288
+ }
2289
+ if (size != null) {
2290
+ lines.push(`<div><strong>Size</strong> ${size}px</div>`);
2291
+ }
2292
+ if (line != null) {
2293
+ lines.push(`<div><strong>Line height</strong> ${line}px</div>`);
2294
+ }
2295
+ return lines.join('\n ');
2296
+ };
2277
2297
  return `
2278
2298
  <div class="ds-type-card">
2279
2299
  <div class="ds-type-preview">
@@ -2281,33 +2301,30 @@ ${renderPreview(id, title)}
2281
2301
  </div>
2282
2302
 
2283
2303
  <div class="ds-type-meta">
2284
- <div><strong>Font</strong> ${dFamily}</div>
2285
- <div><strong>Size</strong> ${dSize}px</div>
2286
- <div><strong>Line height</strong> ${dLine}px</div>
2304
+ ${renderMeta(defaultFamily, defaultSize, defaultLine)}
2287
2305
  </div>
2288
2306
 
2307
+ ${hasDesktopVariant ? `
2289
2308
  <div class="ds-type-mobile">
2290
2309
  <div class="ds-type-preview">
2291
- ${renderPreview(id, title)}
2310
+ ${renderPreview(id, title)}
2292
2311
  </div>
2293
2312
 
2294
2313
  <div class="ds-type-meta">
2295
- <div><strong>Font</strong> ${mFamily}</div>
2296
- <div><strong>Size</strong> ${mSize}px</div>
2297
- <div><strong>Line height</strong> ${mLine}px</div>
2314
+ ${renderMeta(mFamily, mSize, mLine)}
2298
2315
  </div>
2299
- </div>
2316
+ </div>` : ''}
2300
2317
  </div>`;
2301
2318
  }
2302
2319
 
2303
- /* ---------------------------------------------
2304
- * category render
2320
+ /* ---------------------------------------------
2321
+ * category render
2305
2322
  * ------------------------------------------- */
2306
2323
 
2307
2324
  function renderCategory(title, entries) {
2308
2325
  return `
2309
2326
  <section class="ds-type-category">
2310
- <vv-headline text="${title}" size="3" modifier="headline-2" />
2327
+ <vv-headline text="${title}" size="@HeadlineSize.H2" modifier="headline-2" />
2311
2328
 
2312
2329
  <div class="ds-type-grid">
2313
2330
  ${entries.join('\n')}
@@ -2315,8 +2332,8 @@ ${entries.join('\n')}
2315
2332
  </section>`;
2316
2333
  }
2317
2334
 
2318
- /* ---------------------------------------------
2319
- * main render
2335
+ /* ---------------------------------------------
2336
+ * main render
2320
2337
  * ------------------------------------------- */
2321
2338
 
2322
2339
  function renderTypographyCshtml(data, projectName) {
@@ -2346,7 +2363,7 @@ function renderTypographyCshtml(data, projectName) {
2346
2363
  <vv-headline
2347
2364
  identifier="ds-title"
2348
2365
  modifier="headline-1"
2349
- size="2"
2366
+ size="@HeadlineSize.H2"
2350
2367
  text="Typography"
2351
2368
  />
2352
2369
 
@@ -2356,8 +2373,8 @@ ${sections}
2356
2373
  </section>`;
2357
2374
  }
2358
2375
 
2359
- /* ---------------------------------------------
2360
- * public API
2376
+ /* ---------------------------------------------
2377
+ * public API
2361
2378
  * ------------------------------------------- */
2362
2379
 
2363
2380
  async function generateTypography(typography, config, outpath, projectName) {
@@ -2384,7 +2401,7 @@ function renderTablesCshtml(projectName) {
2384
2401
  <vv-headline
2385
2402
  identifier="ds__headline"
2386
2403
  modifier="headline-2"
2387
- size="2"
2404
+ size="@HeadlineSize.H2"
2388
2405
  text="Tables"
2389
2406
  />
2390
2407
 
@@ -2441,6 +2458,7 @@ function renderRichtextCshtml(projectName) {
2441
2458
  <vv-headline
2442
2459
  identifier="ds__headline"
2443
2460
  modifier="headline-2"
2461
+ size="@HeadlineSize.H2"
2444
2462
  text="Richtext"
2445
2463
  />
2446
2464
 
@@ -2547,6 +2565,7 @@ function renderSection({
2547
2565
  <vv-headline
2548
2566
  identifier="ds__headline"
2549
2567
  modifier="headline-2"
2568
+ size="@HeadlineSize.H2"
2550
2569
  text="${escapeAttr(title)}"
2551
2570
  />
2552
2571
  `;
@@ -2841,6 +2860,7 @@ ${razorPrelude}
2841
2860
  <vv-headline
2842
2861
  identifier="ds__headline"
2843
2862
  modifier="headline-2"
2863
+ size="@HeadlineSize.H2"
2844
2864
  text="Inputs"
2845
2865
  />
2846
2866
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vettvangur/design-system",
3
- "version": "2.0.12",
3
+ "version": "2.0.14",
4
4
  "description": "",
5
5
  "access": "public",
6
6
  "type": "module",