Coder Social home page Coder Social logo

Comments (9)

bhough avatar bhough commented on May 13, 2024 2

Thanks for digging into this further @kmctown. This may be an issue with styled-components not handling the object version correctly. This is what I get as output from our version:

{"&::after":{"clear":"both","content":"","display":"table"}}

My guess is styled-components is not handling the empty string correctly. @mxstbr @geelen thoughts?

from polished.

mxstbr avatar mxstbr commented on May 13, 2024 2

I don't think this is a bug in styled-components (let's double check what other CSS-in-JS libs do here) but we should do this instead:

{
  "&::after": {
    "clear": "both",
    // Notice: Quotes inside quotes
    "content": "''",
    "display": "table"
  }
}

I think that'd fix it?

from polished.

bhough avatar bhough commented on May 13, 2024 1

Closed by #157

from polished.

nikgraf avatar nikgraf commented on May 13, 2024

Looks good to me. @bhough @mxstbr any objections?

from polished.

bhough avatar bhough commented on May 13, 2024

Our implementation is the accepted approach for all browsers (IE8+) and uses the minimum amount of properties and selectors to reduce potential impact on pseudo elements. I'm not sure I like the idea of of expanding that to accommodate one specific (albeit popular) library.

from polished.

kmctown avatar kmctown commented on May 13, 2024

Thanks for the feedback. Closing this...something else weird is going on. I created the following function in a util lib:

export function clearFix() {
  return `
    &:after {
      display: table;
      content: "";
      clear: both;
    }
  `;
}

And dropped it into styled-components the same way:

const El = styled.div`
...
${clearFix()}
...
`

And it works, where the clearFix from polished doesn't. Does that make any sense?

from polished.

bhough avatar bhough commented on May 13, 2024

Looks like the difference between the one we use and your example above is we use &::after (double colon) where you are using a single colon. https://developer.mozilla.org/en-US/docs/Web/CSS/::after

Could be some browsers aren't liking the :: colon version and we need to move to using the CSS2 version.

from polished.

kmctown avatar kmctown commented on May 13, 2024

Right, I tried it both ways. The :: colon version works as well -- as long as I'm returning the string.

export function clearFix() {
  return `
    &::after {
      display: table;
      content: "";
      clear: both;
    }
  `;
}

⬆️ That works as well. Swapping out to the polished version breaks it. For whatever reason, chrome is not liking content: '' when using the version from polished.

Here is a screenshot from Chrome devtools when using the function that returns the string:

image

And here is what it looks like when using the polished version:

image

from polished.

nikgraf avatar nikgraf commented on May 13, 2024

sweet 👍

from polished.

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.