File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed
packages/@tailwindcss-upgrade/src Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919- Don’t replace ` _ ` in suggested theme keys ([ #16433 ] ( https://github.com/tailwindlabs/tailwindcss/pull/16433 ) )
2020- Ensure ` --default-outline-width ` can be used to change the ` outline-width ` value of the ` outline ` utility
2121- Ensure drop shadow utilities don't inherit unexpectedly ([ #16471 ] ( https://github.com/tailwindlabs/tailwindcss/pull/16471 ) )
22+ - Upgrade: Ensure a ` darkMode ` JS config setting with block syntax converts to use ` @slot `
2223
2324## [ 4.0.6] - 2025-02-10
2425
Original file line number Diff line number Diff line change @@ -318,6 +318,7 @@ test(
318318 import customPlugin from './custom-plugin'
319319
320320 export default {
321+ darkMode: ['variant', '@media not print { .dark & }'],
321322 plugins: [
322323 typography,
323324 customPlugin({
Original file line number Diff line number Diff line change @@ -196,15 +196,36 @@ async function migrateTheme(
196196}
197197
198198function migrateDarkMode ( unresolvedConfig : Config & { darkMode : any } ) : string {
199- let variant : string = ''
199+ let variant : string | string [ ] = ''
200200 let addVariant = ( _name : string , _variant : string ) => ( variant = _variant )
201201 let config = ( ) => unresolvedConfig . darkMode
202202 darkModePlugin ( { config, addVariant } )
203203
204204 if ( variant === '' ) {
205205 return ''
206206 }
207- return `\n@tw-bucket custom-variant {\n@custom-variant dark (${ variant } );\n}\n`
207+
208+ if ( ! Array . isArray ( variant ) ) {
209+ variant = [ variant ]
210+ }
211+
212+ let output = ''
213+
214+ for ( let variantName of variant ) {
215+ if ( variantName === 'class' ) {
216+ continue
217+ }
218+
219+ // Convert to the block syntax if a block is used
220+ if ( variantName . includes ( '{' ) ) {
221+ variantName = variantName . replace ( '}' , '{ @slot }}' )
222+ output += `\n@tw-bucket custom-variant {\n@custom-variant dark {${ variantName } }}\n`
223+ } else {
224+ output += `\n@tw-bucket custom-variant {\n@custom-variant dark (${ variantName } );\n}\n`
225+ }
226+ }
227+
228+ return output
208229}
209230
210231// Returns a string identifier used to section theme declarations
You can’t perform that action at this time.
0 commit comments