@spaced-out/ui-design-system 0.1.0 → 0.1.2
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/CHANGELOG.md +15 -0
- package/design-tokens/elevation/app-elevation.json +3 -0
- package/lib/components/Icon/ClickableIcon.js +9 -6
- package/lib/components/Icon/ClickableIcon.js.flow +57 -45
- package/lib/components/Menu/Menu.js.flow +1 -0
- package/lib/components/Menu/MenuOptionButton.js +4 -3
- package/lib/components/Menu/MenuOptionButton.js.flow +3 -2
- package/lib/components/Tooltip/Tooltip.js +9 -4
- package/lib/components/Tooltip/Tooltip.js.flow +38 -29
- package/lib/components/Tooltip/Tooltip.module.css +3 -0
- package/lib/styles/variables/_elevation.css +2 -0
- package/lib/styles/variables/_elevation.js +4 -2
- package/lib/styles/variables/_elevation.js.flow +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.1.2](https://github.com/spaced-out/ui-design-system/compare/v0.1.1...v0.1.2) (2023-03-31)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* tooltip elevation fixes ([09fd443](https://github.com/spaced-out/ui-design-system/commit/09fd44388a30d4a5753c5cb30bcc8f8e8b564d46))
|
|
11
|
+
|
|
12
|
+
### [0.1.1](https://github.com/spaced-out/ui-design-system/compare/v0.1.0...v0.1.1) (2023-03-31)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* forward ref in clickableIcon ([#92](https://github.com/spaced-out/ui-design-system/issues/92)) ([8037aa4](https://github.com/spaced-out/ui-design-system/commit/8037aa4b4c5ee77076ea6a8dc002e5526e3d9da7))
|
|
18
|
+
* tooltip fixes menu option accepts optionVariant override ([2d23b04](https://github.com/spaced-out/ui-design-system/commit/2d23b040885a5bf380c383e596647e76d988454b))
|
|
19
|
+
|
|
5
20
|
## [0.1.0](https://github.com/spaced-out/ui-design-system/compare/v0.0.68...v0.1.0) (2023-03-31)
|
|
6
21
|
|
|
7
22
|
|
|
@@ -14,7 +14,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
14
14
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
15
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
16
|
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); }
|
|
17
|
-
const ClickableIcon = _ref => {
|
|
17
|
+
const ClickableIcon = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
18
18
|
let {
|
|
19
19
|
size = 'medium',
|
|
20
20
|
className,
|
|
@@ -35,13 +35,14 @@ const ClickableIcon = _ref => {
|
|
|
35
35
|
className: (0, _classify.default)(_ClickableIconModule.default.button, {
|
|
36
36
|
[_ClickableIconModule.default.small]: size === 'small',
|
|
37
37
|
[_ClickableIconModule.default.medium]: size === 'medium'
|
|
38
|
-
}, className)
|
|
38
|
+
}, className),
|
|
39
|
+
ref: ref
|
|
39
40
|
}), /*#__PURE__*/React.createElement(_.Icon, _extends({
|
|
40
41
|
size: size
|
|
41
42
|
}, props)));
|
|
42
|
-
};
|
|
43
|
+
});
|
|
43
44
|
exports.ClickableIcon = ClickableIcon;
|
|
44
|
-
const CloseIcon = _ref2 => {
|
|
45
|
+
const CloseIcon = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
45
46
|
let {
|
|
46
47
|
size = 'medium',
|
|
47
48
|
type = 'regular',
|
|
@@ -53,6 +54,8 @@ const CloseIcon = _ref2 => {
|
|
|
53
54
|
size: size,
|
|
54
55
|
type: type,
|
|
55
56
|
color: color
|
|
56
|
-
}, props
|
|
57
|
-
|
|
57
|
+
}, props, {
|
|
58
|
+
ref: ref
|
|
59
|
+
}));
|
|
60
|
+
});
|
|
58
61
|
exports.CloseIcon = CloseIcon;
|
|
@@ -13,38 +13,41 @@ import {Icon} from './';
|
|
|
13
13
|
import css from './ClickableIcon.module.css';
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
export const ClickableIcon
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
e.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
16
|
+
export const ClickableIcon: React$AbstractComponent<
|
|
17
|
+
IconProps,
|
|
18
|
+
HTMLButtonElement,
|
|
19
|
+
> = React.forwardRef<IconProps, HTMLButtonElement>(
|
|
20
|
+
(
|
|
21
|
+
{size = 'medium', className, ariaLabel, onClick, ...props}: IconProps,
|
|
22
|
+
ref,
|
|
23
|
+
) => {
|
|
24
|
+
const onKeyDownHandler = (e) => {
|
|
25
|
+
if (e.key === 'Enter') {
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
onClick && onClick(e);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
return (
|
|
31
|
+
<UnstyledButton
|
|
32
|
+
{...props}
|
|
33
|
+
onClick={onClick}
|
|
34
|
+
onKeyDown={onKeyDownHandler}
|
|
35
|
+
ariaLabel={ariaLabel}
|
|
36
|
+
className={classify(
|
|
37
|
+
css.button,
|
|
38
|
+
{
|
|
39
|
+
[css.small]: size === 'small',
|
|
40
|
+
[css.medium]: size === 'medium',
|
|
41
|
+
},
|
|
42
|
+
className,
|
|
43
|
+
)}
|
|
44
|
+
ref={ref}
|
|
45
|
+
>
|
|
46
|
+
<Icon size={size} {...props} />
|
|
47
|
+
</UnstyledButton>
|
|
48
|
+
);
|
|
49
|
+
},
|
|
50
|
+
);
|
|
48
51
|
|
|
49
52
|
export type CloseIconProps = {
|
|
50
53
|
size?: IconSize,
|
|
@@ -55,17 +58,26 @@ export type CloseIconProps = {
|
|
|
55
58
|
ariaLabel?: string,
|
|
56
59
|
};
|
|
57
60
|
|
|
58
|
-
export const CloseIcon
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
export const CloseIcon: React$AbstractComponent<
|
|
62
|
+
CloseIconProps,
|
|
63
|
+
HTMLButtonElement,
|
|
64
|
+
> = React.forwardRef<CloseIconProps, HTMLButtonElement>(
|
|
65
|
+
(
|
|
66
|
+
{
|
|
67
|
+
size = 'medium',
|
|
68
|
+
type = 'regular',
|
|
69
|
+
color = TEXT_COLORS.primary,
|
|
70
|
+
...props
|
|
71
|
+
}: CloseIconProps,
|
|
72
|
+
ref,
|
|
73
|
+
) => (
|
|
74
|
+
<ClickableIcon
|
|
75
|
+
name="close"
|
|
76
|
+
size={size}
|
|
77
|
+
type={type}
|
|
78
|
+
color={color}
|
|
79
|
+
{...props}
|
|
80
|
+
ref={ref}
|
|
81
|
+
/>
|
|
82
|
+
),
|
|
71
83
|
);
|
|
@@ -37,7 +37,8 @@ const MenuOptionButton = props => {
|
|
|
37
37
|
iconRight,
|
|
38
38
|
iconRightType,
|
|
39
39
|
disabled,
|
|
40
|
-
optionSize
|
|
40
|
+
optionSize,
|
|
41
|
+
optionVariant = optionsVariant
|
|
41
42
|
} = option;
|
|
42
43
|
const [buttonSize, setButtonSize] = React.useState(optionSize || size);
|
|
43
44
|
const isSelected = () => {
|
|
@@ -61,11 +62,11 @@ const MenuOptionButton = props => {
|
|
|
61
62
|
disabled: menuDisabled || disabled,
|
|
62
63
|
onClick: () => onSelect && onSelect(option),
|
|
63
64
|
autoFocus: selectedOption?.key === key
|
|
64
|
-
},
|
|
65
|
+
}, optionVariant === 'checkbox' && /*#__PURE__*/React.createElement(_Checkbox.Checkbox, {
|
|
65
66
|
tabIndex: -1,
|
|
66
67
|
disabled: menuDisabled || disabled,
|
|
67
68
|
checked: isSelected()
|
|
68
|
-
}),
|
|
69
|
+
}), optionVariant === 'radio' && /*#__PURE__*/React.createElement(_RadioButton.RadioButton, {
|
|
69
70
|
disabled: menuDisabled || disabled,
|
|
70
71
|
value: option.key,
|
|
71
72
|
selectedValue: selectedKeys?.[0],
|
|
@@ -40,6 +40,7 @@ export const MenuOptionButton = (props: MenuOptionProps): React.Node => {
|
|
|
40
40
|
iconRightType,
|
|
41
41
|
disabled,
|
|
42
42
|
optionSize,
|
|
43
|
+
optionVariant = optionsVariant,
|
|
43
44
|
} = option;
|
|
44
45
|
const [buttonSize, setButtonSize] = React.useState(optionSize || size);
|
|
45
46
|
const isSelected = () => {
|
|
@@ -72,14 +73,14 @@ export const MenuOptionButton = (props: MenuOptionProps): React.Node => {
|
|
|
72
73
|
onClick={() => onSelect && onSelect(option)}
|
|
73
74
|
autoFocus={selectedOption?.key === key}
|
|
74
75
|
>
|
|
75
|
-
{
|
|
76
|
+
{optionVariant === 'checkbox' && (
|
|
76
77
|
<Checkbox
|
|
77
78
|
tabIndex={-1}
|
|
78
79
|
disabled={menuDisabled || disabled}
|
|
79
80
|
checked={isSelected()}
|
|
80
81
|
/>
|
|
81
82
|
)}
|
|
82
|
-
{
|
|
83
|
+
{optionVariant === 'radio' && (
|
|
83
84
|
<RadioButton
|
|
84
85
|
disabled={menuDisabled || disabled}
|
|
85
86
|
value={option.key}
|
|
@@ -5,7 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Tooltip = exports.DELAY_MOTION_DURATION_TYPES = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactDom = require("react-dom");
|
|
8
9
|
var _reactDomInteractions = require("@floating-ui/react-dom-interactions");
|
|
10
|
+
var ELEVATION = _interopRequireWildcard(require("../../styles/variables/_elevation"));
|
|
9
11
|
var MOTION = _interopRequireWildcard(require("../../styles/variables/_motion"));
|
|
10
12
|
var _space = require("../../styles/variables/_space");
|
|
11
13
|
var _classify = require("../../utils/classify");
|
|
@@ -36,8 +38,10 @@ const Tooltip = _ref => {
|
|
|
36
38
|
placement = 'top',
|
|
37
39
|
bodyMaxLines = 2,
|
|
38
40
|
titleMaxLines = 1,
|
|
39
|
-
delayMotionDuration = 'none'
|
|
41
|
+
delayMotionDuration = 'none',
|
|
42
|
+
elevation = ELEVATION['elevationTooltip']
|
|
40
43
|
} = _ref;
|
|
44
|
+
const bodyRef = React.useRef(document.querySelector('body'));
|
|
41
45
|
const [open, setOpen] = React.useState(false);
|
|
42
46
|
const {
|
|
43
47
|
x,
|
|
@@ -72,13 +76,14 @@ const Tooltip = _ref => {
|
|
|
72
76
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.cloneElement(children, getReferenceProps({
|
|
73
77
|
ref,
|
|
74
78
|
...children.props
|
|
75
|
-
})), open && /*#__PURE__*/React.createElement("div", _extends({
|
|
79
|
+
})), open && /*#__PURE__*/(0, _reactDom.createPortal)( /*#__PURE__*/React.createElement("div", _extends({
|
|
76
80
|
ref: floating,
|
|
77
81
|
className: (0, _classify.classify)(_TooltipModule.default.tooltip, classNames?.tooltip),
|
|
78
82
|
style: {
|
|
79
83
|
position: strategy,
|
|
80
84
|
top: y ?? _space.spaceNone,
|
|
81
|
-
left: x ?? _space.spaceNone
|
|
85
|
+
left: x ?? _space.spaceNone,
|
|
86
|
+
'--tooltip-elevation': elevation
|
|
82
87
|
}
|
|
83
88
|
}, getFloatingProps()), !!title && /*#__PURE__*/React.createElement(_Truncate.Truncate, {
|
|
84
89
|
line: titleMaxLines
|
|
@@ -88,6 +93,6 @@ const Tooltip = _ref => {
|
|
|
88
93
|
line: bodyMaxLines
|
|
89
94
|
}, /*#__PURE__*/React.createElement(_Text.BodyMedium, {
|
|
90
95
|
color: !title ? 'inversePrimary' : 'inverseSecondary'
|
|
91
|
-
}, body))));
|
|
96
|
+
}, body))), bodyRef.current));
|
|
92
97
|
};
|
|
93
98
|
exports.Tooltip = Tooltip;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// @flow strict
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
+
// $FlowFixMe[untyped-import]
|
|
5
|
+
import {createPortal} from 'react-dom';
|
|
4
6
|
import {
|
|
5
7
|
// $FlowFixMe[untyped-import]
|
|
6
8
|
autoUpdate,
|
|
@@ -24,6 +26,7 @@ import {
|
|
|
24
26
|
useRole,
|
|
25
27
|
} from '@floating-ui/react-dom-interactions';
|
|
26
28
|
|
|
29
|
+
import * as ELEVATION from '../../styles/variables/_elevation';
|
|
27
30
|
import * as MOTION from '../../styles/variables/_motion';
|
|
28
31
|
import {spaceNone, spaceXXSmall} from '../../styles/variables/_space';
|
|
29
32
|
import {classify} from '../../utils/classify';
|
|
@@ -71,6 +74,7 @@ export type TooltipProps = {
|
|
|
71
74
|
// TODO(Nishant): Decide on a type to use
|
|
72
75
|
// $FlowFixMe
|
|
73
76
|
children: any,
|
|
77
|
+
elevation?: string,
|
|
74
78
|
};
|
|
75
79
|
|
|
76
80
|
export const Tooltip = ({
|
|
@@ -82,7 +86,9 @@ export const Tooltip = ({
|
|
|
82
86
|
bodyMaxLines = 2,
|
|
83
87
|
titleMaxLines = 1,
|
|
84
88
|
delayMotionDuration = 'none',
|
|
89
|
+
elevation = ELEVATION['elevationTooltip'],
|
|
85
90
|
}: TooltipProps): React.Node => {
|
|
91
|
+
const bodyRef = React.useRef(document.querySelector('body'));
|
|
86
92
|
const [open, setOpen] = React.useState(false);
|
|
87
93
|
const {x, y, reference, floating, strategy, context} = useFloating({
|
|
88
94
|
placement,
|
|
@@ -126,36 +132,39 @@ export const Tooltip = ({
|
|
|
126
132
|
...children.props,
|
|
127
133
|
}),
|
|
128
134
|
)}
|
|
129
|
-
{open &&
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
135
|
+
{open &&
|
|
136
|
+
createPortal(
|
|
137
|
+
<div
|
|
138
|
+
ref={floating}
|
|
139
|
+
className={classify(css.tooltip, classNames?.tooltip)}
|
|
140
|
+
style={{
|
|
141
|
+
position: strategy,
|
|
142
|
+
top: y ?? spaceNone,
|
|
143
|
+
left: x ?? spaceNone,
|
|
144
|
+
'--tooltip-elevation': elevation,
|
|
145
|
+
}}
|
|
146
|
+
{...getFloatingProps()}
|
|
147
|
+
>
|
|
148
|
+
{!!title && (
|
|
149
|
+
<Truncate line={titleMaxLines}>
|
|
150
|
+
<SubTitleExtraSmall color="inversePrimary">
|
|
151
|
+
{title}
|
|
152
|
+
</SubTitleExtraSmall>
|
|
153
|
+
</Truncate>
|
|
154
|
+
)}
|
|
147
155
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
156
|
+
{!!body && (
|
|
157
|
+
<Truncate line={bodyMaxLines}>
|
|
158
|
+
<BodyMedium
|
|
159
|
+
color={!title ? 'inversePrimary' : 'inverseSecondary'}
|
|
160
|
+
>
|
|
161
|
+
{body}
|
|
162
|
+
</BodyMedium>
|
|
163
|
+
</Truncate>
|
|
164
|
+
)}
|
|
165
|
+
</div>,
|
|
166
|
+
bodyRef.current,
|
|
167
|
+
)}
|
|
159
168
|
</>
|
|
160
169
|
);
|
|
161
170
|
};
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
@value (size300) from '../../styles/variables/_size.css';
|
|
3
3
|
@value (spaceXSmall, spaceSmall, spaceXXSmall) from '../../styles/variables/_space.css';
|
|
4
4
|
@value (borderRadiusSmall) from '../../styles/variables/_border.css';
|
|
5
|
+
@value (elevationTooltip) from '../../styles/variables/_elevation.css';
|
|
5
6
|
|
|
6
7
|
.tooltip {
|
|
8
|
+
--tooltip-elevation: elevationTooltip;
|
|
7
9
|
display: flex;
|
|
8
10
|
flex-flow: column;
|
|
9
11
|
max-width: size300;
|
|
@@ -13,4 +15,5 @@
|
|
|
13
15
|
pointer-events: none;
|
|
14
16
|
border-radius: borderRadiusSmall;
|
|
15
17
|
word-wrap: break-word;
|
|
18
|
+
z-index: var(--tooltip-elevation);
|
|
16
19
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.elevationToast = exports.elevationNone = exports.elevationModal = exports.elevationMenu = exports.elevationCard = exports.elevationBackdrop = void 0;
|
|
6
|
+
exports.elevationTooltip = exports.elevationToast = exports.elevationNone = exports.elevationModal = exports.elevationMenu = exports.elevationCard = exports.elevationBackdrop = void 0;
|
|
7
7
|
|
|
8
8
|
const elevationNone = '0';
|
|
9
9
|
exports.elevationNone = elevationNone;
|
|
@@ -16,4 +16,6 @@ exports.elevationBackdrop = elevationBackdrop;
|
|
|
16
16
|
const elevationModal = '40';
|
|
17
17
|
exports.elevationModal = elevationModal;
|
|
18
18
|
const elevationToast = '60';
|
|
19
|
-
exports.elevationToast = elevationToast;
|
|
19
|
+
exports.elevationToast = elevationToast;
|
|
20
|
+
const elevationTooltip = '4';
|
|
21
|
+
exports.elevationTooltip = elevationTooltip;
|