-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathcheckMargin.ts
More file actions
41 lines (32 loc) · 962 Bytes
/
checkMargin.ts
File metadata and controls
41 lines (32 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { getBsVer } from 'ngx-bootstrap/utils';
import { AvailableBSPositions } from '../models';
const availablePositions = {
top: ['top', 'top start', 'top end'],
bottom: ['bottom', 'bottom start', 'bottom end'],
start: ['start', 'start top', 'start bottom'],
end: ['end', 'end top', 'end bottom']
};
export function checkPopoverMargin(placement: AvailableBSPositions, checkPosition: 'top' | 'bottom' | 'start' | 'end'): boolean {
if (!getBsVer().isBs5) {
return false;
}
return availablePositions[checkPosition].includes(placement);
}
export function checkMargins(placement: any): string {
if (!getBsVer().isBs5) {
return '';
}
if (checkPopoverMargin(placement, 'end')) {
return 'ms-2';
}
if (checkPopoverMargin(placement, 'start')) {
return 'me-2';
}
if (checkPopoverMargin(placement, 'top')) {
return 'mb-2';
}
if (checkPopoverMargin(placement, 'bottom')) {
return 'mt-2';
}
return '';
}