-
Notifications
You must be signed in to change notification settings - Fork 182
/
Copy pathCol.svelte
66 lines (57 loc) · 1.57 KB
/
Col.svelte
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<script>
import { getColumnSizeClass, isObject } from './utils';
let className = '';
export { className as class };
export let xs = undefined;
export let sm = undefined;
export let md = undefined;
export let lg = undefined;
export let xl = undefined;
export let xxl = undefined;
const colClasses = [];
const lookup = {
xs,
sm,
md,
lg,
xl,
xxl
};
Object.keys(lookup).forEach((colWidth) => {
const columnProp = lookup[colWidth];
if (!columnProp && columnProp !== '') {
return; //no value for this width
}
const isXs = colWidth === 'xs';
if (isObject(columnProp)) {
const colSizeInterfix = isXs ? '-' : `-${colWidth}-`;
const colClass = getColumnSizeClass(isXs, colWidth, columnProp.size);
if (columnProp.size || columnProp.size === '') {
colClasses.push(colClass);
}
if (columnProp.push) {
colClasses.push(`push${colSizeInterfix}${columnProp.push}`);
}
if (columnProp.pull) {
colClasses.push(`pull${colSizeInterfix}${columnProp.pull}`);
}
if (columnProp.offset) {
colClasses.push(`offset${colSizeInterfix}${columnProp.offset}`);
}
if (columnProp.order) {
colClasses.push(`order${colSizeInterfix}${columnProp.order}`);
}
} else {
colClasses.push(getColumnSizeClass(isXs, colWidth, columnProp));
}
});
if (!colClasses.length) {
colClasses.push('col');
}
if (className) {
colClasses.push(className);
}
</script>
<div {...$$restProps} class={colClasses.join(' ')}>
<slot />
</div>