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

How to use a specific direction as varient? #14

Open
sarmad4444 opened this issue Mar 4, 2020 · 9 comments · May be fixed by #17
Open

How to use a specific direction as varient? #14

sarmad4444 opened this issue Mar 4, 2020 · 9 comments · May be fixed by #17

Comments

@sarmad4444
Copy link

How can I achieve something like:

@variant rtl {
    .menu-collapsed {
        @apply border-l;
    }
}
@rant989
Copy link

rant989 commented May 25, 2020

+++++++

@RonMelkhior
Copy link
Owner

Hi,

This plugin doesn't translate well into CSS (seeing as how you can't @apply variants).

What I did to get around this in my own personal projects, is add a scss mixin:

@mixin ltr {
	[dir='ltr'] & {
		@content;
	}
}

@mixin rtl {
	[dir='rtl'] & {
		@content;
	}
}

.field {
	@include ltr() {
		@apply ml-12;
	}

	@include rtl() {
		@apply mr-12;
	}
}

@jzabala
Copy link

jzabala commented Jun 19, 2020

I would like to have this feature too. Are you accepting PRs @RonMelkhior? I wouldn't mind to add it.

@RonMelkhior
Copy link
Owner

I would like to have this feature too. Are you accepting PRs @RonMelkhior? I wouldn't mind to add it.

Hi!

Do you mean adding variant support in @apply? Or adding some helpers to the PostCSS side?

I'd love to accept a PR for it, but depending on your implementation it might fit better in it's own repo so people who don't use tailwind can enjoy it. If your implementation will be pretty Tailwind-specific then of course :)

@jzabala
Copy link

jzabala commented Jun 20, 2020

Hi!

Do you mean adding variant support in @apply? Or adding some helpers to the PostCSS side?

I'd love to accept a PR for it, but depending on your implementation it might fit better in it's own repo so people who don't use tailwind can enjoy it. If your implementation will be pretty Tailwind-specific then of course :)

hi @RonMelkhior

My idea is just adding the additional variants (rtl and ltf) to allow what was initially proposed in this issue:

@variant rtl {
    .menu-collapsed {
        @apply border-l;
    }
}

By default I program my styles in ltr and only needs the variant for rtl. What do you think?

@RonMelkhior
Copy link
Owner

I doubt you can change @variant rtl to work like that since @variant is a Tailwind directive. If it's possible sure but I'd just create a custom PostCSS directive independent of Tailwind

@jzabala jzabala linked a pull request Jun 20, 2020 that will close this issue
@jzabala
Copy link

jzabala commented Jun 20, 2020

I doubt you can change @variant rtl to work like that since @variant is a Tailwind directive. If it's possible sure but I'd just create a custom PostCSS directive independent of Tailwind

I think it is not possible right now because only the direction variant is being registered in tailwind. I created a PR to add the other variants. Let me know what do you think 🙂

@RonMelkhior
Copy link
Owner

RonMelkhior commented Jun 20, 2020

Thanks! I'm unfortunately not home until Friday, so I'll only be able to merge it then.

@jzabala
Copy link

jzabala commented Jun 20, 2020

Thanks! I'm unfortunately not home until Friday, so I'll only be able to merge it then.

Sure, when you have time. Thanks @RonMelkhior

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

Successfully merging a pull request may close this issue.

4 participants