@nxds/core 0.10.0 → 0.12.0

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.
@@ -437,6 +437,13 @@ var CHART_PALETTE_REFERENCES = [
437
437
  { palette: "rose", light: "600", dark: "200" },
438
438
  { palette: "indigo", light: "600", dark: "200" }
439
439
  ];
440
+ var SYNTAX_PALETTE_REFERENCES = {
441
+ keyword: CHART_PALETTE_REFERENCES[3],
442
+ string: CHART_PALETTE_REFERENCES[1],
443
+ function: CHART_PALETTE_REFERENCES[4],
444
+ type: CHART_PALETTE_REFERENCES[0],
445
+ constant: CHART_PALETTE_REFERENCES[2]
446
+ };
440
447
 
441
448
  // src/lib/apca-pairs.ts
442
449
  var COLOR_FAMILIES = [
@@ -451,6 +458,8 @@ var CATEGORICAL_INDICES = CHART_PALETTE_REFERENCES.map(
451
458
  (_, index) => index + 1
452
459
  );
453
460
  var CHART_STAGGER_LC = 4.5;
461
+ var DIFF_SURFACES = ["success-subtle", "error-subtle"];
462
+ var CODE_SURFACES = ["container", "container-hover", ...DIFF_SURFACES];
454
463
  var FOCUS_SURFACES = [
455
464
  "background",
456
465
  "container",
@@ -510,11 +519,23 @@ var APCA_PAIRS = [
510
519
  ink(`${family}-subtle-foreground`, `${family}-subtle-active`, "ui")
511
520
  ]),
512
521
  ...CATEGORICAL_INDICES.flatMap(
513
- (index) => ["container", "background"].map((bg) => ({
522
+ (index) => ["container", "container-hover", "background"].map((bg) => ({
514
523
  ...ink(`chart-categorical-${index}`, bg, "ui"),
515
524
  offset: (index - 1) * CHART_STAGGER_LC
516
525
  }))
517
526
  ),
527
+ ...CODE_SURFACES.flatMap(
528
+ (bg) => Object.keys(SYNTAX_PALETTE_REFERENCES).map(
529
+ (role) => ink(`syntax-${role}`, bg, "ui")
530
+ )
531
+ ),
532
+ // codeBlockTheme also colours code with the text tokens, which already read
533
+ // on container and container-hover.
534
+ ...DIFF_SURFACES.flatMap((bg) => [
535
+ text("foreground", bg, "ui"),
536
+ text("muted-foreground", bg, "ui"),
537
+ text("muted-foreground-subtle", bg, "incidental")
538
+ ]),
518
539
  // Focus is the primary accent (components.md § Focus States), so it shares
519
540
  // one solved color with primary-subtle-foreground.
520
541
  ...FOCUS_SURFACES.flatMap((surface) => [
@@ -945,8 +966,10 @@ function rampFromSeed(seedHex, options = {}) {
945
966
  }
946
967
 
947
968
  // src/lib/contrast.ts
969
+ var CONTRAST_MIN = 0;
970
+ var CONTRAST_MAX = 100;
948
971
  function normalizeContrast(value, fallback = 50) {
949
- return typeof value === "number" && Number.isFinite(value) ? Math.round(Math.max(0, Math.min(100, value))) : fallback;
972
+ return typeof value === "number" && Number.isFinite(value) ? Math.round(Math.max(CONTRAST_MIN, Math.min(CONTRAST_MAX, value))) : fallback;
950
973
  }
951
974
  function contrastTarget(tier, contrast) {
952
975
  return TIER_THRESHOLDS[tier] + 15 * contrast / 100;
@@ -1119,6 +1142,7 @@ var DEFAULT_NXDS_APPEARANCE = {
1119
1142
  stroke: "normal",
1120
1143
  prefs: {
1121
1144
  uiFont: '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
1145
+ headingFont: null,
1122
1146
  codeFont: 'ui-monospace, "SF Mono", Menlo, monospace',
1123
1147
  uiFontSize: 14,
1124
1148
  codeFontSize: 12,
@@ -2811,6 +2835,14 @@ function deriveChart(mode) {
2811
2835
  ])
2812
2836
  );
2813
2837
  }
2838
+ function deriveSyntax(mode) {
2839
+ return Object.fromEntries(
2840
+ Object.entries(SYNTAX_PALETTE_REFERENCES).map(([role, reference]) => [
2841
+ `--nx-color-syntax-${role}`,
2842
+ getPaletteShade(reference.palette, reference[mode])
2843
+ ])
2844
+ );
2845
+ }
2814
2846
  function deriveAlpha(surfaceTone, mode, profile) {
2815
2847
  const tone = SURFACE_TONE[surfaceTone];
2816
2848
  const dark = mode === "dark";
@@ -2926,6 +2958,7 @@ function deriveThemeMode(input, mode) {
2926
2958
  ...deriveSecondary(mode),
2927
2959
  ...deriveStatus(mode),
2928
2960
  ...deriveChart(mode),
2961
+ ...deriveSyntax(mode),
2929
2962
  ...deriveAlpha(surfaceTone, mode, profile),
2930
2963
  "--nx-color-focus-error": getPaletteShade(
2931
2964
  STATUS_PALETTE_FAMILIES.error,
@@ -3057,6 +3090,13 @@ var CHART_TOKEN_NAMES = [
3057
3090
  "chart-categorical-4",
3058
3091
  "chart-categorical-5"
3059
3092
  ];
3093
+ var SYNTAX_TOKEN_NAMES = [
3094
+ "syntax-keyword",
3095
+ "syntax-string",
3096
+ "syntax-function",
3097
+ "syntax-type",
3098
+ "syntax-constant"
3099
+ ];
3060
3100
  var FOCUS_TOKEN_NAMES = ["focus-default", "focus-error"];
3061
3101
  var ALPHA_TOKEN_NAMES = [
3062
3102
  "background-hover-alpha",
@@ -3075,6 +3115,7 @@ var SEMANTIC_TOKEN_REGISTRY = [
3075
3115
  ...metas("brand", BRAND_TOKEN_NAMES),
3076
3116
  ...metas("status", STATUS_TOKEN_NAMES),
3077
3117
  ...metas("chart", CHART_TOKEN_NAMES),
3118
+ ...metas("syntax", SYNTAX_TOKEN_NAMES),
3078
3119
  ...metas("focus", FOCUS_TOKEN_NAMES),
3079
3120
  ...metas("alpha", ALPHA_TOKEN_NAMES)
3080
3121
  ];
@@ -3245,7 +3286,7 @@ function formatTypographyDeclarations(tokenPath, value, primitiveMap) {
3245
3286
  const css = fieldValue === "auto" ? "normal" : resolveValue(fieldValue, primitiveMap);
3246
3287
  declarations.push({ property, value: css });
3247
3288
  }
3248
- if (tokenPath[0] === "heading") {
3289
+ if (tokenPath[0] === "display" || tokenPath[0] === "heading") {
3249
3290
  declarations.push({ property: "text-wrap", value: "balance" });
3250
3291
  }
3251
3292
  if (tokenPath[0] === "body") {
@@ -3445,6 +3486,11 @@ var NEUTRAL_DESCRIPTIONS = {
3445
3486
  "chart-categorical-3": "Third chart series, on container or background.",
3446
3487
  "chart-categorical-4": "Fourth chart series, on container or background.",
3447
3488
  "chart-categorical-5": "Fifth chart series, on container or background.",
3489
+ "syntax-keyword": "Keywords in code, such as const and return, on CodeBlock surfaces.",
3490
+ "syntax-string": "Strings in code, on CodeBlock surfaces.",
3491
+ "syntax-function": "Function and attribute names in code, on CodeBlock surfaces.",
3492
+ "syntax-type": "Type, class and tag names in code, on CodeBlock surfaces.",
3493
+ "syntax-constant": "Numbers and constants in code, on CodeBlock surfaces.",
3448
3494
  "focus-default": "Focus ring of every interactive control, on any surface.",
3449
3495
  "focus-error": "Focus ring of an invalid control.",
3450
3496
  "background-hover-alpha": "Translucent hover fill for controls that sit on an image or an unknown surface.",
@@ -10819,6 +10865,41 @@ var shadows_default = {
10819
10865
 
10820
10866
  // tokens/styles/typography.json
10821
10867
  var typography_default = {
10868
+ display: {
10869
+ large: {
10870
+ $type: "typography",
10871
+ $value: {
10872
+ fontFamily: "{family.font-heading}",
10873
+ fontSize: "{size.5xl}",
10874
+ fontWeight: "{weight.semibold}",
10875
+ lineHeight: "{line-height.5xl}",
10876
+ letterSpacing: "{letterspacing.tighter}"
10877
+ },
10878
+ $description: "Largest display title \u2014 hero and landing-page section titles"
10879
+ },
10880
+ medium: {
10881
+ $type: "typography",
10882
+ $value: {
10883
+ fontFamily: "{family.font-heading}",
10884
+ fontSize: "{size.4xl}",
10885
+ fontWeight: "{weight.semibold}",
10886
+ lineHeight: "{line-height.4xl}",
10887
+ letterSpacing: "{letterspacing.tighter}"
10888
+ },
10889
+ $description: "Display title one step below display-large, for page sections"
10890
+ },
10891
+ small: {
10892
+ $type: "typography",
10893
+ $value: {
10894
+ fontFamily: "{family.font-heading}",
10895
+ fontSize: "{size.3xl}",
10896
+ fontWeight: "{weight.semibold}",
10897
+ lineHeight: "{line-height.3xl}",
10898
+ letterSpacing: "{letterspacing.tighter}"
10899
+ },
10900
+ $description: "Smallest display title \u2014 page-section titles in narrow layouts"
10901
+ }
10902
+ },
10822
10903
  heading: {
10823
10904
  large: {
10824
10905
  $type: "typography",
@@ -11039,6 +11120,7 @@ function typographyControl(path) {
11039
11120
  }
11040
11121
  if (group !== "family") return null;
11041
11122
  if (key === "font-sans") return { kind: "pref", field: "uiFont" };
11123
+ if (key === "font-heading") return { kind: "pref", field: "headingFont" };
11042
11124
  if (key === "font-mono") return { kind: "pref", field: "codeFont" };
11043
11125
  return null;
11044
11126
  }