diff --git a/CHANGELOG.md b/CHANGELOG.md index 72972633acea..5a6c2ec82e89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Make `outline` configurable, `outline-none` more accessible by default, and add `outline-black` and `outline-white` ([#2460](https://github.com/tailwindlabs/tailwindcss/pull/2460)) - Add additional small `rotate` and `skew` values ([#2528](https://github.com/tailwindlabs/tailwindcss/pull/2528)) - Add `xl`, `2xl`, and `3xl` border radius values ([#2529](https://github.com/tailwindlabs/tailwindcss/pull/2529)) +- Support disabling dark mode variants globally ([#2530](https://github.com/tailwindlabs/tailwindcss/pull/2530)) ## [1.8.12] - 2020-10-07 diff --git a/__tests__/darkMode.test.js b/__tests__/darkMode.test.js index eda74a4967ad..e2b73b062e9a 100644 --- a/__tests__/darkMode.test.js +++ b/__tests__/darkMode.test.js @@ -143,6 +143,29 @@ test('dark mode variants can be generated using the class strategy', () => { }) }) +test('dark mode variants can be disabled', () => { + const input = ` + @variants dark { + .text-red { + color: red; + } + } + ` + + const expected = ` + .text-red { + color: red; + } + ` + + expect.assertions(2) + + return run(input, { dark: false }).then(result => { + expect(result.css).toMatchCss(expected) + expect(result.warnings().length).toBe(0) + }) +}) + test('dark mode variants stack with other variants', () => { const input = ` @variants responsive, dark, hover, focus { diff --git a/src/flagged/darkModeVariantPlugin.js b/src/flagged/darkModeVariantPlugin.js index fb9606702634..7257942e702c 100644 --- a/src/flagged/darkModeVariantPlugin.js +++ b/src/flagged/darkModeVariantPlugin.js @@ -4,6 +4,10 @@ export default function({ addVariant, config, postcss, prefix }) { addVariant( 'dark', ({ container, separator, modifySelectors }) => { + if (config('dark') === false) { + return postcss.root() + } + if (config('dark') === 'media') { const modified = modifySelectors(({ selector }) => { return buildSelectorVariant(selector, 'dark', separator, message => {