@@ -185,7 +185,7 @@ module.exports = class Breakpoints {
185185 . toLowerCase ( ) } `;
186186 if ( this . #config. options . mediaQuery ) {
187187 this . #customProperties. push ( {
188- identifier : `${ baseName } -mediaQuery` ,
188+ name : `${ baseName } -mediaQuery` ,
189189 value : option . mediaQuery ,
190190 } ) ;
191191 }
@@ -194,19 +194,22 @@ module.exports = class Breakpoints {
194194 Breakpoints . getResolutions ( option )
195195 ) {
196196 this . #customProperties. push ( {
197- identifier : `${ baseName } -resolution` ,
197+ mediaFeature : "resolution" ,
198+ name : `${ baseName } -resolution` ,
198199 value : Breakpoints . getResolutions ( option ) ,
199200 } ) ;
200201 }
201202 if ( this . #config. options . minWidth && Breakpoints . getMinWidths ( option ) ) {
202203 this . #customProperties. push ( {
203- identifier : `${ baseName } -minWidth` ,
204+ mediaFeature : "minWidth" ,
205+ name : `${ baseName } -minWidth` ,
204206 value : Breakpoints . getMinWidths ( option ) ,
205207 } ) ;
206208 }
207209 if ( this . #config. options . maxWidth && Breakpoints . getMaxWidths ( option ) ) {
208210 this . #customProperties. push ( {
209- identifier : `${ baseName } -maxWidth` ,
211+ mediaFeature : "maxWidth" ,
212+ name : `${ baseName } -maxWidth` ,
210213 value : Breakpoints . getMaxWidths ( option ) ,
211214 } ) ;
212215 }
@@ -236,16 +239,19 @@ module.exports = class Breakpoints {
236239 let string = "" ;
237240 if ( this . #config. css . customMedia ) {
238241 this . #customProperties. forEach ( ( customProperty ) => {
242+ const mediaFeature = customProperty . mediaFeature
243+ ? `${ customProperty . mediaFeature } :`
244+ : "" ;
239245 // For syntax see postcss-custom-media plugin or W3C draft
240246 // Ref: https://www.npmjs.com/package/postcss-custom-media
241247 // Ref: https://www.w3.org/TR/mediaqueries-5/#at-ruledef-custom-media
242- string += `@custom-media --${ customProperty . identifier } (${ customProperty . value } );` ;
248+ string += `@custom-media --${ customProperty . name } (${ mediaFeature } ${ customProperty . value } );` ;
243249 } ) ;
244250 }
245251 if ( this . #config. css . customProperty ) {
246252 string += `${ this . #config. css . element } {` ;
247253 this . #customProperties. forEach ( ( customProperty ) => {
248- string += `--${ customProperty . identifier } : "${ customProperty . value } ";` ;
254+ string += `--${ customProperty . name } : "${ customProperty . value } ";` ;
249255 } ) ;
250256 string += `}` ;
251257 }
@@ -262,10 +268,20 @@ module.exports = class Breakpoints {
262268 */
263269 async #generateAndWriteJS( ) {
264270 const filePath = path . resolve ( process . cwd ( ) , this . #config. js . path ) ;
265- const strings = this . #customProperties. map (
266- ( customProperty ) =>
267- `"${ customProperty . identifier } ": "${ customProperty . value } "`
268- ) ;
271+ const stringArray = [ ] ;
272+ this . #customProperties. forEach ( ( customProperty ) => {
273+ const mediaFeature = customProperty . mediaFeature
274+ ? `${ customProperty . mediaFeature } :`
275+ : "" ;
276+ if ( mediaFeature ) {
277+ stringArray . push (
278+ `"${ customProperty . name } ": "(${ mediaFeature } ${ customProperty . value } )"`
279+ ) ;
280+ }
281+ stringArray . push (
282+ `"${ customProperty . name } --raw": "${ customProperty . value } "`
283+ ) ;
284+ } ) ;
269285 const prettierConfig = {
270286 ...( this . #config. prettier ?. configPath
271287 ? await Breakpoints . getPrettierConfig ( this . #config. prettier . configPath )
@@ -285,7 +301,7 @@ module.exports = class Breakpoints {
285301 await Breakpoints . writeFile (
286302 filePath ,
287303 prettier . format (
288- `const BREAKPOINTS = {${ strings . join (
304+ `const BREAKPOINTS = {${ stringArray . join (
289305 ","
290306 ) } }; export default BREAKPOINTS;`,
291307 prettierConfig
@@ -300,7 +316,7 @@ module.exports = class Breakpoints {
300316 await Breakpoints . writeFile (
301317 filePath ,
302318 prettier . format (
303- `module.exports = {${ strings . join ( "," ) } };` ,
319+ `module.exports = {${ stringArray . join ( "," ) } };` ,
304320 prettierConfig
305321 )
306322 ) ;
@@ -339,7 +355,7 @@ module.exports = class Breakpoints {
339355 if ( ! Number . isFinite ( width [ 2 ] ) && ! UNITS . length . includes ( width [ 4 ] ) ) {
340356 throw new RangeError ( MESSAGES . widthRangeError ( option ) ) ;
341357 }
342- return `min- width: ${ width [ 2 ] } ${ width [ 4 ] } ` ;
358+ return width [ 2 ] + width [ 4 ] ;
343359 }
344360
345361 /**
@@ -360,7 +376,7 @@ module.exports = class Breakpoints {
360376 if ( ! Number . isFinite ( width [ 2 ] ) && ! UNITS . length . includes ( width [ 4 ] ) ) {
361377 throw new RangeError ( MESSAGES . widthRangeError ( option ) ) ;
362378 }
363- return `max- width: ${ width [ 2 ] } ${ width [ 4 ] } ` ;
379+ return width [ 2 ] + width [ 4 ] ;
364380 }
365381
366382 /**
@@ -389,7 +405,7 @@ module.exports = class Breakpoints {
389405 ) {
390406 throw new RangeError ( MESSAGES . resolutionRangeError ( option ) ) ;
391407 }
392- return ` resolution: ${ resolution [ 1 ] } ${ resolution [ 2 ] } ` ;
408+ return resolution [ 1 ] + resolution [ 2 ] ;
393409 }
394410
395411 /**
0 commit comments