Skip to content

Commit e07fca0

Browse files
committed
not sure, wip
1 parent b46ffe3 commit e07fca0

File tree

2 files changed

+80
-22
lines changed

2 files changed

+80
-22
lines changed

src/corePlugins.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ export let variantPlugins = {
127127

128128
// Interactive
129129
'focus-within',
130-
['hover', config('shittyHover') ? '&:hover' : '@media (hover: hover) { &:hover }'],
130+
'hover',
131+
['@hover', '@media (hover: hover) { &:hover }'],
132+
['@hover-any', '@media (any-hover: hover) { &:hover }'],
131133
'focus',
132134
'focus-visible',
133135
'active',

tests/variants.test.js

Lines changed: 77 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -756,11 +756,16 @@ it('variants only picks the used selectors in a group (apply)', () => {
756756
})
757757
})
758758
759-
test('hover includes hover media feature by default', () => {
759+
test('hover media feature variants', () => {
760760
let config = {
761761
content: [
762762
{
763-
raw: html`<div class="hover:underline group-hover:underline peer-hover:underline"></div>`,
763+
raw: html`
764+
<div class="can-hover:block"></div>
765+
<div class="any-hover:flex"></div>
766+
<div class="can-hover-none:grid"></div>
767+
<div class="any-hover-none:hidden"></div>
768+
`,
764769
},
765770
],
766771
corePlugins: { preflight: false },
@@ -776,34 +781,75 @@ test('hover includes hover media feature by default', () => {
776781
expect(result.css).toMatchFormattedCss(css`
777782
${defaults}
778783
@media (hover: hover) {
779-
.hover\:underline:hover,
780-
.group:hover .group-hover\:underline,
781-
.peer:hover ~ .peer-hover\:underline {
782-
text-decoration-line: underline;
784+
.can-hover\:block {
785+
display: block;
786+
}
787+
}
788+
@media (any-hover: hover) {
789+
.any-hover\:flex {
790+
display: flex;
791+
}
792+
}
793+
@media (hover: none) {
794+
.can-hover-none\:grid {
795+
display: grid;
796+
}
797+
}
798+
@media (any-hover: none) {
799+
.any-hover-none\:hidden {
800+
display: none;
783801
}
784802
}
785803
`)
786804
})
787805
})
788806
789-
test('legacy hover behavior using the config option', () => {
807+
test('@hover includes hover media feature', () => {
790808
let config = {
791-
hover: 'any',
792809
content: [
793810
{
794-
raw: html`<div class="hover:underline group-hover:underline peer-hover:underline"></div>`,
811+
raw: html`<div class="@hover:block group-@hover:flex peer-@hover:grid"></div>`,
795812
},
796813
],
797814
corePlugins: { preflight: false },
798-
variants: {
799-
hover: '&:hover',
800-
},
801-
plugins: [
802-
// require('tailwindcss/hover-compat'),
803-
// function ({ addVariant }) {
804-
// addVariant('hover', '&:hover')
805-
// },
815+
}
816+
817+
let input = css`
818+
@tailwind base;
819+
@tailwind components;
820+
@tailwind utilities;
821+
`
822+
823+
return run(input, config).then((result) => {
824+
expect(result.css).toMatchFormattedCss(css`
825+
${defaults}
826+
@media (hover: hover) {
827+
.\@hover\:block:hover {
828+
display: block;
829+
}
830+
}
831+
@media (hover: hover) {
832+
.group:hover .group-\@hover\:flex {
833+
display: flex;
834+
}
835+
}
836+
@media (hover: hover) {
837+
.peer:hover ~ .peer-\@hover\:grid {
838+
display: grid;
839+
}
840+
}
841+
`)
842+
})
843+
})
844+
845+
test('@hover-any includes any-hover media feature', () => {
846+
let config = {
847+
content: [
848+
{
849+
raw: html`<div class="@hover-any:block group-@hover-any:flex peer-@hover-any:grid"></div>`,
850+
},
806851
],
852+
corePlugins: { preflight: false },
807853
}
808854
809855
let input = css`
@@ -815,10 +861,20 @@ test('legacy hover behavior using the config option', () => {
815861
return run(input, config).then((result) => {
816862
expect(result.css).toMatchFormattedCss(css`
817863
${defaults}
818-
.hover\:underline:hover,
819-
.group:hover .group-hover\:underline,
820-
.peer:hover ~ .peer-hover\:underline {
821-
text-decoration-line: underline;
864+
@media (any-hover: hover) {
865+
.\@hover-any\:block:hover {
866+
display: block;
867+
}
868+
}
869+
@media (any-hover: hover) {
870+
.group:hover .group-\@hover-any\:flex {
871+
display: flex;
872+
}
873+
}
874+
@media (any-hover: hover) {
875+
.peer:hover ~ .peer-\@hover-any\:grid {
876+
display: grid;
877+
}
822878
}
823879
`)
824880
})

0 commit comments

Comments
 (0)