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

FR: extra field per swatch to use in conjunction with Tailwind #39

Closed
robdekort opened this issue Nov 1, 2022 · 1 comment
Closed

Comments

@robdekort
Copy link
Contributor

It would be lovely if we could have another field per swatch. I currently abuse the label field as follows:

-
  handle: theme
  field:
    colors:
      -
        label: '44 103 153'
        value:
          - '#2C6799'

In my HTML I set the current theme like this:

<style>
    {{ selector or ':root' }} {
        --color-theme: {{ theme.label }};
    }
</style>

And in the Tailwind config I reference the RGB values so I maintain support for the Tailwind shorthand opacity syntax.

module.exports = {
  theme: {
    colors: {
      primary: {
        DEFAULT: 'rgb(var(--color-theme) / <alpha-value>)'
      },
    }
  }
}

Abusing the label field works, but it is not ideal in the CP since it's used as a label for the button. Also this wouldn't work when a swatch gets multiple colours. An array per value might be a nice solution.

@robdekort
Copy link
Contributor Author

I bypassed this by using rgb values as the color value and then doing this in Antlers:

<style>
    {{ selector or ':root' }} {
        --color-theme: {{ theme.value[0] | replace('rgb(', '') | replace(')', '') }};
    }
</style>

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