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

Distributed less variables and mixins ? #1

Open
hmelenok opened this issue Jan 9, 2018 · 4 comments
Open

Distributed less variables and mixins ? #1

hmelenok opened this issue Jan 9, 2018 · 4 comments

Comments

@hmelenok
Copy link

hmelenok commented Jan 9, 2018

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
Copy link
Author

hmelenok commented Jan 9, 2018

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

@erasmo-marin
Copy link
Owner

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:
giuseppeg/styled-jsx-plugin-sass#10

@peterchealse
Copy link

any solutions ? plz

@hmelenok
Copy link
Author

hmelenok commented Apr 10, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants