From 476bf0afe1c890b0f08587b3942981c8c591c7be Mon Sep 17 00:00:00 2001 From: shpuld Date: Thu, 31 Jan 2019 17:00:31 +0200 Subject: Fix media timeline attachments being small by adding an option to not render background tabs in tab switcher --- src/components/settings/settings.js | 2 +- src/components/style_switcher/style_switcher.js | 2 +- src/components/tab_switcher/tab_switcher.js | 67 +++++++++++++++++++++++++ src/components/tab_switcher/tab_switcher.jsx | 65 ------------------------ src/components/user_profile/user_profile.vue | 48 +++++++++++++++--- src/components/user_settings/user_settings.js | 2 +- src/components/user_settings/user_settings.vue | 2 +- 7 files changed, 112 insertions(+), 76 deletions(-) create mode 100644 src/components/tab_switcher/tab_switcher.js delete mode 100644 src/components/tab_switcher/tab_switcher.jsx (limited to 'src') diff --git a/src/components/settings/settings.js b/src/components/settings/settings.js index 06011e7c..7000fa5e 100644 --- a/src/components/settings/settings.js +++ b/src/components/settings/settings.js @@ -1,5 +1,5 @@ /* eslint-env browser */ -import TabSwitcher from '../tab_switcher/tab_switcher.jsx' +import TabSwitcher from '../tab_switcher/tab_switcher.js' import StyleSwitcher from '../style_switcher/style_switcher.vue' import InterfaceLanguageSwitcher from '../interface_language_switcher/interface_language_switcher.vue' import { filter, trim } from 'lodash' diff --git a/src/components/style_switcher/style_switcher.js b/src/components/style_switcher/style_switcher.js index 6a4e1cba..8c3d4861 100644 --- a/src/components/style_switcher/style_switcher.js +++ b/src/components/style_switcher/style_switcher.js @@ -7,7 +7,7 @@ import OpacityInput from '../opacity_input/opacity_input.vue' import ShadowControl from '../shadow_control/shadow_control.vue' import FontControl from '../font_control/font_control.vue' import ContrastRatio from '../contrast_ratio/contrast_ratio.vue' -import TabSwitcher from '../tab_switcher/tab_switcher.jsx' +import TabSwitcher from '../tab_switcher/tab_switcher.js' import Preview from './preview.vue' import ExportImport from '../export_import/export_import.vue' diff --git a/src/components/tab_switcher/tab_switcher.js b/src/components/tab_switcher/tab_switcher.js new file mode 100644 index 00000000..f9c3f927 --- /dev/null +++ b/src/components/tab_switcher/tab_switcher.js @@ -0,0 +1,67 @@ +import Vue from 'vue' + +import './tab_switcher.scss' + +export default Vue.component('tab-switcher', { + name: 'TabSwitcher', + props: ['renderOnlyFocused'], + data () { + return { + active: this.$slots.default.findIndex(_ => _.tag) + } + }, + methods: { + activateTab (index) { + return () => { + this.active = index + } + } + }, + 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'] + + if (index === this.active) { + classesTab.push('active') + classesWrapper.push('active') + } + + return ( +
+ +
+ ) + }) + + const contents = this.$slots.default.map((slot, index) => { + if (!slot.tag) return + const active = index === this.active + if (this.renderOnlyFocused) { + return active + ?
{slot}
+ : + } + return
{slot}
+ }) + + return ( +
+
+ {tabs} +
+
+ {contents} +
+
+ ) + } +}) diff --git a/src/components/tab_switcher/tab_switcher.jsx b/src/components/tab_switcher/tab_switcher.jsx deleted file mode 100644 index 9038733c..00000000 --- a/src/components/tab_switcher/tab_switcher.jsx +++ /dev/null @@ -1,65 +0,0 @@ -import Vue from 'vue' - -import './tab_switcher.scss' - -export default Vue.component('tab-switcher', { - name: 'TabSwitcher', - data () { - return { - active: this.$slots.default.findIndex(_ => _.tag) - } - }, - methods: { - activateTab (index) { - return () => { - this.active = index - } - } - }, - 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'] - - if (index === this.active) { - classesTab.push('active') - classesWrapper.push('active') - } - - return ( -
- -
- ) - }) - - const contents = this.$slots.default.map((slot, index) => { - if (!slot.tag) return - const active = index === this.active - return ( -
- {slot} -
- ) - }) - - return ( -
-
- {tabs} -
-
- {contents} -
-
- ) - } -}) diff --git a/src/components/user_profile/user_profile.vue b/src/components/user_profile/user_profile.vue index f9b964ce..e53ce4cc 100644 --- a/src/components/user_profile/user_profile.vue +++ b/src/components/user_profile/user_profile.vue @@ -1,12 +1,28 @@