@zendeskgarden/react-theming 9.0.0-next.6 → 9.0.0-next.8
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 +24 -0
- package/dist/esm/elements/palette/index.js +283 -0
- package/dist/esm/elements/palette/v8.js +149 -0
- package/dist/esm/elements/theme/index.js +209 -0
- package/dist/esm/index.js +26 -0
- package/dist/esm/types/index.js +11 -0
- package/dist/esm/utils/arrowStyles.js +64 -0
- package/dist/esm/utils/focusStyles.js +43 -0
- package/dist/esm/utils/getArrowPosition.js +35 -0
- package/dist/esm/utils/getColor.js +148 -0
- package/dist/esm/utils/getColorV8.js +72 -0
- package/dist/esm/utils/getFloatingPlacements.js +58 -0
- package/dist/esm/utils/getFocusBoxShadow.js +45 -0
- package/dist/esm/utils/getLineHeight.js +22 -0
- package/dist/esm/utils/getMenuPosition.js +11 -0
- package/dist/esm/utils/mediaQuery.js +56 -0
- package/dist/esm/utils/menuStyles.js +63 -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/index.cjs.js +121 -66
- package/dist/typings/elements/ThemeProvider.d.ts +3 -3
- package/dist/typings/index.d.ts +1 -1
- package/dist/typings/types/index.d.ts +35 -9
- package/dist/typings/utils/focusStyles.d.ts +3 -11
- package/dist/typings/utils/getColor.d.ts +1 -22
- package/dist/typings/utils/getFocusBoxShadow.d.ts +6 -20
- package/package.json +3 -5
- package/dist/index.esm.js +0 -1158
|
@@ -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 };
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
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');
|
|
11
10
|
var styledComponents = require('styled-components');
|
|
12
|
-
var containerFocusvisible = require('@zendeskgarden/container-focusvisible');
|
|
13
|
-
var containerUtilities = require('@zendeskgarden/container-utilities');
|
|
14
11
|
var chromaJs = require('chroma-js');
|
|
15
12
|
var polished = require('polished');
|
|
16
13
|
var get = require('lodash.get');
|
|
@@ -22,21 +19,6 @@ var React__default = /*#__PURE__*/_interopDefault(React);
|
|
|
22
19
|
var get__default = /*#__PURE__*/_interopDefault(get);
|
|
23
20
|
var memoize__default = /*#__PURE__*/_interopDefault(memoize);
|
|
24
21
|
|
|
25
|
-
function _extends() {
|
|
26
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
27
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
28
|
-
var source = arguments[i];
|
|
29
|
-
for (var key in source) {
|
|
30
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
31
|
-
target[key] = source[key];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return target;
|
|
36
|
-
};
|
|
37
|
-
return _extends.apply(this, arguments);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
22
|
const PALETTE = {
|
|
41
23
|
black: '#000',
|
|
42
24
|
white: '#fff',
|
|
@@ -346,24 +328,84 @@ const colors = {
|
|
|
346
328
|
variables: {
|
|
347
329
|
dark: {
|
|
348
330
|
background: {
|
|
349
|
-
default: 'neutralHue.1100'
|
|
331
|
+
default: 'neutralHue.1100',
|
|
332
|
+
raised: 'neutralHue.1000',
|
|
333
|
+
recessed: 'neutralHue.1200',
|
|
334
|
+
subtle: 'neutralHue.1000',
|
|
335
|
+
emphasis: 'neutralHue.600',
|
|
336
|
+
primary: 'primaryHue.900',
|
|
337
|
+
success: 'successHue.1000',
|
|
338
|
+
warning: 'warningHue.1000',
|
|
339
|
+
danger: 'dangerHue.1000',
|
|
340
|
+
primaryEmphasis: 'primaryHue.600',
|
|
341
|
+
successEmphasis: 'successHue.600',
|
|
342
|
+
warningEmphasis: 'warningHue.600',
|
|
343
|
+
dangerEmphasis: 'dangerHue.600'
|
|
350
344
|
},
|
|
351
345
|
border: {
|
|
352
|
-
default: 'neutralHue.
|
|
346
|
+
default: 'neutralHue.800',
|
|
347
|
+
emphasis: 'neutralHue.600',
|
|
348
|
+
subtle: 'neutralHue.900',
|
|
349
|
+
success: 'successHue.800',
|
|
350
|
+
warning: 'warningHue.800',
|
|
351
|
+
danger: 'dangerHue.800',
|
|
352
|
+
primaryEmphasis: 'primaryHue.600',
|
|
353
|
+
successEmphasis: 'successHue.600',
|
|
354
|
+
warningEmphasis: 'warningHue.600',
|
|
355
|
+
dangerEmphasis: 'dangerHue.600'
|
|
353
356
|
},
|
|
354
357
|
foreground: {
|
|
355
|
-
default: 'neutralHue.300'
|
|
358
|
+
default: 'neutralHue.300',
|
|
359
|
+
subtle: 'neutralHue.500',
|
|
360
|
+
onEmphasis: 'neutralHue.1100',
|
|
361
|
+
primary: 'primaryHue.600',
|
|
362
|
+
success: 'successHue.400',
|
|
363
|
+
warning: 'warningHue.400',
|
|
364
|
+
danger: 'dangerHue.400',
|
|
365
|
+
successEmphasis: 'successHue.300',
|
|
366
|
+
warningEmphasis: 'warningHue.300',
|
|
367
|
+
dangerEmphasis: 'dangerHue.300'
|
|
356
368
|
}
|
|
357
369
|
},
|
|
358
370
|
light: {
|
|
359
371
|
background: {
|
|
360
|
-
default: 'palette.white'
|
|
372
|
+
default: 'palette.white',
|
|
373
|
+
raised: 'palette.white',
|
|
374
|
+
recessed: 'neutralHue.100',
|
|
375
|
+
subtle: 'neutralHue.100',
|
|
376
|
+
emphasis: 'neutralHue.700',
|
|
377
|
+
primary: 'primaryHue.100',
|
|
378
|
+
success: 'successHue.100',
|
|
379
|
+
warning: 'warningHue.100',
|
|
380
|
+
danger: 'dangerHue.100',
|
|
381
|
+
primaryEmphasis: 'primaryHue.700',
|
|
382
|
+
successEmphasis: 'successHue.700',
|
|
383
|
+
warningEmphasis: 'warningHue.700',
|
|
384
|
+
dangerEmphasis: 'dangerHue.700'
|
|
361
385
|
},
|
|
362
386
|
border: {
|
|
363
|
-
default: 'neutralHue.
|
|
387
|
+
default: 'neutralHue.300',
|
|
388
|
+
emphasis: 'neutralHue.600',
|
|
389
|
+
subtle: 'neutralHue.200',
|
|
390
|
+
success: 'successHue.300',
|
|
391
|
+
warning: 'warningHue.300',
|
|
392
|
+
danger: 'dangerHue.300',
|
|
393
|
+
primaryEmphasis: 'primaryHue.700',
|
|
394
|
+
successEmphasis: 'successHue.700',
|
|
395
|
+
warningEmphasis: 'warningHue.700',
|
|
396
|
+
dangerEmphasis: 'dangerHue.700'
|
|
364
397
|
},
|
|
365
398
|
foreground: {
|
|
366
|
-
default: 'neutralHue.900'
|
|
399
|
+
default: 'neutralHue.900',
|
|
400
|
+
subtle: 'neutralHue.700',
|
|
401
|
+
onEmphasis: 'palette.white',
|
|
402
|
+
primary: 'primaryHue.700',
|
|
403
|
+
success: 'successHue.700',
|
|
404
|
+
warning: 'warningHue.700',
|
|
405
|
+
danger: 'dangerHue.700',
|
|
406
|
+
successEmphasis: 'successHue.900',
|
|
407
|
+
warningEmphasis: 'warningHue.900',
|
|
408
|
+
dangerEmphasis: 'dangerHue.900'
|
|
367
409
|
}
|
|
368
410
|
}
|
|
369
411
|
}
|
|
@@ -453,37 +495,14 @@ const DEFAULT_THEME = {
|
|
|
453
495
|
space
|
|
454
496
|
};
|
|
455
497
|
|
|
456
|
-
const useDocument = theme => {
|
|
457
|
-
const [controlledDocument, setControlledDocument] = React.useState();
|
|
458
|
-
React.useEffect(() => {
|
|
459
|
-
if (theme && theme.document) {
|
|
460
|
-
setControlledDocument(theme.document);
|
|
461
|
-
} else {
|
|
462
|
-
setControlledDocument(document);
|
|
463
|
-
}
|
|
464
|
-
}, [theme]);
|
|
465
|
-
return controlledDocument;
|
|
466
|
-
};
|
|
467
|
-
|
|
468
498
|
const ThemeProvider = _ref => {
|
|
469
499
|
let {
|
|
470
500
|
theme,
|
|
471
|
-
focusVisibleRef,
|
|
472
|
-
children,
|
|
473
501
|
...other
|
|
474
502
|
} = _ref;
|
|
475
|
-
|
|
476
|
-
const relativeDocument = useDocument(theme);
|
|
477
|
-
const controlledScopeRef = focusVisibleRef === null ? React__default.default.createRef() : containerUtilities.getControlledValue(focusVisibleRef, scopeRef);
|
|
478
|
-
containerFocusvisible.useFocusVisible({
|
|
479
|
-
scope: controlledScopeRef,
|
|
480
|
-
relativeDocument
|
|
481
|
-
});
|
|
482
|
-
return React__default.default.createElement(styledComponents.ThemeProvider, _extends({
|
|
503
|
+
return React__default.default.createElement(styledComponents.ThemeProvider, Object.assign({
|
|
483
504
|
theme: theme
|
|
484
|
-
}, other)
|
|
485
|
-
ref: scopeRef
|
|
486
|
-
}, children) : children);
|
|
505
|
+
}, other));
|
|
487
506
|
};
|
|
488
507
|
ThemeProvider.defaultProps = {
|
|
489
508
|
theme: DEFAULT_THEME
|
|
@@ -710,7 +729,7 @@ const toColor = (colors, palette, scheme, hue, shade, offset, transparency) => {
|
|
|
710
729
|
}
|
|
711
730
|
if (typeof _hue === 'object') {
|
|
712
731
|
retVal = toHex(_hue, shade, offset, scheme);
|
|
713
|
-
} else if (chromaJs.valid(_hue)) {
|
|
732
|
+
} else if (_hue === 'transparent' || chromaJs.valid(_hue)) {
|
|
714
733
|
if (shade === undefined) {
|
|
715
734
|
retVal = _hue;
|
|
716
735
|
} else {
|
|
@@ -920,22 +939,32 @@ const getFocusBoxShadow = _ref => {
|
|
|
920
939
|
let {
|
|
921
940
|
boxShadow,
|
|
922
941
|
inset = false,
|
|
923
|
-
|
|
924
|
-
|
|
942
|
+
color = {
|
|
943
|
+
variable: 'border.primaryEmphasis'
|
|
944
|
+
},
|
|
925
945
|
shadowWidth = 'md',
|
|
926
|
-
|
|
927
|
-
|
|
946
|
+
spacerColor = {
|
|
947
|
+
variable: 'background.default'
|
|
948
|
+
},
|
|
928
949
|
spacerWidth = 'xs',
|
|
929
|
-
theme = DEFAULT_THEME
|
|
950
|
+
theme = DEFAULT_THEME,
|
|
951
|
+
...args
|
|
930
952
|
} = _ref;
|
|
931
|
-
const
|
|
932
|
-
const
|
|
953
|
+
const _args = args;
|
|
954
|
+
const _color = _args.hue ? getColorV8(_args.hue, _args.shade, theme) : getColor({
|
|
955
|
+
...color,
|
|
956
|
+
theme
|
|
957
|
+
});
|
|
958
|
+
const shadow = theme.shadows[shadowWidth](_color);
|
|
933
959
|
if (spacerWidth === null) {
|
|
934
960
|
return `${inset ? 'inset' : ''} ${shadow}`;
|
|
935
961
|
}
|
|
936
|
-
const
|
|
962
|
+
const _spacerColor = _args.spacerHue ? getColorV8(_args.spacerHue, _args.spacerShade, theme) : getColor({
|
|
963
|
+
...spacerColor,
|
|
964
|
+
theme
|
|
965
|
+
});
|
|
937
966
|
const retVal = `
|
|
938
|
-
${inset ? 'inset' : ''} ${theme.shadows[spacerWidth](
|
|
967
|
+
${inset ? 'inset' : ''} ${theme.shadows[spacerWidth](_spacerColor)},
|
|
939
968
|
${inset ? 'inset' : ''} ${shadow}`;
|
|
940
969
|
return boxShadow ? `${retVal}, ${boxShadow}` : retVal;
|
|
941
970
|
};
|
|
@@ -1057,6 +1086,18 @@ function arrowStyles(position) {
|
|
|
1057
1086
|
return styledComponents.css(["position:relative;&::before{border-width:inherit;border-style:inherit;border-color:transparent;background-clip:content-box;}&::after{z-index:-1;border:inherit;box-shadow:inherit;}&::before,&::after{position:absolute;transform:rotate(45deg);background-color:inherit;box-sizing:inherit;width:", ";height:", ";content:'';}", ";", ";"], squareSize, squareSize, positionStyles(position, squareSize, inset), options.animationModifier && animationStyles$1(position, options.animationModifier));
|
|
1058
1087
|
}
|
|
1059
1088
|
|
|
1089
|
+
const useDocument = theme => {
|
|
1090
|
+
const [controlledDocument, setControlledDocument] = React.useState();
|
|
1091
|
+
React.useEffect(() => {
|
|
1092
|
+
if (theme && theme.document) {
|
|
1093
|
+
setControlledDocument(theme.document);
|
|
1094
|
+
} else {
|
|
1095
|
+
setControlledDocument(document);
|
|
1096
|
+
}
|
|
1097
|
+
}, [theme]);
|
|
1098
|
+
return controlledDocument;
|
|
1099
|
+
};
|
|
1100
|
+
|
|
1060
1101
|
const useWindow = theme => {
|
|
1061
1102
|
const [controlledWindow, setControlledWindow] = React.useState();
|
|
1062
1103
|
React.useEffect(() => {
|
|
@@ -1124,10 +1165,24 @@ function menuStyles(position) {
|
|
|
1124
1165
|
} else {
|
|
1125
1166
|
marginProperty = 'margin-right';
|
|
1126
1167
|
}
|
|
1127
|
-
return styledComponents.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,
|
|
1168
|
+
return styledComponents.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;color:", ";font-size:", ";font-weight:", ";direction:", ";:focus{outline:none;}}", ";", ";"], options.zIndex || 0, marginProperty, options.margin, options.childSelector || '> *', theme.borders.sm, getColor({
|
|
1169
|
+
theme,
|
|
1170
|
+
variable: 'border.default'
|
|
1171
|
+
}), theme.borderRadii.md, theme.shadows.lg(`${theme.space.base * 5}px`, `${theme.space.base * 7.5}px`, getColor({
|
|
1172
|
+
theme,
|
|
1173
|
+
hue: 'chromeHue',
|
|
1174
|
+
shade: 600,
|
|
1175
|
+
transparency: 0.15
|
|
1176
|
+
})), getColor({
|
|
1177
|
+
theme,
|
|
1178
|
+
variable: 'background.raised'
|
|
1179
|
+
}), theme.rtl ? 'right' : 'left', getColor({
|
|
1180
|
+
theme,
|
|
1181
|
+
variable: 'foreground.default'
|
|
1182
|
+
}), theme.fontSizes.md, theme.fontWeights.regular, theme.rtl && 'rtl', options.animationModifier && animationStyles(position, options), options.hidden && hiddenStyles(options));
|
|
1128
1183
|
}
|
|
1129
1184
|
|
|
1130
|
-
const SELECTOR_FOCUS_VISIBLE = '&:focus-visible
|
|
1185
|
+
const SELECTOR_FOCUS_VISIBLE = '&:focus-visible';
|
|
1131
1186
|
const focusStyles = _ref => {
|
|
1132
1187
|
let {
|
|
1133
1188
|
condition = true,
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
import React, { PropsWithChildren } from 'react';
|
|
8
|
-
import {
|
|
8
|
+
import { IThemeProviderProps } from '../types';
|
|
9
9
|
export declare const ThemeProvider: {
|
|
10
|
-
({ theme,
|
|
10
|
+
({ theme, ...other }: PropsWithChildren<IThemeProviderProps>): React.JSX.Element;
|
|
11
11
|
defaultProps: {
|
|
12
|
-
theme: IGardenTheme;
|
|
12
|
+
theme: import("../types").IGardenTheme;
|
|
13
13
|
};
|
|
14
14
|
};
|
package/dist/typings/index.d.ts
CHANGED
|
@@ -23,4 +23,4 @@ export { useWindow } from './utils/useWindow';
|
|
|
23
23
|
export { useText } from './utils/useText';
|
|
24
24
|
export { default as menuStyles } from './utils/menuStyles';
|
|
25
25
|
export { focusStyles, SELECTOR_FOCUS_VISIBLE } from './utils/focusStyles';
|
|
26
|
-
export { ARROW_POSITION, MENU_POSITION, PLACEMENT, type IGardenTheme, type IThemeProviderProps, type ArrowPosition, type MenuPosition, type Placement } from './types';
|
|
26
|
+
export { ARROW_POSITION, MENU_POSITION, PLACEMENT, type IGardenTheme, type IThemeProviderProps, type ArrowPosition, type ColorParameters, type FocusBoxShadowParameters, type FocusStylesParameters, type MenuPosition, type Placement } from './types';
|
|
@@ -4,14 +4,47 @@
|
|
|
4
4
|
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
import { ThemeProviderProps } from 'styled-components';
|
|
7
|
+
import { CSSObject, ThemeProviderProps } from 'styled-components';
|
|
9
8
|
export declare const ARROW_POSITION: readonly ["top", "top-left", "top-right", "right", "right-top", "right-bottom", "bottom", "bottom-left", "bottom-right", "left", "left-top", "left-bottom"];
|
|
10
9
|
export type ArrowPosition = (typeof ARROW_POSITION)[number];
|
|
11
10
|
export declare const MENU_POSITION: readonly ["top", "right", "bottom", "left"];
|
|
12
11
|
export type MenuPosition = (typeof MENU_POSITION)[number];
|
|
13
12
|
export declare const PLACEMENT: readonly ["top", "top-start", "top-end", "bottom", "bottom-start", "bottom-end", "end", "end-top", "end-bottom", "start", "start-top", "start-bottom"];
|
|
14
13
|
export type Placement = (typeof PLACEMENT)[number];
|
|
14
|
+
export type ColorParameters = {
|
|
15
|
+
dark?: {
|
|
16
|
+
hue?: string;
|
|
17
|
+
offset?: number;
|
|
18
|
+
shade?: number;
|
|
19
|
+
transparency?: number;
|
|
20
|
+
};
|
|
21
|
+
hue?: string;
|
|
22
|
+
light?: {
|
|
23
|
+
hue?: string;
|
|
24
|
+
offset?: number;
|
|
25
|
+
shade?: number;
|
|
26
|
+
transparency?: number;
|
|
27
|
+
};
|
|
28
|
+
offset?: number;
|
|
29
|
+
shade?: number;
|
|
30
|
+
theme: IGardenTheme;
|
|
31
|
+
transparency?: number;
|
|
32
|
+
variable?: string;
|
|
33
|
+
};
|
|
34
|
+
export type FocusStylesParameters = FocusBoxShadowParameters & {
|
|
35
|
+
condition?: boolean;
|
|
36
|
+
selector?: string;
|
|
37
|
+
styles?: CSSObject;
|
|
38
|
+
};
|
|
39
|
+
export type FocusBoxShadowParameters = {
|
|
40
|
+
boxShadow?: string;
|
|
41
|
+
inset?: boolean;
|
|
42
|
+
color?: Omit<ColorParameters, 'theme'>;
|
|
43
|
+
shadowWidth?: 'sm' | 'md';
|
|
44
|
+
spacerColor?: Omit<ColorParameters, 'theme'>;
|
|
45
|
+
spacerWidth?: null | 'xs' | 'sm';
|
|
46
|
+
theme: IGardenTheme;
|
|
47
|
+
};
|
|
15
48
|
export type Hue = Record<number | string, string> | string;
|
|
16
49
|
export interface IGardenTheme {
|
|
17
50
|
rtl: boolean;
|
|
@@ -128,11 +161,4 @@ export interface IThemeProviderProps extends Partial<ThemeProviderProps<IGardenT
|
|
|
128
161
|
* for details.
|
|
129
162
|
*/
|
|
130
163
|
theme?: IGardenTheme | ((theme: IGardenTheme) => IGardenTheme);
|
|
131
|
-
/**
|
|
132
|
-
* Provides a reference to the DOM node used to scope a `:focus-visible`
|
|
133
|
-
* polyfill. If left `undefined`, a scoping `<div>` will be rendered.
|
|
134
|
-
* Assigning `null` (on a nested `ThemeProvider`, for example) prevents the
|
|
135
|
-
* added polyfill and scoping `<div>`.
|
|
136
|
-
*/
|
|
137
|
-
focusVisibleRef?: React.RefObject<HTMLElement> | null;
|
|
138
164
|
}
|
|
@@ -4,14 +4,8 @@
|
|
|
4
4
|
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
export declare const SELECTOR_FOCUS_VISIBLE = "&:focus-visible, &[data-garden-focus-visible=\"true\"]";
|
|
10
|
-
type FocusStylesParameters = FocusBoxShadowParameters & {
|
|
11
|
-
condition?: boolean;
|
|
12
|
-
selector?: string;
|
|
13
|
-
styles?: CSSObject;
|
|
14
|
-
};
|
|
7
|
+
import { FocusStylesParameters } from '../types';
|
|
8
|
+
export declare const SELECTOR_FOCUS_VISIBLE = "&:focus-visible";
|
|
15
9
|
/**
|
|
16
10
|
* Garden standard `box-shadow` focus styling.
|
|
17
11
|
*
|
|
@@ -33,8 +27,7 @@ type FocusStylesParameters = FocusBoxShadowParameters & {
|
|
|
33
27
|
* outline: none;
|
|
34
28
|
* }
|
|
35
29
|
*
|
|
36
|
-
* :focus-visible
|
|
37
|
-
* [data-garden-focus-visible='true'] {
|
|
30
|
+
* :focus-visible {
|
|
38
31
|
* box-shadow: 0 0 0 {1px} #fff,
|
|
39
32
|
* 0 0 0 {3px} {blue};
|
|
40
33
|
* outline: {2px} solid transparent;
|
|
@@ -44,4 +37,3 @@ type FocusStylesParameters = FocusBoxShadowParameters & {
|
|
|
44
37
|
* ```
|
|
45
38
|
*/
|
|
46
39
|
export declare const focusStyles: ({ condition, selector, shadowWidth, spacerWidth, styles: { boxShadow, ...styles }, theme, ...options }: FocusStylesParameters) => import("styled-components").FlattenSimpleInterpolation;
|
|
47
|
-
export {};
|
|
@@ -5,27 +5,7 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
/// <reference types="lodash" />
|
|
8
|
-
import {
|
|
9
|
-
type ColorParameters = {
|
|
10
|
-
dark?: {
|
|
11
|
-
hue?: string;
|
|
12
|
-
offset?: number;
|
|
13
|
-
shade?: number;
|
|
14
|
-
transparency?: number;
|
|
15
|
-
};
|
|
16
|
-
hue?: string;
|
|
17
|
-
light?: {
|
|
18
|
-
hue?: string;
|
|
19
|
-
offset?: number;
|
|
20
|
-
shade?: number;
|
|
21
|
-
transparency?: number;
|
|
22
|
-
};
|
|
23
|
-
offset?: number;
|
|
24
|
-
shade?: number;
|
|
25
|
-
theme: IGardenTheme;
|
|
26
|
-
transparency?: number;
|
|
27
|
-
variable?: string;
|
|
28
|
-
};
|
|
8
|
+
import { ColorParameters } from '../types';
|
|
29
9
|
/**
|
|
30
10
|
* Get a color value from the theme. Variable lookup takes precedence, followed
|
|
31
11
|
* by `dark` and `light` object values. If none of these are provided, `hue`,
|
|
@@ -48,4 +28,3 @@ type ColorParameters = {
|
|
|
48
28
|
* @param {number} [options.transparency] An alpha-channel value between 0 and 1
|
|
49
29
|
*/
|
|
50
30
|
export declare const getColor: (({ dark, hue, light, offset, shade, theme, transparency, variable }: ColorParameters) => string) & import("lodash").MemoizedFunction;
|
|
51
|
-
export {};
|
|
@@ -4,33 +4,19 @@
|
|
|
4
4
|
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
export type FocusBoxShadowParameters = {
|
|
9
|
-
boxShadow?: string;
|
|
10
|
-
inset?: boolean;
|
|
11
|
-
hue?: Hue;
|
|
12
|
-
shade?: number;
|
|
13
|
-
shadowWidth?: 'sm' | 'md';
|
|
14
|
-
spacerHue?: Hue;
|
|
15
|
-
spacerShade?: number;
|
|
16
|
-
spacerWidth?: null | 'xs' | 'sm';
|
|
17
|
-
theme: IGardenTheme;
|
|
18
|
-
};
|
|
7
|
+
import { FocusBoxShadowParameters } from '../types';
|
|
19
8
|
/**
|
|
20
|
-
* Get a CSS `box-shadow` property value for focus state styling.
|
|
21
|
-
* `shade` are used to determine the color of the focus ring.
|
|
9
|
+
* Get a CSS `box-shadow` property value for focus state styling.
|
|
22
10
|
*
|
|
23
11
|
* @param {string} [options.boxShadow] Provides an existing `box-shadow` (a drop shadow, for example) to be retained along with the focus ring
|
|
24
12
|
* @param {boolean} [options.inset=false] Determines whether the `box-shadow` is inset
|
|
25
|
-
* @param {
|
|
26
|
-
* @param {number} [options.shade=600] Selects a shade for the given `hue`
|
|
13
|
+
* @param {Object} [options.color={ variable: 'border.primaryEmphasis' }] Provides an object with `getColor` parameters used to determine the focus ring color
|
|
27
14
|
* @param {string} [options.shadowWidth='md'] Provides a theme object `shadowWidth` key for the cumulative width of the `box-shadow`
|
|
28
|
-
* @param {
|
|
29
|
-
* @param {number} [options.spacerShade=600] Selects a shade for the given `spacerHue`
|
|
15
|
+
* @param {Object} [options.spacerColor={ variable: 'background.default' }] Provides an object with `getColor` parameters used to determine the spacer color
|
|
30
16
|
* @param {string} [options.spacerWidth='xs'] Provides a theme object `shadowWidth` for the white spacer, or `null` to remove
|
|
31
17
|
* @param {Object} options.theme Provides values used to resolve the desired color
|
|
32
18
|
*
|
|
33
19
|
* @returns A `box-shadow` property value for the given options. Default is a
|
|
34
|
-
* 3px
|
|
20
|
+
* 3px blue ring with a 1px spacer overlay that matches the background.
|
|
35
21
|
*/
|
|
36
|
-
export declare const getFocusBoxShadow: ({ boxShadow, inset,
|
|
22
|
+
export declare const getFocusBoxShadow: ({ boxShadow, inset, color, shadowWidth, spacerColor, spacerWidth, theme, ...args }: FocusBoxShadowParameters) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zendeskgarden/react-theming",
|
|
3
|
-
"version": "9.0.0-next.
|
|
3
|
+
"version": "9.0.0-next.8",
|
|
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
|
],
|
|
@@ -22,8 +22,6 @@
|
|
|
22
22
|
"types": "dist/typings/index.d.ts",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@floating-ui/react-dom": "^2.0.0",
|
|
25
|
-
"@zendeskgarden/container-focusvisible": "^2.0.0",
|
|
26
|
-
"@zendeskgarden/container-utilities": "^2.0.0",
|
|
27
25
|
"chroma-js": "^2.4.2",
|
|
28
26
|
"lodash.get": "^4.4.2",
|
|
29
27
|
"lodash.memoize": "^4.1.2",
|
|
@@ -50,5 +48,5 @@
|
|
|
50
48
|
"access": "public"
|
|
51
49
|
},
|
|
52
50
|
"zendeskgarden:src": "src/index.ts",
|
|
53
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "a3d6534843d5a4f5cb60b52bc67264f3230f2da0"
|
|
54
52
|
}
|