@multiplatform.one/theme 10.25.1 → 10.26.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@multiplatform.one/theme",
3
- "version": "10.25.1",
3
+ "version": "10.26.0",
4
4
  "description": "Tamagui theme system for multiplatform.one",
5
5
  "keywords": [
6
6
  "multiplatform",
@@ -163,8 +163,8 @@
163
163
  "access": "public"
164
164
  },
165
165
  "dependencies": {
166
- "@multiplatform.one/platform": "^10.25.1",
167
- "@multiplatform.one/store": "^10.25.1",
166
+ "@multiplatform.one/platform": "^10.26.0",
167
+ "@multiplatform.one/store": "^10.26.0",
168
168
  "@tamagui/animations-react-native": "3.2.3",
169
169
  "@tamagui/colors": "3.2.3",
170
170
  "@tamagui/config": "3.2.3",
@@ -178,8 +178,8 @@
178
178
  },
179
179
  "devDependencies": {
180
180
  "@expo/prebuild-config": "58.0.19",
181
- "@multiplatform.one/config": "10.25.1",
182
- "@multiplatform.one/test-utils": "10.25.1",
181
+ "@multiplatform.one/config": "10.26.0",
182
+ "@multiplatform.one/test-utils": "10.26.0",
183
183
  "@tamagui/animations-css": "3.2.3",
184
184
  "@tamagui/animations-reanimated": "3.2.3",
185
185
  "@tamagui/build": "3.2.3",
package/src/menuRow.ts CHANGED
@@ -54,7 +54,7 @@ export function menuRowCheckedFill(scheme: ColorScheme) {
54
54
  * HIG lifts a selection off its material (FZ-8557, Round 40). Light rests on
55
55
  * `$color3` over the white `$color1` panel, a tint and not the `$color4` slab.
56
56
  * A dark overlay is `$color5` (the house `surface2`, FZ-8400), so dark rests on
57
- * `$color6`, a step lighter: a recessed `$color2` read as a hole in the panel. In a colour theme
57
+ * `$color6`, a step lighter than the panel. In a colour theme
58
58
  * both steps carry its hue. Hover and press keep the fill, so a checked row
59
59
  * never drops to the transient hover fill: a consumer composes it at rest and
60
60
  * again through `stateFragment("hover", …)` and `stateFragment("press", …)`,
@@ -0,0 +1,64 @@
1
+ import * as Colors from "@tamagui/colors";
2
+ import { describe, expect, it } from "vitest";
3
+ import { contrastRatio, normalizeToHex, relativeLuminance } from "./colorRules";
4
+ import { createDefaultThemeConfig } from "./createDefaultThemeConfig";
5
+ import { resolveAllThemes } from "./dedupeInherited";
6
+ import { apcaContrast } from "./fillContrast";
7
+
8
+ function color(value: unknown): string {
9
+ return String(
10
+ typeof value === "object" && value !== null ? (value as { val: unknown }).val : value,
11
+ );
12
+ }
13
+
14
+ describe("LC-172 consumer accent state fills", () => {
15
+ const palettes = [
16
+ ...(["blue", "purple", "pink"] as const).map((hue) => ({
17
+ name: hue,
18
+ lightPalette: Object.values(Colors[hue]),
19
+ darkPalette: Object.values(Colors[`${hue}Dark`]),
20
+ })),
21
+ {
22
+ name: "SHC console",
23
+ lightPalette: [57, 54, 51, 48, 46, 44, 42, 40, 38, 36, 95, 98].map(
24
+ (lightness) => `hsla(250, 50%, ${lightness}%, 1)`,
25
+ ),
26
+ darkPalette: [35, 38, 41, 43, 46, 49, 52, 54, 57, 60, 86, 95].map(
27
+ (lightness, index) => `hsla(250, ${index === 10 ? 80 : 50}%, ${lightness}%, 1)`,
28
+ ),
29
+ },
30
+ ];
31
+ for (const { name, lightPalette, darkPalette } of palettes) {
32
+ const resolved = resolveAllThemes(
33
+ createDefaultThemeConfig({
34
+ accent: {
35
+ lightPalette,
36
+ darkPalette,
37
+ },
38
+ }).tamagui.themes as unknown as Record<string, Record<string, unknown>>,
39
+ );
40
+
41
+ for (const scheme of ["light", "dark"] as const) {
42
+ for (const component of ["", "_Button"] as const) {
43
+ for (const state of ["hover", "press", "focus"] as const) {
44
+ it(`${name} ${scheme}_accent${component} ${state} holds its label`, () => {
45
+ const theme = resolved[`${scheme}_accent${component}`];
46
+ const fill = color(theme[`background-${state}`]);
47
+ const label = color(theme[`color-${state}`] ?? theme.color);
48
+ expect(
49
+ contrastRatio(
50
+ relativeLuminance(normalizeToHex(label)!),
51
+ relativeLuminance(normalizeToHex(fill)!),
52
+ ),
53
+ `${label} on ${fill}`,
54
+ ).toBeGreaterThanOrEqual(4.5);
55
+ expect(
56
+ Math.abs(apcaContrast(label, fill)),
57
+ `${label} on ${fill}`,
58
+ ).toBeGreaterThanOrEqual(60);
59
+ });
60
+ }
61
+ }
62
+ }
63
+ }
64
+ });
@@ -1135,6 +1135,41 @@ function holdStateFill(ramp: string[], fill: string, label: string, paper: numbe
1135
1135
  );
1136
1136
  }
1137
1137
 
1138
+ function holdConsumerAccentStates(themes: Record<string, Record<string, string>>) {
1139
+ const out = { ...themes };
1140
+ for (const scheme of ["light", "dark"] as const) {
1141
+ const base = themes[scheme];
1142
+ if (!base) continue;
1143
+ const ramp = Array.from({ length: 12 }, (_, index) => base[`accent-${index + 1}`]);
1144
+ const paper = luminanceOf(base["color-1"]);
1145
+ if (!isFullRamp(ramp) || isAchromaticRamp(ramp) || paper === null) continue;
1146
+ const scopeName = `${scheme}_accent`;
1147
+ const scope = themes[scopeName];
1148
+ if (!scope) continue;
1149
+ for (const [name, theme] of Object.entries(themes)) {
1150
+ if (name !== scopeName && !name.startsWith(`${scopeName}_`)) continue;
1151
+ const held = { ...theme };
1152
+ for (const state of ["hover", "press", "focus"] as const) {
1153
+ const fillKey = `background-${state}`;
1154
+ const inkKey = `color-${state}`;
1155
+ const fill = theme[fillKey] ?? scope[fillKey] ?? theme.background ?? scope.background;
1156
+ const label = theme[inkKey] ?? scope[inkKey] ?? theme.color ?? scope.color;
1157
+ if (labelHolds(label, fill)) continue;
1158
+ const pair =
1159
+ holdFillLabel(fill, ramp, [label], paper) ??
1160
+ holdFillLabel(fill, ramp, [scope.color, base["color-1"], base["color-12"]], paper);
1161
+ if (!pair) continue;
1162
+ held[fillKey] = pair.fill;
1163
+ held[inkKey] = pair.label;
1164
+ if ((theme[`border-color-${state}`] ?? scope[`border-color-${state}`]) === fill)
1165
+ held[`border-color-${state}`] = pair.fill;
1166
+ }
1167
+ out[name] = held;
1168
+ }
1169
+ }
1170
+ return out;
1171
+ }
1172
+
1138
1173
  /**
1139
1174
  * LC-172 FILL-CONTRAST. The step of a hue's ramp its accent solid fills with,
1140
1175
  * and the label on it: the step nearest in luminance to `preferred` where a
@@ -1890,10 +1925,12 @@ export function createThemesBuilder(
1890
1925
  return Object.fromEntries(Object.entries(raw).map(([name, theme]) => [name, { ...theme }]));
1891
1926
  };
1892
1927
 
1893
- const initialTheme = buildRawThemes({
1894
- dark: accentTheme.darkPalette,
1895
- light: accentTheme.lightPalette,
1896
- });
1928
+ const initialTheme = holdConsumerAccentStates(
1929
+ buildRawThemes({
1930
+ dark: accentTheme.darkPalette,
1931
+ light: accentTheme.lightPalette,
1932
+ }),
1933
+ );
1897
1934
  const scrimAlphas = {
1898
1935
  light: baseTheme.lightScrims ?? (defaultBaseTheme.lightScrims as ScrimAlphas),
1899
1936
  dark: baseTheme.darkScrims ?? (defaultBaseTheme.darkScrims as ScrimAlphas),
@@ -47,7 +47,7 @@ export declare function menuRowCheckedFill(scheme: ColorScheme): "$color-3" | "$
47
47
  * HIG lifts a selection off its material (FZ-8557, Round 40). Light rests on
48
48
  * `$color3` over the white `$color1` panel, a tint and not the `$color4` slab.
49
49
  * A dark overlay is `$color5` (the house `surface2`, FZ-8400), so dark rests on
50
- * `$color6`, a step lighter: a recessed `$color2` read as a hole in the panel. In a colour theme
50
+ * `$color6`, a step lighter than the panel. In a colour theme
51
51
  * both steps carry its hue. Hover and press keep the fill, so a checked row
52
52
  * never drops to the transient hover fill: a consumer composes it at rest and
53
53
  * again through `stateFragment("hover", …)` and `stateFragment("press", …)`,
@@ -1 +1 @@
1
- {"version":3,"file":"createThemes.d.ts","sourceRoot":"","sources":["../../src/theme/createThemes.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAY7C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;IACz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