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 should support a css property that allows to use other props to create custom css #219

Open
sastan opened this issue Oct 19, 2021 · 1 comment
Labels
✨ Feature Request Something should be added 🙅 Hold Progress on the issue is stopped

Comments

@sastan
Copy link
Collaborator

sastan commented Oct 19, 2021

import { styled } from "@twind/react"

interface IAutoGridProps {
  amount: number;
  minWidth: number;
  maxWidth: number;
}

const AutoGrid = styled('div', {
  // New property that accepts a function which is passed all props
  css: ({ amount, minWidth, maxWidth }: IAutoGridProps) => ({
    gridTemplateColumns: `repeat(${amount}, minmax(${minWidth}, ${maxWidth}))`
  })
})
@joseDaKing
Copy link

I think the css method should take a second parameter and it is type would be the variants. I think there are some scenarios where it is needed.

import { styled } from "@twind/react"

interface IAutoGridProps {
  amount: number;
  minWidth: number;
  maxWidth: number;
}

const AutoGrid = styled('div', {
  variants: {
    a: {
      1: "",
      2: ""
    },
    b: {
      3: "",
      2: ""
    }
  }
  // New property that accepts a function which is passed all props
  // The type of the second argument would be { a: 1 | 2, b: 3 | 2 }
  css: ({ amount, minWidth, maxWidth }: IAutoGridProps, { a, b }) => ({
    gridTemplateColumns: `repeat(${amount}, minmax(${minWidth}, ${maxWidth}))`
  })
})

And also all properties for the css method should have variants for them.

@stale stale bot added the 🛑 Abandoned The issue or Pull Request will not be worked on label Nov 18, 2022
@sastan sastan added 🙅 Hold Progress on the issue is stopped ✨ Feature Request Something should be added 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
✨ Feature Request Something should be added 🙅 Hold Progress on the issue is stopped
Projects
None yet
Development

No branches or pull requests

2 participants