diff options
| author | kaniini <nenolod@gmail.com> | 2018-08-31 04:10:17 +0000 |
|---|---|---|
| committer | kaniini <nenolod@gmail.com> | 2018-08-31 04:10:17 +0000 |
| commit | 958acbab8d43b7514369f4bc69bc2fe0353eddf2 (patch) | |
| tree | 9c7b9d868f4b1cf8f0e592cdd607999d5484a18c /src/components/tab_switcher/tab_switcher.jsx | |
| parent | 48391a45ba8924e20f280868bca78d77a32c3ddd (diff) | |
| parent | 8c07e63f773a15119f3cf773c083fe3b76306c3f (diff) | |
Merge branch 'polish' into 'develop'
Another one of those MR that fixes many many small-to-medium things
Closes #92, #75, #122, #52, #72, and #87
See merge request pleroma/pleroma-fe!324
Diffstat (limited to 'src/components/tab_switcher/tab_switcher.jsx')
| -rw-r--r-- | src/components/tab_switcher/tab_switcher.jsx | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/components/tab_switcher/tab_switcher.jsx b/src/components/tab_switcher/tab_switcher.jsx new file mode 100644 index 00000000..3fff38f6 --- /dev/null +++ b/src/components/tab_switcher/tab_switcher.jsx @@ -0,0 +1,44 @@ +import Vue from 'vue' + +import './tab_switcher.scss' + +export default Vue.component('tab-switcher', { + name: 'TabSwitcher', + data () { + return { + active: 0 + } + }, + methods: { + activateTab(index) { + return () => this.active = index; + } + }, + render(h) { + const tabs = this.$slots.default + .filter(slot => slot.data) + .map((slot, index) => { + const classes = ['tab'] + + if (index === this.active) { + classes.push('active') + } + return (<button onClick={this.activateTab(index)} class={ classes.join(' ') }>{slot.data.attrs.label}</button>) + }); + const contents = ( + <div> + {this.$slots.default.filter(slot => slot.data)[this.active]} + </div> + ); + return ( + <div class="tab-switcher"> + <div class="tabs"> + {tabs} + </div> + <div class="contents"> + {contents} + </div> + </div> + ) + } +}) |
