Last active
August 28, 2018 04:25
-
-
Save Nattarat/28ef67c28db6da8ff8164737228b6b4a to your computer and use it in GitHub Desktop.
React Native : Media query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
Platform, | |
Dimensions | |
} from 'react-native' | |
import styled, { | |
css | |
} from 'styled-components' | |
const PLATFORM = Platform.OS | |
const DEVICE_WIDTH = Dimensions.get('window').width; | |
const DEVICE_HEIGHT = Dimensions.get('window').height; | |
const MOBILE = DEVICE_WIDTH <= 414 | |
const TABLET = DEVICE_WIDTH >= 415 && DEVICE_WIDTH <= 1024 | |
const IPHONE_X = PLATFORM === 'ios' && DEVICE_WIDTH === 375 && DEVICE_HEIGHT === 812 | |
export const Container = styled.View` | |
padding: ${MOBILE ? '15px' : '30px'}; | |
margin-top: ${IPHONE_X ? '60px' : '0'}; | |
` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment