|
| 1 | +const tailwindcssVariables = require('../src/index') |
| 2 | +const utils = require('./util/_utils')(__filename) |
| 3 | +const colorVariable = require('../colorVariable') |
| 4 | + |
| 5 | +test('fallback', async () => { |
| 6 | + expect( |
| 7 | + await utils.diffOnly({ |
| 8 | + corePlugins: ['textColor', 'textOpacity', 'backgroundColor', 'backgroundOpacity'], |
| 9 | + content: [utils.content()], |
| 10 | + darkMode: false, |
| 11 | + theme: { |
| 12 | + screens: false, |
| 13 | + colors: { |
| 14 | + red: { |
| 15 | + 400: 'var(--colors-red-400 red)', |
| 16 | + 500: 'var(--colors-red red)', |
| 17 | + 600: colorVariable('var(--header-color, black)'), |
| 18 | + 700: colorVariable('var(--header-color, black)', true), |
| 19 | + 800: colorVariable('var(--header-color, black)', false), |
| 20 | + }, |
| 21 | + |
| 22 | + gray: 'var(--header-color, blue)', |
| 23 | + }, |
| 24 | + |
| 25 | + variables: { |
| 26 | + DEFAULT: { |
| 27 | + header: { |
| 28 | + color: '#ffffff', |
| 29 | + }, |
| 30 | + |
| 31 | + colors: { |
| 32 | + red: { |
| 33 | + DEFAULT: '#ff0000', |
| 34 | + 400: '#ff3f3f', |
| 35 | + }, |
| 36 | + }, |
| 37 | + }, |
| 38 | + }, |
| 39 | + }, |
| 40 | + |
| 41 | + plugins: [ |
| 42 | + tailwindcssVariables({ |
| 43 | + colorVariables: true, |
| 44 | + }), |
| 45 | + ], |
| 46 | + }) |
| 47 | + ).toMatchInlineSnapshot(` |
| 48 | + " |
| 49 | +
|
| 50 | + - |
| 51 | + + :root { |
| 52 | + + --header-color: #ffffff; |
| 53 | + + --header-color-rgb: 255,255,255; |
| 54 | + + --colors-red-400: #ff3f3f; |
| 55 | + + --colors-red: #ff0000; |
| 56 | + + --colors-red-400-rgb: 255,63,63; |
| 57 | + + --colors-red-rgb: 255,0,0 |
| 58 | + + } |
| 59 | + + .bg-red-400 { |
| 60 | + + background-color: var(--colors-red-400 red) |
| 61 | + + } |
| 62 | + + .bg-red-500 { |
| 63 | + + background-color: var(--colors-red red) |
| 64 | + + } |
| 65 | + + .bg-red-600 { |
| 66 | + + --tw-bg-opacity: 1; |
| 67 | + + background-color: rgba(var(--header-color-rgb, black), var(--tw-bg-opacity)) |
| 68 | + + } |
| 69 | + + .bg-red-700 { |
| 70 | + + --tw-bg-opacity: 1; |
| 71 | + + background-color: rgba(var(--header-color, black), var(--tw-bg-opacity)) |
| 72 | + + } |
| 73 | + + .bg-gray { |
| 74 | + + background-color: var(--header-color, blue) |
| 75 | + + } |
| 76 | + + .bg-opacity-50 { |
| 77 | + + --tw-bg-opacity: 0.5 |
| 78 | + + } |
| 79 | + + .text-red-800 { |
| 80 | + + --tw-text-opacity: 1; |
| 81 | + + color: rgba(var(--header-color-rgb, black), var(--tw-text-opacity)) |
| 82 | + + } |
| 83 | + + .text-gray { |
| 84 | + + color: var(--header-color, blue) |
| 85 | + + } |
| 86 | +
|
| 87 | + " |
| 88 | + `) |
| 89 | +}) |
0 commit comments