@zendeskgarden/react-theming 8.75.1 → 8.76.1
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/esm/elements/ThemeProvider.js +38 -0
- package/dist/esm/elements/palette/index.js +149 -0
- package/dist/esm/elements/theme/index.js +127 -0
- package/dist/esm/index.js +24 -0
- package/dist/esm/types/index.js +10 -0
- package/dist/esm/utils/arrowStyles.js +64 -0
- package/dist/esm/utils/focusStyles.js +43 -0
- package/dist/esm/utils/getColorV8.js +61 -0
- package/dist/esm/utils/getDocument.js +14 -0
- package/dist/esm/utils/getFocusBoxShadow.js +34 -0
- package/dist/esm/utils/getLineHeight.js +22 -0
- package/dist/esm/utils/isRtl.js +14 -0
- package/dist/esm/utils/mediaQuery.js +56 -0
- package/dist/esm/utils/menuStyles.js +49 -0
- package/dist/esm/utils/retrieveComponentStyles.js +19 -0
- package/dist/esm/utils/useDocument.js +21 -0
- package/dist/esm/utils/useText.js +29 -0
- package/dist/esm/utils/useWindow.js +21 -0
- package/dist/esm/utils/withTheme.js +13 -0
- package/dist/index.cjs.js +6 -22
- package/package.json +3 -3
- package/dist/index.esm.js +0 -648
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { css, keyframes } from 'styled-components';
|
|
8
|
+
import { getColorV8 } from './getColorV8.js';
|
|
9
|
+
import DEFAULT_THEME from '../elements/theme/index.js';
|
|
10
|
+
|
|
11
|
+
const animationStyles = (position, options) => {
|
|
12
|
+
const theme = options.theme || DEFAULT_THEME;
|
|
13
|
+
let translateValue = `${theme.space.base * 5}px`;
|
|
14
|
+
let transformFunction;
|
|
15
|
+
if (position === 'top') {
|
|
16
|
+
transformFunction = 'translateY';
|
|
17
|
+
} else if (position === 'right') {
|
|
18
|
+
transformFunction = 'translateX';
|
|
19
|
+
translateValue = `-${translateValue}`;
|
|
20
|
+
} else if (position === 'bottom') {
|
|
21
|
+
transformFunction = 'translateY';
|
|
22
|
+
translateValue = `-${translateValue}`;
|
|
23
|
+
} else {
|
|
24
|
+
transformFunction = 'translateX';
|
|
25
|
+
}
|
|
26
|
+
const animationName = keyframes(["0%{transform:", "(", ");}"], transformFunction, translateValue);
|
|
27
|
+
return css(["&", " ", "{animation:0.2s cubic-bezier(0.15,0.85,0.35,1.2) ", ";}"], options.animationModifier, options.childSelector || '> *', animationName);
|
|
28
|
+
};
|
|
29
|
+
const hiddenStyles = options => {
|
|
30
|
+
const transition = 'opacity 0.2s ease-in-out, 0.2s visibility 0s linear';
|
|
31
|
+
return css(["transition:", ";visibility:hidden;opacity:0;"], options.animationModifier && transition);
|
|
32
|
+
};
|
|
33
|
+
function menuStyles(position) {
|
|
34
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
35
|
+
const theme = options.theme || DEFAULT_THEME;
|
|
36
|
+
let marginProperty;
|
|
37
|
+
if (position === 'top') {
|
|
38
|
+
marginProperty = 'margin-bottom';
|
|
39
|
+
} else if (position === 'right') {
|
|
40
|
+
marginProperty = 'margin-left';
|
|
41
|
+
} else if (position === 'bottom') {
|
|
42
|
+
marginProperty = 'margin-top';
|
|
43
|
+
} else {
|
|
44
|
+
marginProperty = 'margin-right';
|
|
45
|
+
}
|
|
46
|
+
return css(["position:absolute;z-index:", ";", ":", ";line-height:0;font-size:0.01px;& ", "{display:inline-block;position:relative;margin:0;box-sizing:border-box;border:", " ", ";border-radius:", ";box-shadow:", ";background-color:", ";cursor:default;padding:0;text-align:", ";white-space:normal;font-size:", ";font-weight:", ";direction:", ";:focus{outline:none;}}", ";", ";"], options.zIndex || 0, marginProperty, options.margin, options.childSelector || '> *', theme.borders.sm, getColorV8('neutralHue', 300, theme), theme.borderRadii.md, theme.shadows.lg(`${theme.space.base * 5}px`, `${theme.space.base * 7.5}px`, getColorV8('chromeHue', 600, theme, 0.15)), getColorV8('background', 600 , theme), theme.rtl ? 'right' : 'left', theme.fontSizes.md, theme.fontWeights.regular, theme.rtl && 'rtl', options.animationModifier && animationStyles(position, options), options.hidden && hiddenStyles(options));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { menuStyles as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
function retrieveComponentStyles(componentId, props) {
|
|
8
|
+
const components = props.theme && props.theme.components;
|
|
9
|
+
if (!components) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
const componentStyles = components[componentId];
|
|
13
|
+
if (typeof componentStyles === 'function') {
|
|
14
|
+
return componentStyles(props);
|
|
15
|
+
}
|
|
16
|
+
return componentStyles;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { retrieveComponentStyles as default };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { useState, useEffect } from 'react';
|
|
8
|
+
|
|
9
|
+
const useDocument = theme => {
|
|
10
|
+
const [controlledDocument, setControlledDocument] = useState();
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (theme && theme.document) {
|
|
13
|
+
setControlledDocument(theme.document);
|
|
14
|
+
} else {
|
|
15
|
+
setControlledDocument(document);
|
|
16
|
+
}
|
|
17
|
+
}, [theme]);
|
|
18
|
+
return controlledDocument;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { useDocument };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { useMemo } from 'react';
|
|
8
|
+
|
|
9
|
+
const useText = function (component, props, name, text) {
|
|
10
|
+
let condition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
11
|
+
const value = condition ? props[name] : undefined;
|
|
12
|
+
return useMemo(() => {
|
|
13
|
+
if (condition) {
|
|
14
|
+
if (name === 'children') {
|
|
15
|
+
throw new Error('Error: `children` is not a valid `useText` prop.');
|
|
16
|
+
} else if (value === null || value === '') {
|
|
17
|
+
throw new Error(component.displayName ? `Error: you must provide a valid \`${name}\` text value for <${component.displayName}>.` : `Error: you must provide a valid \`${name}\` text value.`);
|
|
18
|
+
} else if (value === undefined) {
|
|
19
|
+
if (process.env.NODE_ENV === 'development') {
|
|
20
|
+
console.warn(component.displayName ? `Warning: you did not provide a customized/translated \`${name}\` text value for <${component.displayName}>. Zendesk Garden is rendering <${component.displayName} ${name}="${text}"> by default.` : `Warning: you did not provide a customized/translated \`${name}\` text value. Zendesk Garden is rendering ${name}="${text}" by default.`);
|
|
21
|
+
}
|
|
22
|
+
return text;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
}, [component.displayName, value, name, text, condition]);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { useText };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { useState, useEffect } from 'react';
|
|
8
|
+
|
|
9
|
+
const useWindow = theme => {
|
|
10
|
+
const [controlledWindow, setControlledWindow] = useState();
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (theme && theme.window) {
|
|
13
|
+
setControlledWindow(theme.window);
|
|
14
|
+
} else {
|
|
15
|
+
setControlledWindow(window);
|
|
16
|
+
}
|
|
17
|
+
}, [theme]);
|
|
18
|
+
return controlledWindow;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { useWindow };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { withTheme as withTheme$1 } from 'styled-components';
|
|
8
|
+
|
|
9
|
+
function withTheme(WrappedComponent) {
|
|
10
|
+
return withTheme$1(WrappedComponent);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { withTheme as default };
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
8
7
|
'use strict';
|
|
9
8
|
|
|
10
9
|
var React = require('react');
|
|
@@ -19,21 +18,6 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
19
18
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
20
19
|
var memoize__default = /*#__PURE__*/_interopDefault(memoize);
|
|
21
20
|
|
|
22
|
-
function _extends() {
|
|
23
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
24
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
25
|
-
var source = arguments[i];
|
|
26
|
-
for (var key in source) {
|
|
27
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
28
|
-
target[key] = source[key];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return target;
|
|
33
|
-
};
|
|
34
|
-
return _extends.apply(this, arguments);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
21
|
const PALETTE = {
|
|
38
22
|
black: '#000',
|
|
39
23
|
white: '#fff',
|
|
@@ -320,7 +304,7 @@ const ThemeProvider = _ref => {
|
|
|
320
304
|
scope: controlledScopeRef,
|
|
321
305
|
relativeDocument
|
|
322
306
|
});
|
|
323
|
-
return React__default.default.createElement(styledComponents.ThemeProvider,
|
|
307
|
+
return React__default.default.createElement(styledComponents.ThemeProvider, Object.assign({
|
|
324
308
|
theme: theme
|
|
325
309
|
}, other), focusVisibleRef === undefined ? React__default.default.createElement("div", {
|
|
326
310
|
ref: scopeRef
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zendeskgarden/react-theming",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.76.1",
|
|
4
4
|
"description": "Theming utilities and components within the Garden Design System",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Zendesk Garden <garden@zendesk.com>",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"url": "https://github.com/zendeskgarden/react-components/issues"
|
|
11
11
|
},
|
|
12
12
|
"main": "dist/index.cjs.js",
|
|
13
|
-
"module": "dist/index.
|
|
13
|
+
"module": "dist/esm/index.js",
|
|
14
14
|
"files": [
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
47
|
"zendeskgarden:src": "src/index.ts",
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "8351e305688a65273cb18741c0800be8027cf878"
|
|
49
49
|
}
|