This repository was archived by the owner on Jan 30, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed
Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change 1- import type { CustomCSSProperties , ClassesObjectType } from '../_internal' ;
1+ import type { CustomCSSProperties , ClassesObjectType , ReturnStyleType } from '../_internal' ;
2+ import styles from '../core/styles/style.module.css' ;
3+ import { isClassesObjectType , isInDevelopment } from '../_internal' ;
24
35export const media = ( query : string , secondary ?: string ) => {
4- return ( target : CustomCSSProperties | ClassesObjectType ) : ClassesObjectType => {
6+ return < T extends ClassesObjectType > ( object : T | CustomCSSProperties ) : T => {
57 const mediaQuery = `@media (${ query } ${ secondary ? ' and ' + secondary : '' } )` ;
6- return { [ mediaQuery ] : target } ;
8+
9+ if ( isClassesObjectType ( object ) ) {
10+ const result : ClassesObjectType = { } ;
11+
12+ Object . keys ( object ) . forEach ( ( className ) => {
13+ result [ className ] = {
14+ ...( ( isInDevelopment ? className : styles [ className ] ) as ReturnStyleType < T > ) ,
15+ } ;
16+ } ) ;
17+
18+ return {
19+ ...( { [ mediaQuery ] : object } as unknown as T ) ,
20+ ...( result as T ) ,
21+ } ;
22+ } else {
23+ return { [ mediaQuery ] : object } as T ;
24+ }
725 } ;
826} ;
You can’t perform that action at this time.
0 commit comments