grommet 2.25.3 → 2.27.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/all/stories/AllComponents.js +19 -126
- package/components/Accordion/stories/CustomHeader.js +3 -1
- package/components/Avatar/Avatar.js +22 -9
- 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/CheckBox/StyledCheckBox.js +9 -5
- package/components/CheckBoxGroup/CheckBoxGroup.js +3 -2
- package/components/CheckBoxGroup/index.d.ts +2 -1
- package/components/CheckBoxGroup/propTypes.js +1 -0
- package/components/DataChart/Detail.js +3 -1
- package/components/DataTable/index.d.ts +6 -6
- package/components/DateInput/DateInput.js +1 -1
- package/components/Diagram/Diagram.js +2 -1
- package/components/Drop/stories/Inline.js +1 -1
- package/components/Drop/stories/Overflow.js +1 -1
- package/components/Drop/stories/Plain.js +1 -1
- package/components/Drop/stories/Simple.js +1 -1
- package/components/Drop/stories/Styled.js +1 -1
- 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 +125 -41
- package/components/List/index.d.ts +1 -0
- package/components/List/propTypes.js +1 -0
- package/components/List/stories/Order.js +1 -0
- package/components/List/stories/Pinned.js +37 -0
- package/components/List/stories/Selection.js +1 -0
- package/components/List/stories/onClickItem.js +1 -0
- package/components/Notification/Notification.js +2 -2
- package/components/Notification/index.d.ts +1 -1
- package/components/Notification/propTypes.js +1 -1
- package/components/Notification/stories/CustomThemed/ThemedNotification.tsx +2 -2
- package/components/RadioButton/README.md +1 -279
- package/components/RadioButton/RadioButton.js +1 -0
- package/components/Select/DefaultSelectTextInput.js +43 -0
- package/components/Select/EmptySearchOption.js +34 -0
- package/components/Select/Select.js +38 -99
- package/components/Select/SelectContainer.js +20 -60
- 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 +129 -3
- package/components/SelectMultiple/README.md +2 -0
- package/components/SelectMultiple/SelectMultiple.js +476 -0
- package/components/SelectMultiple/SelectMultipleContainer.js +483 -0
- package/components/SelectMultiple/SelectMultipleValue.js +163 -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 +104 -0
- package/components/SelectMultiple/stories/ShowSelectedInline.js +76 -0
- package/components/SelectMultiple/stories/typescript/Children.tsx +106 -0
- package/components/Sidebar/stories/Labels.js +4 -1
- package/components/TextArea/stories/NonResizable.js +1 -0
- package/components/TextArea/stories/Simple.js +1 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +8 -0
- package/es6/all/stories/AllComponents.js +21 -121
- package/es6/components/Accordion/stories/CustomHeader.js +3 -1
- package/es6/components/Avatar/Avatar.js +21 -9
- 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/CheckBox/StyledCheckBox.js +9 -5
- 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/DataChart/Detail.js +3 -1
- package/es6/components/DataTable/index.d.ts +6 -6
- package/es6/components/DateInput/DateInput.js +1 -1
- package/es6/components/Diagram/Diagram.js +2 -1
- package/es6/components/Drop/stories/Inline.js +1 -1
- package/es6/components/Drop/stories/Overflow.js +1 -1
- package/es6/components/Drop/stories/Plain.js +1 -1
- package/es6/components/Drop/stories/Simple.js +1 -1
- package/es6/components/Drop/stories/Styled.js +1 -1
- 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 +126 -42
- package/es6/components/List/index.d.ts +1 -0
- package/es6/components/List/propTypes.js +1 -0
- package/es6/components/List/stories/Order.js +1 -0
- package/es6/components/List/stories/Pinned.js +22 -0
- package/es6/components/List/stories/Selection.js +1 -0
- package/es6/components/List/stories/onClickItem.js +1 -0
- package/es6/components/Notification/Notification.js +2 -2
- package/es6/components/Notification/index.d.ts +1 -1
- package/es6/components/Notification/propTypes.js +1 -1
- package/es6/components/Notification/stories/CustomThemed/ThemedNotification.tsx +2 -2
- package/es6/components/RadioButton/README.md +1 -279
- package/es6/components/RadioButton/RadioButton.js +1 -0
- package/es6/components/Select/DefaultSelectTextInput.js +31 -0
- package/es6/components/Select/EmptySearchOption.js +21 -0
- package/es6/components/Select/Select.js +34 -93
- package/es6/components/Select/SelectContainer.js +20 -59
- 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 +95 -1
- package/es6/components/SelectMultiple/README.md +2 -0
- package/es6/components/SelectMultiple/SelectMultiple.js +447 -0
- package/es6/components/SelectMultiple/SelectMultipleContainer.js +455 -0
- package/es6/components/SelectMultiple/SelectMultipleValue.js +149 -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 +88 -0
- package/es6/components/SelectMultiple/stories/ShowSelectedInline.js +61 -0
- package/es6/components/SelectMultiple/stories/typescript/Children.tsx +106 -0
- package/es6/components/Sidebar/stories/Labels.js +4 -1
- package/es6/components/TextArea/stories/NonResizable.js +1 -0
- package/es6/components/TextArea/stories/Simple.js +1 -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 +16 -5
- package/es6/themes/base.js +60 -39
- package/es6/themes/grommet.js +15 -0
- package/es6/themes/hacktoberfest2022.js +129 -0
- package/es6/themes/index.js +2 -1
- 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/es6/utils/styles.js +3 -1
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/index.d.ts +1 -0
- package/package.json +44 -41
- package/themes/base.d.ts +16 -5
- package/themes/base.js +61 -39
- package/themes/grommet.js +15 -0
- package/themes/hacktoberfest2022.js +137 -0
- package/themes/index.js +6 -2
- package/tools/grommet-babel-preset-es2015.js +1 -12
- package/tools/pack.js +1 -94
- package/tools/release-stable.js +1 -27
- package/utils/background.js +64 -12
- package/utils/general-prop-types.js +2 -0
- package/utils/index.d.ts +2 -0
- package/utils/styles.js +3 -1
package/tools/pack.js
CHANGED
|
@@ -1,94 +1 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import del from 'del';
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import cp from 'child_process';
|
|
5
|
-
import tarball from 'tarball-extract';
|
|
6
|
-
|
|
7
|
-
const packageJSON = path.resolve(__dirname, '../package.json');
|
|
8
|
-
const packageJSONAsString = fs.readFileSync(packageJSON);
|
|
9
|
-
const json = JSON.parse(packageJSONAsString);
|
|
10
|
-
if (json.dependencies) {
|
|
11
|
-
json.bundledDependencies = Object.keys(json.dependencies);
|
|
12
|
-
fs.writeFileSync(packageJSON, JSON.stringify(json, null, 2));
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
cp.exec('npm pack', (packErr) => {
|
|
17
|
-
if (packErr) {
|
|
18
|
-
throw packErr;
|
|
19
|
-
}
|
|
20
|
-
const licenseMap = {
|
|
21
|
-
name: json.name,
|
|
22
|
-
version: json.version,
|
|
23
|
-
dependencies: {
|
|
24
|
-
licenseNotFound: [],
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const tarballName = `${json.name}-${json.version}.tgz`;
|
|
29
|
-
tarball.extractTarball(tarballName, './tmp', (err) => {
|
|
30
|
-
if (err) {
|
|
31
|
-
throw err;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
fs.renameSync(
|
|
35
|
-
path.resolve(__dirname, `../${tarballName}`),
|
|
36
|
-
path.resolve(
|
|
37
|
-
__dirname,
|
|
38
|
-
`../${json.name}-${json.version}-src-with-dependecies.tgz`,
|
|
39
|
-
),
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
const dependencies = fs.readdirSync(
|
|
43
|
-
path.resolve(__dirname, '../tmp/package/node_modules'),
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
dependencies.forEach((dependency) => {
|
|
47
|
-
const dependencyPackageJSON = path.resolve(
|
|
48
|
-
__dirname,
|
|
49
|
-
`../node_modules/${dependency}/package.json`,
|
|
50
|
-
);
|
|
51
|
-
if (fs.existsSync(dependencyPackageJSON)) {
|
|
52
|
-
const contents = fs.readFileSync(dependencyPackageJSON);
|
|
53
|
-
const instance = JSON.parse(contents);
|
|
54
|
-
let license = instance.license;
|
|
55
|
-
if (!license && instance.licenses) {
|
|
56
|
-
license = instance.licenses[0];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (!license) {
|
|
60
|
-
licenseMap.dependencies.licenseNotFound.push(dependency);
|
|
61
|
-
} else if (license.type) {
|
|
62
|
-
licenseMap.dependencies[dependency] = license.type;
|
|
63
|
-
} else {
|
|
64
|
-
licenseMap.dependencies[dependency] = license;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
const dependencyLicense = path.resolve(
|
|
70
|
-
__dirname,
|
|
71
|
-
`../${json.name}-${json.version}-licenses.json`,
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
// write dependency license map
|
|
75
|
-
fs.writeFileSync(dependencyLicense, JSON.stringify(licenseMap, null, 2));
|
|
76
|
-
|
|
77
|
-
// revert original package.json
|
|
78
|
-
fs.writeFileSync(
|
|
79
|
-
packageJSON,
|
|
80
|
-
`${JSON.stringify(JSON.parse(packageJSONAsString), null, 2)}\n`,
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
del.sync(['./tmp']);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
} catch (e) {
|
|
87
|
-
console.log(e);
|
|
88
|
-
|
|
89
|
-
// revert original package.json
|
|
90
|
-
fs.writeFileSync(
|
|
91
|
-
packageJSON,
|
|
92
|
-
`${JSON.stringify(JSON.parse(packageJSONAsString), null, 2)}\n`,
|
|
93
|
-
);
|
|
94
|
-
}
|
|
1
|
+
import path from"path";import del from"del";import fs from"fs";import cp from"child_process";import tarball from"tarball-extract";const packageJSON=path.resolve(__dirname,"../package.json"),packageJSONAsString=fs.readFileSync(packageJSON),json=JSON.parse(packageJSONAsString);json.dependencies&&(json.bundledDependencies=Object.keys(json.dependencies),fs.writeFileSync(packageJSON,JSON.stringify(json,null,2)));try{cp.exec("npm pack",(e=>{if(e)throw e;const n={name:json.name,version:json.version,dependencies:{licenseNotFound:[]}},s=`${json.name}-${json.version}.tgz`;tarball.extractTarball(s,"./tmp",(e=>{if(e)throw e;fs.renameSync(path.resolve(__dirname,`../${s}`),path.resolve(__dirname,`../${json.name}-${json.version}-src-with-dependecies.tgz`)),fs.readdirSync(path.resolve(__dirname,"../tmp/package/node_modules")).forEach((e=>{const s=path.resolve(__dirname,`../node_modules/${e}/package.json`);if(fs.existsSync(s)){const a=fs.readFileSync(s),r=JSON.parse(a);let i=r.license;!i&&r.licenses&&(i=r.licenses[0]),i?i.type?n.dependencies[e]=i.type:n.dependencies[e]=i:n.dependencies.licenseNotFound.push(e)}}));const a=path.resolve(__dirname,`../${json.name}-${json.version}-licenses.json`);fs.writeFileSync(a,JSON.stringify(n,null,2)),fs.writeFileSync(packageJSON,`${JSON.stringify(JSON.parse(packageJSONAsString),null,2)}\n`),del.sync(["./tmp"])}))}))}catch(e){console.log(e),fs.writeFileSync(packageJSON,`${JSON.stringify(JSON.parse(packageJSONAsString),null,2)}\n`)}
|
package/tools/release-stable.js
CHANGED
|
@@ -1,27 +1 @@
|
|
|
1
|
-
import del from
|
|
2
|
-
import fs from 'fs-extra';
|
|
3
|
-
import git from 'simple-git/promise';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
|
|
6
|
-
const repoURL = `https://${process.env.GH_TOKEN}@github.com/grommet/grommet.git`;
|
|
7
|
-
const localFolder = path.resolve('.tmp/grommet');
|
|
8
|
-
const localDist = path.resolve('dist');
|
|
9
|
-
|
|
10
|
-
if (process.env.CI) {
|
|
11
|
-
del(localFolder).then(() => {
|
|
12
|
-
git()
|
|
13
|
-
.silent(false)
|
|
14
|
-
.clone(repoURL, localFolder)
|
|
15
|
-
.then(() => git(localFolder).checkout('stable'))
|
|
16
|
-
.then(() => del([`${localFolder}/**/*`]))
|
|
17
|
-
.then(() => fs.copy(localDist, localFolder))
|
|
18
|
-
.then(() => git(localFolder).add(['--all', '.']))
|
|
19
|
-
.then(() => git(localFolder).commit('stable updated'))
|
|
20
|
-
.then(() => git(localFolder).push('origin', 'stable'))
|
|
21
|
-
.catch((err) => console.error('failed: ', err));
|
|
22
|
-
});
|
|
23
|
-
} else {
|
|
24
|
-
console.warn(
|
|
25
|
-
'Skipping release. Release:stable task should be executed by CI only.',
|
|
26
|
-
);
|
|
27
|
-
}
|
|
1
|
+
import del from"del";import fs from"fs-extra";import git from"simple-git/promise";import path from"path";const repoURL=`https://${process.env.GH_TOKEN}@github.com/grommet/grommet.git`,localFolder=path.resolve(".tmp/grommet"),localDist=path.resolve("dist");process.env.CI?del(localFolder).then((()=>{git().silent(!1).clone(repoURL,localFolder).then((()=>git(localFolder).checkout("stable"))).then((()=>del([`${localFolder}/**/*`]))).then((()=>fs.copy(localDist,localFolder))).then((()=>git(localFolder).add(["--all","."]))).then((()=>git(localFolder).commit("stable updated"))).then((()=>git(localFolder).push("origin","stable"))).catch((e=>console.error("failed: ",e)))})):console.warn("Skipping release. Release:stable task should be executed by CI only.");
|
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, _theme$global$backgro5;
|
|
57
|
+
|
|
58
|
+
result = normalizeBackground(background.dark ? (_theme$global$backgro3 = theme.global.backgrounds) == null ? void 0 : (_theme$global$backgro4 = _theme$global$backgro3[background.image]) == null ? void 0 : _theme$global$backgro4.dark : (_theme$global$backgro5 = theme.global.backgrounds) == null ? void 0 : _theme$global$backgro5[background.image], theme) || background.image;
|
|
59
|
+
} else {
|
|
60
|
+
var _theme$global$backgro6;
|
|
61
|
+
|
|
62
|
+
var normalized = normalizeBackground((_theme$global$backgro6 = theme.global.backgrounds) == null ? void 0 : _theme$global$backgro6[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 =
|
package/utils/styles.js
CHANGED
|
@@ -13,7 +13,7 @@ var _responsive = require("./responsive");
|
|
|
13
13
|
|
|
14
14
|
var _mixins = require("./mixins");
|
|
15
15
|
|
|
16
|
-
var baseStyle = (0, _styledComponents.css)(["font-family:", ";font-size:", ";line-height:", ";font-weight:", ";", " box-sizing:border-box;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;"], function (props) {
|
|
16
|
+
var baseStyle = (0, _styledComponents.css)(["font-family:", ";font-size:", ";line-height:", ";font-weight:", ";", " ", " box-sizing:border-box;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;"], function (props) {
|
|
17
17
|
return props.theme.global.font.family;
|
|
18
18
|
}, function (props) {
|
|
19
19
|
return props.theme.global.font.size;
|
|
@@ -21,6 +21,8 @@ var baseStyle = (0, _styledComponents.css)(["font-family:", ";font-size:", ";lin
|
|
|
21
21
|
return props.theme.global.font.height;
|
|
22
22
|
}, function (props) {
|
|
23
23
|
return props.theme.global.font.weight;
|
|
24
|
+
}, function (props) {
|
|
25
|
+
return props.theme.global.font.variant && "\n font-variant:" + props.theme.global.font.variant + ";\n ";
|
|
24
26
|
}, function (props) {
|
|
25
27
|
return !props.plain && (0, _background.backgroundStyle)(props.theme.baseBackground, props.theme);
|
|
26
28
|
});
|