@codecademy/gamut-styles 17.1.1 → 17.1.2-alpha.01cdc8.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 +5 -7
- 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.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 +2 -2
- package/dist/themes/admin.js +1 -1
- package/dist/themes/core.js +14 -12
- package/dist/themes/platform.d.ts +2 -2
- 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.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
|
});
|
package/dist/ColorMode.d.ts
CHANGED
|
@@ -489,7 +489,7 @@ export declare function useCurrentMode(mode?: ColorModes): "light" | "dark";
|
|
|
489
489
|
export declare function usePrefersDarkMode(): boolean;
|
|
490
490
|
export declare const VariableProvider: import("@emotion/styled").StyledComponent<{
|
|
491
491
|
theme?: Theme | undefined;
|
|
492
|
-
as?: import("react").ElementType<any> | undefined;
|
|
492
|
+
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
493
493
|
} & {
|
|
494
494
|
p?: import("@codecademy/variance/dist/types/config").Scale<{
|
|
495
495
|
readonly property: "padding";
|
|
@@ -893,10 +893,10 @@ export declare const VariableProvider: import("@emotion/styled").StyledComponent
|
|
|
893
893
|
} & {
|
|
894
894
|
variables?: CSSObject | undefined;
|
|
895
895
|
alwaysSetVariables?: boolean | undefined;
|
|
896
|
-
}, Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style" | "slot" | "title" | "id" | "property" | "translate" | "hidden" | "children" | "className" | "prefix" | "role" | "lang" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "
|
|
897
|
-
export declare const ColorMode: import("react").ForwardRefExoticComponent<
|
|
896
|
+
}, Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style" | "rel" | "slot" | "title" | "rev" | "id" | "nonce" | "property" | "content" | "translate" | "hidden" | "children" | "className" | "prefix" | "role" | "suppressHydrationWarning" | "lang" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "accessKey" | "autoFocus" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | keyof import("react").ClassAttributes<HTMLDivElement>>, {}>;
|
|
897
|
+
export declare const ColorMode: import("react").ForwardRefExoticComponent<Omit<Omit<{
|
|
898
898
|
theme?: Theme | undefined;
|
|
899
|
-
as?: import("react").ElementType<any> | undefined;
|
|
899
|
+
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
900
900
|
} & {
|
|
901
901
|
p?: import("@codecademy/variance/dist/types/config").Scale<{
|
|
902
902
|
readonly property: "padding";
|
|
@@ -1300,6 +1300,4 @@ export declare const ColorMode: import("react").ForwardRefExoticComponent<Pick<O
|
|
|
1300
1300
|
} & {
|
|
1301
1301
|
variables?: CSSObject | undefined;
|
|
1302
1302
|
alwaysSetVariables?: boolean | undefined;
|
|
1303
|
-
} & Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style" | "slot" | "title" | "id" | "property" | "translate" | "hidden" | "children" | "className" | "prefix" | "role" | "lang" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "
|
|
1304
|
-
children?: import("react").ReactNode;
|
|
1305
|
-
}, "bg"> & ColorModeProps, "style" | "p" | "slot" | "title" | "as" | "id" | "key" | "color" | "background" | "property" | "alignContent" | "alignItems" | "alignSelf" | "backgroundImage" | "backgroundPosition" | "backgroundRepeat" | "backgroundSize" | "bottom" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridColumnEnd" | "gridColumnStart" | "gridRowEnd" | "gridRowStart" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "inset" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "opacity" | "order" | "overflowX" | "overflowY" | "position" | "right" | "rowGap" | "top" | "translate" | "verticalAlign" | "width" | "zIndex" | "border" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderStyle" | "borderTop" | "borderWidth" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "overflow" | "hidden" | "variables" | "children" | "theme" | "dimensions" | "textColor" | "borderColorX" | "borderColorY" | "borderColorLeft" | "borderColorRight" | "borderColorTop" | "borderColorBottom" | "px" | "py" | "pt" | "pb" | "pr" | "pl" | "m" | "mx" | "my" | "mt" | "mb" | "mr" | "ml" | "borderX" | "borderY" | "borderWidthX" | "borderWidthY" | "borderWidthLeft" | "borderWidthRight" | "borderWidthTop" | "borderWidthBottom" | "borderRadiusLeft" | "borderRadiusTop" | "borderRadiusBottom" | "borderRadiusRight" | "borderRadiusTopLeft" | "borderRadiusTopRight" | "borderRadiusBottomRight" | "borderRadiusBottomLeft" | "borderStyleX" | "borderStyleY" | "borderStyleLeft" | "borderStyleRight" | "borderStyleTop" | "borderStyleBottom" | "className" | "prefix" | "role" | "lang" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "placeholder" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "alwaysSetVariables" | keyof ColorModeProps> & import("react").RefAttributes<HTMLDivElement>>;
|
|
1303
|
+
} & Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style" | "rel" | "slot" | "title" | "rev" | "id" | "nonce" | "property" | "content" | "translate" | "hidden" | "children" | "className" | "prefix" | "role" | "suppressHydrationWarning" | "lang" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "accessKey" | "autoFocus" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | keyof import("react").ClassAttributes<HTMLDivElement>>, "bg"> & ColorModeProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
package/dist/ColorMode.js
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
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
1
|
import _styled from "@emotion/styled/base";
|
|
3
|
-
function
|
|
4
|
-
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; }
|
|
5
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
-
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."); }
|
|
7
|
-
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); }
|
|
8
|
-
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; }
|
|
9
|
-
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; } }
|
|
10
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
-
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; }
|
|
12
|
-
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; }
|
|
13
|
-
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; }
|
|
14
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
15
|
-
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); }
|
|
16
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
17
3
|
import { serializeTokens, variance } from '@codecademy/variance';
|
|
18
4
|
import { ThemeProvider, useTheme } from '@emotion/react';
|
|
19
5
|
import mapValues from 'lodash/mapValues';
|
|
@@ -22,26 +8,31 @@ import { createContext, forwardRef, useContext, useEffect, useMemo, useState } f
|
|
|
22
8
|
import { background, border, color, css, flex, grid, layout, positioning, space } from './variance/props';
|
|
23
9
|
import { styledOptions } from './variance/utils';
|
|
24
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
11
|
+
export const providerProps = variance.compose(layout, color, grid, flex, positioning, space, border, background);
|
|
12
|
+
export const modeColorProps = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
theme,
|
|
15
|
+
mode
|
|
16
|
+
} = _ref;
|
|
17
|
+
if (!theme || !mode || mode === theme?.mode) return {};
|
|
18
|
+
const {
|
|
19
|
+
colors
|
|
20
|
+
} = theme;
|
|
21
|
+
return serializeTokens(mapValues(theme?.modes[mode], color => colors[color]), 'color', theme).variables;
|
|
34
22
|
};
|
|
35
|
-
|
|
23
|
+
const BackgroundCurrentContext = /*#__PURE__*/createContext({
|
|
36
24
|
'background-current': undefined
|
|
37
25
|
});
|
|
38
26
|
export function useColorModes() {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
mode
|
|
42
|
-
modes
|
|
43
|
-
getColorValue
|
|
44
|
-
|
|
27
|
+
const bgCurrent = useContext(BackgroundCurrentContext);
|
|
28
|
+
const {
|
|
29
|
+
mode,
|
|
30
|
+
modes,
|
|
31
|
+
_getColorValue: getColorValue
|
|
32
|
+
} = useTheme() || {};
|
|
33
|
+
const modesCopy = {
|
|
34
|
+
...modes
|
|
35
|
+
};
|
|
45
36
|
if (bgCurrent['background-current'] && modesCopy[mode]['background-current'] !== bgCurrent['background-current']) {
|
|
46
37
|
/* sets the color to the copy of our modes object, and casts the type as the default color values for background-current.
|
|
47
38
|
we could potentially alter the Merge type utility function from createTheme, but since 'background-current' is the only exception to the type-merging rule and this is the only place we override, this seems to be a more straightforward + lower-risk solution.
|
|
@@ -49,98 +40,100 @@ export function useColorModes() {
|
|
|
49
40
|
|
|
50
41
|
modesCopy[mode]['background-current'] = bgCurrent['background-current'];
|
|
51
42
|
}
|
|
52
|
-
return [mode, modesCopy
|
|
43
|
+
return [mode, modesCopy?.[mode], modes, getColorValue];
|
|
53
44
|
}
|
|
54
45
|
export function useCurrentMode(mode) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
activeMode = _useColorModes2[0];
|
|
58
|
-
return mode !== null && mode !== void 0 ? mode : activeMode;
|
|
46
|
+
const [activeMode] = useColorModes();
|
|
47
|
+
return mode ?? activeMode;
|
|
59
48
|
}
|
|
60
49
|
export function usePrefersDarkMode() {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
prefersDarkMode = _useState2[0],
|
|
64
|
-
setPrefersDarkMode = _useState2[1];
|
|
65
|
-
useEffect(function () {
|
|
50
|
+
const [prefersDarkMode, setPrefersDarkMode] = useState(false);
|
|
51
|
+
useEffect(() => {
|
|
66
52
|
function onChange(event) {
|
|
67
53
|
setPrefersDarkMode(event.matches);
|
|
68
54
|
}
|
|
69
55
|
if (window && 'matchMedia' in window) {
|
|
70
|
-
|
|
56
|
+
const mq = window.matchMedia('(prefers-color-scheme: dark)');
|
|
71
57
|
if (mq && 'addEventListener' in mq) {
|
|
72
58
|
setPrefersDarkMode(mq.matches);
|
|
73
59
|
mq.addEventListener('change', onChange);
|
|
74
|
-
return
|
|
75
|
-
return mq.removeEventListener('change', onChange);
|
|
76
|
-
};
|
|
60
|
+
return () => mq.removeEventListener('change', onChange);
|
|
77
61
|
}
|
|
78
62
|
}
|
|
79
63
|
}, []);
|
|
80
64
|
return prefersDarkMode;
|
|
81
65
|
}
|
|
82
|
-
export
|
|
66
|
+
export const VariableProvider = /*#__PURE__*/_styled('div', _extends({}, {
|
|
83
67
|
target: "e1skjn880",
|
|
84
68
|
label: "VariableProvider"
|
|
85
|
-
}, styledOptions(['variables', 'alwaysSetVariables'])))(
|
|
86
|
-
|
|
69
|
+
}, styledOptions(['variables', 'alwaysSetVariables'])))(_ref2 => {
|
|
70
|
+
let {
|
|
71
|
+
variables
|
|
72
|
+
} = _ref2;
|
|
87
73
|
return variables;
|
|
88
74
|
}, css({
|
|
89
75
|
textColor: 'text'
|
|
90
76
|
}), providerProps, process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9Db2xvck1vZGUudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXFJZ0MiLCJmaWxlIjoiLi4vc3JjL0NvbG9yTW9kZS50c3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQge1xuICBzZXJpYWxpemVUb2tlbnMsXG4gIFN0eWxlUHJvcHMsXG4gIFRoZW1lUHJvcHMsXG4gIHZhcmlhbmNlLFxufSBmcm9tICdAY29kZWNhZGVteS92YXJpYW5jZSc7XG5pbXBvcnQgeyBDU1NPYmplY3QsIFRoZW1lLCBUaGVtZVByb3ZpZGVyLCB1c2VUaGVtZSB9IGZyb20gJ0BlbW90aW9uL3JlYWN0JztcbmltcG9ydCBzdHlsZWQgZnJvbSAnQGVtb3Rpb24vc3R5bGVkJztcbmltcG9ydCBtYXBWYWx1ZXMgZnJvbSAnbG9kYXNoL21hcFZhbHVlcyc7XG5pbXBvcnQgcGljayBmcm9tICdsb2Rhc2gvcGljayc7XG5pbXBvcnQge1xuICBDb21wb25lbnRQcm9wcyxcbiAgY3JlYXRlQ29udGV4dCxcbiAgZm9yd2FyZFJlZixcbiAgdXNlQ29udGV4dCxcbiAgdXNlRWZmZWN0LFxuICB1c2VNZW1vLFxuICB1c2VTdGF0ZSxcbn0gZnJvbSAncmVhY3QnO1xuXG5pbXBvcnQgeyB0aGVtZSBhcyBHYW11dFRoZW1lIH0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XG5cbiAgaWYgKGFjdGl2ZSA9PT0gbW9kZSkge1xuICAgIGNvbnN0IHZhcnMgPSBhbHdheXNTZXRWYXJpYWJsZXNcbiAgICAgID8gdmFyaWFibGVzXG4gICAgICA6IHBpY2sodmFyaWFibGVzLCBbJy0tY29sb3ItYmFja2dyb3VuZC1jdXJyZW50J10pO1xuXG4gICAgcmV0dXJuIChcbiAgICAgIDxCYWNrZ3JvdW5kQ3VycmVudENvbnRleHQuUHJvdmlkZXJcbiAgICAgICAgdmFsdWU9e3sgJ2JhY2tncm91bmQtY3VycmVudCc6IGJnQ3VycmVudCB9fVxuICAgICAgPlxuICAgICAgICA8VmFyaWFibGVQcm92aWRlciB7Li4ucmVzdH0gdmFyaWFibGVzPXt2YXJzfSBiZz17Y29udGV4dEJnfSByZWY9e3JlZn0gLz5cbiAgICAgIDwvQmFja2dyb3VuZEN1cnJlbnRDb250ZXh0LlByb3ZpZGVyPlxuICAgICk7XG4gIH1cblxuICByZXR1cm4gKFxuICAgIDxUaGVtZVByb3ZpZGVyIHRoZW1lPXt7IG1vZGUgfX0+XG4gICAgICA8VmFyaWFibGVQcm92aWRlclxuICAgICAgICB7Li4ucmVzdH1cbiAgICAgICAgdmFyaWFibGVzPXt2YXJpYWJsZXN9XG4gICAgICAgIGJnPXtjb250ZXh0Qmd9XG4gICAgICAgIHJlZj17cmVmfVxuICAgICAgLz5cbiAgICA8L1RoZW1lUHJvdmlkZXI+XG4gICk7XG59KTtcbiJdfQ== */");
|
|
91
|
-
export
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
77
|
+
export const ColorMode = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
78
|
+
let {
|
|
79
|
+
mode: preference,
|
|
80
|
+
alwaysSetVariables,
|
|
81
|
+
bg,
|
|
82
|
+
...rest
|
|
83
|
+
} = _ref3;
|
|
96
84
|
// checks if the user has set 'system' as their color mode preference
|
|
97
85
|
// then sets the color mode
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
86
|
+
const prefersDarkMode = usePrefersDarkMode();
|
|
87
|
+
const mode = preference === 'system' ? prefersDarkMode ? 'dark' : 'light' : preference;
|
|
88
|
+
const theme = useTheme();
|
|
89
|
+
const {
|
|
90
|
+
modes,
|
|
91
|
+
mode: active,
|
|
92
|
+
colors
|
|
93
|
+
} = theme;
|
|
94
|
+
const contextBg = bg ? 'background-current' : undefined;
|
|
105
95
|
// This makes sure the background-current context is always set to the correct color + not the semantic color name.
|
|
106
|
-
|
|
107
|
-
|
|
96
|
+
const currentParentBg = useContext(BackgroundCurrentContext);
|
|
97
|
+
const bgCurrent = bg === 'background-current' ? currentParentBg['background-current'] ? currentParentBg['background-current'] : modes[active]['background-current'] : bg;
|
|
108
98
|
|
|
109
99
|
/** Serialize color variables for the current mode
|
|
110
100
|
* 1. If all variables are required add all mode variables to the current context
|
|
111
101
|
* 2. If the user has specified a background color - set that color to the current-bg
|
|
112
102
|
* 3. If not
|
|
113
103
|
*/
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return colors[
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
104
|
+
const {
|
|
105
|
+
variables
|
|
106
|
+
} = useMemo(() => {
|
|
107
|
+
return serializeTokens(mapValues(modes[mode], (color, key) => {
|
|
108
|
+
if (key === 'background-current' && typeof bg !== 'undefined') {
|
|
109
|
+
return colors[bg];
|
|
110
|
+
}
|
|
111
|
+
return colors[color];
|
|
112
|
+
}), 'color', theme);
|
|
113
|
+
}, [colors, mode, modes, theme, bg]);
|
|
123
114
|
if (active === mode) {
|
|
124
|
-
|
|
115
|
+
const vars = alwaysSetVariables ? variables : pick(variables, ['--color-background-current']);
|
|
125
116
|
return /*#__PURE__*/_jsx(BackgroundCurrentContext.Provider, {
|
|
126
117
|
value: {
|
|
127
118
|
'background-current': bgCurrent
|
|
128
119
|
},
|
|
129
|
-
children: /*#__PURE__*/_jsx(VariableProvider,
|
|
120
|
+
children: /*#__PURE__*/_jsx(VariableProvider, {
|
|
121
|
+
...rest,
|
|
130
122
|
variables: vars,
|
|
131
123
|
bg: contextBg,
|
|
132
124
|
ref: ref
|
|
133
|
-
})
|
|
125
|
+
})
|
|
134
126
|
});
|
|
135
127
|
}
|
|
136
128
|
return /*#__PURE__*/_jsx(ThemeProvider, {
|
|
137
129
|
theme: {
|
|
138
|
-
mode
|
|
130
|
+
mode
|
|
139
131
|
},
|
|
140
|
-
children: /*#__PURE__*/_jsx(VariableProvider,
|
|
132
|
+
children: /*#__PURE__*/_jsx(VariableProvider, {
|
|
133
|
+
...rest,
|
|
141
134
|
variables: variables,
|
|
142
135
|
bg: contextBg,
|
|
143
136
|
ref: ref
|
|
144
|
-
})
|
|
137
|
+
})
|
|
145
138
|
});
|
|
146
139
|
});
|
package/dist/GamutProvider.js
CHANGED
|
@@ -5,37 +5,35 @@ import { createEmotionCache } from './cache';
|
|
|
5
5
|
import { Reboot, Typography } from './globals';
|
|
6
6
|
import { Variables } from './globals/Variables';
|
|
7
7
|
import { coreTheme } from './themes/core';
|
|
8
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
|
|
10
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
export var GamutContext = /*#__PURE__*/React.createContext({
|
|
8
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
export const GamutContext = /*#__PURE__*/React.createContext({
|
|
12
10
|
hasGlobals: false,
|
|
13
11
|
hasCache: false
|
|
14
12
|
});
|
|
15
13
|
GamutContext.displayName = 'GamutContext';
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
theme =
|
|
21
|
-
variables
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
14
|
+
export const GamutProvider = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
children,
|
|
17
|
+
cache,
|
|
18
|
+
theme = coreTheme,
|
|
19
|
+
variables,
|
|
20
|
+
useGlobals = true,
|
|
21
|
+
useCache = true
|
|
22
|
+
} = _ref;
|
|
23
|
+
const {
|
|
24
|
+
hasGlobals,
|
|
25
|
+
hasCache
|
|
26
|
+
} = useContext(GamutContext);
|
|
27
|
+
const shouldCreateCache = useCache && !hasCache;
|
|
28
|
+
const shouldInsertGlobals = useGlobals && !hasGlobals;
|
|
31
29
|
|
|
32
30
|
// Do not initialize a new cache if one has been provided as props
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
const activeCache = useRef(shouldCreateCache && (cache ?? createEmotionCache()));
|
|
32
|
+
const contextValue = {
|
|
35
33
|
hasGlobals: shouldInsertGlobals,
|
|
36
34
|
hasCache: shouldCreateCache
|
|
37
35
|
};
|
|
38
|
-
|
|
36
|
+
const globals = shouldInsertGlobals && /*#__PURE__*/_jsxs(_Fragment, {
|
|
39
37
|
children: [/*#__PURE__*/_jsx(Typography, {}), /*#__PURE__*/_jsx(Reboot, {}), /*#__PURE__*/_jsx(Variables, {
|
|
40
38
|
variables: theme._variables
|
|
41
39
|
}), variables && /*#__PURE__*/_jsx(Variables, {
|