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

twind/style matches property should be able to be a function that takes in the variants and outputs a tw class names as a string #220

Open
joseDaKing opened this issue Oct 19, 2021 · 0 comments
Labels
🙅 Hold Progress on the issue is stopped pr³ ✨ Feature New Feature

Comments

@joseDaKing
Copy link

joseDaKing commented Oct 19, 2021

twind/style matches property should be able to be a function that takes in the variants and outputs a tw class names as a string. As of now, I cannot concat strings to form tw class names. The variants props that are set to false should indicate that they would be derived in the matches property.

const button = style({
  base: "",
  variants: {
    size: {
      sm: "",
      md: "",
      lg: ""
    },
    color: {
      secondary: false,
      primary: false,
      danger: false,
      success: false
    },
    variant: {
      filled: false,
      outlined: "inset ring-2 ",
      text: false
    },
    block: {
      true: ""
    }
  },
  defaults: {
    variant: "filled",
    color: "primary"
    size: "sm",
  },
  matches: ({ color, variant }) => {
    const colors = {
      secondary: "red",
      primary: "blue",
      danger: "yellow",
      success: "green"
    };

    const currentColor = colors[color];

    const colorLight = `${currentColor}-100`;

    const colorStrong = `${currentColor}-200`;
   
    const styles = {
      filled: `bg-${currentColor} hover:bg-${currentColor} text-white`,
      outlined: `ring-${currentColor} text-${currentColor} hover:text-${currentColor}`,
      text: `text-${currentColor} hover:text-${currentColor}`
    };
  },
})
@stale stale bot added the 🛑 Abandoned The issue or Pull Request will not be worked on label Nov 18, 2022
@sastan sastan added pr³ ✨ Feature New Feature 🙅 Hold Progress on the issue is stopped and removed 🛑 Abandoned The issue or Pull Request will not be worked on labels Nov 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙅 Hold Progress on the issue is stopped pr³ ✨ Feature New Feature
Projects
None yet
Development

No branches or pull requests

2 participants