@rojaostudio/ds-core 1.1.0-next.11 → 1.1.0-next.13

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.
@@ -913,7 +913,7 @@ var ROLES = [
913
913
  ["text/on/accent", "d", "d"],
914
914
  ["text/on/tint", "d", "b"],
915
915
  ["colors/state/error", "l", "l"],
916
- ["colors/state/error-strong", "d", "d"],
916
+ ["colors/state/error-strong", "p", "p"],
917
917
  ["surface/tint/strong", "d", "b"],
918
918
  ["text/on/error", "l", "l"],
919
919
  ["surface/action/default", "d", "b"],
@@ -992,8 +992,17 @@ var ROLES = [
992
992
  ["colors/state/neutral-strong", "d", "d"],
993
993
  ["text/on/primary-subtle", "d", "b"],
994
994
  ["surface/tint/subtle", "d", "b"],
995
- ["border/error", "d", "d"]
995
+ ["border/error", "d", "d"],
996
+ ["surface/attention/low", "p", "p"],
997
+ ["surface/attention/medium", "p", "p"],
998
+ ["surface/attention/high", "p", "p"]
996
999
  ];
1000
+ var amber = palettes.amber;
1001
+ var ATTENTION = {
1002
+ "surface/attention/low": amber[100],
1003
+ "surface/attention/medium": amber[200],
1004
+ "surface/attention/high": amber[400]
1005
+ };
997
1006
  var awayFrom = (bg) => contrastRatio(bg, BLACK) >= contrastRatio(bg, WHITE) ? "darker" : "lighter";
998
1007
  var TINT_DEFAULT = 200;
999
1008
  var lighterStep = (s) => s - 100 ;
@@ -1023,7 +1032,7 @@ function generateRdsTheme(def, opts = {}) {
1023
1032
  }
1024
1033
  } else heading = readableFrom(P.base, P.scale, lightBgs, "darker", BLACK);
1025
1034
  const invert = b.invert ? ramp(b.invert, own).base : WHITE;
