@zendeskgarden/react-buttons 9.0.0-next.7 → 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/Anchor.js +54 -0
- package/dist/esm/elements/Button.js +49 -0
- package/dist/esm/elements/ChevronButton.js +27 -0
- package/dist/esm/elements/IconButton.js +50 -0
- package/dist/esm/elements/SplitButton.js +29 -0
- package/dist/esm/elements/ToggleButton.js +30 -0
- package/dist/esm/elements/ToggleIconButton.js +32 -0
- package/dist/esm/elements/components/EndIcon.js +21 -0
- package/dist/esm/elements/components/StartIcon.js +21 -0
- package/dist/esm/index.js +13 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/new-window-stroke.svg.js +27 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/chevron-down-stroke.svg.js +25 -0
- package/dist/esm/styled/StyledAnchor.js +27 -0
- package/dist/esm/styled/StyledButton.js +155 -0
- package/dist/esm/styled/StyledExternalIcon.js +23 -0
- package/dist/esm/styled/StyledIcon.js +40 -0
- package/dist/esm/styled/StyledIconButton.js +39 -0
- package/dist/esm/styled/StyledSplitButton.js +22 -0
- package/dist/esm/types/index.js +9 -0
- package/dist/esm/utils/useSplitButtonContext.js +14 -0
- package/dist/index.cjs.js +26 -38
- package/package.json +5 -5
- package/dist/index.esm.js +0 -484
|
@@ -0,0 +1,54 @@
|
|
|
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 React__default, { forwardRef } from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { StyledAnchor } from '../styled/StyledAnchor.js';
|
|
10
|
+
import '../styled/StyledButton.js';
|
|
11
|
+
import '../styled/StyledSplitButton.js';
|
|
12
|
+
import { StyledExternalIcon } from '../styled/StyledExternalIcon.js';
|
|
13
|
+
import '../styled/StyledIcon.js';
|
|
14
|
+
import '../styled/StyledIconButton.js';
|
|
15
|
+
import { useText } from '@zendeskgarden/react-theming';
|
|
16
|
+
|
|
17
|
+
const Anchor = forwardRef((_ref, ref) => {
|
|
18
|
+
let {
|
|
19
|
+
children,
|
|
20
|
+
isExternal,
|
|
21
|
+
externalIconLabel,
|
|
22
|
+
...otherProps
|
|
23
|
+
} = _ref;
|
|
24
|
+
let anchorProps = otherProps;
|
|
25
|
+
if (isExternal) {
|
|
26
|
+
anchorProps = {
|
|
27
|
+
target: '_blank',
|
|
28
|
+
rel: 'noopener noreferrer',
|
|
29
|
+
...anchorProps
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const checkProps = isExternal ? {
|
|
33
|
+
externalIconLabel
|
|
34
|
+
} : {
|
|
35
|
+
noIconLabel: 'true'
|
|
36
|
+
};
|
|
37
|
+
const iconAriaLabel = useText(Anchor, checkProps, isExternal ? 'externalIconLabel' : 'noIconLabel', '(opens in a new tab)');
|
|
38
|
+
return React__default.createElement(StyledAnchor, Object.assign({
|
|
39
|
+
ref: ref
|
|
40
|
+
}, anchorProps), children, isExternal &&
|
|
41
|
+
React__default.createElement(StyledExternalIcon, {
|
|
42
|
+
role: "img",
|
|
43
|
+
"aria-label": iconAriaLabel,
|
|
44
|
+
"aria-hidden": undefined
|
|
45
|
+
}));
|
|
46
|
+
});
|
|
47
|
+
Anchor.displayName = 'Anchor';
|
|
48
|
+
Anchor.propTypes = {
|
|
49
|
+
isExternal: PropTypes.bool,
|
|
50
|
+
isDanger: PropTypes.bool,
|
|
51
|
+
externalIconLabel: PropTypes.string
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { Anchor };
|
|
@@ -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 React__default, { forwardRef } from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { SIZE } from '../types/index.js';
|
|
10
|
+
import '../styled/StyledAnchor.js';
|
|
11
|
+
import { StyledButton } from '../styled/StyledButton.js';
|
|
12
|
+
import '../styled/StyledSplitButton.js';
|
|
13
|
+
import '../styled/StyledExternalIcon.js';
|
|
14
|
+
import '../styled/StyledIcon.js';
|
|
15
|
+
import '../styled/StyledIconButton.js';
|
|
16
|
+
import { useSplitButtonContext } from '../utils/useSplitButtonContext.js';
|
|
17
|
+
import { StartIcon } from './components/StartIcon.js';
|
|
18
|
+
import { EndIcon } from './components/EndIcon.js';
|
|
19
|
+
|
|
20
|
+
const ButtonComponent = forwardRef((props, ref) => {
|
|
21
|
+
const splitButtonContext = useSplitButtonContext();
|
|
22
|
+
const computedProps = {
|
|
23
|
+
...props,
|
|
24
|
+
focusInset: props.focusInset || splitButtonContext
|
|
25
|
+
};
|
|
26
|
+
return React__default.createElement(StyledButton, Object.assign({}, computedProps, {
|
|
27
|
+
ref: ref
|
|
28
|
+
}));
|
|
29
|
+
});
|
|
30
|
+
ButtonComponent.displayName = 'Button';
|
|
31
|
+
ButtonComponent.propTypes = {
|
|
32
|
+
isNeutral: PropTypes.bool,
|
|
33
|
+
isPrimary: PropTypes.bool,
|
|
34
|
+
isDanger: PropTypes.bool,
|
|
35
|
+
isPill: PropTypes.bool,
|
|
36
|
+
isBasic: PropTypes.bool,
|
|
37
|
+
focusInset: PropTypes.bool,
|
|
38
|
+
isLink: PropTypes.bool,
|
|
39
|
+
isStretched: PropTypes.bool,
|
|
40
|
+
size: PropTypes.oneOf(SIZE)
|
|
41
|
+
};
|
|
42
|
+
ButtonComponent.defaultProps = {
|
|
43
|
+
size: 'medium'
|
|
44
|
+
};
|
|
45
|
+
const Button = ButtonComponent;
|
|
46
|
+
Button.EndIcon = EndIcon;
|
|
47
|
+
Button.StartIcon = StartIcon;
|
|
48
|
+
|
|
49
|
+
export { Button };
|
|
@@ -0,0 +1,27 @@
|
|
|
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 React__default, { forwardRef } from 'react';
|
|
8
|
+
import { IconButton } from './IconButton.js';
|
|
9
|
+
import SvgChevronDownStroke from '../node_modules/@zendeskgarden/svg-icons/src/16/chevron-down-stroke.svg.js';
|
|
10
|
+
|
|
11
|
+
const ChevronButton = forwardRef((_ref, ref) => {
|
|
12
|
+
let {
|
|
13
|
+
...buttonProps
|
|
14
|
+
} = _ref;
|
|
15
|
+
return React__default.createElement(IconButton, Object.assign({
|
|
16
|
+
ref: ref
|
|
17
|
+
}, buttonProps), React__default.createElement(SvgChevronDownStroke, null));
|
|
18
|
+
});
|
|
19
|
+
ChevronButton.displayName = 'ChevronButton';
|
|
20
|
+
ChevronButton.propTypes = IconButton.propTypes;
|
|
21
|
+
ChevronButton.defaultProps = {
|
|
22
|
+
isBasic: false,
|
|
23
|
+
isPill: false,
|
|
24
|
+
size: 'medium'
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { ChevronButton };
|
|
@@ -0,0 +1,50 @@
|
|
|
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 React__default, { forwardRef } from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { SIZE } from '../types/index.js';
|
|
10
|
+
import '../styled/StyledAnchor.js';
|
|
11
|
+
import '../styled/StyledButton.js';
|
|
12
|
+
import '../styled/StyledSplitButton.js';
|
|
13
|
+
import '../styled/StyledExternalIcon.js';
|
|
14
|
+
import { StyledIcon } from '../styled/StyledIcon.js';
|
|
15
|
+
import { StyledIconButton } from '../styled/StyledIconButton.js';
|
|
16
|
+
import { useSplitButtonContext } from '../utils/useSplitButtonContext.js';
|
|
17
|
+
|
|
18
|
+
const IconButton = forwardRef((_ref, ref) => {
|
|
19
|
+
let {
|
|
20
|
+
children,
|
|
21
|
+
isRotated,
|
|
22
|
+
...otherProps
|
|
23
|
+
} = _ref;
|
|
24
|
+
const focusInset = useSplitButtonContext();
|
|
25
|
+
return React__default.createElement(StyledIconButton, Object.assign({
|
|
26
|
+
ref: ref
|
|
27
|
+
}, otherProps, {
|
|
28
|
+
focusInset: otherProps.focusInset || focusInset
|
|
29
|
+
}), React__default.createElement(StyledIcon, {
|
|
30
|
+
isRotated: isRotated
|
|
31
|
+
}, children));
|
|
32
|
+
});
|
|
33
|
+
IconButton.displayName = 'IconButton';
|
|
34
|
+
IconButton.propTypes = {
|
|
35
|
+
isDanger: PropTypes.bool,
|
|
36
|
+
size: PropTypes.oneOf(SIZE),
|
|
37
|
+
isNeutral: PropTypes.bool,
|
|
38
|
+
isPrimary: PropTypes.bool,
|
|
39
|
+
isBasic: PropTypes.bool,
|
|
40
|
+
isPill: PropTypes.bool,
|
|
41
|
+
focusInset: PropTypes.bool,
|
|
42
|
+
isRotated: PropTypes.bool
|
|
43
|
+
};
|
|
44
|
+
IconButton.defaultProps = {
|
|
45
|
+
isPill: true,
|
|
46
|
+
isBasic: true,
|
|
47
|
+
size: 'medium'
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export { IconButton };
|
|
@@ -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 React__default, { forwardRef } from 'react';
|
|
8
|
+
import '../styled/StyledAnchor.js';
|
|
9
|
+
import '../styled/StyledButton.js';
|
|
10
|
+
import { StyledSplitButton } from '../styled/StyledSplitButton.js';
|
|
11
|
+
import '../styled/StyledExternalIcon.js';
|
|
12
|
+
import '../styled/StyledIcon.js';
|
|
13
|
+
import '../styled/StyledIconButton.js';
|
|
14
|
+
import { SplitButtonContext } from '../utils/useSplitButtonContext.js';
|
|
15
|
+
|
|
16
|
+
const SplitButton = forwardRef((_ref, ref) => {
|
|
17
|
+
let {
|
|
18
|
+
children,
|
|
19
|
+
...other
|
|
20
|
+
} = _ref;
|
|
21
|
+
return React__default.createElement(SplitButtonContext.Provider, {
|
|
22
|
+
value: true
|
|
23
|
+
}, React__default.createElement(StyledSplitButton, Object.assign({
|
|
24
|
+
ref: ref
|
|
25
|
+
}, other), children));
|
|
26
|
+
});
|
|
27
|
+
SplitButton.displayName = 'SplitButton';
|
|
28
|
+
|
|
29
|
+
export { SplitButton };
|
|
@@ -0,0 +1,30 @@
|
|
|
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 React__default, { forwardRef } from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { Button } from './Button.js';
|
|
10
|
+
|
|
11
|
+
const ToggleButton = forwardRef((_ref, ref) => {
|
|
12
|
+
let {
|
|
13
|
+
isPressed,
|
|
14
|
+
...otherProps
|
|
15
|
+
} = _ref;
|
|
16
|
+
return React__default.createElement(Button, Object.assign({
|
|
17
|
+
"aria-pressed": isPressed,
|
|
18
|
+
ref: ref
|
|
19
|
+
}, otherProps));
|
|
20
|
+
});
|
|
21
|
+
ToggleButton.displayName = 'ToggleButton';
|
|
22
|
+
ToggleButton.propTypes = {
|
|
23
|
+
...Button.propTypes,
|
|
24
|
+
isPressed: PropTypes.oneOf([true, false, 'mixed'])
|
|
25
|
+
};
|
|
26
|
+
ToggleButton.defaultProps = {
|
|
27
|
+
size: 'medium'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { ToggleButton };
|
|
@@ -0,0 +1,32 @@
|
|
|
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 React__default, { forwardRef } from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { IconButton } from './IconButton.js';
|
|
10
|
+
|
|
11
|
+
const ToggleIconButton = forwardRef((_ref, ref) => {
|
|
12
|
+
let {
|
|
13
|
+
isPressed,
|
|
14
|
+
...otherProps
|
|
15
|
+
} = _ref;
|
|
16
|
+
return React__default.createElement(IconButton, Object.assign({
|
|
17
|
+
"aria-pressed": isPressed,
|
|
18
|
+
ref: ref
|
|
19
|
+
}, otherProps));
|
|
20
|
+
});
|
|
21
|
+
ToggleIconButton.displayName = 'ToggleIconButton';
|
|
22
|
+
ToggleIconButton.propTypes = {
|
|
23
|
+
...IconButton.propTypes,
|
|
24
|
+
isPressed: PropTypes.oneOf([true, false, 'mixed'])
|
|
25
|
+
};
|
|
26
|
+
ToggleIconButton.defaultProps = {
|
|
27
|
+
isPill: true,
|
|
28
|
+
isBasic: true,
|
|
29
|
+
size: 'medium'
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { ToggleIconButton };
|
|
@@ -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 React__default from 'react';
|
|
8
|
+
import '../../styled/StyledAnchor.js';
|
|
9
|
+
import '../../styled/StyledButton.js';
|
|
10
|
+
import '../../styled/StyledSplitButton.js';
|
|
11
|
+
import '../../styled/StyledExternalIcon.js';
|
|
12
|
+
import { StyledIcon } from '../../styled/StyledIcon.js';
|
|
13
|
+
import '../../styled/StyledIconButton.js';
|
|
14
|
+
|
|
15
|
+
const EndIconComponent = props => React__default.createElement(StyledIcon, Object.assign({
|
|
16
|
+
position: "end"
|
|
17
|
+
}, props));
|
|
18
|
+
EndIconComponent.displayName = 'Button.EndIcon';
|
|
19
|
+
const EndIcon = EndIconComponent;
|
|
20
|
+
|
|
21
|
+
export { EndIcon };
|
|
@@ -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 React__default from 'react';
|
|
8
|
+
import '../../styled/StyledAnchor.js';
|
|
9
|
+
import '../../styled/StyledButton.js';
|
|
10
|
+
import '../../styled/StyledSplitButton.js';
|
|
11
|
+
import '../../styled/StyledExternalIcon.js';
|
|
12
|
+
import { StyledIcon } from '../../styled/StyledIcon.js';
|
|
13
|
+
import '../../styled/StyledIconButton.js';
|
|
14
|
+
|
|
15
|
+
const StartIconComponent = props => React__default.createElement(StyledIcon, Object.assign({
|
|
16
|
+
position: "start"
|
|
17
|
+
}, props));
|
|
18
|
+
StartIconComponent.displayName = 'Button.StartIcon';
|
|
19
|
+
const StartIcon = StartIconComponent;
|
|
20
|
+
|
|
21
|
+
export { StartIcon };
|
|
@@ -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
|
+
export { Button } from './elements/Button.js';
|
|
8
|
+
export { Anchor } from './elements/Anchor.js';
|
|
9
|
+
export { ChevronButton } from './elements/ChevronButton.js';
|
|
10
|
+
export { IconButton } from './elements/IconButton.js';
|
|
11
|
+
export { SplitButton } from './elements/SplitButton.js';
|
|
12
|
+
export { ToggleButton } from './elements/ToggleButton.js';
|
|
13
|
+
export { ToggleIconButton } from './elements/ToggleIconButton.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
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 * as React from 'react';
|
|
8
|
+
|
|
9
|
+
var _path;
|
|
10
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
11
|
+
var SvgNewWindowStroke = function SvgNewWindowStroke(props) {
|
|
12
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
13
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
14
|
+
width: 12,
|
|
15
|
+
height: 12,
|
|
16
|
+
focusable: "false",
|
|
17
|
+
viewBox: "0 0 12 12",
|
|
18
|
+
"aria-hidden": "true"
|
|
19
|
+
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
20
|
+
fill: "none",
|
|
21
|
+
stroke: "currentColor",
|
|
22
|
+
strokeLinecap: "round",
|
|
23
|
+
d: "M10.5 8.5V10c0 .3-.2.5-.5.5H2c-.3 0-.5-.2-.5-.5V2c0-.3.2-.5.5-.5h1.5M6 6l4-4m-3.5-.5H10c.3 0 .5.2.5.5v3.5"
|
|
24
|
+
})));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { SvgNewWindowStroke as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
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 * as React from 'react';
|
|
8
|
+
|
|
9
|
+
var _path;
|
|
10
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
11
|
+
var SvgChevronDownStroke = function SvgChevronDownStroke(props) {
|
|
12
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
13
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
14
|
+
width: 16,
|
|
15
|
+
height: 16,
|
|
16
|
+
focusable: "false",
|
|
17
|
+
viewBox: "0 0 16 16",
|
|
18
|
+
"aria-hidden": "true"
|
|
19
|
+
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
20
|
+
fill: "currentColor",
|
|
21
|
+
d: "M12.688 5.61a.5.5 0 01.69.718l-.066.062-5 4a.5.5 0 01-.542.054l-.082-.054-5-4a.5.5 0 01.55-.83l.074.05L8 9.359l4.688-3.75z"
|
|
22
|
+
})));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { SvgChevronDownStroke as default };
|
|
@@ -0,0 +1,27 @@
|
|
|
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 styled from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
import { StyledButton } from './StyledButton.js';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'buttons.anchor';
|
|
12
|
+
const StyledAnchor = styled(StyledButton).attrs(props => ({
|
|
13
|
+
'data-garden-id': COMPONENT_ID,
|
|
14
|
+
'data-garden-version': '9.0.0-next.8',
|
|
15
|
+
as: 'a',
|
|
16
|
+
dir: props.theme.rtl ? 'rtl' : undefined,
|
|
17
|
+
isLink: true,
|
|
18
|
+
type: undefined
|
|
19
|
+
})).withConfig({
|
|
20
|
+
displayName: "StyledAnchor",
|
|
21
|
+
componentId: "sc-xshgmo-0"
|
|
22
|
+
})(["direction:", ";", ";"], props => props.theme.rtl && 'rtl', props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
23
|
+
StyledAnchor.defaultProps = {
|
|
24
|
+
theme: DEFAULT_THEME
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { StyledAnchor };
|
|
@@ -0,0 +1,155 @@
|
|
|
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 styled, { css } from 'styled-components';
|
|
8
|
+
import { rgba, math, em } from 'polished';
|
|
9
|
+
import { SELECTOR_FOCUS_VISIBLE, retrieveComponentStyles, DEFAULT_THEME, getColorV8, focusStyles, getFocusBoxShadow } from '@zendeskgarden/react-theming';
|
|
10
|
+
import { StyledSplitButton } from './StyledSplitButton.js';
|
|
11
|
+
import { StyledIcon } from './StyledIcon.js';
|
|
12
|
+
|
|
13
|
+
const COMPONENT_ID = 'buttons.button';
|
|
14
|
+
const getBorderRadius = props => {
|
|
15
|
+
if (props.isPill) {
|
|
16
|
+
return '100px';
|
|
17
|
+
}
|
|
18
|
+
return props.theme.borderRadii.md;
|
|
19
|
+
};
|
|
20
|
+
const getDisabledBackgroundColor = props => {
|
|
21
|
+
return getColorV8('neutralHue', 200, props.theme);
|
|
22
|
+
};
|
|
23
|
+
const getHeight = props => {
|
|
24
|
+
if (props.size === 'small') {
|
|
25
|
+
return `${props.theme.space.base * 8}px`;
|
|
26
|
+
} else if (props.size === 'large') {
|
|
27
|
+
return `${props.theme.space.base * 12}px`;
|
|
28
|
+
}
|
|
29
|
+
return `${props.theme.space.base * 10}px`;
|
|
30
|
+
};
|
|
31
|
+
const colorStyles = props => {
|
|
32
|
+
let retVal;
|
|
33
|
+
let hue;
|
|
34
|
+
if (props.disabled || props.isNeutral && props.isPrimary && !props.isDanger) {
|
|
35
|
+
hue = 'neutralHue';
|
|
36
|
+
} else if (props.isDanger) {
|
|
37
|
+
hue = 'dangerHue';
|
|
38
|
+
} else {
|
|
39
|
+
hue = 'primaryHue';
|
|
40
|
+
}
|
|
41
|
+
const shade = 600;
|
|
42
|
+
const baseColor = getColorV8(hue, shade, props.theme);
|
|
43
|
+
const hoverColor = getColorV8(hue, shade + 100, props.theme);
|
|
44
|
+
const activeColor = getColorV8(hue, shade + 200, props.theme);
|
|
45
|
+
const focusColor = getColorV8('primaryHue', shade, props.theme);
|
|
46
|
+
const disabledBackgroundColor = getDisabledBackgroundColor(props);
|
|
47
|
+
const disabledForegroundColor = getColorV8(hue, shade - 200, props.theme);
|
|
48
|
+
if (props.isLink) {
|
|
49
|
+
retVal = css(["outline-color:transparent;background-color:transparent;color:", ";", " &:hover{color:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{color:", ";}&:disabled{color:", ";}"], baseColor, focusStyles({
|
|
50
|
+
theme: props.theme,
|
|
51
|
+
condition: false,
|
|
52
|
+
styles: {
|
|
53
|
+
color: baseColor,
|
|
54
|
+
outlineColor: focusColor
|
|
55
|
+
}
|
|
56
|
+
}), hoverColor, activeColor, disabledForegroundColor);
|
|
57
|
+
} else if (props.isPrimary) {
|
|
58
|
+
retVal = css(["outline-color:transparent;background-color:", ";color:", ";&:hover{background-color:", ";}", " &:active{background-color:", ";}&[aria-pressed='true'],&[aria-pressed='mixed']{background-color:", ";}&:disabled{background-color:", ";color:", ";}"], baseColor, props.theme.palette.white, hoverColor, focusStyles({
|
|
59
|
+
theme: props.theme,
|
|
60
|
+
inset: props.focusInset,
|
|
61
|
+
shadowWidth: props.focusInset ? 'sm' : 'md',
|
|
62
|
+
spacerWidth: props.focusInset ? 'sm' : 'xs',
|
|
63
|
+
styles: props.isDanger && props.focusInset ? {
|
|
64
|
+
borderColor: focusColor
|
|
65
|
+
} : undefined
|
|
66
|
+
}), activeColor, props.isPrimary && activeColor, disabledBackgroundColor, disabledForegroundColor);
|
|
67
|
+
} else {
|
|
68
|
+
const borderColor = props.isNeutral && !props.isDanger ? getColorV8('neutralHue', 300, props.theme) : baseColor;
|
|
69
|
+
const foregroundColor = props.isNeutral ? getColorV8('foreground', 600 , props.theme) : baseColor;
|
|
70
|
+
const hoverBorderColor = props.isNeutral && !props.isDanger ? baseColor : hoverColor;
|
|
71
|
+
const hoverForegroundColor = props.isNeutral ? foregroundColor : hoverColor;
|
|
72
|
+
retVal = css(["outline-color:transparent;border-color:", ";background-color:transparent;color:", ";&:hover{border-color:", ";background-color:", ";color:", ";}", " &:active,&[aria-pressed='true'],&[aria-pressed='mixed']{border-color:", ";background-color:", ";color:", ";}&:disabled{border-color:transparent;background-color:", ";color:", ";}& ", "{color:", ";}&:hover ", ",&:focus-visible ", "{color:", ";}&:active ", "{color:", ";}&:disabled ", "{color:", ";}"], !props.isBasic && borderColor, foregroundColor, !props.isBasic && hoverBorderColor, rgba(baseColor, 0.08), hoverForegroundColor, focusStyles({
|
|
73
|
+
theme: props.theme,
|
|
74
|
+
inset: props.focusInset,
|
|
75
|
+
styles: props.isNeutral ? {
|
|
76
|
+
borderColor: baseColor
|
|
77
|
+
} : undefined
|
|
78
|
+
}), !props.isBasic && activeColor, rgba(baseColor, 0.2), !props.isNeutral && activeColor, disabledBackgroundColor, disabledForegroundColor, StyledIcon, props.isNeutral && getColorV8('neutralHue', shade, props.theme), StyledIcon, StyledIcon, props.isNeutral && getColorV8('neutralHue', shade + 100, props.theme), StyledIcon, props.isNeutral && foregroundColor, StyledIcon, disabledForegroundColor);
|
|
79
|
+
}
|
|
80
|
+
return retVal;
|
|
81
|
+
};
|
|
82
|
+
const groupStyles = props => {
|
|
83
|
+
const {
|
|
84
|
+
theme,
|
|
85
|
+
isPrimary,
|
|
86
|
+
isBasic,
|
|
87
|
+
isPill,
|
|
88
|
+
focusInset
|
|
89
|
+
} = props;
|
|
90
|
+
const {
|
|
91
|
+
rtl,
|
|
92
|
+
borderWidths,
|
|
93
|
+
borders
|
|
94
|
+
} = theme;
|
|
95
|
+
const startPosition = rtl ? 'right' : 'left';
|
|
96
|
+
const endPosition = rtl ? 'left' : 'right';
|
|
97
|
+
const marginOffset = borderWidths.sm;
|
|
98
|
+
const marginDisplacement = `${isPrimary || isBasic ? '' : '-'}${marginOffset}`;
|
|
99
|
+
const iconMarginDisplacement = isPill && '-2px';
|
|
100
|
+
const disabledBackgroundColor = !isPrimary && getDisabledBackgroundColor(props);
|
|
101
|
+
const borderColor = isBasic ? 'transparent' : 'revert';
|
|
102
|
+
const focusColor = getColorV8('primaryHue', 600, theme);
|
|
103
|
+
const focusBoxShadow = isBasic && !isPrimary && getFocusBoxShadow({
|
|
104
|
+
theme,
|
|
105
|
+
inset: focusInset,
|
|
106
|
+
spacerColor: {
|
|
107
|
+
hue: focusColor
|
|
108
|
+
},
|
|
109
|
+
color: {
|
|
110
|
+
hue: 'transparent'
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
return css(["position:relative;transition:border-color 0.1s ease-in-out,background-color 0.1s ease-in-out,box-shadow 0.1s ease-in-out,color 0.1s ease-in-out,margin-", " 0.1s ease-in-out,outline-color 0.1s ease-in-out,z-index 0.25s ease-in-out;border:", " ", ";", "{border-color:", ";box-shadow:", ";}&:hover,&:active,", "{z-index:1;}&:disabled{z-index:-1;background-color:", ";}&:not(:first-of-type){margin-", ":", ";}&:not(:first-of-type):disabled{margin-", ":", ";}&:not(:first-of-type):not(:last-of-type){border-radius:0;}&:first-of-type:not(:last-of-type){border-top-", "-radius:0;border-bottom-", "-radius:0;}&:last-of-type:not(:first-of-type){border-top-", "-radius:0;border-bottom-", "-radius:0;}&:first-of-type:not(:last-of-type) ", "{margin-", ":", ";}&:last-of-type:not(:first-of-type) ", "{margin-", ":", ";}"], startPosition, borders.sm, borderColor, SELECTOR_FOCUS_VISIBLE, focusColor, focusBoxShadow, SELECTOR_FOCUS_VISIBLE, disabledBackgroundColor, startPosition, marginDisplacement, startPosition, marginOffset, endPosition, endPosition, startPosition, startPosition, StyledIcon, endPosition, iconMarginDisplacement, StyledIcon, startPosition, iconMarginDisplacement);
|
|
114
|
+
};
|
|
115
|
+
const iconStyles = props => {
|
|
116
|
+
const size = props.size === 'small' ? props.theme.iconSizes.sm : props.theme.iconSizes.md;
|
|
117
|
+
return css(["width:", ";min-width:", ";height:", ";vertical-align:", ";"], size, size, size, props.isLink && 'middle');
|
|
118
|
+
};
|
|
119
|
+
const sizeStyles = props => {
|
|
120
|
+
let retVal;
|
|
121
|
+
if (props.isLink) {
|
|
122
|
+
retVal = css(["padding:0;font-size:inherit;"]);
|
|
123
|
+
} else {
|
|
124
|
+
const height = getHeight(props);
|
|
125
|
+
const lineHeight = math(`${height} - (${props.theme.borderWidths.sm} * 2)`);
|
|
126
|
+
let padding;
|
|
127
|
+
let fontSize;
|
|
128
|
+
if (props.size === 'small') {
|
|
129
|
+
fontSize = props.theme.fontSizes.sm;
|
|
130
|
+
padding = `${props.theme.space.base * 3}px`;
|
|
131
|
+
} else {
|
|
132
|
+
fontSize = props.theme.fontSizes.md;
|
|
133
|
+
if (props.size === 'large') {
|
|
134
|
+
padding = `${props.theme.space.base * 5}px`;
|
|
135
|
+
} else {
|
|
136
|
+
padding = `${props.theme.space.base * 4}px`;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
retVal = css(["padding:0 ", ";height:", ";line-height:", ";font-size:", ";"], em(math(`${padding} - ${props.theme.borderWidths.sm}`), fontSize), height, lineHeight, fontSize);
|
|
140
|
+
}
|
|
141
|
+
return retVal;
|
|
142
|
+
};
|
|
143
|
+
const StyledButton = styled.button.attrs(props => ({
|
|
144
|
+
'data-garden-id': COMPONENT_ID,
|
|
145
|
+
'data-garden-version': '9.0.0-next.8',
|
|
146
|
+
type: props.type || 'button'
|
|
147
|
+
})).withConfig({
|
|
148
|
+
displayName: "StyledButton",
|
|
149
|
+
componentId: "sc-qe3ace-0"
|
|
150
|
+
})(["display:", ";align-items:", ";justify-content:", ";transition:border-color 0.25s ease-in-out,box-shadow 0.1s ease-in-out,background-color 0.25s ease-in-out,color 0.25s ease-in-out,outline-color 0.1s ease-in-out,z-index 0.25s ease-in-out;margin:0;border:", ";border-radius:", ";cursor:pointer;width:", ";overflow:hidden;text-decoration:none;text-overflow:ellipsis;white-space:", ";font-family:inherit;font-weight:", ";-webkit-font-smoothing:subpixel-antialiased;box-sizing:border-box;user-select:", ";-webkit-touch-callout:none;", ";&::-moz-focus-inner{border:0;padding:0;}", "{text-decoration:none;}&:hover{text-decoration:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{transition:border-color 0.1s ease-in-out,background-color 0.1s ease-in-out,box-shadow 0.1s ease-in-out,color 0.1s ease-in-out,outline-color 0.1s ease-in-out,z-index 0.25s ease-in-out;text-decoration:", ";}", ";&:disabled{cursor:default;text-decoration:", ";}& ", "{", "}", " &&{", "}", ""], props => props.isLink ? 'inline' : 'inline-flex', props => !props.isLink && 'center', props => !props.isLink && 'center', props => `${props.isLink ? `0px solid` : props.theme.borders.sm} transparent`, props => getBorderRadius(props), props => props.isStretched ? '100%' : '', props => !props.isLink && 'nowrap', props => props.isLink ? 'inherit' : props.theme.fontWeights.regular, props => !props.isLink && 'none', props => sizeStyles(props), SELECTOR_FOCUS_VISIBLE, props => props.isLink ? 'underline' : 'none', props => props.isLink ? 'underline' : 'none', props => colorStyles(props), props => props.isLink && 'none', StyledIcon, props => iconStyles(props), StyledSplitButton, props => groupStyles(props), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
151
|
+
StyledButton.defaultProps = {
|
|
152
|
+
theme: DEFAULT_THEME
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export { StyledButton, getHeight };
|
|
@@ -0,0 +1,23 @@
|
|
|
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 styled from 'styled-components';
|
|
8
|
+
import SvgNewWindowStroke from '../node_modules/@zendeskgarden/svg-icons/src/12/new-window-stroke.svg.js';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'buttons.external_icon';
|
|
12
|
+
const StyledExternalIcon = styled(SvgNewWindowStroke).attrs({
|
|
13
|
+
'data-garden-id': COMPONENT_ID,
|
|
14
|
+
'data-garden-version': '9.0.0-next.8'
|
|
15
|
+
}).withConfig({
|
|
16
|
+
displayName: "StyledExternalIcon",
|
|
17
|
+
componentId: "sc-16oz07e-0"
|
|
18
|
+
})(["transform:", ";margin-bottom:-0.085em;padding-left:0.25em;box-sizing:content-box;width:0.85em;height:0.85em;", ";"], props => props.theme.rtl && 'scaleX(-1)', props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
19
|
+
StyledExternalIcon.defaultProps = {
|
|
20
|
+
theme: DEFAULT_THEME
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { StyledExternalIcon };
|
|
@@ -0,0 +1,40 @@
|
|
|
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 styled, { css } from 'styled-components';
|
|
8
|
+
import React__default, { Children } from 'react';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'buttons.icon';
|
|
12
|
+
const sizeStyles = props => {
|
|
13
|
+
let marginProperty;
|
|
14
|
+
if (props.position === 'start') {
|
|
15
|
+
marginProperty = `margin-${props.theme.rtl ? 'left' : 'right'}`;
|
|
16
|
+
} else if (props.position === 'end') {
|
|
17
|
+
marginProperty = `margin-${props.theme.rtl ? 'right' : 'left'}`;
|
|
18
|
+
}
|
|
19
|
+
return marginProperty && css(["", ":", "px;"], marginProperty, props.theme.space.base * 2);
|
|
20
|
+
};
|
|
21
|
+
const StyledIcon = styled(_ref => {
|
|
22
|
+
let {
|
|
23
|
+
children,
|
|
24
|
+
isRotated,
|
|
25
|
+
theme,
|
|
26
|
+
...props
|
|
27
|
+
} = _ref;
|
|
28
|
+
return React__default.cloneElement(Children.only(children), props);
|
|
29
|
+
}).attrs({
|
|
30
|
+
'data-garden-id': COMPONENT_ID,
|
|
31
|
+
'data-garden-version': '9.0.0-next.8'
|
|
32
|
+
}).withConfig({
|
|
33
|
+
displayName: "StyledIcon",
|
|
34
|
+
componentId: "sc-19meqgg-0"
|
|
35
|
+
})(["transform:", ";transition:transform 0.25s ease-in-out,color 0.25s ease-in-out;", ";", ";"], props => props.isRotated && `rotate(${props.theme.rtl ? '-' : '+'}180deg)`, props => sizeStyles(props), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
36
|
+
StyledIcon.defaultProps = {
|
|
37
|
+
theme: DEFAULT_THEME
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { StyledIcon };
|