import { Style , Query } from './shared' ; export function media ( list , style ) { return { [ `@media ${ typeof list === 'string' ? list : query ( list ) }` ] : style } ; } export function query ( list ) { const results = Object . keys ( list ) . map ( feature => { const value = list [ feature ] ; return value === true ? `(${ hyphenateProperty ( feature ) })` : `(${ hyphenateProperty ( feature ) }: ${ value })` ; } ) ; return results . join ( ' and ' ) ; } const hyphenateRegex = /(?:^(ms|moz|webkit))|[A-Z]/g ; export function hyphenateProperty ( property ) { return property . replace ( hyphenateRegex , '-$&' ) . toLowerCase ( ) ; } export function selector ( selectors , style ) { return typeof selectors === 'string' ? { [ selectors ] : style } : selectors . reduce ( ( acc , value ) => ( { ... acc , [ value ] : style } ) , { } ) ; }