Ran linter
This commit is contained in:
@ -5,7 +5,7 @@ Renders a tooltip component.
|
||||
Use the `React.useState()` hook to create the `show` variable and initialize it to `false`.
|
||||
Return a `<div>` element that contains the `<div>` that will be the tooltip and the `children` passed to the component.
|
||||
Handle the `onMouseEnter` and `onMouseLeave` methods, by altering the value of the `show` variable.
|
||||
|
||||
|
||||
```css
|
||||
.tooltip {
|
||||
position: relative;
|
||||
@ -24,21 +24,18 @@ Handle the `onMouseEnter` and `onMouseLeave` methods, by altering the value of t
|
||||
border-color: rgba(0, 0, 0, 0.7) transparent transparent;
|
||||
}
|
||||
```
|
||||
|
||||
```jsx
|
||||
function Tooltip({ children, text, ...rest }) {
|
||||
const [show, setShow] = React.useState(false);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="tooltip" style={show ? { visibility: "visible" } : {}}>
|
||||
<div className="tooltip" style={show ? { visibility: 'visible' } : {}}>
|
||||
{text}
|
||||
<span className="tooltip-arrow" />
|
||||
</div>
|
||||
<div
|
||||
{...rest}
|
||||
onMouseEnter={() => setShow(true)}
|
||||
onMouseLeave={() => setShow(false)}
|
||||
>
|
||||
<div {...rest} onMouseEnter={() => setShow(true)} onMouseLeave={() => setShow(false)}>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
@ -47,14 +44,14 @@ function Tooltip({ children, text, ...rest }) {
|
||||
```
|
||||
|
||||
```jsx
|
||||
ReactDOM.render(
|
||||
<Tooltip text='Simple tooltip'>
|
||||
<button>Hover me!</button>
|
||||
</Tooltip>,
|
||||
document.getElementById('root')
|
||||
);
|
||||
ReactDOM.render(
|
||||
<Tooltip text="Simple tooltip">
|
||||
<button>Hover me!</button>
|
||||
</Tooltip>,
|
||||
document.getElementById('root')
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
<!-- tags: visual,state,children -->
|
||||
|
||||
<!-- expertise: 1 -->
|
||||
|
||||
Reference in New Issue
Block a user