|
1 |
| -<template> |
2 |
| - <div :class="rowClassList" :style="rowStyle"> |
3 |
| - <slot></slot> |
4 |
| - </div> |
5 |
| -</template> |
6 |
| - |
7 |
| -<script> |
8 |
| - const ROW_PREFIX = 'simple-row'; |
9 |
| - const ROW_FLEX_PREFIX = `${ROW_PREFIX}-flex`; |
10 |
| - export default { |
11 |
| - name:ROW_PREFIX, |
12 |
| - props: { |
13 |
| - gutter: { |
14 |
| - type: Number |
15 |
| - }, |
16 |
| - type: { |
17 |
| - type: String, |
18 |
| - required: false, |
19 |
| - validator: function (value) { |
20 |
| - return ['', 'flex'].indexOf(value) !== -1; |
21 |
| - } |
22 |
| - }, |
23 |
| - justify: { |
24 |
| - type: String, |
25 |
| - default: 'start', |
26 |
| - validator: function (value) { |
27 |
| - return ['start', 'end', 'center', 'space-around', 'space-between'].indexOf(value) !== -1; |
28 |
| - }, |
29 |
| - }, |
30 |
| - align: { |
31 |
| - type: String, |
32 |
| - default: 'top', |
33 |
| - validator: function (value) { |
34 |
| - return ['top', 'middle', 'bottom'].indexOf(value) !== -1; |
35 |
| - }, |
36 |
| - }, |
37 |
| - className: { |
38 |
| - type: String |
39 |
| - }, |
40 |
| - }, |
41 |
| - data() { |
42 |
| - return { |
43 |
| - } |
44 |
| - }, |
45 |
| - computed: { |
46 |
| - rowClassList() { |
47 |
| - let list = [this.type == 'flex' ? ROW_FLEX_PREFIX : ROW_PREFIX]; |
48 |
| - if (this.type === 'flex') { |
49 |
| - list.push({ |
50 |
| - [`${ROW_FLEX_PREFIX}-${this.justify}`]: this.justify, |
51 |
| - [`${ROW_FLEX_PREFIX}-${this.align}`]: this.align, |
52 |
| - }) |
53 |
| - } |
54 |
| - list.push({[`${this.className}`]: this.className}); |
55 |
| - return list; |
56 |
| - }, |
57 |
| - rowStyle() { |
58 |
| - return this.gutter !== 0 ? { |
59 |
| - 'margin-left': `${-this.gutter/2}px`, |
60 |
| - 'margin-right': `${-this.gutter/2}px` |
61 |
| - } : {}; |
62 |
| - } |
63 |
| - }, |
64 |
| - mounted() { |
65 |
| -
|
66 |
| - }, |
67 |
| - methods: { |
68 |
| - updateGutter() { |
69 |
| - this.$children.forEach(children => { |
70 |
| - let componentName = children.$options.name; |
71 |
| - if (componentName === 'simple-col') { |
72 |
| - children.gutter = this.gutter; |
73 |
| - } |
74 |
| - }); |
75 |
| - } |
76 |
| - } |
77 |
| - } |
78 |
| -</script> |
79 |
| - |
80 |
| -<!-- Add "scoped" attribute to limit CSS to this component only --> |
81 |
| -<style scoped> |
82 |
| -</style> |
| 1 | +<template> |
| 2 | + <div :class="rowClassList" :style="rowStyle"> |
| 3 | + <slot></slot> |
| 4 | + </div> |
| 5 | +</template> |
| 6 | + |
| 7 | +<script> |
| 8 | + const ROW_PREFIX = 'simple-row'; |
| 9 | + const ROW_FLEX_PREFIX = `${ROW_PREFIX}-flex`; |
| 10 | + export default { |
| 11 | + name:ROW_PREFIX, |
| 12 | + props: { |
| 13 | + gutter: { |
| 14 | + type: Number |
| 15 | + }, |
| 16 | + type: { |
| 17 | + type: String, |
| 18 | + required: false, |
| 19 | + validator: function (value) { |
| 20 | + return ['', 'flex'].indexOf(value) !== -1; |
| 21 | + } |
| 22 | + }, |
| 23 | + justify: { |
| 24 | + type: String, |
| 25 | + default: 'start', |
| 26 | + validator: function (value) { |
| 27 | + return ['start', 'end', 'center', 'space-around', 'space-between'].indexOf(value) !== -1; |
| 28 | + }, |
| 29 | + }, |
| 30 | + align: { |
| 31 | + type: String, |
| 32 | + default: 'top', |
| 33 | + validator: function (value) { |
| 34 | + return ['top', 'middle', 'bottom'].indexOf(value) !== -1; |
| 35 | + }, |
| 36 | + }, |
| 37 | + className: { |
| 38 | + type: String |
| 39 | + }, |
| 40 | + }, |
| 41 | + data() { |
| 42 | + return { |
| 43 | + } |
| 44 | + }, |
| 45 | + computed: { |
| 46 | + rowClassList() { |
| 47 | + let list = [this.type == 'flex' ? ROW_FLEX_PREFIX : ROW_PREFIX]; |
| 48 | + if (this.type === 'flex') { |
| 49 | + list.push({ |
| 50 | + [`${ROW_FLEX_PREFIX}-${this.justify}`]: this.justify, |
| 51 | + [`${ROW_FLEX_PREFIX}-${this.align}`]: this.align, |
| 52 | + }) |
| 53 | + } |
| 54 | + list.push({[`${this.className}`]: this.className}); |
| 55 | + return list; |
| 56 | + }, |
| 57 | + rowStyle() { |
| 58 | + return this.gutter !== 0 ? { |
| 59 | + 'margin-left': `${-this.gutter/2}px`, |
| 60 | + 'margin-right': `${-this.gutter/2}px` |
| 61 | + } : {}; |
| 62 | + } |
| 63 | + }, |
| 64 | + mounted() { |
| 65 | +
|
| 66 | + }, |
| 67 | + methods: { |
| 68 | + updateGutter() { |
| 69 | + this.$children.forEach(children => { |
| 70 | + let componentName = children.$options.name; |
| 71 | + if (componentName === 'simple-col') { |
| 72 | + children.gutter = this.gutter; |
| 73 | + } |
| 74 | + }); |
| 75 | + } |
| 76 | + } |
| 77 | + } |
| 78 | +</script> |
| 79 | + |
| 80 | +<!-- Add "scoped" attribute to limit CSS to this component only --> |
| 81 | +<style lang="sass"> |
| 82 | +</style> |
0 commit comments