@codecademy/gamut-styles 14.0.1 → 14.0.2-alpha.0e532d.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/CHANGELOG.md +8 -0
- package/dist/ColorMode.d.ts +224 -224
- package/dist/__tests__/Background.test.js +94 -0
- package/dist/__tests__/GamutProvider.test.js +90 -0
- package/dist/cache/__tests__/createEmotionCache.test.js +29 -0
- package/dist/styles/fontSmoothing.d.ts +1 -1
- package/dist/themes/__tests__/theme.test.js +8 -0
- package/dist/themes/admin.d.ts +10 -10
- package/dist/themes/core.d.ts +6 -6
- package/dist/themes/platform.d.ts +12 -12
- package/dist/utilities/__tests__/themed.test.js +29 -0
- package/dist/variance/props.d.ts +15 -15
- package/package.json +3 -3
- package/project.json +2 -2
- package/tsconfig.json +23 -3
- package/tsconfig.lib.json +28 -0
- package/tsconfig.spec.json +21 -0
- package/dist/AssetProvider.js.map +0 -1
- package/dist/Background.js.map +0 -1
- package/dist/ColorMode.js.map +0 -1
- package/dist/GamutProvider.js.map +0 -1
- package/dist/__tests__/Background-test.d.ts +0 -1
- package/dist/__tests__/GamutProvider-test.d.ts +0 -1
- package/dist/cache/__tests__/createEmotionCache-test.d.ts +0 -1
- package/dist/cache/createEmotionCache.js.map +0 -1
- package/dist/cache/index.js.map +0 -1
- package/dist/cache/stylisPlugins/focusVisible.js.map +0 -1
- package/dist/cache/stylisPlugins/index.js.map +0 -1
- package/dist/globals/Reboot.js.map +0 -1
- package/dist/globals/Typography.js.map +0 -1
- package/dist/globals/Variables.js.map +0 -1
- package/dist/globals/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/remoteAssets/fonts.js.map +0 -1
- package/dist/styles/boxShadow.js.map +0 -1
- package/dist/styles/fontSmoothing.js.map +0 -1
- package/dist/styles/index.js.map +0 -1
- package/dist/styles/noSelect.js.map +0 -1
- package/dist/styles/pxRem.js.map +0 -1
- package/dist/styles/responsive.js.map +0 -1
- package/dist/styles/screenReaderOnly.js.map +0 -1
- package/dist/styles/transitionConcat.js.map +0 -1
- package/dist/themes/__tests__/theme-test.d.ts +0 -1
- package/dist/themes/admin.js.map +0 -1
- package/dist/themes/core.js.map +0 -1
- package/dist/themes/index.js.map +0 -1
- package/dist/themes/platform.js.map +0 -1
- package/dist/utilities/__tests__/themed-test.d.ts +0 -1
- package/dist/utilities/index.js.map +0 -1
- package/dist/utilities/themed.js.map +0 -1
- package/dist/variables/colors.js.map +0 -1
- package/dist/variables/deprecated-colors.js.map +0 -1
- package/dist/variables/elements.js.map +0 -1
- package/dist/variables/index.js.map +0 -1
- package/dist/variables/responsive.js.map +0 -1
- package/dist/variables/spacing.js.map +0 -1
- package/dist/variables/timing.js.map +0 -1
- package/dist/variables/typography.js.map +0 -1
- package/dist/variance/config.js.map +0 -1
- package/dist/variance/index.js.map +0 -1
- package/dist/variance/props.js.map +0 -1
- package/dist/variance/utils.js.map +0 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { matchers } from '@emotion/jest';
|
|
2
|
+
import { ThemeProvider, useTheme } from '@emotion/react';
|
|
3
|
+
import { setupRtl as setupRtlBase } from 'component-test-setup';
|
|
4
|
+
import { overArgs } from 'lodash';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { Background } from '../Background';
|
|
7
|
+
import { coreTheme as theme } from '../themes';
|
|
8
|
+
expect.extend(matchers);
|
|
9
|
+
|
|
10
|
+
function withThemeProvider(WrappedComponent) {
|
|
11
|
+
var WithBoundaryComponent = function WithBoundaryComponent(props) {
|
|
12
|
+
return /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
13
|
+
theme: theme
|
|
14
|
+
}, /*#__PURE__*/React.createElement(WrappedComponent, props));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return WithBoundaryComponent;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var setupRtl = overArgs(setupRtlBase, withThemeProvider);
|
|
21
|
+
var renderView = setupRtl(Background, {
|
|
22
|
+
children: /*#__PURE__*/React.createElement("div", {
|
|
23
|
+
"data-testid": "content"
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
var ActiveMode = function ActiveMode() {
|
|
28
|
+
var _useTheme = useTheme(),
|
|
29
|
+
mode = _useTheme.mode;
|
|
30
|
+
|
|
31
|
+
return /*#__PURE__*/React.createElement("div", null, mode);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
describe('Background', function () {
|
|
35
|
+
it('switches the default colormode when contrast standards are not met', function () {
|
|
36
|
+
var _renderView = renderView({
|
|
37
|
+
bg: 'navy'
|
|
38
|
+
}),
|
|
39
|
+
view = _renderView.view;
|
|
40
|
+
|
|
41
|
+
expect(view.getByTestId('content').parentElement).toHaveStyleRule('--color-background-current', theme.colors.navy);
|
|
42
|
+
expect(view.getByTestId('content').parentElement).toHaveStyleRule('background-color', theme.colors['background-current']);
|
|
43
|
+
});
|
|
44
|
+
it('allows for changing the color mode while nested', function () {
|
|
45
|
+
var _renderView2 = renderView({
|
|
46
|
+
bg: 'navy',
|
|
47
|
+
children: /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
"data-testid": "content"
|
|
49
|
+
}, /*#__PURE__*/React.createElement(Background, {
|
|
50
|
+
bg: "beige"
|
|
51
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
52
|
+
"data-testid": "nested-content"
|
|
53
|
+
})))
|
|
54
|
+
}),
|
|
55
|
+
view = _renderView2.view;
|
|
56
|
+
|
|
57
|
+
expect(view.getByTestId('content').parentElement).toHaveStyleRule('--color-background-current', theme.colors.navy);
|
|
58
|
+
expect(view.getByTestId('nested-content').parentElement).toHaveStyleRule('--color-background-current', theme.colors.beige);
|
|
59
|
+
});
|
|
60
|
+
it('updates the theme context to the current mode', function () {
|
|
61
|
+
var _renderView3 = renderView({
|
|
62
|
+
bg: 'navy',
|
|
63
|
+
children: /*#__PURE__*/React.createElement(ActiveMode, null)
|
|
64
|
+
}),
|
|
65
|
+
view = _renderView3.view;
|
|
66
|
+
|
|
67
|
+
view.getByText('dark');
|
|
68
|
+
});
|
|
69
|
+
it('does not update the theme context when the color mode has not changed', function () {
|
|
70
|
+
var _renderView4 = renderView({
|
|
71
|
+
bg: 'white',
|
|
72
|
+
children: /*#__PURE__*/React.createElement(ActiveMode, null)
|
|
73
|
+
}),
|
|
74
|
+
view = _renderView4.view;
|
|
75
|
+
|
|
76
|
+
view.getByText('light');
|
|
77
|
+
});
|
|
78
|
+
it('it sets the current background color to the specified bg', function () {
|
|
79
|
+
var _renderView5 = renderView({
|
|
80
|
+
bg: 'paleBlue'
|
|
81
|
+
}),
|
|
82
|
+
view = _renderView5.view;
|
|
83
|
+
|
|
84
|
+
expect(view.getByTestId('content').parentElement).toHaveStyleRule('--color-background-current', theme.colors.paleBlue);
|
|
85
|
+
});
|
|
86
|
+
it('it sets the current background color to the specified bg when switch modes', function () {
|
|
87
|
+
var _renderView6 = renderView({
|
|
88
|
+
bg: 'navy'
|
|
89
|
+
}),
|
|
90
|
+
view = _renderView6.view;
|
|
91
|
+
|
|
92
|
+
expect(view.getByTestId('content').parentElement).toHaveStyleRule('--color-background-current', theme.colors.navy);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import createCache from '@emotion/cache';
|
|
2
|
+
import { Global, ThemeContext } from '@emotion/react';
|
|
3
|
+
import { setupEnzyme } from 'component-test-setup';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { createEmotionCache } from '../cache';
|
|
6
|
+
import { GamutProvider } from '../GamutProvider';
|
|
7
|
+
import { coreTheme as theme } from '../themes';
|
|
8
|
+
jest.mock('../cache', function () {
|
|
9
|
+
var cacheMock = jest.fn();
|
|
10
|
+
return {
|
|
11
|
+
createEmotionCache: cacheMock
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
var renderWrapper = setupEnzyme(GamutProvider, {
|
|
15
|
+
theme: theme
|
|
16
|
+
});
|
|
17
|
+
describe(GamutProvider, function () {
|
|
18
|
+
beforeEach(function () {
|
|
19
|
+
jest.resetAllMocks();
|
|
20
|
+
});
|
|
21
|
+
it('renders with a cache by default', function () {
|
|
22
|
+
var _renderWrapper = renderWrapper(),
|
|
23
|
+
wrapper = _renderWrapper.wrapper;
|
|
24
|
+
|
|
25
|
+
expect(wrapper).toBeDefined();
|
|
26
|
+
expect(createEmotionCache).toHaveBeenCalled();
|
|
27
|
+
});
|
|
28
|
+
it('does not create a cache when configured not to', function () {
|
|
29
|
+
renderWrapper({
|
|
30
|
+
useCache: false
|
|
31
|
+
});
|
|
32
|
+
expect(createEmotionCache).not.toHaveBeenCalled();
|
|
33
|
+
});
|
|
34
|
+
it('renders global styles', function () {
|
|
35
|
+
var _renderWrapper2 = renderWrapper(),
|
|
36
|
+
wrapper = _renderWrapper2.wrapper;
|
|
37
|
+
|
|
38
|
+
expect(wrapper.find(Global).length).toBe(4);
|
|
39
|
+
});
|
|
40
|
+
it('does not render global styles when configured', function () {
|
|
41
|
+
var _renderWrapper3 = renderWrapper({
|
|
42
|
+
useGlobals: false
|
|
43
|
+
}),
|
|
44
|
+
wrapper = _renderWrapper3.wrapper;
|
|
45
|
+
|
|
46
|
+
expect(wrapper.find(Global).length).toBe(0);
|
|
47
|
+
});
|
|
48
|
+
it('wraps all elements in a ThemeProvider', function () {
|
|
49
|
+
var _renderWrapper4 = renderWrapper({
|
|
50
|
+
children: /*#__PURE__*/React.createElement(ThemeContext.Consumer, null, function (value) {
|
|
51
|
+
return /*#__PURE__*/React.createElement("div", null, JSON.stringify(value));
|
|
52
|
+
})
|
|
53
|
+
}),
|
|
54
|
+
wrapper = _renderWrapper4.wrapper;
|
|
55
|
+
|
|
56
|
+
expect(wrapper.find('div').text()).toBe(JSON.stringify(theme));
|
|
57
|
+
});
|
|
58
|
+
it('it can have another GamutProvider as a child with creating multiple caches or globals', function () {
|
|
59
|
+
var _renderWrapper5 = renderWrapper({
|
|
60
|
+
children: /*#__PURE__*/React.createElement(GamutProvider, {
|
|
61
|
+
theme: theme
|
|
62
|
+
})
|
|
63
|
+
}),
|
|
64
|
+
wrapper = _renderWrapper5.wrapper;
|
|
65
|
+
|
|
66
|
+
expect(createEmotionCache).toHaveBeenCalledTimes(1);
|
|
67
|
+
expect(wrapper.find(Global).length).toEqual(4);
|
|
68
|
+
});
|
|
69
|
+
it('can accept a custom cache', function () {
|
|
70
|
+
renderWrapper({
|
|
71
|
+
cache: createCache({
|
|
72
|
+
key: 'gamut'
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
expect(createEmotionCache).toHaveBeenCalledTimes(0);
|
|
76
|
+
});
|
|
77
|
+
it('can render custom variables', function () {
|
|
78
|
+
var _renderWrapper6 = renderWrapper({
|
|
79
|
+
variables: {
|
|
80
|
+
cool: {
|
|
81
|
+
'--cool': 'blue'
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}),
|
|
85
|
+
wrapper = _renderWrapper6.wrapper;
|
|
86
|
+
|
|
87
|
+
var globals = wrapper.find(Global);
|
|
88
|
+
expect(globals.length).toBe(5);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createEmotionCache } from '../createEmotionCache';
|
|
2
|
+
describe(createEmotionCache, function () {
|
|
3
|
+
beforeEach(function () {
|
|
4
|
+
document.body.innerHTML = '';
|
|
5
|
+
});
|
|
6
|
+
it('creates a container if none exists', function () {
|
|
7
|
+
var prebuild = document.getElementById('emotion-styles');
|
|
8
|
+
expect(prebuild).toBe(null);
|
|
9
|
+
createEmotionCache();
|
|
10
|
+
var container = document.getElementById('emotion-styles');
|
|
11
|
+
expect(container).toBeDefined();
|
|
12
|
+
});
|
|
13
|
+
it('creates a cache with our correct cache key', function () {
|
|
14
|
+
var cache = createEmotionCache();
|
|
15
|
+
expect(cache.key).toBe('gamut');
|
|
16
|
+
});
|
|
17
|
+
it('accepts arguments to override the default settings', function () {
|
|
18
|
+
var customContainer = document.createElement('div');
|
|
19
|
+
customContainer.setAttribute('id', 'custom');
|
|
20
|
+
document.body.appendChild(customContainer);
|
|
21
|
+
var cache = createEmotionCache({
|
|
22
|
+
key: 'custom',
|
|
23
|
+
container: customContainer
|
|
24
|
+
});
|
|
25
|
+
expect(cache.key).toBe('custom');
|
|
26
|
+
var container = document.getElementById('emotion-styles');
|
|
27
|
+
expect(container).toBe(null);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -8,7 +8,7 @@ declare const smoothing: {
|
|
|
8
8
|
MozOsxFontSmoothing: string;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
-
export declare const fontSmoothing: import("
|
|
11
|
+
export declare const fontSmoothing: import("packages/variance/dist/types/config").Parser<import("packages/variance/dist/types/config").TransformerMap<{
|
|
12
12
|
fontSmoothing: {
|
|
13
13
|
property: "fontSmooth";
|
|
14
14
|
scale: {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { adminTheme } from '../admin';
|
|
2
|
+
import { coreTheme } from '../core';
|
|
3
|
+
import { platformTheme } from '../platform';
|
|
4
|
+
describe('themes', function () {
|
|
5
|
+
it.each([['core', coreTheme], ['platform', platformTheme], ['admin', adminTheme]])("%s - theme shape", function (_, theme) {
|
|
6
|
+
return expect(theme).toMatchSnapshot();
|
|
7
|
+
});
|
|
8
|
+
});
|
package/dist/themes/admin.d.ts
CHANGED
|
@@ -4,19 +4,19 @@ export declare const adminTheme: Record<"breakpoints", {
|
|
|
4
4
|
md: string;
|
|
5
5
|
lg: string;
|
|
6
6
|
xl: string;
|
|
7
|
-
}> & import("
|
|
7
|
+
}> & import("packages/variance/dist/createTheme/types").Merge<Record<"elements", Record<"elements", import("@codecademy/variance").KeyAsVariable<{
|
|
8
8
|
readonly headerHeight: {
|
|
9
9
|
readonly base: "4rem";
|
|
10
10
|
readonly md: "5rem";
|
|
11
11
|
};
|
|
12
12
|
readonly headerZ: 15;
|
|
13
|
-
}, "elements">>> & import("
|
|
13
|
+
}, "elements">>> & import("packages/variance/dist/createTheme/types").Merge<import("packages/variance/dist/createTheme/types").MergeTheme<import("packages/variance/dist/createTheme/types").MergeTheme<Record<"breakpoints", {
|
|
14
14
|
xs: string;
|
|
15
15
|
sm: string;
|
|
16
16
|
md: string;
|
|
17
17
|
lg: string;
|
|
18
18
|
xl: string;
|
|
19
|
-
}> & import("
|
|
19
|
+
}> & import("packages/variance/dist/createTheme/types").Merge<{
|
|
20
20
|
breakpoints: {
|
|
21
21
|
xs: string;
|
|
22
22
|
sm: string;
|
|
@@ -72,7 +72,7 @@ export declare const adminTheme: Record<"breakpoints", {
|
|
|
72
72
|
};
|
|
73
73
|
readonly headerZ: 15;
|
|
74
74
|
};
|
|
75
|
-
} & import("
|
|
75
|
+
} & import("packages/variance/dist/createTheme/types").PrivateThemeKeys, Record<"colors", import("@codecademy/variance").KeyAsVariable<import("@codecademy/variance").LiteralPaths<{
|
|
76
76
|
readonly beige: "#FFF0E5";
|
|
77
77
|
readonly blue: "#1557FF";
|
|
78
78
|
readonly green: "#008A27";
|
|
@@ -131,7 +131,7 @@ export declare const adminTheme: Record<"breakpoints", {
|
|
|
131
131
|
readonly "gray-200": "#EEEEEE";
|
|
132
132
|
readonly "gray-600": "#9E9E9E";
|
|
133
133
|
readonly "gray-900": "#424242";
|
|
134
|
-
}, "-", "">, "color">>> & import("
|
|
134
|
+
}, "-", "">, "color">>> & import("packages/variance/dist/createTheme/types").PrivateThemeKeys, {
|
|
135
135
|
colors: import("@codecademy/variance").KeyAsVariable<import("@codecademy/variance").LiteralPaths<{
|
|
136
136
|
text: {
|
|
137
137
|
_: "navy-800";
|
|
@@ -274,7 +274,7 @@ export declare const adminTheme: Record<"breakpoints", {
|
|
|
274
274
|
readonly "gray-600": "#9E9E9E";
|
|
275
275
|
readonly "gray-900": "#424242";
|
|
276
276
|
}, "-", "">, "color">;
|
|
277
|
-
modes: import("
|
|
277
|
+
modes: import("packages/variance/dist/createTheme/types").Merge<unknown, {
|
|
278
278
|
light: import("@codecademy/variance").LiteralPaths<{
|
|
279
279
|
text: {
|
|
280
280
|
_: "navy-800";
|
|
@@ -436,13 +436,13 @@ export declare const adminTheme: Record<"breakpoints", {
|
|
|
436
436
|
md: string;
|
|
437
437
|
lg: string;
|
|
438
438
|
xl: string;
|
|
439
|
-
}>>, import("
|
|
439
|
+
}>>, import("packages/variance/dist/createTheme/types").PrivateThemeKeys> & import("packages/variance/dist/createTheme/types").PrivateThemeKeys, {
|
|
440
440
|
colors: import("@codecademy/variance").KeyAsVariable<import("@codecademy/variance").LiteralPaths<{
|
|
441
441
|
primary: {
|
|
442
442
|
_: "blue-500";
|
|
443
443
|
hover: "blue-400";
|
|
444
444
|
};
|
|
445
|
-
} | {}, "-", "_">, "colors"> & import("
|
|
445
|
+
} | {}, "-", "_">, "colors"> & import("packages/variance/dist/createTheme/types").Assign<import("@codecademy/variance").KeyAsVariable<import("@codecademy/variance").LiteralPaths<{
|
|
446
446
|
readonly beige: "#FFF0E5";
|
|
447
447
|
readonly blue: "#1557FF";
|
|
448
448
|
readonly green: "#008A27";
|
|
@@ -643,7 +643,7 @@ export declare const adminTheme: Record<"breakpoints", {
|
|
|
643
643
|
readonly "gray-600": "#9E9E9E";
|
|
644
644
|
readonly "gray-900": "#424242";
|
|
645
645
|
}, "-", "">, "color">>;
|
|
646
|
-
modes: import("
|
|
646
|
+
modes: import("packages/variance/dist/createTheme/types").Merge<import("packages/variance/dist/createTheme/types").Merge<unknown, {
|
|
647
647
|
light: import("@codecademy/variance").LiteralPaths<{
|
|
648
648
|
text: {
|
|
649
649
|
_: "navy-800";
|
|
@@ -798,7 +798,7 @@ export declare const adminTheme: Record<"breakpoints", {
|
|
|
798
798
|
readonly "gray-600": "#9E9E9E";
|
|
799
799
|
readonly "gray-900": "#424242";
|
|
800
800
|
}, "-"> | "text" | "background" | "primary" | "secondary" | "danger" | "interface" | "shadow-opaque" | "shadow-solid" | "text-accent" | "text-disabled" | "feedback-error" | "feedback-success" | "feedback-warning" | "background-disabled" | "background-contrast" | "background-current" | "background-primary" | "background-selected" | "background-hover" | "primary-hover" | "primary-inverse" | "secondary-hover" | "danger-hover" | "interface-hover") => string;
|
|
801
|
-
}> & import("
|
|
801
|
+
}> & import("packages/variance/dist/createTheme/types").PrivateThemeKeys;
|
|
802
802
|
export declare type AdminThemeShape = typeof adminTheme;
|
|
803
803
|
export interface AdminTheme extends AdminThemeShape {
|
|
804
804
|
}
|
package/dist/themes/core.d.ts
CHANGED
|
@@ -9,13 +9,13 @@ export declare const coreTheme: Record<"elements", Record<"elements", import("@c
|
|
|
9
9
|
readonly md: "5rem";
|
|
10
10
|
};
|
|
11
11
|
readonly headerZ: 15;
|
|
12
|
-
}, "elements">>> & import("
|
|
12
|
+
}, "elements">>> & import("packages/variance/dist/createTheme/types").Merge<import("packages/variance/dist/createTheme/types").MergeTheme<import("packages/variance/dist/createTheme/types").MergeTheme<Record<"breakpoints", {
|
|
13
13
|
xs: string;
|
|
14
14
|
sm: string;
|
|
15
15
|
md: string;
|
|
16
16
|
lg: string;
|
|
17
17
|
xl: string;
|
|
18
|
-
}> & import("
|
|
18
|
+
}> & import("packages/variance/dist/createTheme/types").Merge<{
|
|
19
19
|
breakpoints: {
|
|
20
20
|
xs: string;
|
|
21
21
|
sm: string;
|
|
@@ -71,7 +71,7 @@ export declare const coreTheme: Record<"elements", Record<"elements", import("@c
|
|
|
71
71
|
};
|
|
72
72
|
readonly headerZ: 15;
|
|
73
73
|
};
|
|
74
|
-
} & import("
|
|
74
|
+
} & import("packages/variance/dist/createTheme/types").PrivateThemeKeys, Record<"colors", import("@codecademy/variance").KeyAsVariable<import("@codecademy/variance").LiteralPaths<{
|
|
75
75
|
readonly beige: "#FFF0E5";
|
|
76
76
|
readonly blue: "#1557FF";
|
|
77
77
|
readonly green: "#008A27";
|
|
@@ -130,7 +130,7 @@ export declare const coreTheme: Record<"elements", Record<"elements", import("@c
|
|
|
130
130
|
readonly "gray-200": "#EEEEEE";
|
|
131
131
|
readonly "gray-600": "#9E9E9E";
|
|
132
132
|
readonly "gray-900": "#424242";
|
|
133
|
-
}, "-", "">, "color">>> & import("
|
|
133
|
+
}, "-", "">, "color">>> & import("packages/variance/dist/createTheme/types").PrivateThemeKeys, {
|
|
134
134
|
colors: import("@codecademy/variance").KeyAsVariable<import("@codecademy/variance").LiteralPaths<{
|
|
135
135
|
text: {
|
|
136
136
|
_: "navy-800";
|
|
@@ -273,7 +273,7 @@ export declare const coreTheme: Record<"elements", Record<"elements", import("@c
|
|
|
273
273
|
readonly "gray-600": "#9E9E9E";
|
|
274
274
|
readonly "gray-900": "#424242";
|
|
275
275
|
}, "-", "">, "color">;
|
|
276
|
-
modes: import("
|
|
276
|
+
modes: import("packages/variance/dist/createTheme/types").Merge<unknown, {
|
|
277
277
|
light: import("@codecademy/variance").LiteralPaths<{
|
|
278
278
|
text: {
|
|
279
279
|
_: "navy-800";
|
|
@@ -435,7 +435,7 @@ export declare const coreTheme: Record<"elements", Record<"elements", import("@c
|
|
|
435
435
|
md: string;
|
|
436
436
|
lg: string;
|
|
437
437
|
xl: string;
|
|
438
|
-
}>>, import("
|
|
438
|
+
}>>, import("packages/variance/dist/createTheme/types").PrivateThemeKeys> & import("packages/variance/dist/createTheme/types").PrivateThemeKeys;
|
|
439
439
|
export declare type CoreThemeShape = typeof coreTheme;
|
|
440
440
|
export interface CoreTheme extends CoreThemeShape {
|
|
441
441
|
}
|
|
@@ -8,25 +8,25 @@ export declare const platformTheme: Record<"breakpoints", {
|
|
|
8
8
|
md: string;
|
|
9
9
|
lg: string;
|
|
10
10
|
xl: string;
|
|
11
|
-
}> & import("
|
|
11
|
+
}> & import("packages/variance/dist/createTheme/types").Merge<Record<"breakpoints", {
|
|
12
12
|
xs: string;
|
|
13
13
|
sm: string;
|
|
14
14
|
md: string;
|
|
15
15
|
lg: string;
|
|
16
16
|
xl: string;
|
|
17
|
-
}> & import("
|
|
17
|
+
}> & import("packages/variance/dist/createTheme/types").Merge<Record<"elements", Record<"elements", import("@codecademy/variance").KeyAsVariable<{
|
|
18
18
|
readonly headerHeight: {
|
|
19
19
|
readonly base: "4rem";
|
|
20
20
|
readonly md: "5rem";
|
|
21
21
|
};
|
|
22
22
|
readonly headerZ: 15;
|
|
23
|
-
}, "elements">>> & import("
|
|
23
|
+
}, "elements">>> & import("packages/variance/dist/createTheme/types").Merge<import("packages/variance/dist/createTheme/types").MergeTheme<import("packages/variance/dist/createTheme/types").MergeTheme<Record<"breakpoints", {
|
|
24
24
|
xs: string;
|
|
25
25
|
sm: string;
|
|
26
26
|
md: string;
|
|
27
27
|
lg: string;
|
|
28
28
|
xl: string;
|
|
29
|
-
}> & import("
|
|
29
|
+
}> & import("packages/variance/dist/createTheme/types").Merge<{
|
|
30
30
|
breakpoints: {
|
|
31
31
|
xs: string;
|
|
32
32
|
sm: string;
|
|
@@ -82,7 +82,7 @@ export declare const platformTheme: Record<"breakpoints", {
|
|
|
82
82
|
};
|
|
83
83
|
readonly headerZ: 15;
|
|
84
84
|
};
|
|
85
|
-
} & import("
|
|
85
|
+
} & import("packages/variance/dist/createTheme/types").PrivateThemeKeys, Record<"colors", import("@codecademy/variance").KeyAsVariable<import("@codecademy/variance").LiteralPaths<{
|
|
86
86
|
readonly beige: "#FFF0E5";
|
|
87
87
|
readonly blue: "#1557FF";
|
|
88
88
|
readonly green: "#008A27";
|
|
@@ -141,7 +141,7 @@ export declare const platformTheme: Record<"breakpoints", {
|
|
|
141
141
|
readonly "gray-200": "#EEEEEE";
|
|
142
142
|
readonly "gray-600": "#9E9E9E";
|
|
143
143
|
readonly "gray-900": "#424242";
|
|
144
|
-
}, "-", "">, "color">>> & import("
|
|
144
|
+
}, "-", "">, "color">>> & import("packages/variance/dist/createTheme/types").PrivateThemeKeys, {
|
|
145
145
|
colors: import("@codecademy/variance").KeyAsVariable<import("@codecademy/variance").LiteralPaths<{
|
|
146
146
|
text: {
|
|
147
147
|
_: "navy-800";
|
|
@@ -284,7 +284,7 @@ export declare const platformTheme: Record<"breakpoints", {
|
|
|
284
284
|
readonly "gray-600": "#9E9E9E";
|
|
285
285
|
readonly "gray-900": "#424242";
|
|
286
286
|
}, "-", "">, "color">;
|
|
287
|
-
modes: import("
|
|
287
|
+
modes: import("packages/variance/dist/createTheme/types").Merge<unknown, {
|
|
288
288
|
light: import("@codecademy/variance").LiteralPaths<{
|
|
289
289
|
text: {
|
|
290
290
|
_: "navy-800";
|
|
@@ -446,7 +446,7 @@ export declare const platformTheme: Record<"breakpoints", {
|
|
|
446
446
|
md: string;
|
|
447
447
|
lg: string;
|
|
448
448
|
xl: string;
|
|
449
|
-
}>>, import("
|
|
449
|
+
}>>, import("packages/variance/dist/createTheme/types").PrivateThemeKeys> & import("packages/variance/dist/createTheme/types").PrivateThemeKeys, Record<"colors", import("@codecademy/variance").KeyAsVariable<import("@codecademy/variance").LiteralPaths<{
|
|
450
450
|
readonly lightBeige: "#FFFBF8";
|
|
451
451
|
readonly gold: "#8A7300";
|
|
452
452
|
readonly teal: "#027E97";
|
|
@@ -457,7 +457,7 @@ export declare const platformTheme: Record<"breakpoints", {
|
|
|
457
457
|
readonly "gold-800": "#8A7300";
|
|
458
458
|
readonly "teal-500": "#027E97";
|
|
459
459
|
readonly "purple-300": "#B3CCFF";
|
|
460
|
-
}, "-", "">, "color">>> & import("
|
|
460
|
+
}, "-", "">, "color">>> & import("packages/variance/dist/createTheme/types").PrivateThemeKeys, {
|
|
461
461
|
colors: import("@codecademy/variance").KeyAsVariable<import("@codecademy/variance").LiteralPaths<{
|
|
462
462
|
editor: {
|
|
463
463
|
attribute: "green-700";
|
|
@@ -518,7 +518,7 @@ export declare const platformTheme: Record<"breakpoints", {
|
|
|
518
518
|
'line-number': "gray-600";
|
|
519
519
|
};
|
|
520
520
|
};
|
|
521
|
-
}, "-", "_">, "colors"> & import("
|
|
521
|
+
}, "-", "_">, "colors"> & import("packages/variance/dist/createTheme/types").Assign<import("packages/variance/dist/createTheme/types").Assign<import("@codecademy/variance").KeyAsVariable<import("@codecademy/variance").LiteralPaths<{
|
|
522
522
|
readonly beige: "#FFF0E5";
|
|
523
523
|
readonly blue: "#1557FF";
|
|
524
524
|
readonly green: "#008A27";
|
|
@@ -730,7 +730,7 @@ export declare const platformTheme: Record<"breakpoints", {
|
|
|
730
730
|
readonly "teal-500": "#027E97";
|
|
731
731
|
readonly "purple-300": "#B3CCFF";
|
|
732
732
|
}, "-", "">, "color">>;
|
|
733
|
-
modes: import("
|
|
733
|
+
modes: import("packages/variance/dist/createTheme/types").Merge<import("packages/variance/dist/createTheme/types").Merge<unknown, {
|
|
734
734
|
light: import("@codecademy/variance").LiteralPaths<{
|
|
735
735
|
text: {
|
|
736
736
|
_: "navy-800";
|
|
@@ -951,7 +951,7 @@ export declare const platformTheme: Record<"breakpoints", {
|
|
|
951
951
|
readonly "teal-500": "#027E97";
|
|
952
952
|
readonly "purple-300": "#B3CCFF";
|
|
953
953
|
}, "-">) => string;
|
|
954
|
-
}> & import("
|
|
954
|
+
}> & import("packages/variance/dist/createTheme/types").PrivateThemeKeys;
|
|
955
955
|
export declare type PlatformThemeShape = typeof platformTheme;
|
|
956
956
|
export interface PlatformTheme extends PlatformThemeShape {
|
|
957
957
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
|
+
|
|
3
|
+
import { coreTheme } from '../../themes';
|
|
4
|
+
import { spacing } from '../../variables';
|
|
5
|
+
import { themed } from '../themed';
|
|
6
|
+
var theme = coreTheme;
|
|
7
|
+
describe('themed', function () {
|
|
8
|
+
it('returns a function', function () {
|
|
9
|
+
expect(_typeof(themed('colors.blue-300'))).toBe('function');
|
|
10
|
+
});
|
|
11
|
+
it('returned function looks up the value at the supplied path', function () {
|
|
12
|
+
var getLineHeight = themed('lineHeight.title');
|
|
13
|
+
expect(getLineHeight({
|
|
14
|
+
theme: theme
|
|
15
|
+
})).toEqual(1.1);
|
|
16
|
+
});
|
|
17
|
+
it('returned function looks up the value at the supplied path with a number', function () {
|
|
18
|
+
var getSpacing4 = themed('spacing.4');
|
|
19
|
+
expect(getSpacing4({
|
|
20
|
+
theme: theme
|
|
21
|
+
})).toEqual('0.25rem');
|
|
22
|
+
});
|
|
23
|
+
it('can return a full object', function () {
|
|
24
|
+
var getSpacing = themed('spacing');
|
|
25
|
+
expect(getSpacing({
|
|
26
|
+
theme: theme
|
|
27
|
+
})).toEqual(spacing);
|
|
28
|
+
});
|
|
29
|
+
});
|
package/dist/variance/props.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** General Prop Groups */
|
|
2
|
-
export declare const typography: import("
|
|
2
|
+
export declare const typography: import("packages/variance/dist/types/config").Parser<import("packages/variance/dist/types/config").TransformerMap<{
|
|
3
3
|
readonly fontFamily: {
|
|
4
4
|
readonly property: "fontFamily";
|
|
5
5
|
readonly scale: "fontFamily";
|
|
@@ -35,7 +35,7 @@ export declare const typography: import("@codecademy/variance/dist/types/config"
|
|
|
35
35
|
readonly property: "whiteSpace";
|
|
36
36
|
};
|
|
37
37
|
}>>;
|
|
38
|
-
export declare const grid: import("
|
|
38
|
+
export declare const grid: import("packages/variance/dist/types/config").Parser<import("packages/variance/dist/types/config").TransformerMap<{
|
|
39
39
|
readonly gridColumn: {
|
|
40
40
|
readonly property: "gridColumn";
|
|
41
41
|
};
|
|
@@ -106,7 +106,7 @@ export declare const grid: import("@codecademy/variance/dist/types/config").Pars
|
|
|
106
106
|
readonly scale: "spacing";
|
|
107
107
|
};
|
|
108
108
|
}>>;
|
|
109
|
-
export declare const flex: import("
|
|
109
|
+
export declare const flex: import("packages/variance/dist/types/config").Parser<import("packages/variance/dist/types/config").TransformerMap<{
|
|
110
110
|
readonly flexBasis: {
|
|
111
111
|
readonly property: "flexBasis";
|
|
112
112
|
};
|
|
@@ -150,7 +150,7 @@ export declare const flex: import("@codecademy/variance/dist/types/config").Pars
|
|
|
150
150
|
readonly property: "flex";
|
|
151
151
|
};
|
|
152
152
|
}>>;
|
|
153
|
-
export declare const layout: import("
|
|
153
|
+
export declare const layout: import("packages/variance/dist/types/config").Parser<import("packages/variance/dist/types/config").TransformerMap<{
|
|
154
154
|
readonly flexBasis: {
|
|
155
155
|
readonly property: "flexBasis";
|
|
156
156
|
};
|
|
@@ -235,7 +235,7 @@ export declare const layout: import("@codecademy/variance/dist/types/config").Pa
|
|
|
235
235
|
readonly property: "verticalAlign";
|
|
236
236
|
};
|
|
237
237
|
}>>;
|
|
238
|
-
export declare const positioning: import("
|
|
238
|
+
export declare const positioning: import("packages/variance/dist/types/config").Parser<import("packages/variance/dist/types/config").TransformerMap<{
|
|
239
239
|
readonly position: {
|
|
240
240
|
readonly property: "position";
|
|
241
241
|
};
|
|
@@ -267,7 +267,7 @@ export declare const positioning: import("@codecademy/variance/dist/types/config
|
|
|
267
267
|
readonly property: "opacity";
|
|
268
268
|
};
|
|
269
269
|
}>>;
|
|
270
|
-
export declare const background: import("
|
|
270
|
+
export declare const background: import("packages/variance/dist/types/config").Parser<import("packages/variance/dist/types/config").TransformerMap<{
|
|
271
271
|
readonly background: {
|
|
272
272
|
readonly property: "background";
|
|
273
273
|
};
|
|
@@ -284,7 +284,7 @@ export declare const background: import("@codecademy/variance/dist/types/config"
|
|
|
284
284
|
readonly property: "backgroundPosition";
|
|
285
285
|
};
|
|
286
286
|
}>>;
|
|
287
|
-
export declare const color: import("
|
|
287
|
+
export declare const color: import("packages/variance/dist/types/config").Parser<import("packages/variance/dist/types/config").TransformerMap<{
|
|
288
288
|
readonly color: {
|
|
289
289
|
readonly property: "color";
|
|
290
290
|
readonly scale: "colors";
|
|
@@ -328,7 +328,7 @@ export declare const color: import("@codecademy/variance/dist/types/config").Par
|
|
|
328
328
|
readonly scale: "colors";
|
|
329
329
|
};
|
|
330
330
|
}>>;
|
|
331
|
-
export declare const shadow: import("
|
|
331
|
+
export declare const shadow: import("packages/variance/dist/types/config").Parser<import("packages/variance/dist/types/config").TransformerMap<{
|
|
332
332
|
readonly boxShadow: {
|
|
333
333
|
readonly property: "boxShadow";
|
|
334
334
|
};
|
|
@@ -336,7 +336,7 @@ export declare const shadow: import("@codecademy/variance/dist/types/config").Pa
|
|
|
336
336
|
readonly property: "textShadow";
|
|
337
337
|
};
|
|
338
338
|
}>>;
|
|
339
|
-
export declare const space: import("
|
|
339
|
+
export declare const space: import("packages/variance/dist/types/config").Parser<import("packages/variance/dist/types/config").TransformerMap<{
|
|
340
340
|
readonly p: {
|
|
341
341
|
readonly property: "padding";
|
|
342
342
|
readonly scale: "spacing";
|
|
@@ -398,7 +398,7 @@ export declare const space: import("@codecademy/variance/dist/types/config").Par
|
|
|
398
398
|
readonly scale: "spacing";
|
|
399
399
|
};
|
|
400
400
|
}>>;
|
|
401
|
-
export declare const border: import("
|
|
401
|
+
export declare const border: import("packages/variance/dist/types/config").Parser<import("packages/variance/dist/types/config").TransformerMap<{
|
|
402
402
|
readonly border: {
|
|
403
403
|
readonly property: "border";
|
|
404
404
|
readonly scale: "borders";
|
|
@@ -508,7 +508,7 @@ export declare const border: import("@codecademy/variance/dist/types/config").Pa
|
|
|
508
508
|
};
|
|
509
509
|
}>>;
|
|
510
510
|
/** Sub Groups */
|
|
511
|
-
export declare const padding: import("
|
|
511
|
+
export declare const padding: import("packages/variance/dist/types/config").Parser<import("packages/variance/dist/types/config").TransformerMap<{
|
|
512
512
|
readonly p: {
|
|
513
513
|
readonly property: "padding";
|
|
514
514
|
readonly scale: "spacing";
|
|
@@ -540,7 +540,7 @@ export declare const padding: import("@codecademy/variance/dist/types/config").P
|
|
|
540
540
|
readonly scale: "spacing";
|
|
541
541
|
};
|
|
542
542
|
}>>;
|
|
543
|
-
export declare const margin: import("
|
|
543
|
+
export declare const margin: import("packages/variance/dist/types/config").Parser<import("packages/variance/dist/types/config").TransformerMap<{
|
|
544
544
|
readonly m: {
|
|
545
545
|
readonly property: "margin";
|
|
546
546
|
readonly scale: "spacing";
|
|
@@ -573,7 +573,7 @@ export declare const margin: import("@codecademy/variance/dist/types/config").Pa
|
|
|
573
573
|
};
|
|
574
574
|
}>>;
|
|
575
575
|
/** CSS */
|
|
576
|
-
export declare const css: import("
|
|
576
|
+
export declare const css: import("packages/variance/dist/types/config").CSS<import("packages/variance/dist/types/config").Parser<import("packages/variance/dist/types/config").TransformerMap<{
|
|
577
577
|
color: {
|
|
578
578
|
readonly property: "color";
|
|
579
579
|
readonly scale: "colors";
|
|
@@ -1003,7 +1003,7 @@ export declare const css: import("@codecademy/variance/dist/types/config").CSS<i
|
|
|
1003
1003
|
readonly property: "whiteSpace";
|
|
1004
1004
|
};
|
|
1005
1005
|
}>>>;
|
|
1006
|
-
export declare const variant: import("
|
|
1006
|
+
export declare const variant: import("packages/variance/dist/types/config").Variant<import("packages/variance/dist/types/config").Parser<import("packages/variance/dist/types/config").TransformerMap<{
|
|
1007
1007
|
color: {
|
|
1008
1008
|
readonly property: "color";
|
|
1009
1009
|
readonly scale: "colors";
|
|
@@ -1433,7 +1433,7 @@ export declare const variant: import("@codecademy/variance/dist/types/config").V
|
|
|
1433
1433
|
readonly property: "whiteSpace";
|
|
1434
1434
|
};
|
|
1435
1435
|
}>>>;
|
|
1436
|
-
export declare const states: import("
|
|
1436
|
+
export declare const states: import("packages/variance/dist/types/config").States<import("packages/variance/dist/types/config").Parser<import("packages/variance/dist/types/config").TransformerMap<{
|
|
1437
1437
|
color: {
|
|
1438
1438
|
readonly property: "color";
|
|
1439
1439
|
readonly scale: "colors";
|