You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					42 lines
				
				1.1 KiB
			
		
		
			
		
	
	
					42 lines
				
				1.1 KiB
			| 
								 
											3 years ago
										 
									 | 
							
								"use strict";
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								exports.__esModule = true;
							 | 
						||
| 
								 | 
							
								exports["default"] = hiDPI;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * Generates a media query to target HiDPI devices.
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @example
							 | 
						||
| 
								 | 
							
								 * // Styles as object usage
							 | 
						||
| 
								 | 
							
								 * const styles = {
							 | 
						||
| 
								 | 
							
								 *  [hiDPI(1.5)]: {
							 | 
						||
| 
								 | 
							
								 *    width: 200px;
							 | 
						||
| 
								 | 
							
								 *  }
							 | 
						||
| 
								 | 
							
								 * }
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * // styled-components usage
							 | 
						||
| 
								 | 
							
								 * const div = styled.div`
							 | 
						||
| 
								 | 
							
								 *   ${hiDPI(1.5)} {
							 | 
						||
| 
								 | 
							
								 *     width: 200px;
							 | 
						||
| 
								 | 
							
								 *   }
							 | 
						||
| 
								 | 
							
								 * `
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * // CSS as JS Output
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * '@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
							 | 
						||
| 
								 | 
							
								 *  only screen and (min--moz-device-pixel-ratio: 1.5),
							 | 
						||
| 
								 | 
							
								 *  only screen and (-o-min-device-pixel-ratio: 1.5/1),
							 | 
						||
| 
								 | 
							
								 *  only screen and (min-resolution: 144dpi),
							 | 
						||
| 
								 | 
							
								 *  only screen and (min-resolution: 1.5dppx)': {
							 | 
						||
| 
								 | 
							
								 *   'width': '200px',
							 | 
						||
| 
								 | 
							
								 * }
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								function hiDPI(ratio) {
							 | 
						||
| 
								 | 
							
								  if (ratio === void 0) {
							 | 
						||
| 
								 | 
							
								    ratio = 1.3;
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  return "\n    @media only screen and (-webkit-min-device-pixel-ratio: " + ratio + "),\n    only screen and (min--moz-device-pixel-ratio: " + ratio + "),\n    only screen and (-o-min-device-pixel-ratio: " + ratio + "/1),\n    only screen and (min-resolution: " + Math.round(ratio * 96) + "dpi),\n    only screen and (min-resolution: " + ratio + "dppx)\n  ";
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								module.exports = exports.default;
							 |