|
| 1 | +import { run, html, css, defaults } from './util/run' |
| 2 | + |
| 3 | +it('should be possible to use contrast-more and contrast-less variants', () => { |
| 4 | + let config = { |
| 5 | + content: [ |
| 6 | + { raw: html`<div class="contrast-more:bg-pink-500 contrast-less:bg-black bg-white"></div>` }, |
| 7 | + ], |
| 8 | + corePlugins: { preflight: false }, |
| 9 | + } |
| 10 | + |
| 11 | + let input = css` |
| 12 | + @tailwind base; |
| 13 | + @tailwind components; |
| 14 | + @tailwind utilities; |
| 15 | + ` |
| 16 | + |
| 17 | + return run(input, config).then((result) => { |
| 18 | + expect(result.css).toMatchFormattedCss(css` |
| 19 | + ${defaults} |
| 20 | +
|
| 21 | + .bg-white { |
| 22 | + --tw-bg-opacity: 1; |
| 23 | + background-color: rgb(255 255 255 / var(--tw-bg-opacity)); |
| 24 | + } |
| 25 | +
|
| 26 | + @media (prefers-contrast: more) { |
| 27 | + .contrast-more\:bg-pink-500 { |
| 28 | + --tw-bg-opacity: 1; |
| 29 | + background-color: rgb(236 72 153 / var(--tw-bg-opacity)); |
| 30 | + } |
| 31 | + } |
| 32 | +
|
| 33 | + @media (prefers-contrast: less) { |
| 34 | + .contrast-less\:bg-black { |
| 35 | + --tw-bg-opacity: 1; |
| 36 | + background-color: rgb(0 0 0 / var(--tw-bg-opacity)); |
| 37 | + } |
| 38 | + } |
| 39 | + `) |
| 40 | + }) |
| 41 | +}) |
| 42 | + |
| 43 | +it('dark mode should appear after the contrast variants', () => { |
| 44 | + let config = { |
| 45 | + content: [{ raw: html`<div class="contrast-more:bg-black dark:bg-white"></div>` }], |
| 46 | + corePlugins: { preflight: false }, |
| 47 | + } |
| 48 | + |
| 49 | + let input = css` |
| 50 | + @tailwind base; |
| 51 | + @tailwind components; |
| 52 | + @tailwind utilities; |
| 53 | + ` |
| 54 | + |
| 55 | + return run(input, config).then((result) => { |
| 56 | + expect(result.css).toMatchFormattedCss(css` |
| 57 | + ${defaults} |
| 58 | +
|
| 59 | + @media (prefers-contrast: more) { |
| 60 | + .contrast-more\:bg-black { |
| 61 | + --tw-bg-opacity: 1; |
| 62 | + background-color: rgb(0 0 0 / var(--tw-bg-opacity)); |
| 63 | + } |
| 64 | + } |
| 65 | +
|
| 66 | + @media (prefers-color-scheme: dark) { |
| 67 | + .dark\:bg-white { |
| 68 | + --tw-bg-opacity: 1; |
| 69 | + background-color: rgb(255 255 255 / var(--tw-bg-opacity)); |
| 70 | + } |
| 71 | + } |
| 72 | + `) |
| 73 | + }) |
| 74 | +}) |
0 commit comments