Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support styled component #99

Open
Kreezag opened this issue Apr 16, 2020 · 0 comments
Open

Add support styled component #99

Kreezag opened this issue Apr 16, 2020 · 0 comments

Comments

@Kreezag
Copy link

Kreezag commented Apr 16, 2020

I want to apply styles to react-portal-tooltip with a styled-components,
but i can't.
The solution may be using inline styles in different syntax, which makes DX worse

Example with styled-components:

import React from 'react'
import ToolTip from 'react-portal-tooltip'
import styled from 'styled-components'

const ToolTipStyled = styled(ToolTip)`
   color: #fff;
   background-color: #000;
   z-index: 99999
`
 
class MyComponent extends React.Component {
    state = {
        isTooltipActive: false
    }
    showTooltip() {
        this.setState({isTooltipActive: true})
    }
    hideTooltip() {
        this.setState({isTooltipActive: false})
    }
    render() {
        return (
            <div>
                <p id="text" onMouseEnter={this.showTooltip.bind(this)} onMouseLeave={this.hideTooltip.bind(this)}>This is a cool component</p>
                <ToolTipStyled active={this.state.isTooltipActive} position="top" arrow="center" parent="#text">
                    <div>
                        <p>This is the content of the tooltip</p>
                        <img src="image.png"/>
                    </div>
                </ToolTip>
            </div>
        )
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant