morajabi / styled-media-query

💅💍 Better media queries for styled-component
MIT License
1.32k stars 53 forks source link

[feature request] Specific Devices #28

Open alex-cory opened 4 years ago

alex-cory commented 4 years ago

Sometimes you need to do custom css that only applies for specific devices (i.e. iphone x). Would be cool if you had built in features for these.

Here's an example:

const Cool = styled.div`
  ${media.iphonex`
    /* styles to be applied to iphonex only */
  `}
`

Or something like

const Cool = styled.div`
  ${media.device('iphonex').orientation('portrait')`
    /* styles to be applied to iphonex only */
  `}
`

Here's some iphone device media queries

const media = {
  iphonex: (...args) => css`
    @media only screen 
    and (device-width : 375px) 
    and (device-height : 812px) 
    and (-webkit-device-pixel-ratio : 3) {
      ${css(...args)}
    }
  `
}