|
| 1 | +const plugin = require('tailwindcss/plugin') |
| 2 | + |
| 3 | +module.exports = { |
| 4 | + disabledFilterPlugins: { |
| 5 | + blur: false, |
| 6 | + brightness: false, |
| 7 | + contrast: false, |
| 8 | + dropShadow: false, |
| 9 | + grayscale: false, |
| 10 | + hueRotate: false, |
| 11 | + invert: false, |
| 12 | + saturate: false, |
| 13 | + sepia: false, |
| 14 | + backdropBlur: false, |
| 15 | + backdropBrightness: false, |
| 16 | + backdropContrast: false, |
| 17 | + backdropGrayscale: false, |
| 18 | + backdropHueRotate: false, |
| 19 | + backdropInvert: false, |
| 20 | + backdropOpacity: false, |
| 21 | + backdropSaturate: false, |
| 22 | + backdropSepia: false, |
| 23 | + }, |
| 24 | + blur: plugin(function({ matchUtilities, theme }) { |
| 25 | + matchUtilities( |
| 26 | + { |
| 27 | + blur: (value) => ({ |
| 28 | + filter: `blur(${value})` |
| 29 | + }), |
| 30 | + }, |
| 31 | + { values: theme('blur', ) } |
| 32 | + ) |
| 33 | + }), |
| 34 | + brightness: plugin(function({ matchUtilities, theme }) { |
| 35 | + matchUtilities( |
| 36 | + { |
| 37 | + brightness: (value) => ({ |
| 38 | + filter: `brightness(${value})` |
| 39 | + }), |
| 40 | + }, |
| 41 | + { values: theme('brightness') } |
| 42 | + ) |
| 43 | + }), |
| 44 | + contrast: plugin(function({ matchUtilities, theme }) { |
| 45 | + matchUtilities( |
| 46 | + { |
| 47 | + contrast: (value) => ({ |
| 48 | + filter: `contrast(${value})` |
| 49 | + }), |
| 50 | + }, |
| 51 | + { values: theme('contrast') } |
| 52 | + ) |
| 53 | + }), |
| 54 | + dropShadow: plugin(function({ matchUtilities, theme }) { |
| 55 | + matchUtilities( |
| 56 | + { |
| 57 | + 'drop-shadow': (value) => ({ |
| 58 | + filter: Array.isArray(value) |
| 59 | + ? value.map((v) => `drop-shadow(${v})`).join(' ') |
| 60 | + : `drop-shadow(${value})` |
| 61 | + }), |
| 62 | + }, |
| 63 | + { values: theme('dropShadow') } |
| 64 | + ) |
| 65 | + }), |
| 66 | + grayscale: plugin(function({ matchUtilities, theme }) { |
| 67 | + matchUtilities( |
| 68 | + { |
| 69 | + grayscale: (value) => ({ |
| 70 | + filter: `grayscale(${value})` |
| 71 | + }), |
| 72 | + }, |
| 73 | + { values: theme('grayscale') } |
| 74 | + ) |
| 75 | + }), |
| 76 | + hueRotate: plugin(function({ matchUtilities, theme }) { |
| 77 | + matchUtilities( |
| 78 | + { |
| 79 | + 'hue-rotate': (value) => ({ |
| 80 | + filter: `hue-rotate(${value})` |
| 81 | + }), |
| 82 | + }, |
| 83 | + { values: theme('hueRotate'), supportsNegativeValues: true } |
| 84 | + ) |
| 85 | + }), |
| 86 | + invert: plugin(function({ matchUtilities, theme }) { |
| 87 | + matchUtilities( |
| 88 | + { |
| 89 | + invert: (value) => ({ |
| 90 | + filter: `invert(${value})` |
| 91 | + }), |
| 92 | + }, |
| 93 | + { values: theme('invert') } |
| 94 | + ) |
| 95 | + }), |
| 96 | + saturate: plugin(function({ matchUtilities, theme }) { |
| 97 | + matchUtilities( |
| 98 | + { |
| 99 | + saturate: (value) => ({ |
| 100 | + filter: `saturate(${value})` |
| 101 | + }), |
| 102 | + }, |
| 103 | + { values: theme('saturate') } |
| 104 | + ) |
| 105 | + }), |
| 106 | + sepia: plugin(function({ matchUtilities, theme }) { |
| 107 | + matchUtilities( |
| 108 | + { |
| 109 | + sepia: (value) => ({ |
| 110 | + filter: `sepia(${value})` |
| 111 | + }), |
| 112 | + }, |
| 113 | + { values: theme('sepia') } |
| 114 | + ) |
| 115 | + }), |
| 116 | + backdropBlur: plugin(function({ matchUtilities, theme }) { |
| 117 | + matchUtilities( |
| 118 | + { |
| 119 | + 'backdrop-blur': (value) => ({ |
| 120 | + backdropFilter: `blur(${value})` |
| 121 | + }), |
| 122 | + }, |
| 123 | + { values: theme('backdropBlur') } |
| 124 | + ) |
| 125 | + }), |
| 126 | + backdropBrightness: plugin(function({ matchUtilities, theme }) { |
| 127 | + matchUtilities( |
| 128 | + { |
| 129 | + 'backdrop-brightness': (value) => ({ |
| 130 | + backdropFilter: `brightness(${value})` |
| 131 | + }), |
| 132 | + }, |
| 133 | + { values: theme('backdropBrightness') } |
| 134 | + ) |
| 135 | + }), |
| 136 | + backdropContrast: plugin(function({ matchUtilities, theme }) { |
| 137 | + matchUtilities( |
| 138 | + { |
| 139 | + 'backdrop-contrast': (value) => ({ |
| 140 | + backdropFilter: `contrast(${value})` |
| 141 | + }), |
| 142 | + }, |
| 143 | + { values: theme('backdropContrast') } |
| 144 | + ) |
| 145 | + }), |
| 146 | + backdropGrayscale: plugin(function({ matchUtilities, theme }) { |
| 147 | + matchUtilities( |
| 148 | + { |
| 149 | + 'backdrop-grayscale': (value) => ({ |
| 150 | + backdropFilter: `grayscale(${value})` |
| 151 | + }), |
| 152 | + }, |
| 153 | + { values: theme('backdropGrayscale') } |
| 154 | + ) |
| 155 | + }), |
| 156 | + backdropHueRotate: plugin(function({ matchUtilities, theme }) { |
| 157 | + matchUtilities( |
| 158 | + { |
| 159 | + 'backdrop-hue-rotate': (value) => ({ |
| 160 | + backdropFilter: `hue-rotate(${value})` |
| 161 | + }), |
| 162 | + }, |
| 163 | + { values: theme('backdropHueRotate'), supportsNegativeValues: true } |
| 164 | + ) |
| 165 | + }), |
| 166 | + backdropInvert: plugin(function({ matchUtilities, theme }) { |
| 167 | + matchUtilities( |
| 168 | + { |
| 169 | + 'backdrop-invert': (value) => ({ |
| 170 | + backdropFilter: `invert(${value})` |
| 171 | + }), |
| 172 | + }, |
| 173 | + { values: theme('backdropInvert') } |
| 174 | + ) |
| 175 | + }), |
| 176 | + backdropOpacity: plugin(function({ matchUtilities, theme }) { |
| 177 | + matchUtilities( |
| 178 | + { |
| 179 | + 'backdrop-opacity': (value) => ({ |
| 180 | + backdropFilter: `opacity(${value})` |
| 181 | + }), |
| 182 | + }, |
| 183 | + { values: theme('backdropOpacity') } |
| 184 | + ) |
| 185 | + }), |
| 186 | + backdropSaturate: plugin(function({ matchUtilities, theme }) { |
| 187 | + matchUtilities( |
| 188 | + { |
| 189 | + 'backdrop-saturate': (value) => ({ |
| 190 | + backdropFilter: `saturate(${value})` |
| 191 | + }), |
| 192 | + }, |
| 193 | + { values: theme('backdropSaturate') } |
| 194 | + ) |
| 195 | + }), |
| 196 | + backdropSepia: plugin(function({ matchUtilities, theme }) { |
| 197 | + matchUtilities( |
| 198 | + { |
| 199 | + 'backdrop-sepia': (value) => ({ |
| 200 | + backdropFilter: `sepia(${value})` |
| 201 | + }), |
| 202 | + }, |
| 203 | + { values: theme('backdropSepia') } |
| 204 | + ) |
| 205 | + }), |
| 206 | +} |
0 commit comments