@multiplatform.one/theme 7.88.5 → 7.88.7
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/cjs/theme/accentInk.cjs +122 -0
- package/dist/cjs/theme/accentInk.native.js +200 -0
- package/dist/cjs/theme/accentInk.native.js.map +1 -0
- package/dist/cjs/theme/createThemes.cjs +7 -6
- package/dist/cjs/theme/createThemes.native.js +7 -6
- package/dist/cjs/theme/createThemes.native.js.map +1 -1
- package/dist/cjs/theme/readableColor.cjs +11 -77
- package/dist/cjs/theme/readableColor.native.js +13 -148
- package/dist/cjs/theme/readableColor.native.js.map +1 -1
- package/dist/cjs/theme/tintHues.cjs +28 -0
- package/dist/cjs/theme/tintHues.native.js +31 -0
- package/dist/cjs/theme/tintHues.native.js.map +1 -0
- package/dist/esm/theme/accentInk.mjs +91 -0
- package/dist/esm/theme/accentInk.mjs.map +1 -0
- package/dist/esm/theme/accentInk.native.js +166 -0
- package/dist/esm/theme/accentInk.native.js.map +1 -0
- package/dist/esm/theme/createThemes.mjs +5 -4
- package/dist/esm/theme/createThemes.mjs.map +1 -1
- package/dist/esm/theme/createThemes.native.js +5 -4
- package/dist/esm/theme/createThemes.native.js.map +1 -1
- package/dist/esm/theme/readableColor.mjs +6 -72
- package/dist/esm/theme/readableColor.mjs.map +1 -1
- package/dist/esm/theme/readableColor.native.js +7 -142
- package/dist/esm/theme/readableColor.native.js.map +1 -1
- package/dist/esm/theme/tintHues.mjs +3 -0
- package/dist/esm/theme/tintHues.mjs.map +1 -0
- package/dist/esm/theme/tintHues.native.js +3 -0
- package/dist/esm/theme/tintHues.native.js.map +1 -0
- package/package.json +5 -5
- package/src/theme/accentInk.ts +134 -0
- package/src/theme/accentOnSurface.flip.spec.tsx +155 -0
- package/src/theme/accentOnSurface.palette.spec.tsx +2 -1
- package/src/theme/accentOnSurface.spec.tsx +2 -1
- package/src/theme/createDefaultThemeConfig.spec.ts +2 -2
- package/src/theme/createThemes.ts +21 -47
- package/src/theme/readableColor.ts +15 -100
- package/src/theme/tintHues.ts +36 -0
- package/types/theme/accentInk.d.ts +34 -0
- package/types/theme/accentInk.d.ts.map +1 -0
- package/types/theme/createThemes.d.ts +2 -1
- package/types/theme/createThemes.d.ts.map +1 -1
- package/types/theme/readableColor.d.ts +2 -21
- package/types/theme/readableColor.d.ts.map +1 -1
- package/types/theme/tintHues.d.ts +2 -0
- package/types/theme/tintHues.d.ts.map +1 -0
|
@@ -22,10 +22,10 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
|
22
22
|
}), mod);
|
|
23
23
|
var readableColor_exports = {};
|
|
24
24
|
__export(readableColor_exports, {
|
|
25
|
-
resolveAccentOnSurface: () => resolveAccentOnSurface,
|
|
25
|
+
resolveAccentOnSurface: () => import_accentInk.resolveAccentOnSurface,
|
|
26
26
|
resolveAccentTintedSurface: () => resolveAccentTintedSurface,
|
|
27
27
|
resolveActiveTabInk: () => resolveActiveTabInk,
|
|
28
|
-
resolveIdentityInk: () => resolveIdentityInk,
|
|
28
|
+
resolveIdentityInk: () => import_accentInk.resolveIdentityInk,
|
|
29
29
|
resolveLegibleInkOn: () => resolveLegibleInkOn,
|
|
30
30
|
useAccentOnSurface: () => useAccentOnSurface,
|
|
31
31
|
useAccentTintedSurface: () => useAccentTintedSurface,
|
|
@@ -38,9 +38,9 @@ __export(readableColor_exports, {
|
|
|
38
38
|
module.exports = __toCommonJS(readableColor_exports);
|
|
39
39
|
var import_react = require("react");
|
|
40
40
|
var import_tamagui = require("tamagui");
|
|
41
|
+
var import_accentInk = require("./accentInk.cjs");
|
|
41
42
|
var import_colorRules = require("./colorRules.cjs");
|
|
42
43
|
var import_controlTiers = require("./controlTiers.cjs");
|
|
43
|
-
var import_createThemes = require("./createThemes.cjs");
|
|
44
44
|
function resolveTokenValue(theme, token) {
|
|
45
45
|
const key = token.startsWith("$") ? token.slice(1) : token;
|
|
46
46
|
const val = theme[key]?.val;
|
|
@@ -89,81 +89,13 @@ function useLegibleInkOn(fill_, preferred) {
|
|
|
89
89
|
return !resolved || resolved === preferredValue ? preferred : resolved;
|
|
90
90
|
}, [fill, preferred, preferredValue, paper, ink]);
|
|
91
91
|
}
|
|
92
|
-
const IDENTITY_CHROMA_FLOOR = 0.1;
|
|
93
|
-
function chromaOf(hex) {
|
|
94
|
-
const rgb = [1, 3, 5].map(offset => parseInt(hex.slice(offset, offset + 2), 16) / 255);
|
|
95
|
-
return Math.max(...rgb) - Math.min(...rgb);
|
|
96
|
-
}
|
|
97
|
-
function surfaceLuminances(surfaces) {
|
|
98
|
-
const lums = [];
|
|
99
|
-
for (const surface of surfaces) {
|
|
100
|
-
const hex = surface ? (0, import_colorRules.normalizeToHex)(surface) : null;
|
|
101
|
-
if (!hex) return null;
|
|
102
|
-
lums.push((0, import_colorRules.relativeLuminance)(hex));
|
|
103
|
-
}
|
|
104
|
-
return lums;
|
|
105
|
-
}
|
|
106
|
-
function pickIdentityInk(candidates, surfaces) {
|
|
107
|
-
const surfaceLums = surfaceLuminances(surfaces);
|
|
108
|
-
if (!surfaceLums) return void 0;
|
|
109
|
-
let best;
|
|
110
|
-
let bestChroma = IDENTITY_CHROMA_FLOOR;
|
|
111
|
-
for (const candidate of candidates) {
|
|
112
|
-
const hex = candidate ? (0, import_colorRules.normalizeToHex)(candidate) : null;
|
|
113
|
-
if (!candidate || !hex) continue;
|
|
114
|
-
const lum = (0, import_colorRules.relativeLuminance)(hex);
|
|
115
|
-
if (surfaceLums.some(surface => (0, import_colorRules.contrastRatio)(lum, surface) < import_colorRules.aaTextContrastRatio)) continue;
|
|
116
|
-
const chroma = chromaOf(hex);
|
|
117
|
-
if (chroma > bestChroma) {
|
|
118
|
-
bestChroma = chroma;
|
|
119
|
-
best = candidate;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return best;
|
|
123
|
-
}
|
|
124
|
-
function resolveIdentityInk({
|
|
125
|
-
candidates,
|
|
126
|
-
surfaces,
|
|
127
|
-
ink
|
|
128
|
-
}) {
|
|
129
|
-
return pickIdentityInk(candidates, surfaces) ?? ink;
|
|
130
|
-
}
|
|
131
|
-
function resolveAccentOnSurface({
|
|
132
|
-
identity,
|
|
133
|
-
accentSteps,
|
|
134
|
-
surfaces,
|
|
135
|
-
ink
|
|
136
|
-
}) {
|
|
137
|
-
const hued = pickIdentityInk(identity, surfaces);
|
|
138
|
-
if (hued) return hued;
|
|
139
|
-
const surfaceLums = surfaceLuminances(surfaces);
|
|
140
|
-
if (!surfaceLums) return ink;
|
|
141
|
-
let best;
|
|
142
|
-
let bestMin = Number.POSITIVE_INFINITY;
|
|
143
|
-
for (const step of accentSteps) {
|
|
144
|
-
const hex = step ? (0, import_colorRules.normalizeToHex)(step) : null;
|
|
145
|
-
if (!step || !hex) continue;
|
|
146
|
-
const stepLum = (0, import_colorRules.relativeLuminance)(hex);
|
|
147
|
-
const min = Math.min(...surfaceLums.map(surface => (0, import_colorRules.contrastRatio)(stepLum, surface)));
|
|
148
|
-
if (min >= import_colorRules.aaTextContrastRatio && min < bestMin) {
|
|
149
|
-
bestMin = min;
|
|
150
|
-
best = step;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return best ?? ink;
|
|
154
|
-
}
|
|
155
|
-
const accentStepKeys = Array.from({
|
|
156
|
-
length: 12
|
|
157
|
-
}, (_, index) => `accent${index + 1}`);
|
|
158
92
|
function useIdentityInputs() {
|
|
159
93
|
const themeName = (0, import_tamagui.useThemeName)() ?? "";
|
|
160
94
|
const theme = (0, import_tamagui.useTheme)();
|
|
161
|
-
const
|
|
162
|
-
const isTint = hue !== void 0 && import_createThemes.tintHueNames.has(hue);
|
|
163
|
-
const keys = isTint ? ["color8", "color9", "color10", `${hue}11`, `${hue}12`] : accentStepKeys;
|
|
95
|
+
const keys = (0, import_accentInk.identityKeys)(themeName);
|
|
164
96
|
return {
|
|
165
97
|
candidates: keys.map(key => resolveTokenValue(theme, key)),
|
|
166
|
-
accentSteps: accentStepKeys.map(key => resolveTokenValue(theme, key)),
|
|
98
|
+
accentSteps: import_accentInk.accentStepKeys.map(key => resolveTokenValue(theme, key)),
|
|
167
99
|
c1: resolveTokenValue(theme, "color1"),
|
|
168
100
|
c2: resolveTokenValue(theme, "color2"),
|
|
169
101
|
ink: resolveTokenValue(theme, "color12") ?? "$color12"
|
|
@@ -177,9 +109,10 @@ function useAccentOnSurface() {
|
|
|
177
109
|
c2,
|
|
178
110
|
ink
|
|
179
111
|
} = useIdentityInputs();
|
|
112
|
+
const theme = (0, import_tamagui.useTheme)();
|
|
180
113
|
const candidateKey = candidates.join("|");
|
|
181
114
|
const stepKey = accentSteps.join("|");
|
|
182
|
-
|
|
115
|
+
const picked = (0, import_react.useMemo)(() => (0, import_accentInk.resolveAccentOnSurface)({
|
|
183
116
|
identity: candidates,
|
|
184
117
|
accentSteps,
|
|
185
118
|
surfaces: [c1, c2],
|
|
@@ -187,6 +120,7 @@ function useAccentOnSurface() {
|
|
|
187
120
|
}),
|
|
188
121
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
189
122
|
[candidateKey, stepKey, c1, c2, ink]);
|
|
123
|
+
return import_tamagui.isWeb && theme.accentOnSurface?.val === picked ? "$accentOnSurface" : picked;
|
|
190
124
|
}
|
|
191
125
|
function useIdentityInkOnSurface() {
|
|
192
126
|
const {
|
|
@@ -196,7 +130,7 @@ function useIdentityInkOnSurface() {
|
|
|
196
130
|
ink
|
|
197
131
|
} = useIdentityInputs();
|
|
198
132
|
const candidateKey = candidates.join("|");
|
|
199
|
-
return (0, import_react.useMemo)(() => resolveIdentityInk({
|
|
133
|
+
return (0, import_react.useMemo)(() => (0, import_accentInk.resolveIdentityInk)({
|
|
200
134
|
candidates,
|
|
201
135
|
surfaces: [c1, c2],
|
|
202
136
|
ink
|
|
@@ -212,7 +146,7 @@ function useIdentityHue() {
|
|
|
212
146
|
ink
|
|
213
147
|
} = useIdentityInputs();
|
|
214
148
|
const candidateKey = candidates.join("|");
|
|
215
|
-
const hue = (0, import_react.useMemo)(() => pickIdentityInk(candidates, [c1, c2]),
|
|
149
|
+
const hue = (0, import_react.useMemo)(() => (0, import_accentInk.pickIdentityInk)(candidates, [c1, c2]),
|
|
216
150
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
217
151
|
[candidateKey, c1, c2]);
|
|
218
152
|
return {
|
|
@@ -259,7 +193,7 @@ function resolveActiveTabInk({
|
|
|
259
193
|
}) {
|
|
260
194
|
if (hue) return hue;
|
|
261
195
|
const solidHex = solid ? (0, import_colorRules.normalizeToHex)(solid) : null;
|
|
262
|
-
if (solidHex && chromaOf(solidHex) >= ACTIVE_TAB_CHROMA_FLOOR) {
|
|
196
|
+
if (solidHex && (0, import_accentInk.chromaOf)(solidHex) >= ACTIVE_TAB_CHROMA_FLOOR) {
|
|
263
197
|
return (0, import_colorRules.holdHueToFloor)(solidHex, surfaces, dark, import_colorRules.aaTextContrastRatio);
|
|
264
198
|
}
|
|
265
199
|
return ink;
|
|
@@ -24,10 +24,10 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
|
24
24
|
}), mod);
|
|
25
25
|
var readableColor_exports = {};
|
|
26
26
|
__export(readableColor_exports, {
|
|
27
|
-
resolveAccentOnSurface: () => resolveAccentOnSurface,
|
|
27
|
+
resolveAccentOnSurface: () => import_accentInk.resolveAccentOnSurface,
|
|
28
28
|
resolveAccentTintedSurface: () => resolveAccentTintedSurface,
|
|
29
29
|
resolveActiveTabInk: () => resolveActiveTabInk,
|
|
30
|
-
resolveIdentityInk: () => resolveIdentityInk,
|
|
30
|
+
resolveIdentityInk: () => import_accentInk.resolveIdentityInk,
|
|
31
31
|
resolveLegibleInkOn: () => resolveLegibleInkOn,
|
|
32
32
|
useAccentOnSurface: () => useAccentOnSurface,
|
|
33
33
|
useAccentTintedSurface: () => useAccentTintedSurface,
|
|
@@ -40,9 +40,9 @@ __export(readableColor_exports, {
|
|
|
40
40
|
module.exports = __toCommonJS(readableColor_exports);
|
|
41
41
|
var import_react = require("react");
|
|
42
42
|
var import_tamagui = require("tamagui");
|
|
43
|
+
var import_accentInk = require("./accentInk.native.js");
|
|
43
44
|
var import_colorRules = require("./colorRules.native.js");
|
|
44
45
|
var import_controlTiers = require("./controlTiers.native.js");
|
|
45
|
-
var import_createThemes = require("./createThemes.native.js");
|
|
46
46
|
function _type_of(obj) {
|
|
47
47
|
"@swc/helpers - typeof";
|
|
48
48
|
|
|
@@ -98,154 +98,16 @@ function useLegibleInkOn(fill_, preferred) {
|
|
|
98
98
|
return !resolved || resolved === preferredValue ? preferred : resolved;
|
|
99
99
|
}, [fill, preferred, preferredValue, paper, ink]);
|
|
100
100
|
}
|
|
101
|
-
var IDENTITY_CHROMA_FLOOR = 0.1;
|
|
102
|
-
function chromaOf(hex) {
|
|
103
|
-
var rgb = [1, 3, 5].map(function (offset) {
|
|
104
|
-
return parseInt(hex.slice(offset, offset + 2), 16) / 255;
|
|
105
|
-
});
|
|
106
|
-
return Math.max(...rgb) - Math.min(...rgb);
|
|
107
|
-
}
|
|
108
|
-
function surfaceLuminances(surfaces) {
|
|
109
|
-
var lums = [];
|
|
110
|
-
var _iteratorNormalCompletion = true,
|
|
111
|
-
_didIteratorError = false,
|
|
112
|
-
_iteratorError = void 0;
|
|
113
|
-
try {
|
|
114
|
-
for (var _iterator = surfaces[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
115
|
-
var surface = _step.value;
|
|
116
|
-
var hex = surface ? (0, import_colorRules.normalizeToHex)(surface) : null;
|
|
117
|
-
if (!hex) return null;
|
|
118
|
-
lums.push((0, import_colorRules.relativeLuminance)(hex));
|
|
119
|
-
}
|
|
120
|
-
} catch (err) {
|
|
121
|
-
_didIteratorError = true;
|
|
122
|
-
_iteratorError = err;
|
|
123
|
-
} finally {
|
|
124
|
-
try {
|
|
125
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
126
|
-
_iterator.return();
|
|
127
|
-
}
|
|
128
|
-
} finally {
|
|
129
|
-
if (_didIteratorError) {
|
|
130
|
-
throw _iteratorError;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return lums;
|
|
135
|
-
}
|
|
136
|
-
function pickIdentityInk(candidates, surfaces) {
|
|
137
|
-
var surfaceLums = surfaceLuminances(surfaces);
|
|
138
|
-
if (!surfaceLums) return void 0;
|
|
139
|
-
var best;
|
|
140
|
-
var bestChroma = IDENTITY_CHROMA_FLOOR;
|
|
141
|
-
var _iteratorNormalCompletion = true,
|
|
142
|
-
_didIteratorError = false,
|
|
143
|
-
_iteratorError = void 0;
|
|
144
|
-
try {
|
|
145
|
-
var _loop = function () {
|
|
146
|
-
var candidate = _step.value;
|
|
147
|
-
var hex = candidate ? (0, import_colorRules.normalizeToHex)(candidate) : null;
|
|
148
|
-
if (!candidate || !hex) return "continue";
|
|
149
|
-
var lum = (0, import_colorRules.relativeLuminance)(hex);
|
|
150
|
-
if (surfaceLums.some(function (surface) {
|
|
151
|
-
return (0, import_colorRules.contrastRatio)(lum, surface) < import_colorRules.aaTextContrastRatio;
|
|
152
|
-
})) return "continue";
|
|
153
|
-
var chroma = chromaOf(hex);
|
|
154
|
-
if (chroma > bestChroma) {
|
|
155
|
-
bestChroma = chroma;
|
|
156
|
-
best = candidate;
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
for (var _iterator = candidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop();
|
|
160
|
-
} catch (err) {
|
|
161
|
-
_didIteratorError = true;
|
|
162
|
-
_iteratorError = err;
|
|
163
|
-
} finally {
|
|
164
|
-
try {
|
|
165
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
166
|
-
_iterator.return();
|
|
167
|
-
}
|
|
168
|
-
} finally {
|
|
169
|
-
if (_didIteratorError) {
|
|
170
|
-
throw _iteratorError;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return best;
|
|
175
|
-
}
|
|
176
|
-
function resolveIdentityInk(param) {
|
|
177
|
-
var {
|
|
178
|
-
candidates,
|
|
179
|
-
surfaces,
|
|
180
|
-
ink
|
|
181
|
-
} = param;
|
|
182
|
-
var _pickIdentityInk;
|
|
183
|
-
return (_pickIdentityInk = pickIdentityInk(candidates, surfaces)) !== null && _pickIdentityInk !== void 0 ? _pickIdentityInk : ink;
|
|
184
|
-
}
|
|
185
|
-
function resolveAccentOnSurface(param) {
|
|
186
|
-
var {
|
|
187
|
-
identity,
|
|
188
|
-
accentSteps,
|
|
189
|
-
surfaces,
|
|
190
|
-
ink
|
|
191
|
-
} = param;
|
|
192
|
-
var hued = pickIdentityInk(identity, surfaces);
|
|
193
|
-
if (hued) return hued;
|
|
194
|
-
var surfaceLums = surfaceLuminances(surfaces);
|
|
195
|
-
if (!surfaceLums) return ink;
|
|
196
|
-
var best;
|
|
197
|
-
var bestMin = Number.POSITIVE_INFINITY;
|
|
198
|
-
var _iteratorNormalCompletion = true,
|
|
199
|
-
_didIteratorError = false,
|
|
200
|
-
_iteratorError = void 0;
|
|
201
|
-
try {
|
|
202
|
-
var _loop = function () {
|
|
203
|
-
var step = _step.value;
|
|
204
|
-
var hex = step ? (0, import_colorRules.normalizeToHex)(step) : null;
|
|
205
|
-
if (!step || !hex) return "continue";
|
|
206
|
-
var stepLum = (0, import_colorRules.relativeLuminance)(hex);
|
|
207
|
-
var min = Math.min(...surfaceLums.map(function (surface) {
|
|
208
|
-
return (0, import_colorRules.contrastRatio)(stepLum, surface);
|
|
209
|
-
}));
|
|
210
|
-
if (min >= import_colorRules.aaTextContrastRatio && min < bestMin) {
|
|
211
|
-
bestMin = min;
|
|
212
|
-
best = step;
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
for (var _iterator = accentSteps[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop();
|
|
216
|
-
} catch (err) {
|
|
217
|
-
_didIteratorError = true;
|
|
218
|
-
_iteratorError = err;
|
|
219
|
-
} finally {
|
|
220
|
-
try {
|
|
221
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
222
|
-
_iterator.return();
|
|
223
|
-
}
|
|
224
|
-
} finally {
|
|
225
|
-
if (_didIteratorError) {
|
|
226
|
-
throw _iteratorError;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return best !== null && best !== void 0 ? best : ink;
|
|
231
|
-
}
|
|
232
|
-
var accentStepKeys = Array.from({
|
|
233
|
-
length: 12
|
|
234
|
-
}, function (_, index) {
|
|
235
|
-
return `accent${index + 1}`;
|
|
236
|
-
});
|
|
237
101
|
function useIdentityInputs() {
|
|
238
102
|
var _useThemeName, _resolveTokenValue;
|
|
239
103
|
var themeName = (_useThemeName = (0, import_tamagui.useThemeName)()) !== null && _useThemeName !== void 0 ? _useThemeName : "";
|
|
240
104
|
var theme = (0, import_tamagui.useTheme)();
|
|
241
|
-
var
|
|
242
|
-
var isTint = hue !== void 0 && import_createThemes.tintHueNames.has(hue);
|
|
243
|
-
var keys = isTint ? ["color8", "color9", "color10", `${hue}11`, `${hue}12`] : accentStepKeys;
|
|
105
|
+
var keys = (0, import_accentInk.identityKeys)(themeName);
|
|
244
106
|
return {
|
|
245
107
|
candidates: keys.map(function (key) {
|
|
246
108
|
return resolveTokenValue(theme, key);
|
|
247
109
|
}),
|
|
248
|
-
accentSteps: accentStepKeys.map(function (key) {
|
|
110
|
+
accentSteps: import_accentInk.accentStepKeys.map(function (key) {
|
|
249
111
|
return resolveTokenValue(theme, key);
|
|
250
112
|
}),
|
|
251
113
|
c1: resolveTokenValue(theme, "color1"),
|
|
@@ -254,6 +116,7 @@ function useIdentityInputs() {
|
|
|
254
116
|
};
|
|
255
117
|
}
|
|
256
118
|
function useAccentOnSurface() {
|
|
119
|
+
var _theme_accentOnSurface;
|
|
257
120
|
var {
|
|
258
121
|
candidates,
|
|
259
122
|
accentSteps,
|
|
@@ -261,10 +124,11 @@ function useAccentOnSurface() {
|
|
|
261
124
|
c2,
|
|
262
125
|
ink
|
|
263
126
|
} = useIdentityInputs();
|
|
127
|
+
var theme = (0, import_tamagui.useTheme)();
|
|
264
128
|
var candidateKey = candidates.join("|");
|
|
265
129
|
var stepKey = accentSteps.join("|");
|
|
266
|
-
|
|
267
|
-
return resolveAccentOnSurface({
|
|
130
|
+
var picked = (0, import_react.useMemo)(function () {
|
|
131
|
+
return (0, import_accentInk.resolveAccentOnSurface)({
|
|
268
132
|
identity: candidates,
|
|
269
133
|
accentSteps,
|
|
270
134
|
surfaces: [c1, c2],
|
|
@@ -273,6 +137,7 @@ function useAccentOnSurface() {
|
|
|
273
137
|
},
|
|
274
138
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
275
139
|
[candidateKey, stepKey, c1, c2, ink]);
|
|
140
|
+
return import_tamagui.isWeb && ((_theme_accentOnSurface = theme.accentOnSurface) === null || _theme_accentOnSurface === void 0 ? void 0 : _theme_accentOnSurface.val) === picked ? "$accentOnSurface" : picked;
|
|
276
141
|
}
|
|
277
142
|
function useIdentityInkOnSurface() {
|
|
278
143
|
var {
|
|
@@ -283,7 +148,7 @@ function useIdentityInkOnSurface() {
|
|
|
283
148
|
} = useIdentityInputs();
|
|
284
149
|
var candidateKey = candidates.join("|");
|
|
285
150
|
return (0, import_react.useMemo)(function () {
|
|
286
|
-
return resolveIdentityInk({
|
|
151
|
+
return (0, import_accentInk.resolveIdentityInk)({
|
|
287
152
|
candidates,
|
|
288
153
|
surfaces: [c1, c2],
|
|
289
154
|
ink
|
|
@@ -301,7 +166,7 @@ function useIdentityHue() {
|
|
|
301
166
|
} = useIdentityInputs();
|
|
302
167
|
var candidateKey = candidates.join("|");
|
|
303
168
|
var hue = (0, import_react.useMemo)(function () {
|
|
304
|
-
return pickIdentityInk(candidates, [c1, c2]);
|
|
169
|
+
return (0, import_accentInk.pickIdentityInk)(candidates, [c1, c2]);
|
|
305
170
|
},
|
|
306
171
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
307
172
|
[candidateKey, c1, c2]);
|
|
@@ -365,7 +230,7 @@ function resolveActiveTabInk(param) {
|
|
|
365
230
|
} = param;
|
|
366
231
|
if (hue) return hue;
|
|
367
232
|
var solidHex = solid ? (0, import_colorRules.normalizeToHex)(solid) : null;
|
|
368
|
-
if (solidHex && chromaOf(solidHex) >= ACTIVE_TAB_CHROMA_FLOOR) {
|
|
233
|
+
if (solidHex && (0, import_accentInk.chromaOf)(solidHex) >= ACTIVE_TAB_CHROMA_FLOOR) {
|
|
369
234
|
return (0, import_colorRules.holdHueToFloor)(solidHex, surfaces, dark, import_colorRules.aaTextContrastRatio);
|
|
370
235
|
}
|
|
371
236
|
return ink;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","readableColor_exports","__export","resolveAccentOnSurface","resolveAccentTintedSurface","resolveActiveTabInk","resolveIdentityInk","resolveLegibleInkOn","useAccentOnSurface","useAccentTintedSurface","useActiveTabInk","useIdentityHue","useIdentityInkOnSurface","useLegibleInkOn","useReadableTextOn","module","exports","import_react","require","import_tamagui","import_colorRules","import_controlTiers","
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","readableColor_exports","__export","resolveAccentOnSurface","import_accentInk","resolveAccentTintedSurface","resolveActiveTabInk","resolveIdentityInk","resolveLegibleInkOn","useAccentOnSurface","useAccentTintedSurface","useActiveTabInk","useIdentityHue","useIdentityInkOnSurface","useLegibleInkOn","useReadableTextOn","module","exports","import_react","require","import_tamagui","import_colorRules","import_controlTiers","_type_of","obj","Symbol","constructor","resolveTokenValue","theme","token","_theme_key","key","startsWith","slice","val","fill_","useTheme","fill","paper","ink","useMemo","normalizeToHex","holdInkFloor","pickReadableForeground","param","preferred","fillHex","preferredHex","fillLum","relativeLuminance","contrastRatio","aaTextContrastRatio","anchor","preferredValue","resolved","useIdentityInputs","_useThemeName","_resolveTokenValue","themeName","useThemeName","keys","identityKeys","candidates","map","accentSteps","accentStepKeys","c1","c2","_theme_accentOnSurface","candidateKey","join","stepKey","picked","identity","surfaces","isWeb","accentOnSurface","hue","pickIdentityInk"],"sources":["../../../src/theme/readableColor.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,qBAAA;AAAAC,QAAA,CAAAD,qBAAA;EAAAE,sBAAA,EAAAA,CAAA,KAAAC,gBAAA,CAAAD,sBAAA;EAAAE,0BAAA,EAAAA,CAAA,KAAAA,0BAAA;EAAAC,mBAAA,EAAAA,CAAA,KAAAA,mBAAA;EAAAC,kBAAA,EAAAA,CAAA,KAAAH,gBAAA,CAAAG,kBAAA;EAAAC,mBAAA,EAAAA,CAAA,KAAAA,mBAAA;EAAAC,kBAAA,EAAAA,CAAA,KAAAA,kBAAA;EAAAC,sBAAA,EAAAA,CAAA,KAAAA,sBAAA;EAAAC,eAAA,EAAAA,CAAA,KAAAA,eAAA;EAAAC,cAAA,EAAAA,CAAA,KAAAA,cAAA;EAAAC,uBAAA,EAAAA,CAAA,KAAAA,uBAAA;EAAAC,eAAA,EAAAA,CAAA,KAAAA,eAAA;EAAAC,iBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAArB,YAAwB,CAAAK,qBAAA;AACxB,IAAAiB,YAAA,GAAAC,OAAiE;AACjE,IAAAC,cAAA,GAAAD,OAOO;AACP,IAAAf,gBAAA,GAAAe,OAQO;AACP,IAAAE,iBAAA,GAAAF,OAAgC;AAUhC,IAAAG,mBAAS,GAAAH,OACP,CACA,0BACoB;AACpB,SAAMI,QAAMA,CAAAC,GAAM;EAClB,uBAAqB;;EACrB,OAAOA,GAAA,IAAO,OAAAC,MAAQ,g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1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var tintHues_exports = {};
|
|
24
|
+
__export(tintHues_exports, {
|
|
25
|
+
tintHueNames: () => tintHueNames
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(tintHues_exports);
|
|
28
|
+
const tintHueNames = /* @__PURE__ */new Set(["amber", "blue", "bronze", "brown", "crimson", "cyan", "gold", "grass", "gray", "green", "indigo", "lime", "mauve", "mint", "olive", "orange", "pink", "plum", "purple", "red", "sage", "sand", "sky", "slate", "teal", "tomato", "violet", "yellow"]);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
}), mod);
|
|
25
|
+
var tintHues_exports = {};
|
|
26
|
+
__export(tintHues_exports, {
|
|
27
|
+
tintHueNames: () => tintHueNames
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(tintHues_exports);
|
|
30
|
+
var tintHueNames = /* @__PURE__ */new Set(["amber", "blue", "bronze", "brown", "crimson", "cyan", "gold", "grass", "gray", "green", "indigo", "lime", "mauve", "mint", "olive", "orange", "pink", "plum", "purple", "red", "sage", "sand", "sky", "slate", "teal", "tomato", "violet", "yellow"]);
|
|
31
|
+
//# sourceMappingURL=tintHues.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","tintHues_exports","__export","tintHueNames","module","exports","Set"],"sources":["../../../src/theme/tintHues.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,gBAAA;AAAAC,QAAA,CAAAD,gBAAA;EAAAE,YAAA,EAAAA,CAAA,KAAAA;AAAA;AAMOC,MAAM,CAAAC,OAAA,GAAAT,YAAe,CAAAK,gBAAQ;AAAA,IAClCE,YAAA,sBAAAG,GAAA,EACA,SACA,QACA,UACA,SACA,WACA,QACA,QACA,SACA,QACA,SACA,UACA,QACA,SACA,QACA,SACA,UACA,QACA,QACA,UACA,OACA,QACA,QACA,OACA,SACA,QACA,UACA,UACD,S","ignoreList":[]}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { aaTextContrastRatio, contrastRatio, normalizeToHex, relativeLuminance } from "./colorRules.mjs";
|
|
2
|
+
import { resolveThemeThroughParents } from "./dedupeInherited.mjs";
|
|
3
|
+
import { tintHueNames } from "./tintHues.mjs";
|
|
4
|
+
const IDENTITY_CHROMA_FLOOR = 0.1;
|
|
5
|
+
function chromaOf(hex) {
|
|
6
|
+
const rgb = [1, 3, 5].map(offset => parseInt(hex.slice(offset, offset + 2), 16) / 255);
|
|
7
|
+
return Math.max(...rgb) - Math.min(...rgb);
|
|
8
|
+
}
|
|
9
|
+
function surfaceLuminances(surfaces) {
|
|
10
|
+
const lums = [];
|
|
11
|
+
for (const surface of surfaces) {
|
|
12
|
+
const hex = surface ? normalizeToHex(surface) : null;
|
|
13
|
+
if (!hex) return null;
|
|
14
|
+
lums.push(relativeLuminance(hex));
|
|
15
|
+
}
|
|
16
|
+
return lums;
|
|
17
|
+
}
|
|
18
|
+
function pickIdentityInk(candidates, surfaces) {
|
|
19
|
+
const surfaceLums = surfaceLuminances(surfaces);
|
|
20
|
+
if (!surfaceLums) return void 0;
|
|
21
|
+
let best;
|
|
22
|
+
let bestChroma = IDENTITY_CHROMA_FLOOR;
|
|
23
|
+
for (const candidate of candidates) {
|
|
24
|
+
const hex = candidate ? normalizeToHex(candidate) : null;
|
|
25
|
+
if (!candidate || !hex) continue;
|
|
26
|
+
const lum = relativeLuminance(hex);
|
|
27
|
+
if (surfaceLums.some(surface => contrastRatio(lum, surface) < aaTextContrastRatio)) continue;
|
|
28
|
+
const chroma = chromaOf(hex);
|
|
29
|
+
if (chroma > bestChroma) {
|
|
30
|
+
bestChroma = chroma;
|
|
31
|
+
best = candidate;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return best;
|
|
35
|
+
}
|
|
36
|
+
function resolveIdentityInk({
|
|
37
|
+
candidates,
|
|
38
|
+
surfaces,
|
|
39
|
+
ink
|
|
40
|
+
}) {
|
|
41
|
+
return pickIdentityInk(candidates, surfaces) ?? ink;
|
|
42
|
+
}
|
|
43
|
+
function resolveAccentOnSurface({
|
|
44
|
+
identity,
|
|
45
|
+
accentSteps,
|
|
46
|
+
surfaces,
|
|
47
|
+
ink
|
|
48
|
+
}) {
|
|
49
|
+
const hued = pickIdentityInk(identity, surfaces);
|
|
50
|
+
if (hued) return hued;
|
|
51
|
+
const surfaceLums = surfaceLuminances(surfaces);
|
|
52
|
+
if (!surfaceLums) return ink;
|
|
53
|
+
let best;
|
|
54
|
+
let bestMin = Number.POSITIVE_INFINITY;
|
|
55
|
+
for (const step of accentSteps) {
|
|
56
|
+
const hex = step ? normalizeToHex(step) : null;
|
|
57
|
+
if (!step || !hex) continue;
|
|
58
|
+
const stepLum = relativeLuminance(hex);
|
|
59
|
+
const min = Math.min(...surfaceLums.map(surface => contrastRatio(stepLum, surface)));
|
|
60
|
+
if (min >= aaTextContrastRatio && min < bestMin) {
|
|
61
|
+
bestMin = min;
|
|
62
|
+
best = step;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return best ?? ink;
|
|
66
|
+
}
|
|
67
|
+
const accentStepKeys = Array.from({
|
|
68
|
+
length: 12
|
|
69
|
+
}, (_, index) => `accent${index + 1}`);
|
|
70
|
+
function identityKeys(themeName) {
|
|
71
|
+
const hue = themeName.split("_")[1];
|
|
72
|
+
return hue !== void 0 && tintHueNames.has(hue) ? ["color8", "color9", "color10", `${hue}11`, `${hue}12`] : accentStepKeys;
|
|
73
|
+
}
|
|
74
|
+
function withAccentOnSurface(themes) {
|
|
75
|
+
return Object.fromEntries(Object.entries(themes).map(([name, theme]) => {
|
|
76
|
+
const values = resolveThemeThroughParents(themes, name);
|
|
77
|
+
if (!values.color12) return [name, theme];
|
|
78
|
+
const accentOnSurface = resolveAccentOnSurface({
|
|
79
|
+
identity: identityKeys(name).map(key => values[key]),
|
|
80
|
+
accentSteps: accentStepKeys.map(key => values[key]),
|
|
81
|
+
surfaces: [values.color1, values.color2],
|
|
82
|
+
ink: values.color12
|
|
83
|
+
});
|
|
84
|
+
return [name, {
|
|
85
|
+
...theme,
|
|
86
|
+
accentOnSurface
|
|
87
|
+
}];
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
export { accentStepKeys, chromaOf, identityKeys, pickIdentityInk, resolveAccentOnSurface, resolveIdentityInk, withAccentOnSurface };
|
|
91
|
+
//# sourceMappingURL=accentInk.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["aaTextContrastRatio","contrastRatio","normalizeToHex","relativeLuminance","resolveThemeThroughParents","tintHueNames","IDENTITY_CHROMA_FLOOR","chromaOf","hex","rgb","map","offset","parseInt","slice","Math","max","min","surfaceLuminances","surfaces","lums","surface","push","pickIdentityInk","candidates","surfaceLums","best","bestChroma","candidate","lum","some","chroma","resolveIdentityInk","ink","resolveAccentOnSurface","identity","accentSteps","hued","bestMin","Number","POSITIVE_INFINITY","step","stepLum","accentStepKeys","Array","from","length","_","index","identityKeys","themeName","hue","split","has","withAccentOnSurface","themes","Object","fromEntries","entries","name","theme","values","color12","accentOnSurface","key","color1","color2"],"sources":["../../../src/theme/accentInk.ts"],"sourcesContent":[null],"mappings":"AAAA,SACEA,mBAAA,EACAC,aAAA,EACAC,cAAA,EACAC,iBAAA,QACK;AACP,SAASC,0BAAA,QAAkC;AAC3C,SAASC,YAAA,QAAoB;AAG7B,MAAMC,qBAAA,GAAwB;AAEvB,SAASC,SAASC,GAAA,EAAqB;EAC5C,MAAMC,GAAA,GAAM,CAAC,GAAG,GAAG,CAAC,EAAEC,GAAA,CAAKC,MAAA,IAAWC,QAAA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