Coder Social home page Coder Social logo

Comments (4)

orar avatar orar commented on August 18, 2024

Instance:

.buttonContainer {
 width: 200px; //doesnt matter
}
.blockButton {
  width: 100%; //will not work
  border-radius: 5px;
}
const Button = ({ innerRef, ...rest })  => {
  return <button ref={innerRef} className="blockButton" >Block Button</button>
}

<div className="buttonContainer" >
  <Floater
    content={something}
    title={someTitle}
  >
    <Button />
  </Floater>
</div>

Will not work because there are additional span wrapped around button suppressing .blockButton effect

from react-floater.

gilbarbara avatar gilbarbara commented on August 18, 2024

Yeah, this won't work since the floater is rendered outside your app in a React Portal...

You can pass your own component to the Floater and set the styles for the button.
Check the WithStyledComponents in the demo

from react-floater.

gilbarbara avatar gilbarbara commented on August 18, 2024

@orar Sorry, I understood your problem after my previous comment.
You can set the Floater styles prop to change the wrapper options.

<div className="buttonContainer" >
  <Floater
    content={something}
    title={someTitle}
	styles={{
      wrapper: {
        display: 'flex', // or display: 'block' or width: '100%'
      }
    }}
  >
    <Button />
  </Floater>
</div>

from react-floater.

zenVentzi avatar zenVentzi commented on August 18, 2024

I second that. The expected behaviour should be to maintain the styles of the parent. I noticed the 2 spans that wrap the actual component that create the issue.

I tried the wrapper: {} style solution but it didn't work. I'm sure if I hang around more I'll eventually figure out the mini mistake I've made but I'd say that this solution is quite unintuitive. Also I have way more props to be copy-pasted from the parent components into the wrapper: {} style and this creates room for mistakes from copy-pasting.

Appreciate your work though!

from react-floater.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.