@learningpool/ui 1.8.0 → 1.8.2
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/components/navigation/helpers.js +15 -13
- package/package.json +1 -1
|
@@ -5,21 +5,21 @@ var DEFAULT_COLOR_ADJUST_AMOUNT = 0.1;
|
|
|
5
5
|
* @returns string
|
|
6
6
|
*/
|
|
7
7
|
export var getNavigationBackground = function (theme) {
|
|
8
|
-
var _a;
|
|
9
|
-
return (_a = theme.palette.navigation.background) !== null &&
|
|
8
|
+
var _a, _b;
|
|
9
|
+
return (_b = (_a = theme.palette.navigation) === null || _a === void 0 ? void 0 : _a.background) !== null && _b !== void 0 ? _b : theme.palette.background.paper;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
12
|
* Returns the contrast color for the navigation
|
|
13
13
|
* @returns string
|
|
14
14
|
*/
|
|
15
15
|
export var getNavigationContrastText = function (theme) {
|
|
16
|
-
var _a;
|
|
16
|
+
var _a, _b, _c, _d, _e;
|
|
17
17
|
var palette = theme.palette;
|
|
18
18
|
// Use background property if navigation properties arent set
|
|
19
|
-
if (!palette.navigation.contrastText && !palette.navigation.background) {
|
|
19
|
+
if (!((_a = palette.navigation) === null || _a === void 0 ? void 0 : _a.contrastText) && !((_b = palette.navigation) === null || _b === void 0 ? void 0 : _b.background)) {
|
|
20
20
|
return palette.getContrastText(palette.background.paper);
|
|
21
21
|
}
|
|
22
|
-
return (
|
|
22
|
+
return (_d = (_c = palette.navigation) === null || _c === void 0 ? void 0 : _c.contrastText) !== null && _d !== void 0 ? _d : palette.getContrastText((_e = palette.navigation) === null || _e === void 0 ? void 0 : _e.background);
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
25
25
|
* Return a darkened or lightened background color for the navigation
|
|
@@ -27,17 +27,18 @@ export var getNavigationContrastText = function (theme) {
|
|
|
27
27
|
* @returns string
|
|
28
28
|
*/
|
|
29
29
|
export var getOffsetNavigationBackground = function (theme, colorAdjustAmount) {
|
|
30
|
+
var _a, _b, _c, _d;
|
|
30
31
|
var palette = theme.palette;
|
|
31
32
|
var adjustAmount = colorAdjustAmount || DEFAULT_COLOR_ADJUST_AMOUNT;
|
|
32
33
|
// Use background property if navigation property isnt set
|
|
33
|
-
if (!palette.navigation.background) {
|
|
34
|
+
if (!((_a = palette.navigation) === null || _a === void 0 ? void 0 : _a.background)) {
|
|
34
35
|
return getLuminance(palette.background.paper) > 0.5
|
|
35
36
|
? darken(adjustAmount, palette.background.paper)
|
|
36
37
|
: lighten(adjustAmount, palette.background.paper);
|
|
37
38
|
}
|
|
38
|
-
return getLuminance(palette.navigation.background) > 0.5
|
|
39
|
-
? darken(adjustAmount, palette.navigation.background)
|
|
40
|
-
: lighten(adjustAmount, palette.navigation.background);
|
|
39
|
+
return getLuminance((_b = palette.navigation) === null || _b === void 0 ? void 0 : _b.background) > 0.5
|
|
40
|
+
? darken(adjustAmount, (_c = palette.navigation) === null || _c === void 0 ? void 0 : _c.background)
|
|
41
|
+
: lighten(adjustAmount, (_d = palette.navigation) === null || _d === void 0 ? void 0 : _d.background);
|
|
41
42
|
};
|
|
42
43
|
/**
|
|
43
44
|
* Return a darkened or lightened contrast color for the navigation
|
|
@@ -45,15 +46,16 @@ export var getOffsetNavigationBackground = function (theme, colorAdjustAmount) {
|
|
|
45
46
|
* @returns string
|
|
46
47
|
*/
|
|
47
48
|
export var getOffsetNavigationContrastText = function (theme, colorAdjustAmount) {
|
|
49
|
+
var _a, _b, _c, _d;
|
|
48
50
|
var palette = theme.palette;
|
|
49
51
|
var adjustAmount = colorAdjustAmount || DEFAULT_COLOR_ADJUST_AMOUNT;
|
|
50
52
|
// Use background property if navigation property isnt set
|
|
51
|
-
if (!palette.navigation.background) {
|
|
53
|
+
if (!((_a = palette.navigation) === null || _a === void 0 ? void 0 : _a.background)) {
|
|
52
54
|
return getLuminance(palette.background.paper) > 0.5
|
|
53
55
|
? palette.getContrastText(darken(adjustAmount, palette.background.paper))
|
|
54
56
|
: palette.getContrastText(lighten(adjustAmount, palette.background.paper));
|
|
55
57
|
}
|
|
56
|
-
return getLuminance(palette.navigation.background) > 0.5
|
|
57
|
-
? palette.getContrastText(darken(adjustAmount, palette.navigation.background))
|
|
58
|
-
: palette.getContrastText(lighten(adjustAmount, palette.navigation.background));
|
|
58
|
+
return getLuminance((_b = palette.navigation) === null || _b === void 0 ? void 0 : _b.background) > 0.5
|
|
59
|
+
? palette.getContrastText(darken(adjustAmount, (_c = palette.navigation) === null || _c === void 0 ? void 0 : _c.background))
|
|
60
|
+
: palette.getContrastText(lighten(adjustAmount, (_d = palette.navigation) === null || _d === void 0 ? void 0 : _d.background));
|
|
59
61
|
};
|