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

Variants #52

Open
sapegin opened this issue Jul 17, 2021 · 1 comment
Open

Variants #52

sapegin opened this issue Jul 17, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@sapegin
Copy link

sapegin commented Jul 17, 2021

Is there a way to define variants like in styled-system?

export const Text = styled.p<Props>(
	{
		boxSizing: 'border-box',
	},
	variant({
		scale: 'textStyles',
		prop: 'variant',
		// Trigger the new styled-system variants API
		// Actual variant to be defined in site-specific themes
		variants: { _: {} },
	}),
	space,
	layout,
	typography,
	color,
	border,
	shadow
);

So you could define multiple props in the theme file:

const theme = {
	textStyles: {
		base: {
			color: 'base',
			fontFamily: 'base',
			fontWeight: 'base',
			lineHeight: 'base',
			letterSpacing: 'base',
			fontSize: 'm',
		},
		large: {
			color: 'base',
			fontFamily: 'base',
			fontWeight: 'base',
			lineHeight: 'base',
			letterSpacing: 'base',
			fontSize: 'l',
		},
	},
}

And use the component like this:

<Text variant="large">Hello</Text>
@roginfarrer
Copy link
Collaborator

Not at the moment. That's probably next for this library, and I've been thinking about incorporating some of the API innovations from newer libraries, like Stitches, that supports compound variants.

@roginfarrer roginfarrer added the enhancement New feature or request label Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants