@spaced-out/ui-design-system 0.1.1 → 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 +7 -0
- package/design-tokens/elevation/app-elevation.json +3 -0
- package/lib/components/Tooltip/Tooltip.js +9 -5
- package/lib/components/Tooltip/Tooltip.js.flow +38 -30
- 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,13 @@
|
|
|
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
|
+
|
|
5
12
|
### [0.1.1](https://github.com/spaced-out/ui-design-system/compare/v0.1.0...v0.1.1) (2023-03-31)
|
|
6
13
|
|
|
7
14
|
|
|
@@ -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,
|
|
@@ -47,7 +51,6 @@ const Tooltip = _ref => {
|
|
|
47
51
|
strategy,
|
|
48
52
|
context
|
|
49
53
|
} = (0, _reactDomInteractions.useFloating)({
|
|
50
|
-
strategy: 'fixed',
|
|
51
54
|
placement,
|
|
52
55
|
open,
|
|
53
56
|
onOpenChange: setOpen,
|
|
@@ -73,13 +76,14 @@ const Tooltip = _ref => {
|
|
|
73
76
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.cloneElement(children, getReferenceProps({
|
|
74
77
|
ref,
|
|
75
78
|
...children.props
|
|
76
|
-
})), open && /*#__PURE__*/React.createElement("div", _extends({
|
|
79
|
+
})), open && /*#__PURE__*/(0, _reactDom.createPortal)( /*#__PURE__*/React.createElement("div", _extends({
|
|
77
80
|
ref: floating,
|
|
78
81
|
className: (0, _classify.classify)(_TooltipModule.default.tooltip, classNames?.tooltip),
|
|
79
82
|
style: {
|
|
80
83
|
position: strategy,
|
|
81
84
|
top: y ?? _space.spaceNone,
|
|
82
|
-
left: x ?? _space.spaceNone
|
|
85
|
+
left: x ?? _space.spaceNone,
|
|
86
|
+
'--tooltip-elevation': elevation
|
|
83
87
|
}
|
|
84
88
|
}, getFloatingProps()), !!title && /*#__PURE__*/React.createElement(_Truncate.Truncate, {
|
|
85
89
|
line: titleMaxLines
|
|
@@ -89,6 +93,6 @@ const Tooltip = _ref => {
|
|
|
89
93
|
line: bodyMaxLines
|
|
90
94
|
}, /*#__PURE__*/React.createElement(_Text.BodyMedium, {
|
|
91
95
|
color: !title ? 'inversePrimary' : 'inverseSecondary'
|
|
92
|
-
}, body))));
|
|
96
|
+
}, body))), bodyRef.current));
|
|
93
97
|
};
|
|
94
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,10 +86,11 @@ 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
|
-
strategy: 'fixed',
|
|
89
94
|
placement,
|
|
90
95
|
open,
|
|
91
96
|
onOpenChange: setOpen,
|
|
@@ -127,36 +132,39 @@ export const Tooltip = ({
|
|
|
127
132
|
...children.props,
|
|
128
133
|
}),
|
|
129
134
|
)}
|
|
130
|
-
{open &&
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
+
)}
|
|
148
155
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
+
)}
|
|
160
168
|
</>
|
|
161
169
|
);
|
|
162
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;
|