1026
- const l = {
1035
+ const l = __spreadValues({
1027
1036
  "colors/primary/light": P.scale[500],
1028
1037
  "colors/primary/default": P.base,
1029
1038
  "colors/primary/dark": P.scale[900],
@@ -1110,7 +1119,7 @@ function generateRdsTheme(def, opts = {}) {
1110
1119
  "logo/inverse": WHITE,
1111
1120
  "logo/inverse-signature": WHITE,
1112
1121
  "social/ink": BLACK
1113
- };
1122
+ }, ATTENTION);
1114
1123
  const single = !b.secondary;
1115
1124
  const K = single ? N : P.scale;
1116
1125
  if (single) {
@@ -1198,7 +1207,6 @@ function generateRdsTheme(def, opts = {}) {
1198
1207
  "text/on/action-tonal": readableFrom(P.scale[200], P.scale, [L[900]], "lighter", WHITE),
1199
1208
  "surface/lift/action": P.scale[800],
1200
1209
  "surface/lift/action-strong": P.scale[700],
1201
- "colors/state/error-strong": red[400],
1202
1210
  "colors/state/success-strong": green[300],
1203
1211
  "colors/state/warning-strong": orange[400],
1204
1212
  "surface/error": red[900],
@@ -1257,7 +1265,6 @@ function generateRdsTheme(def, opts = {}) {
1257
1265
  [d["colors/accent/hover"]] = stateFills(A.scale, d["colors/accent/default"], d["text/on/accent"], [d["colors/accent/hover"]]);
1258
1266
  d["border/error"] = readableFrom(red[400], red, [d["surface/card"]], awayFrom(d["surface/card"]), WHITE, NON_TEXT);
1259
1267
  d["chart/series/1"] = readableFrom(P.scale[400], P.scale, [d["surface/card"]], awayFrom(d["surface/card"]), WHITE, NON_TEXT);
1260
- d["colors/state/error-strong"] = carry(red, l["colors/state/error"], l["text/on/error"], d["colors/state/error-strong"]);
1261
1268
  const ink0 = on(P.base);
1262
1269
  const plate = contrastRatio(ink0, P.base) >= PLATE_MIN ? P.base : readableFrom(P.base, P.scale, [ink0], ink0 === WHITE ? "darker" : "lighter", ink0 === WHITE ? BLACK : WHITE, PLATE_MIN);
1263
1270
  const ink = on(plate);
@@ -1340,11 +1347,13 @@ function generateRdsTheme(def, opts = {}) {
1340
1347
  }
1341
1348
  plateOwn["colors/accent/highlight"] = (_d = [d["colors/accent/highlight"], l["colors/accent/highlight"]].find((c) => contrastRatio(ink, c) >= AA)) != null ? _d : readableFrom(l["colors/accent/highlight"], A.scale, [ink], lightPlate ? "lighter" : "darker", ink === WHITE ? BLACK : WHITE);
1342
1349
  plateOwn["chart/series/1"] = readableFrom(d["chart/series/1"], P.scale, plateBgs, awayFrom(plate), ink, NON_TEXT);
1350
+ plateOwn["colors/state/neutral-strong"] = readableFrom(d["colors/state/neutral-strong"], N, plateBgs, awayFrom(plate), ink, NON_TEXT);
1343
1351
  for (const logo of ["logo/primary", "logo/signature", "logo/accent", "logo/mono", "social/ink"]) plateOwn[logo] = ink;
1352
+ const fixed = __spreadValues({ "colors/state/error-strong": red[700] }, ATTENTION);
1344
1353
  const out = { light: {}, dark: {}, brand: {} };
1345
1354
  const pick = (src, role) => {
1346
1355
  var _a2;
1347
- const table = src === "l" ? l : src === "d" ? d : br;
1356
+ const table = src === "l" ? l : src === "d" ? d : src === "p" ? fixed : br;
1348
1357
  const v = (_a2 = table[role]) != null ? _a2 : l[role];
1349
1358
  if (v === void 0) throw new Error(`rdsTheme: no value for "${role}"`);
1350
1359
  return v;
@@ -1448,7 +1457,7 @@ var RDS_CONTRAST_PAIRS = [
1448
1457
  ["text/on/neutral", "colors/state/neutral"],
1449
1458
  ["text/error", "surface/error"],
1450
1459
  // The pairs the components join (packages/ds, styles/rds/components.css): the label of the neutral Button and
1451
- // Badge on its fill and hovers, the inverse label (colors/primary/default) on the card, the pressed outline Button,
1460
+ // Badge on its fill and hovers, the brand ink as text (colors/primary/default) on the card, the pressed outline Button,
1452
1461
  // the Badge highlight, the selected entry, quiet text and state text where they are placed.
1453
1462
  ["text/on/primary-strong", "colors/primary/default"],
1454
1463
  ["text/on/primary-strong", "colors/primary/light"],
@@ -1472,7 +1481,11 @@ var RDS_CONTRAST_PAIRS = [
1472
1481
  ["text/success", "surface/card"],
1473
1482
  ["text/info", "surface/info"],
1474
1483
  ["text/warning", "surface/warning"],
1475
- ["text/neutral", "surface/neutral"]
1484
+ ["text/neutral", "surface/neutral"],
1485
+ // The attention Banner: text/on/warning on its three levels.
1486
+ ["text/on/warning", "surface/attention/low"],
1487
+ ["text/on/warning", "surface/attention/medium"],
1488
+ ["text/on/warning", "surface/attention/high"]
1476
1489
  ];
1477
1490
  var RDS_NON_TEXT_PAIRS = [
1478
1491
  ["border/strong", "surface/card"],
@@ -1484,7 +1497,9 @@ var RDS_NON_TEXT_PAIRS = [
1484
1497
  ["logo/primary", "surface/page"],
1485
1498
  ["logo/primary", "surface/panel"],
1486
1499
  ["chart/series/1", "surface/card"],
1487
- ["chart/series/1", "surface/page"]
1500
+ ["chart/series/1", "surface/page"],
1501
+ ["colors/state/neutral-strong", "surface/panel"],
1502
+ ["colors/state/neutral-strong", "surface/card"]
1488
1503
  ];
1489
1504
  function rdsContrastReport(theme) {
1490
1505
  const out = [];
@@ -1538,6 +1553,11 @@ function rdsThemeFromTable(table, opts = {}) {
1538
1553
  ref2 = roles[added];
1539
1554
  derived.add(role);
1540
1555
  }
1556
+ if (ref2 === void 0 && ATTENTION[role] !== void 0) {
1557
+ out[mode][roleVar(role)] = ATTENTION[role];
1558
+ derived.add(role);
1559
+ continue;
1560
+ }
1541
1561
  if (ref2 === void 0) problems.push(`${mode}: role "${role}" is missing`);
1542
1562
  else if (isColourRef(ref2)) {
1543
1563
  const value = table.primitives[ref2];
@@ -1565,7 +1585,9 @@ function rdsThemeFromTable(table, opts = {}) {
1565
1585
  const warn = (_c = opts.warn) != null ? _c : defaultWarn;
1566
1586
  if (derived.size)
1567
1587
  warn(
1568
- `${where}: the table was exported before ${[...derived].map((r) => `"${r}"`).join(", ")} existed in the [RDS] theme. Taken from the tokens Figma aliases it to (` + [...derived].map((r) => Object.entries(ADDED_ROLES[r]).map(([m, src]) => `${m}: ${src}`).join(", ")).join("; ") + `). Export the table again with figma/export-brand.js.`
1588
+ `${where}: the table was exported before ${[...derived].map((r) => `"${r}"`).join(", ")} existed in the [RDS] theme. Taken from the tokens Figma aliases it to (` + [...derived].map(
1589
+ (r) => ADDED_ROLES[r] ? Object.entries(ADDED_ROLES[r]).map(([m, src]) => `${m}: ${src}`).join(", ") : `${r}: ${ATTENTION[r]} in every mode`
1590
+ ).join("; ") + `). Export the table again with figma/export-brand.js.`
1569
1591
  );
1570
1592
  const fails = rdsContrastReport(out);
1571
1593
  if (fails.length)
@@ -14,9 +14,10 @@ type RdsThemeOptions = {
14
14
  /**
15
15
  * Roles of the [RDS] theme collection, in Figma order: [name, dark source, brand source].
16
16
  * The light mode always reads the plain base token. In dark and brand, Figma points either to the
17
- * mode's own variant (`d` = base dark/…, `b` = base brand/…) or back to another one (`l` = plain).
17
+ * mode's own variant (`d` = base dark/…, `b` = base brand/…) or back to another one (`l` = plain), or straight
18
+ * to a primitive of the [RDS] Primitives library (`p`: the same colour for every brand, see FIXED in the generator).
18
19
  */
19
- declare const ROLES: ReadonlyArray<readonly [string, "l" | "d", "l" | "d" | "b"]>;
20
+ declare const ROLES: ReadonlyArray<readonly [string, "l" | "d" | "p", "l" | "d" | "b" | "p"]>;
20
21
  /** CSS custom property of a role: the Figma path with hyphens (the [RDS] codeSyntax rule). */
21
22
  declare const roleVar: (role: string) => string;
22
23
  declare function generateRdsTheme(def: BrandDef, opts?: RdsThemeOptions): RdsTheme;
package/dist/generate.js CHANGED
@@ -1,3 +1,3 @@
1
- export { RDS_CONTRAST_PAIRS, RDS_NON_TEXT_PAIRS, ROLES as RDS_ROLES, RDS_SCOPE_SELECTORS, RDS_TOKEN_SCOPE, RdsValidationError, SCALE_STEPS, brandTones, buildScale, contrastRatio, emitClaudeMd, emitCss, emitRdsCss, generateRdsTheme, generateTheme, hexToHsl, hslToHex, isHex, isNeutralBrand, isSafeColor, isSafeFont, isSafeVarName, onColor, rdsContrast, rdsContrastReport, rdsThemeFromTable, refToHex, relativeLuminance, resolveTheme, roleVar } from './chunk-D6HJEVJK.js';
1
+ export { RDS_CONTRAST_PAIRS, RDS_NON_TEXT_PAIRS, ROLES as RDS_ROLES, RDS_SCOPE_SELECTORS, RDS_TOKEN_SCOPE, RdsValidationError, SCALE_STEPS, brandTones, buildScale, contrastRatio, emitClaudeMd, emitCss, emitRdsCss, generateRdsTheme, generateTheme, hexToHsl, hslToHex, isHex, isNeutralBrand, isSafeColor, isSafeFont, isSafeVarName, onColor, rdsContrast, rdsContrastReport, rdsThemeFromTable, refToHex, relativeLuminance, resolveTheme, roleVar } from './chunk-DVJ4TGPZ.js';
2
2
  import './chunk-FRWRLCYM.js';
3
3
  import './chunk-ORMEWXMH.js';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export { recipes } from './chunk-PV6GFEAM.js';
2
- export { RDS_CONTRAST_PAIRS, RDS_NON_TEXT_PAIRS, ROLES as RDS_ROLES, RDS_SCOPE_SELECTORS, RDS_TOKEN_SCOPE, RdsValidationError, SCALE_STEPS, brandTones, buildScale, contrastRatio, emitClaudeMd, emitCss, emitRdsCss, generateRdsTheme, generateTheme, hexToHsl, hslToHex, isHex, isNeutralBrand, isSafeColor, isSafeFont, isSafeVarName, onColor, rdsContrast, rdsContrastReport, rdsThemeFromTable, refToHex, relativeLuminance, resolveTheme, roleVar } from './chunk-D6HJEVJK.js';
2
+ export { RDS_CONTRAST_PAIRS, RDS_NON_TEXT_PAIRS, ROLES as RDS_ROLES, RDS_SCOPE_SELECTORS, RDS_TOKEN_SCOPE, RdsValidationError, SCALE_STEPS, brandTones, buildScale, contrastRatio, emitClaudeMd, emitCss, emitRdsCss, generateRdsTheme, generateTheme, hexToHsl, hslToHex, isHex, isNeutralBrand, isSafeColor, isSafeFont, isSafeVarName, onColor, rdsContrast, rdsContrastReport, rdsThemeFromTable, refToHex, relativeLuminance, resolveTheme, roleVar } from './chunk-DVJ4TGPZ.js';
3
3
  export { primitives, tokens } from './chunk-FRWRLCYM.js';
4
4
  import './chunk-ORMEWXMH.js';
package/dist/themes.js CHANGED
@@ -1,4 +1,4 @@
1
- import { generateTheme } from './chunk-D6HJEVJK.js';
1
+ import { generateTheme } from './chunk-DVJ4TGPZ.js';
2
2
  import './chunk-FRWRLCYM.js';
3
3
  import { __spreadValues, __objRest } from './chunk-ORMEWXMH.js';
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rojaostudio/ds-core",
3
- "version": "1.1.0-next.11",
3
+ "version": "1.1.0-next.13",
4
4
  "description": "O motor do Rojão DS — tokens, derivação de tema e emissores. Sem React, sem Tailwind, sem CSS.",
5
5
  "license": "MIT",
6
6
  "author": "Rojão Studio (https://rojao.studio)",