diff options
| author | Henry Jameson <me@hjkos.com> | 2019-07-05 10:02:14 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2019-07-05 10:02:14 +0300 |
| commit | 2c2b84d31dbe906b89dfb995394d887af110e04c (patch) | |
| tree | 18e70da867cbd2498326cc947916d8ef8b1c6669 /src/components/tab_switcher/tab_switcher.js | |
| parent | 6bea363b9db1c372e0e3add4458ff4c819b7c500 (diff) | |
npm eslint --fix .
Diffstat (limited to 'src/components/tab_switcher/tab_switcher.js')
| -rw-r--r-- | src/components/tab_switcher/tab_switcher.js | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/components/tab_switcher/tab_switcher.js b/src/components/tab_switcher/tab_switcher.js index c949b458..81e4d333 100644 --- a/src/components/tab_switcher/tab_switcher.js +++ b/src/components/tab_switcher/tab_switcher.js @@ -10,6 +10,12 @@ export default Vue.component('tab-switcher', { active: this.$slots.default.findIndex(_ => _.tag) } }, + beforeUpdate () { + const currentSlot = this.$slots.default[this.active] + if (!currentSlot.tag) { + this.active = this.$slots.default.findIndex(_ => _.tag) + } + }, methods: { activateTab (index, dataset) { return () => { @@ -20,34 +26,28 @@ export default Vue.component('tab-switcher', { } } }, - beforeUpdate () { - const currentSlot = this.$slots.default[this.active] - if (!currentSlot.tag) { - this.active = this.$slots.default.findIndex(_ => _.tag) - } - }, render (h) { const tabs = this.$slots.default - .map((slot, index) => { - if (!slot.tag) return - const classesTab = ['tab'] - const classesWrapper = ['tab-wrapper'] + .map((slot, index) => { + if (!slot.tag) return + const classesTab = ['tab'] + const classesWrapper = ['tab-wrapper'] - if (index === this.active) { - classesTab.push('active') - classesWrapper.push('active') - } + if (index === this.active) { + classesTab.push('active') + classesWrapper.push('active') + } - return ( - <div class={ classesWrapper.join(' ')}> - <button - disabled={slot.data.attrs.disabled} - onClick={this.activateTab(index)} - class={classesTab.join(' ')}> - {slot.data.attrs.label}</button> - </div> - ) - }) + return ( + <div class={ classesWrapper.join(' ')}> + <button + disabled={slot.data.attrs.disabled} + onClick={this.activateTab(index)} + class={classesTab.join(' ')}> + {slot.data.attrs.label}</button> + </div> + ) + }) const contents = this.$slots.default.map((slot, index) => { if (!slot.tag) return |
