Skip to content

Commit

Permalink
Merge pull request #352 from simenko/fix/582503-styled-tooltip
Browse files Browse the repository at this point in the history
Fix/582503 styled tooltip
  • Loading branch information
klaidigorishti authored Oct 15, 2021
2 parents 5ce2b09 + 4c4b4a8 commit 8a9fa8a
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Precise UI Changelog

## 2.1.2

- Fix Flyout container styles, add an example
- Improve arrow rendering on some displays

## 2.1.1

- Fix Flyout styling when extended with styled components
Expand Down
Binary file modified integration/__image_snapshots__/Flyout_3-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "precise-ui",
"version": "2.1.1",
"version": "2.1.2",
"description": "Precise UI React component library powered by Styled Components.",
"keywords": [
"react",
Expand Down
15 changes: 8 additions & 7 deletions src/components/Flyout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const FlyoutBody = styled.div(
${getFontStyle({ size: 'medium' })}
z-index: 100;
position: absolute;
box-shadow: 0 2qpx 6px 0 rgba(75, 78, 82, 0.2);
box-shadow: 0 2px 6px 0 rgba(75, 78, 82, 0.2);
border: 1px solid ${theme.ui4};
overflow: visible;
&[data-popper-reference-hidden='true'] {
Expand All @@ -53,7 +53,7 @@ const FlyoutArrow = styled.div(
:before {
content: ' ';
position: absolute;
top: ${theme.flyout.arrowSize}px;
top: ${theme.flyout.arrowSize + 0.5}px;
left: 0;
border-style: solid;
border-width: ${theme.flyout.arrowSize / 2}px;
Expand All @@ -63,11 +63,10 @@ const FlyoutArrow = styled.div(
:after {
content: ' ';
position: absolute;
top: ${theme.flyout.arrowSize}px;
left: 0;
top: ${theme.flyout.arrowSize - 0.5}px;
left: 0.5px;
border-style: solid;
border-width: ${theme.flyout.arrowSize / 2 - 1}px;
margin-left: 1px;
border-width: ${theme.flyout.arrowSize / 2 - 0.5}px;
border-color: ${theme.flyout.background} transparent transparent transparent;
}
`,
Expand Down Expand Up @@ -156,7 +155,9 @@ const FlyoutInt: React.FC<FlyoutProps & WithClickOutsideFCProps> = props => {
<FlyoutBody ref={setPopperElement} style={styles.popper} {...attributes.popper} {...restProps}>
{/* Normally a styled component gets the theme from context. But some other component
may pass a customized theme as a prop. See example at Tooltip component */}
<FlyoutContent theme={theme}>{content}</FlyoutContent>
<FlyoutContent theme={theme} {...restProps}>
{content}
</FlyoutContent>
<FlyoutArrow
theme={theme}
ref={setArrowElement}
Expand Down
18 changes: 18 additions & 0 deletions src/components/Tooltip/Example.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,21 @@ const { Tooltip, Avatar } = require('precise-ui');
```

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.

**Styled**

We can use `styled()` wrapper to customize Tooltip appearance

```jsx
const { styled, Tooltip, Avatar } = require('precise-ui');

const StyledTooltip = styled(Tooltip)`
min-width: 350px;
display: flex;
justify-content: center;
}`;

<StyledTooltip content="Tooltip content" position="right">
<Avatar initials="R" description="Sample" size="x-small" />
</StyledTooltip>
```

0 comments on commit 8a9fa8a

Please sign in to comment.