|
|
@@ -22,6 +22,7 @@
|
|
22
|
22
|
|
|
23
|
23
|
import Speedy from 'speedy-vision';
|
|
24
|
24
|
import { SpeedySize } from 'speedy-vision/types/core/speedy-size';
|
|
|
25
|
+import { IllegalArgumentError } from './errors';
|
|
25
|
26
|
|
|
26
|
27
|
/** Resolution type */
|
|
27
|
28
|
export type Resolution = 'xs' | 'xs+' | 'sm' | 'sm+' | 'md' | 'md+' | 'lg' | 'lg+';
|
|
|
@@ -49,6 +50,11 @@ export function computeResolution(resolution: Resolution, aspectRatio: number):
|
|
49
|
50
|
const referenceHeight = REFERENCE_HEIGHT[resolution];
|
|
50
|
51
|
let width = 0, height = 0;
|
|
51
|
52
|
|
|
|
53
|
+ if(referenceHeight === undefined)
|
|
|
54
|
+ throw new IllegalArgumentError('Invalid resolution: ' + resolution);
|
|
|
55
|
+ else if(aspectRatio <= 0)
|
|
|
56
|
+ throw new IllegalArgumentError('Invalid aspect ratio: ' + aspectRatio);
|
|
|
57
|
+
|
|
52
|
58
|
if(aspectRatio >= 1) {
|
|
53
|
59
|
// landscape
|
|
54
|
60
|
height = referenceHeight;
|