grommet 2.25.3 → 2.26.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/components/Box/stories/BackgroundThemed.js +54 -0
- package/components/Box/stories/CustomThemed/ThemedBackground.tsx +176 -0
- package/components/Calendar/Calendar.js +2 -1
- package/components/CheckBoxGroup/CheckBoxGroup.js +3 -2
- package/components/CheckBoxGroup/index.d.ts +2 -1
- package/components/CheckBoxGroup/propTypes.js +1 -0
- package/components/FormField/FormField.js +1 -1
- package/components/Heading/Heading.js +31 -2
- package/components/Heading/StyledHeading.js +1 -1
- package/components/Heading/index.d.ts +1 -0
- package/components/Heading/propTypes.js +1 -0
- package/components/Heading/stories/All.js +4 -1
- package/components/List/List.js +114 -33
- package/components/List/index.d.ts +1 -0
- package/components/List/propTypes.js +1 -0
- package/components/List/stories/Pinned.js +36 -0
- package/components/Notification/stories/CustomThemed/ThemedNotification.tsx +2 -2
- package/components/Select/DefaultSelectTextInput.js +43 -0
- package/components/Select/EmptySearchOption.js +34 -0
- package/components/Select/Select.js +30 -95
- package/components/Select/SelectContainer.js +19 -59
- package/components/Select/StyledSelect.js +58 -2
- package/components/Select/index.d.ts +11 -9
- package/components/Select/propTypes.js +44 -40
- package/components/Select/utils.js +103 -3
- package/components/SelectMultiple/README.md +2 -0
- package/components/SelectMultiple/SelectMultiple.js +476 -0
- package/components/SelectMultiple/SelectMultipleContainer.js +481 -0
- package/components/SelectMultiple/SelectMultipleValue.js +166 -0
- package/components/SelectMultiple/SelectionSummary.js +104 -0
- package/components/SelectMultiple/index.d.ts +21 -0
- package/components/SelectMultiple/index.js +8 -0
- package/components/SelectMultiple/propTypes.js +28 -0
- package/components/SelectMultiple/stories/Default.js +76 -0
- package/components/SelectMultiple/stories/Disabled.js +84 -0
- package/components/SelectMultiple/stories/FormField.js +66 -0
- package/components/SelectMultiple/stories/Limited.js +68 -0
- package/components/SelectMultiple/stories/LongList.js +76 -0
- package/components/SelectMultiple/stories/ObjectOptions.js +80 -0
- package/components/SelectMultiple/stories/ShowSelectedInline.js +76 -0
- package/components/SelectMultiple/stories/typescript/Children.tsx +106 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +8 -0
- package/es6/components/Box/stories/BackgroundThemed.js +39 -0
- package/es6/components/Box/stories/CustomThemed/ThemedBackground.tsx +176 -0
- package/es6/components/Calendar/Calendar.js +2 -1
- package/es6/components/CheckBoxGroup/CheckBoxGroup.js +3 -2
- package/es6/components/CheckBoxGroup/index.d.ts +2 -1
- package/es6/components/CheckBoxGroup/propTypes.js +1 -0
- package/es6/components/FormField/FormField.js +1 -1
- package/es6/components/Heading/Heading.js +30 -3
- package/es6/components/Heading/StyledHeading.js +1 -1
- package/es6/components/Heading/index.d.ts +1 -0
- package/es6/components/Heading/propTypes.js +1 -0
- package/es6/components/Heading/stories/All.js +4 -1
- package/es6/components/List/List.js +115 -34
- package/es6/components/List/index.d.ts +1 -0
- package/es6/components/List/propTypes.js +1 -0
- package/es6/components/List/stories/Pinned.js +21 -0
- package/es6/components/Notification/stories/CustomThemed/ThemedNotification.tsx +2 -2
- package/es6/components/Select/DefaultSelectTextInput.js +31 -0
- package/es6/components/Select/EmptySearchOption.js +21 -0
- package/es6/components/Select/Select.js +26 -89
- package/es6/components/Select/SelectContainer.js +19 -58
- package/es6/components/Select/StyledSelect.js +45 -1
- package/es6/components/Select/index.d.ts +11 -9
- package/es6/components/Select/propTypes.js +41 -39
- package/es6/components/Select/utils.js +75 -1
- package/es6/components/SelectMultiple/README.md +2 -0
- package/es6/components/SelectMultiple/SelectMultiple.js +447 -0
- package/es6/components/SelectMultiple/SelectMultipleContainer.js +453 -0
- package/es6/components/SelectMultiple/SelectMultipleValue.js +152 -0
- package/es6/components/SelectMultiple/SelectionSummary.js +91 -0
- package/es6/components/SelectMultiple/index.d.ts +21 -0
- package/es6/components/SelectMultiple/index.js +1 -0
- package/es6/components/SelectMultiple/propTypes.js +18 -0
- package/es6/components/SelectMultiple/stories/Default.js +60 -0
- package/es6/components/SelectMultiple/stories/Disabled.js +68 -0
- package/es6/components/SelectMultiple/stories/FormField.js +50 -0
- package/es6/components/SelectMultiple/stories/Limited.js +53 -0
- package/es6/components/SelectMultiple/stories/LongList.js +63 -0
- package/es6/components/SelectMultiple/stories/ObjectOptions.js +64 -0
- package/es6/components/SelectMultiple/stories/ShowSelectedInline.js +61 -0
- package/es6/components/SelectMultiple/stories/typescript/Children.tsx +106 -0
- package/es6/components/index.d.ts +1 -0
- package/es6/components/index.js +1 -0
- package/es6/index.d.ts +1 -0
- package/es6/themes/base.d.ts +8 -2
- package/es6/themes/base.js +54 -38
- package/es6/themes/grommet.js +15 -0
- package/es6/utils/background.js +65 -12
- package/es6/utils/general-prop-types.js +2 -0
- package/es6/utils/index.d.ts +2 -0
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/index.d.ts +1 -0
- package/package.json +4 -3
- package/themes/base.d.ts +8 -2
- package/themes/base.js +55 -38
- package/themes/grommet.js +15 -0
- package/utils/background.js +64 -12
- package/utils/general-prop-types.js +2 -0
- package/utils/index.d.ts +2 -0
package/index.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ export * from './components/RangeSelector';
|
|
|
56
56
|
export * from './components/RoutedAnchor';
|
|
57
57
|
export * from './components/RoutedButton';
|
|
58
58
|
export * from './components/Select';
|
|
59
|
+
export * from './components/SelectMultiple';
|
|
59
60
|
export * from './components/Sidebar';
|
|
60
61
|
export * from './components/SkipLink';
|
|
61
62
|
export * from './components/SkipLinks';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "grommet",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.26.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"module": "es6/index.js",
|
|
6
6
|
"jsnext:main": "es6/index.js",
|
|
@@ -52,7 +52,8 @@
|
|
|
52
52
|
"styled-components": ">= 5.1"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"
|
|
55
|
+
"@testing-library/testcafe": "^4.4.1",
|
|
56
|
+
"grommet-icons": "^4.8.0",
|
|
56
57
|
"hoist-non-react-statics": "^3.2.0",
|
|
57
58
|
"markdown-to-jsx": "^7.1.5",
|
|
58
59
|
"prop-types": "^15.8.1"
|
|
@@ -202,7 +203,7 @@
|
|
|
202
203
|
"bundlesize": [
|
|
203
204
|
{
|
|
204
205
|
"path": "./dist/grommet.min.js",
|
|
205
|
-
"maxSize": "
|
|
206
|
+
"maxSize": "140 kB"
|
|
206
207
|
}
|
|
207
208
|
],
|
|
208
209
|
"keywords": [
|
package/themes/base.d.ts
CHANGED
|
@@ -278,6 +278,9 @@ export interface ThemeType {
|
|
|
278
278
|
duration?: string;
|
|
279
279
|
};
|
|
280
280
|
};
|
|
281
|
+
backgrounds?: {
|
|
282
|
+
[x: string]: BackgroundType | { dark?: string; light?: string };
|
|
283
|
+
};
|
|
281
284
|
borderSize?: {
|
|
282
285
|
xsmall?: string;
|
|
283
286
|
small?: string;
|
|
@@ -782,8 +785,8 @@ export interface ThemeType {
|
|
|
782
785
|
margin?: MarginType;
|
|
783
786
|
pad?: PadType;
|
|
784
787
|
};
|
|
785
|
-
checkBox
|
|
786
|
-
pad
|
|
788
|
+
checkBox?: {
|
|
789
|
+
pad?: PadType;
|
|
787
790
|
};
|
|
788
791
|
disabled?: {
|
|
789
792
|
background?: BackgroundType;
|
|
@@ -1395,6 +1398,9 @@ export interface ThemeType {
|
|
|
1395
1398
|
searchInput?: ReactComponentElement<any>;
|
|
1396
1399
|
step?: number;
|
|
1397
1400
|
};
|
|
1401
|
+
selectMultiple?: {
|
|
1402
|
+
maxInline?: number;
|
|
1403
|
+
};
|
|
1398
1404
|
skipLinks?: {
|
|
1399
1405
|
position?: LayerPositionType;
|
|
1400
1406
|
container?: BoxProps;
|
package/themes/base.js
CHANGED
|
@@ -29,6 +29,8 @@ var _Pause = require("grommet-icons/icons/Pause");
|
|
|
29
29
|
|
|
30
30
|
var _Play = require("grommet-icons/icons/Play");
|
|
31
31
|
|
|
32
|
+
var _FormPin = require("grommet-icons/icons/FormPin");
|
|
33
|
+
|
|
32
34
|
var _Previous = require("grommet-icons/icons/Previous");
|
|
33
35
|
|
|
34
36
|
var _StatusCriticalSmall = require("grommet-icons/icons/StatusCriticalSmall");
|
|
@@ -184,6 +186,7 @@ var generate = function generate(baseSpacing, scale) {
|
|
|
184
186
|
duration: '0.1s'
|
|
185
187
|
}
|
|
186
188
|
},
|
|
189
|
+
// backgrounds: undefined,
|
|
187
190
|
borderSize: {
|
|
188
191
|
xsmall: '1px',
|
|
189
192
|
small: '2px',
|
|
@@ -1163,6 +1166,13 @@ var generate = function generate(baseSpacing, scale) {
|
|
|
1163
1166
|
color: 'status-disabled',
|
|
1164
1167
|
cursor: 'default'
|
|
1165
1168
|
},
|
|
1169
|
+
pinned: {
|
|
1170
|
+
background: 'background-contrast',
|
|
1171
|
+
icon: {
|
|
1172
|
+
size: 'medium',
|
|
1173
|
+
pad: 'small'
|
|
1174
|
+
}
|
|
1175
|
+
},
|
|
1166
1176
|
pad: {
|
|
1167
1177
|
horizontal: 'medium',
|
|
1168
1178
|
vertical: 'small'
|
|
@@ -1171,7 +1181,8 @@ var generate = function generate(baseSpacing, scale) {
|
|
|
1171
1181
|
},
|
|
1172
1182
|
icons: {
|
|
1173
1183
|
down: _FormDown.FormDown,
|
|
1174
|
-
up: _FormUp.FormUp
|
|
1184
|
+
up: _FormUp.FormUp,
|
|
1185
|
+
pin: _FormPin.FormPin
|
|
1175
1186
|
} // extend: undefined,
|
|
1176
1187
|
|
|
1177
1188
|
},
|
|
@@ -1257,6 +1268,7 @@ var generate = function generate(baseSpacing, scale) {
|
|
|
1257
1268
|
direction: 'column',
|
|
1258
1269
|
container: {
|
|
1259
1270
|
// any box props
|
|
1271
|
+
round: 'xsmall',
|
|
1260
1272
|
pad: {
|
|
1261
1273
|
horizontal: 'small',
|
|
1262
1274
|
vertical: 'xsmall'
|
|
@@ -1269,6 +1281,7 @@ var generate = function generate(baseSpacing, scale) {
|
|
|
1269
1281
|
direction: 'row',
|
|
1270
1282
|
container: {
|
|
1271
1283
|
// any box props
|
|
1284
|
+
round: 'none',
|
|
1272
1285
|
pad: {
|
|
1273
1286
|
horizontal: 'large',
|
|
1274
1287
|
vertical: 'xsmall'
|
|
@@ -1280,7 +1293,6 @@ var generate = function generate(baseSpacing, scale) {
|
|
|
1280
1293
|
container: {
|
|
1281
1294
|
// any box props
|
|
1282
1295
|
elevation: 'medium',
|
|
1283
|
-
round: 'xsmall',
|
|
1284
1296
|
width: 'medium'
|
|
1285
1297
|
},
|
|
1286
1298
|
layer: {
|
|
@@ -1313,58 +1325,60 @@ var generate = function generate(baseSpacing, scale) {
|
|
|
1313
1325
|
},
|
|
1314
1326
|
critical: {
|
|
1315
1327
|
icon: _StatusCriticalSmall.StatusCriticalSmall,
|
|
1316
|
-
|
|
1328
|
+
background: {
|
|
1329
|
+
color: 'status-critical',
|
|
1330
|
+
opacity: 'weak'
|
|
1331
|
+
},
|
|
1317
1332
|
color: 'status-critical',
|
|
1318
|
-
global: {
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
}
|
|
1323
|
-
} // toast: {},
|
|
1324
|
-
|
|
1333
|
+
// global: {},
|
|
1334
|
+
toast: {
|
|
1335
|
+
background: 'background-front'
|
|
1336
|
+
}
|
|
1325
1337
|
},
|
|
1326
1338
|
warning: {
|
|
1327
1339
|
icon: _StatusWarningSmall.StatusWarningSmall,
|
|
1328
|
-
|
|
1340
|
+
background: {
|
|
1341
|
+
color: 'status-warning',
|
|
1342
|
+
opacity: 'weak'
|
|
1343
|
+
},
|
|
1329
1344
|
color: 'status-warning',
|
|
1330
|
-
global: {
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
}
|
|
1335
|
-
} // toast: {},
|
|
1336
|
-
|
|
1345
|
+
// global: {},
|
|
1346
|
+
toast: {
|
|
1347
|
+
background: 'background-front'
|
|
1348
|
+
}
|
|
1337
1349
|
},
|
|
1338
1350
|
normal: {
|
|
1339
1351
|
icon: _StatusGoodSmall.StatusGoodSmall,
|
|
1340
|
-
|
|
1352
|
+
background: {
|
|
1353
|
+
color: 'status-ok',
|
|
1354
|
+
opacity: 'weak'
|
|
1355
|
+
},
|
|
1341
1356
|
color: 'status-ok',
|
|
1342
|
-
global: {
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
}
|
|
1347
|
-
} // toast: {},
|
|
1348
|
-
|
|
1357
|
+
// global: {},
|
|
1358
|
+
toast: {
|
|
1359
|
+
background: 'background-front'
|
|
1360
|
+
}
|
|
1349
1361
|
},
|
|
1350
1362
|
info: {
|
|
1351
1363
|
icon: _CircleInformation.CircleInformation,
|
|
1352
|
-
|
|
1353
|
-
color: 'text-strong'
|
|
1354
|
-
//
|
|
1355
|
-
|
|
1364
|
+
background: 'background-contrast',
|
|
1365
|
+
color: 'text-strong',
|
|
1366
|
+
// global: {},
|
|
1367
|
+
toast: {
|
|
1368
|
+
background: 'background-front'
|
|
1369
|
+
}
|
|
1356
1370
|
},
|
|
1357
1371
|
unknown: {
|
|
1358
1372
|
icon: _StatusUnknownSmall.StatusUnknownSmall,
|
|
1359
|
-
|
|
1373
|
+
background: {
|
|
1374
|
+
color: 'status-unknown',
|
|
1375
|
+
opacity: 'weak'
|
|
1376
|
+
},
|
|
1360
1377
|
color: 'status-unknown',
|
|
1361
|
-
global: {
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
}
|
|
1366
|
-
} // toast: {},
|
|
1367
|
-
|
|
1378
|
+
// global: {},
|
|
1379
|
+
toast: {
|
|
1380
|
+
background: 'background-front'
|
|
1381
|
+
}
|
|
1368
1382
|
},
|
|
1369
1383
|
// deprecate "undefined" in v3
|
|
1370
1384
|
// and if undefined, no icon
|
|
@@ -1761,6 +1775,9 @@ var generate = function generate(baseSpacing, scale) {
|
|
|
1761
1775
|
// searchInput: undefined,
|
|
1762
1776
|
step: 20
|
|
1763
1777
|
},
|
|
1778
|
+
selectMultiple: {
|
|
1779
|
+
maxInline: 5
|
|
1780
|
+
},
|
|
1764
1781
|
skipLinks: {
|
|
1765
1782
|
position: 'top',
|
|
1766
1783
|
container: {
|
package/themes/grommet.js
CHANGED
|
@@ -15,6 +15,21 @@ var grommet = (0, _object.deepFreeze)({
|
|
|
15
15
|
dark: '#000000'
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
|
+
backgrounds: {
|
|
19
|
+
stack: {
|
|
20
|
+
color: 'light-1',
|
|
21
|
+
image: "url(https://v2.grommet.io/img/stak-hurrah.svg)"
|
|
22
|
+
},
|
|
23
|
+
'gradient-purple-blue': {
|
|
24
|
+
color: 'neutral-3',
|
|
25
|
+
image: "linear-gradient(\n #3D138D 0%, /* neutral-2 */\n #00739D 100% /* neutral-3 */\n );",
|
|
26
|
+
rotate: 145
|
|
27
|
+
},
|
|
28
|
+
'gradient-purple-gold': {
|
|
29
|
+
color: 'neutral-2',
|
|
30
|
+
image: "linear-gradient(\n #3D138D 0%, /* neutral-2 */\n #EB0F79 75%,\n #FFCA58 100% /* accent-4 */\n );"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
18
33
|
font: {
|
|
19
34
|
family: "-apple-system,\n BlinkMacSystemFont, \n \"Segoe UI\", \n Roboto, \n Oxygen, \n Ubuntu, \n Cantarell, \n \"Fira Sans\", \n \"Droid Sans\", \n \"Helvetica Neue\", \n Arial, sans-serif, \n \"Apple Color Emoji\", \n \"Segoe UI Emoji\", \n \"Segoe UI Symbol\""
|
|
20
35
|
}
|
package/utils/background.js
CHANGED
|
@@ -18,9 +18,11 @@ var evalStyle = function evalStyle(arg, theme) {
|
|
|
18
18
|
return arg;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
var normalizeBackground = function normalizeBackground(
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
var normalizeBackground = function normalizeBackground(backgroundArg, theme) {
|
|
22
|
+
var _theme$global$backgro;
|
|
23
|
+
|
|
24
|
+
var background = ((_theme$global$backgro = theme.global.backgrounds) == null ? void 0 : _theme$global$backgro[backgroundArg]) || backgroundArg;
|
|
25
|
+
var result = background; // If the background has a light or dark object, use that
|
|
24
26
|
|
|
25
27
|
if (background) {
|
|
26
28
|
if (theme.dark && background.dark && typeof background.dark !== 'boolean') {
|
|
@@ -37,6 +39,49 @@ var normalizeBackground = function normalizeBackground(background, theme) {
|
|
|
37
39
|
|
|
38
40
|
exports.normalizeBackground = normalizeBackground;
|
|
39
41
|
|
|
42
|
+
var normalizeBackgroundColor = function normalizeBackgroundColor(backgroundArg, theme) {
|
|
43
|
+
var _theme$global$backgro2;
|
|
44
|
+
|
|
45
|
+
var background = backgroundArg.color || backgroundArg;
|
|
46
|
+
var result = (0, _colors.normalizeColor)( // Background color may be defined by theme.global.backgrounds or
|
|
47
|
+
// theme.global.colors.
|
|
48
|
+
((_theme$global$backgro2 = theme.global.backgrounds) == null ? void 0 : _theme$global$backgro2[background]) || background, theme, backgroundArg.dark);
|
|
49
|
+
return result;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
var normalizeBackgroundImage = function normalizeBackgroundImage(background, theme) {
|
|
53
|
+
var result;
|
|
54
|
+
|
|
55
|
+
if (background.image) {
|
|
56
|
+
var _theme$global$backgro3, _theme$global$backgro4;
|
|
57
|
+
|
|
58
|
+
result = normalizeBackground(background.dark ? (_theme$global$backgro3 = theme.global.backgrounds) == null ? void 0 : _theme$global$backgro3[background.image].dark : (_theme$global$backgro4 = theme.global.backgrounds) == null ? void 0 : _theme$global$backgro4[background.image], theme) || background.image;
|
|
59
|
+
} else {
|
|
60
|
+
var _theme$global$backgro5;
|
|
61
|
+
|
|
62
|
+
var normalized = normalizeBackground((_theme$global$backgro5 = theme.global.backgrounds) == null ? void 0 : _theme$global$backgro5[background], theme);
|
|
63
|
+
result = typeof normalized === 'object' ? normalizeBackgroundImage(normalized, theme) : normalized;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return result;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
var rotateBackground = function rotateBackground(background, theme) {
|
|
70
|
+
var backgroundImage = normalizeBackgroundImage(background, theme);
|
|
71
|
+
var result = backgroundImage;
|
|
72
|
+
|
|
73
|
+
if (backgroundImage.lastIndexOf('linear-gradient', 0) === 0) {
|
|
74
|
+
var regex = /\d{1,}deg\b,/gm; // Contains rotation specified in degrees. Only targets 'deg' string with a trailing comma. Do not match 'deg' string for hsl, etc..
|
|
75
|
+
|
|
76
|
+
result = backgroundImage.lastIndexOf('deg,') >= 0 ? backgroundImage.replace(regex, background.rotate + "deg,") : backgroundImage.replace('linear-gradient(', "linear-gradient(" + background.rotate + "deg, ");
|
|
77
|
+
} else {
|
|
78
|
+
console.warn( // eslint-disable-next-line max-len
|
|
79
|
+
"'background.rotate' property only supports 'background.image' containing a linear-gradient string.");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return result;
|
|
83
|
+
};
|
|
84
|
+
|
|
40
85
|
var backgroundIsDark = function backgroundIsDark(backgroundArg, theme) {
|
|
41
86
|
var background = normalizeBackground(backgroundArg, theme);
|
|
42
87
|
var result;
|
|
@@ -96,7 +141,7 @@ var backgroundAndTextColors = function backgroundAndTextColors(backgroundArg, te
|
|
|
96
141
|
}
|
|
97
142
|
|
|
98
143
|
if (background.color) {
|
|
99
|
-
var color = (
|
|
144
|
+
var color = normalizeBackgroundColor(background, theme);
|
|
100
145
|
var opacity = background.opacity === true ? global.opacity.medium : global.opacity[background.opacity] || background.opacity;
|
|
101
146
|
backgroundColor = (0, _colors.getRGBA)(color, opacity) || color; // If we don't have a textColor already, and we aren't too translucent,
|
|
102
147
|
// set the textColor to have the best contrast against the background
|
|
@@ -108,7 +153,7 @@ var backgroundAndTextColors = function backgroundAndTextColors(backgroundArg, te
|
|
|
108
153
|
}
|
|
109
154
|
}
|
|
110
155
|
} else {
|
|
111
|
-
backgroundColor = (
|
|
156
|
+
backgroundColor = normalizeBackgroundColor(background, theme);
|
|
112
157
|
|
|
113
158
|
var _shade = darkContext(backgroundColor, theme);
|
|
114
159
|
|
|
@@ -134,21 +179,28 @@ var backgroundStyle = function backgroundStyle(backgroundArg, theme, textColorAr
|
|
|
134
179
|
if (backgroundArg === undefined) return undefined;
|
|
135
180
|
var background = normalizeBackground(backgroundArg, theme);
|
|
136
181
|
|
|
137
|
-
if (typeof background === 'string' && background.lastIndexOf('url', 0) === 0) {
|
|
138
|
-
return (0, _styledComponents.css)(["background:", " no-repeat center center;background-size:cover;"], background);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
182
|
var _backgroundAndTextCol = backgroundAndTextColors(background, textColorArg, theme),
|
|
142
183
|
backgroundColor = _backgroundAndTextCol[0],
|
|
143
184
|
textColor = _backgroundAndTextCol[1];
|
|
144
185
|
|
|
145
|
-
|
|
146
|
-
|
|
186
|
+
var backgroundImage = background.rotate ? rotateBackground(background, theme) : normalizeBackgroundImage(background, theme);
|
|
187
|
+
var backgroundClipStyle = '';
|
|
188
|
+
|
|
189
|
+
if (background.clip) {
|
|
190
|
+
backgroundClipStyle = background.clip === 'text' ? "-webkit-text-fill-color: transparent; \n -webkit-background-clip: text; \n background-clip: text;" : "background-clip: " + background.clip + ";";
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (typeof background === 'string' && background.lastIndexOf('url', 0) === 0) {
|
|
194
|
+
return (0, _styledComponents.css)(["background:", " no-repeat center center;background-size:cover;"], background);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (backgroundImage) {
|
|
198
|
+
var backgroundStyles = "\n " + (backgroundColor ? "background-color: " + backgroundColor + ";" : '') + "\n background-image: " + backgroundImage + ";\n background-repeat: " + (typeof background === 'object' && background.repeat || 'no-repeat') + ";\n background-position: " + (background.position || 'center center') + ";\n background-size: " + (background.size || 'cover') + ";\n " + backgroundClipStyle + "\n "; // allow both background color and image, in case the image doesn't fill
|
|
147
199
|
// when image and opacity are used together, we need to use pseudo :before
|
|
148
200
|
// to ensure that only image and background color are affected by opacity
|
|
149
201
|
// but not the container contents
|
|
150
202
|
|
|
151
|
-
return (0, _styledComponents.css)(["", " ", ""], textColor ? "color: " + textColor + ";" : '', !background.opacity ? backgroundStyles : "position: relative;\n z-index: 0;\n &:before {\n content: '';\n position: absolute;\n top: 0;\n right: 0;\n left: 0;\n bottom: 0;\n z-index: -1;\n " + backgroundStyles + "\n opacity: " + (background.opacity === true ? theme.global.opacity.medium : theme.global.opacity[background.opacity] || background.opacity) + ";\n }");
|
|
203
|
+
return (0, _styledComponents.css)(["", " ", ""], textColor ? "color: " + textColor + ";" : '', !background.opacity ? backgroundStyles : "position: relative;\n z-index: 0;\n &:before {\n content: '';\n position: absolute;\n top: 0;\n right: 0;\n left: 0;\n bottom: 0;\n z-index: -1;\n border-radius: inherit;\n " + backgroundStyles + "\n opacity: " + (background.opacity === true ? theme.global.opacity.medium : theme.global.opacity[background.opacity] || background.opacity) + ";\n }");
|
|
152
204
|
}
|
|
153
205
|
|
|
154
206
|
if (backgroundColor) {
|
|
@@ -22,12 +22,14 @@ var colorPropType = _propTypes["default"].oneOfType([_propTypes["default"].strin
|
|
|
22
22
|
exports.colorPropType = colorPropType;
|
|
23
23
|
|
|
24
24
|
var backgroundPropType = _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].shape({
|
|
25
|
+
clip: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['text']), _propTypes["default"].string]),
|
|
25
26
|
color: colorPropType,
|
|
26
27
|
dark: _propTypes["default"].oneOfType([_propTypes["default"].bool, _propTypes["default"].string]),
|
|
27
28
|
image: _propTypes["default"].string,
|
|
28
29
|
position: _propTypes["default"].string,
|
|
29
30
|
opacity: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].bool, _propTypes["default"].number, _propTypes["default"].oneOf(['weak', 'medium', 'strong'])]),
|
|
30
31
|
repeat: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['no-repeat', 'repeat']), _propTypes["default"].string]),
|
|
32
|
+
rotate: _propTypes["default"].oneOfType([_propTypes["default"].number, _propTypes["default"].string]),
|
|
31
33
|
size: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['cover', 'contain']), _propTypes["default"].string]),
|
|
32
34
|
light: _propTypes["default"].string
|
|
33
35
|
})]);
|
package/utils/index.d.ts
CHANGED
|
@@ -139,6 +139,8 @@ export interface BackgroundObject {
|
|
|
139
139
|
repeat?: 'no-repeat' | 'repeat' | string;
|
|
140
140
|
size?: 'cover' | 'contain' | string;
|
|
141
141
|
light?: string;
|
|
142
|
+
clip?: 'text' | string;
|
|
143
|
+
rotate?: number | string;
|
|
142
144
|
}
|
|
143
145
|
export type BackgroundType = string | BackgroundObject;
|
|
144
146
|
export type HoverIndicatorType =
|