styled-jsx-plugin-less icon indicating copy to clipboard operation
styled-jsx-plugin-less copied to clipboard

Distributed less variables and mixins ?

Open hmelenok opened this issue 7 years ago • 4 comments

For example i have:

 {/*language=LESS*/}
        <style jsx>{`
          .ActionButton {
            height: 40px;
            width: 100%;
            background-color: @orangish;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background-color 250ms ease;
            cursor: pointer;
            text-decoration: none;
            &:hover {
              background-color: @dark;
            }
            &__label {
              color: white;
              text-transform: uppercase;
              font-size: 14px;
              font-weight: 600;
              cursor: pointer;
            }
          }
        `}</style>

and @orangish; and @dark should be global variables

Please add it to readme or, show me how i can get it and I will fill it for you

hmelenok avatar Jan 09 '18 14:01 hmelenok

And should add that template literals in that case now works too:

{/*language=LESS*/}
        <style jsx>{`
          .ActionButton {
            height: 40px;
            width: 100%;
            background-color: ${lessVariables['@orangish']};
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background-color 250ms ease;
            cursor: pointer;
            text-decoration: none;
            &:hover {
              background-color: ${lessVariables['@dark']};
            }
            &__label {
              color: white;
              text-transform: uppercase;
              font-size: 14px;
              font-weight: 600;
              cursor: pointer;
            }
          }
        `}</style>

Will give you: (node:3370) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Invalid % without number

hmelenok avatar Jan 09 '18 14:01 hmelenok

Thank you, I think that add support for global variables is a little hard to implement, but yo should be able to import them. Any help is welcome.

This is a related issue in the sass plugin: https://github.com/giuseppeg/styled-jsx-plugin-sass/issues/10

erasmo-marin avatar Feb 18 '18 15:02 erasmo-marin

any solutions ? plz

peterchealse avatar Apr 10 '18 12:04 peterchealse

Sorry to say guys, I should not say this in thread, but we switched to PostCSS plugin for styled jsx(with nesting, prefixing, media queries, etc), seems parser cannot handle variables in template strings.

P.S. Sorry No mixins unfortunately. In this case much more configurable will be webpack with custom loaders, but for someone it is not an option.

hmelenok avatar Apr 10 '18 13:04 hmelenok