-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow adding your own rendering of arrows (#82)
* Allow providing custom arrow content
- Loading branch information
Showing
7 changed files
with
143 additions
and
28 deletions.
There are no files selected for viewing
Binary file added
BIN
+20 KB
...pshots__/storyshots-test-jsx-storyshots-tooltip-custom-arrow-content-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.border-tooltip .react-tooltip-lite { | ||
box-sizing: border-box; | ||
border: 1px solid gray; | ||
border-radius: 8px; | ||
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.2); | ||
} | ||
|
||
.border-tooltip .react-tooltip-lite-down-arrow svg { | ||
transform: translateY(1px); | ||
} | ||
|
||
.border-tooltip .react-tooltip-lite-right-arrow svg { | ||
transform: rotate(270deg) translateY(-4px) translateX(-4px); | ||
} | ||
.border-tooltip .react-tooltip-lite-up-arrow svg { | ||
transform: rotate(180deg) translateY(1px); | ||
} | ||
.border-tooltip .react-tooltip-lite-left-arrow svg { | ||
transform: rotate(90deg) translateY(5px) translateX(4px); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { select } from '@storybook/addon-knobs'; | ||
|
||
import Tooltip from '../src/index'; | ||
import { isOpenOptions } from './shared'; | ||
import Wrapper from './Wrapper'; | ||
|
||
import './arrowContent.css'; | ||
|
||
storiesOf('Tooltip', module) | ||
.add('Custom arrow content', () => { | ||
const isOpen = select('isOpen', isOpenOptions, true); | ||
const svgArrow = ( | ||
<svg style={{ display: 'block' }} viewBox="0 0 21 11" width="20px" height="10px"> | ||
<path | ||
d="M0,11 L9.43630703,1.0733987 L9.43630703,1.0733987 C10.1266203,0.3284971 11.2459708,0 11.936284,1.0733987 L20,11" | ||
style={{ stroke: 'gray', fill: 'white' }} | ||
/> | ||
</svg> | ||
); | ||
|
||
|
||
return ( | ||
<React.StrictMode> | ||
<Wrapper flex> | ||
<Tooltip | ||
content="By default the text is above the element" | ||
isOpen={isOpen} | ||
className="target" | ||
background="white" | ||
color="black" | ||
tipContentClassName="border-tooltip" | ||
spacing={0} | ||
arrowContent={svgArrow} | ||
> | ||
Hover | ||
</Tooltip> | ||
<Tooltip | ||
content="It'll center if it has room" | ||
isOpen={isOpen} | ||
className="target" | ||
background="white" | ||
color="black" | ||
tipContentClassName="border-tooltip" | ||
spacing={0} | ||
arrowContent={svgArrow} | ||
> | ||
Centered | ||
</Tooltip> | ||
<Tooltip | ||
content="down" | ||
direction="down" | ||
isOpen={isOpen} | ||
className="target" | ||
background="white" | ||
color="black" | ||
tipContentClassName="border-tooltip" | ||
spacing={0} | ||
arrowContent={svgArrow} | ||
> | ||
Target is here | ||
</Tooltip> | ||
<Tooltip | ||
content="right" | ||
direction="right" | ||
isOpen={isOpen} | ||
className="target" | ||
background="white" | ||
color="black" | ||
tipContentClassName="border-tooltip" | ||
spacing={0} | ||
arrowContent={svgArrow} | ||
> | ||
Target is here | ||
</Tooltip> | ||
<Tooltip | ||
content="left" | ||
direction="left" | ||
isOpen={isOpen} | ||
className="target" | ||
background="white" | ||
color="black" | ||
tipContentClassName="border-tooltip" | ||
spacing={0} | ||
arrowContent={svgArrow} | ||
> | ||
Target is here | ||
</Tooltip> | ||
</Wrapper> | ||
</React.StrictMode> | ||
); | ||
}); |