Skip to content

Commit 8a9fa8a

Browse files
Merge pull request #352 from simenko/fix/582503-styled-tooltip
Fix/582503 styled tooltip
2 parents 5ce2b09 + 4c4b4a8 commit 8a9fa8a

File tree

7 files changed

+33
-9
lines changed

7 files changed

+33
-9
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Precise UI Changelog
22

3+
## 2.1.2
4+
5+
- Fix Flyout container styles, add an example
6+
- Improve arrow rendering on some displays
7+
38
## 2.1.1
49

510
- Fix Flyout styling when extended with styled components
Loading
Loading

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "precise-ui",
3-
"version": "2.1.1",
3+
"version": "2.1.2",
44
"description": "Precise UI React component library powered by Styled Components.",
55
"keywords": [
66
"react",

src/components/Flyout/index.tsx

+8-7
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const FlyoutBody = styled.div(
3030
${getFontStyle({ size: 'medium' })}
3131
z-index: 100;
3232
position: absolute;
33-
box-shadow: 0 2qpx 6px 0 rgba(75, 78, 82, 0.2);
33+
box-shadow: 0 2px 6px 0 rgba(75, 78, 82, 0.2);
3434
border: 1px solid ${theme.ui4};
3535
overflow: visible;
3636
&[data-popper-reference-hidden='true'] {
@@ -53,7 +53,7 @@ const FlyoutArrow = styled.div(
5353
:before {
5454
content: ' ';
5555
position: absolute;
56-
top: ${theme.flyout.arrowSize}px;
56+
top: ${theme.flyout.arrowSize + 0.5}px;
5757
left: 0;
5858
border-style: solid;
5959
border-width: ${theme.flyout.arrowSize / 2}px;
@@ -63,11 +63,10 @@ const FlyoutArrow = styled.div(
6363
:after {
6464
content: ' ';
6565
position: absolute;
66-
top: ${theme.flyout.arrowSize}px;
67-
left: 0;
66+
top: ${theme.flyout.arrowSize - 0.5}px;
67+
left: 0.5px;
6868
border-style: solid;
69-
border-width: ${theme.flyout.arrowSize / 2 - 1}px;
70-
margin-left: 1px;
69+
border-width: ${theme.flyout.arrowSize / 2 - 0.5}px;
7170
border-color: ${theme.flyout.background} transparent transparent transparent;
7271
}
7372
`,
@@ -156,7 +155,9 @@ const FlyoutInt: React.FC<FlyoutProps & WithClickOutsideFCProps> = props => {
156155
<FlyoutBody ref={setPopperElement} style={styles.popper} {...attributes.popper} {...restProps}>
157156
{/* Normally a styled component gets the theme from context. But some other component
158157
may pass a customized theme as a prop. See example at Tooltip component */}
159-
<FlyoutContent theme={theme}>{content}</FlyoutContent>
158+
<FlyoutContent theme={theme} {...restProps}>
159+
{content}
160+
</FlyoutContent>
160161
<FlyoutArrow
161162
theme={theme}
162163
ref={setArrowElement}

src/components/Tooltip/Example.md

+18
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,21 @@ const { Tooltip, Avatar } = require('precise-ui');
1111
```
1212

1313
The tooltip needs to wrap the content for which it needs to present some content. This pattern ensures the autoplacement and managed mode (on hover) is applied correctly.
14+
15+
**Styled**
16+
17+
We can use `styled()` wrapper to customize Tooltip appearance
18+
19+
```jsx
20+
const { styled, Tooltip, Avatar } = require('precise-ui');
21+
22+
const StyledTooltip = styled(Tooltip)`
23+
min-width: 350px;
24+
display: flex;
25+
justify-content: center;
26+
}`;
27+
28+
<StyledTooltip content="Tooltip content" position="right">
29+
<Avatar initials="R" description="Sample" size="x-small" />
30+
</StyledTooltip>
31+
```

0 commit comments

Comments
 (0)