@codecademy/gamut-styles 17.1.0 → 17.1.1-alpha.004b55.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/dist/AssetProvider.d.ts +2 -3
- package/dist/AssetProvider.js +15 -18
- package/dist/Background.d.ts +1 -1
- package/dist/Background.js +28 -45
- package/dist/ColorMode.d.ts +229 -231
- package/dist/ColorMode.js +70 -77
- package/dist/GamutProvider.js +20 -22
- package/dist/cache/createEmotionCache.js +11 -26
- package/dist/cache/stylisPlugins/focusVisible.js +4 -4
- package/dist/globals/Reboot.d.ts +1 -2
- package/dist/globals/Reboot.js +4 -6
- package/dist/globals/Typography.d.ts +1 -2
- package/dist/globals/Typography.js +18 -20
- package/dist/globals/Variables.js +12 -21
- package/dist/remoteAssets/fonts.js +8 -8
- package/dist/styles/boxShadow.js +10 -20
- package/dist/styles/fontSmoothing.d.ts +1 -1
- package/dist/styles/fontSmoothing.js +5 -7
- package/dist/styles/noSelect.js +1 -1
- package/dist/styles/pxRem.js +3 -3
- package/dist/styles/responsive.js +4 -6
- package/dist/styles/screenReaderOnly.js +2 -2
- package/dist/styles/transitionConcat.js +4 -4
- package/dist/themes/admin.d.ts +12 -12
- package/dist/themes/admin.js +1 -1
- package/dist/themes/core.d.ts +6 -6
- package/dist/themes/core.js +14 -12
- package/dist/themes/platform.d.ts +14 -14
- package/dist/themes/platform.js +1 -1
- package/dist/utilities/themed.js +4 -2
- package/dist/variables/borderRadii.js +1 -1
- package/dist/variables/colors.js +19 -18
- package/dist/variables/deprecated-colors.js +17 -16
- package/dist/variables/elements.js +1 -1
- package/dist/variables/responsive.js +4 -6
- package/dist/variables/spacing.js +1 -1
- package/dist/variables/timing.js +6 -6
- package/dist/variables/typography.js +14 -8
- package/dist/variance/config.js +49 -32
- package/dist/variance/index.js +1 -2
- package/dist/variance/props.d.ts +16 -16
- package/dist/variance/props.js +16 -16
- package/dist/variance/utils.d.ts +1 -1
- package/dist/variance/utils.js +6 -14
- package/package.json +3 -3
package/dist/AssetProvider.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const AssetProvider: () => JSX.Element;
|
|
1
|
+
export declare const createFontLinks: () => import("react/jsx-runtime").JSX.Element[];
|
|
2
|
+
export declare const AssetProvider: () => import("react/jsx-runtime").JSX.Element;
|
package/dist/AssetProvider.js
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import { webFonts } from './remoteAssets/fonts';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
export var AssetProvider = function AssetProvider() {
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
export const createFontLinks = () => webFonts.flatMap(_ref => {
|
|
4
|
+
let {
|
|
5
|
+
filePath,
|
|
6
|
+
extensions
|
|
7
|
+
} = _ref;
|
|
8
|
+
return extensions.map(ext => /*#__PURE__*/_jsx("link", {
|
|
9
|
+
rel: "preload",
|
|
10
|
+
href: `${filePath}.${ext}`,
|
|
11
|
+
crossOrigin: "anonymous",
|
|
12
|
+
as: "font",
|
|
13
|
+
type: `font/${ext}`
|
|
14
|
+
}, `${filePath}-${ext}`));
|
|
15
|
+
});
|
|
16
|
+
export const AssetProvider = () => {
|
|
20
17
|
return /*#__PURE__*/_jsx(_Fragment, {
|
|
21
18
|
children: createFontLinks()
|
|
22
19
|
});
|
package/dist/Background.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ import { ColorMode, Colors } from './ColorMode';
|
|
|
3
3
|
export interface BackgroundProps extends Omit<ComponentProps<typeof ColorMode>, 'mode' | 'alwaysSetVariables' | 'bg'> {
|
|
4
4
|
bg: Colors;
|
|
5
5
|
}
|
|
6
|
-
export declare const Background: import("react").ForwardRefExoticComponent<
|
|
6
|
+
export declare const Background: import("react").ForwardRefExoticComponent<Omit<BackgroundProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
package/dist/Background.js
CHANGED
|
@@ -1,41 +1,25 @@
|
|
|
1
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
11
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0) { ; } } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
12
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
14
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
15
1
|
import { getContrast } from 'polished';
|
|
16
2
|
import { forwardRef, useCallback, useMemo } from 'react';
|
|
17
3
|
import { ColorMode, useColorModes } from './ColorMode';
|
|
18
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
-
|
|
5
|
+
const isColorAlias = (mode, color) => {
|
|
20
6
|
return Object.keys(mode).includes(color);
|
|
21
7
|
};
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
modes = _useColorModes2[2],
|
|
30
|
-
getColorValue = _useColorModes2[3];
|
|
8
|
+
export const Background = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
9
|
+
let {
|
|
10
|
+
bg,
|
|
11
|
+
...rest
|
|
12
|
+
} = _ref;
|
|
13
|
+
const [active, activeColors, modes, getColorValue] = useColorModes();
|
|
14
|
+
|
|
31
15
|
/** If a color alias was used then look up the true color key from the active mode */
|
|
32
|
-
|
|
16
|
+
const trueColor = useMemo(() => {
|
|
33
17
|
if (isColorAlias(activeColors, bg)) {
|
|
34
18
|
return activeColors[bg];
|
|
35
19
|
}
|
|
36
20
|
return bg;
|
|
37
21
|
}, [bg, activeColors]);
|
|
38
|
-
|
|
22
|
+
const getTextContrast = useCallback(foreground => {
|
|
39
23
|
return getContrast(getColorValue(foreground), getColorValue(trueColor));
|
|
40
24
|
}, [trueColor, getColorValue]);
|
|
41
25
|
|
|
@@ -49,10 +33,12 @@ export var Background = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
49
33
|
* This does not guarantee a level of A/AA/AA compliance.
|
|
50
34
|
*/
|
|
51
35
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
36
|
+
const accessibleMode = useMemo(() => {
|
|
37
|
+
const {
|
|
38
|
+
[active]: activeMode,
|
|
39
|
+
...otherModes
|
|
40
|
+
} = modes;
|
|
41
|
+
const possibleModes = Object.entries(otherModes);
|
|
56
42
|
|
|
57
43
|
/**
|
|
58
44
|
* Reduce all remaining modes to the mode key with the highest contrast
|
|
@@ -62,25 +48,22 @@ export var Background = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
62
48
|
* it will likely fail to return a mode outside of the lightest and
|
|
63
49
|
* darkest versions.
|
|
64
50
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
text = _ref5[1].text;
|
|
72
|
-
var contrast = getTextContrast(text);
|
|
51
|
+
const [highestContrastMode] = possibleModes.reduce((_ref2, _ref3) => {
|
|
52
|
+
let [prevMode, prevContrast] = _ref2;
|
|
53
|
+
let [mode, {
|
|
54
|
+
text
|
|
55
|
+
}] = _ref3;
|
|
56
|
+
const contrast = getTextContrast(text);
|
|
73
57
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
_possibleModes$reduce2 = _slicedToArray(_possibleModes$reduce, 1),
|
|
78
|
-
highestContrastMode = _possibleModes$reduce2[0];
|
|
58
|
+
// Keep the higher contrast mode.
|
|
59
|
+
return contrast > prevContrast ? [mode, contrast] : [prevMode, prevContrast];
|
|
60
|
+
}, [active, getTextContrast(activeMode.text)]);
|
|
79
61
|
return highestContrastMode;
|
|
80
62
|
}, [modes, active, getTextContrast]);
|
|
81
|
-
return /*#__PURE__*/_jsx(ColorMode,
|
|
63
|
+
return /*#__PURE__*/_jsx(ColorMode, {
|
|
64
|
+
...rest,
|
|
82
65
|
mode: accessibleMode,
|
|
83
66
|
bg: bg,
|
|
84
67
|
ref: ref
|
|
85
|
-
})
|
|
68
|
+
});
|
|
86
69
|
});
|