better impl of header hiding?
This commit is contained in:
parent
3f4ad34377
commit
8b8af2889b
3 changed files with 22 additions and 16 deletions
|
|
@ -76,7 +76,7 @@ const SettingsModalContent = {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
navCollapsed: false,
|
navCollapsed: false,
|
||||||
childCollapsed: false
|
navHideHeader: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -97,15 +97,15 @@ const SettingsModalContent = {
|
||||||
},
|
},
|
||||||
nestedTooBig () {
|
nestedTooBig () {
|
||||||
this.navCollapsed = false
|
this.navCollapsed = false
|
||||||
this.childCollapsed = this.$refs.generalTab.getNavMode()
|
|
||||||
console.log(this.navCollapsed, this.childCollapsed)
|
|
||||||
this.$refs.tabSwitcher.showNav()
|
this.$refs.tabSwitcher.showNav()
|
||||||
},
|
},
|
||||||
nestedTooSmall () {
|
nestedTooSmall () {
|
||||||
this.navCollapsed = true
|
this.navCollapsed = true
|
||||||
this.childCollapsed = this.$refs.generalTab.getNavMode()
|
|
||||||
console.log(this.navCollapsed, this.childCollapsed)
|
|
||||||
this.$refs.tabSwitcher.hideNav()
|
this.$refs.tabSwitcher.hideNav()
|
||||||
|
},
|
||||||
|
nestedNavSide (side) {
|
||||||
|
console.log('SWITCH')
|
||||||
|
this.navHideHeader = side === 'content'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
:scrollable-tabs="true"
|
:scrollable-tabs="true"
|
||||||
:child-collapsed="childCollapsed"
|
:child-collapsed="childCollapsed"
|
||||||
:body-scroll-lock="bodyLock"
|
:body-scroll-lock="bodyLock"
|
||||||
|
:hide-header="navHideHeader"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
:full-width="true"
|
:full-width="true"
|
||||||
|
|
@ -16,6 +17,7 @@
|
||||||
class="inner-tab -middle"
|
class="inner-tab -middle"
|
||||||
ref="generalTab"
|
ref="generalTab"
|
||||||
:parent-collapsed="navCollapsed"
|
:parent-collapsed="navCollapsed"
|
||||||
|
@side-switch="(side) => nestedNavSide(side)"
|
||||||
@too-small="() => nestedTooSmall()"
|
@too-small="() => nestedTooSmall()"
|
||||||
@too-big="() => nestedTooBig()"
|
@too-big="() => nestedTooBig()"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -37,13 +37,17 @@ export default {
|
||||||
required: false,
|
required: false,
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: null
|
default: null
|
||||||
|
},
|
||||||
|
hideHeader: {
|
||||||
|
required: false,
|
||||||
|
type: Boolean,
|
||||||
|
default: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
emits: ['tooBig', 'tooSmall'],
|
emits: ['tooBig', 'tooSmall', 'sideSwitch'],
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
active: findFirstUsable(this.slots()),
|
active: findFirstUsable(this.slots()),
|
||||||
childCollapsed: null,
|
|
||||||
resizeHandler: null,
|
resizeHandler: null,
|
||||||
navMode: false,
|
navMode: false,
|
||||||
navSide: 'content'
|
navSide: 'content'
|
||||||
|
|
@ -89,7 +93,7 @@ export default {
|
||||||
return (e) => {
|
return (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
this.setTab(index)
|
this.setTab(index)
|
||||||
onResize()
|
this.onResize()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setTab (index) {
|
setTab (index) {
|
||||||
|
|
@ -97,7 +101,7 @@ export default {
|
||||||
this.onSwitch.call(null, this.slots()[index].key)
|
this.onSwitch.call(null, this.slots()[index].key)
|
||||||
}
|
}
|
||||||
this.active = index
|
this.active = index
|
||||||
this.navSide = 'content'
|
this.changeNavSide('content')
|
||||||
},
|
},
|
||||||
showNav () {
|
showNav () {
|
||||||
this.navMode = false
|
this.navMode = false
|
||||||
|
|
@ -105,6 +109,10 @@ export default {
|
||||||
hideNav () {
|
hideNav () {
|
||||||
this.navMode = true
|
this.navMode = true
|
||||||
},
|
},
|
||||||
|
changeNavSide (side) {
|
||||||
|
this.navSide = side
|
||||||
|
this.$emit('sideSwitch', side)
|
||||||
|
},
|
||||||
getNavMode () {
|
getNavMode () {
|
||||||
return this.navMode
|
return this.navMode
|
||||||
},
|
},
|
||||||
|
|
@ -115,11 +123,6 @@ export default {
|
||||||
const navWidth = this.$refs.nav?.clientWidth
|
const navWidth = this.$refs.nav?.clientWidth
|
||||||
const contentsWidth = this.$refs.contents?.clientWidth
|
const contentsWidth = this.$refs.contents?.clientWidth
|
||||||
|
|
||||||
const nestedSwitcher = this.$refs.contents?.querySelector('.vertical-tab-switcher')
|
|
||||||
if (nestedSwitcher) {
|
|
||||||
const childHeader = nestedSwitcher.querySelector('.tab-content-label')
|
|
||||||
this.childCollapsed = childHeader?.checkVisibility()
|
|
||||||
}
|
|
||||||
// if contents takes more space than its container
|
// if contents takes more space than its container
|
||||||
if (contentsWidth < tabContentWidth) {
|
if (contentsWidth < tabContentWidth) {
|
||||||
if (this.parentCollapsed) {
|
if (this.parentCollapsed) {
|
||||||
|
|
@ -190,12 +193,13 @@ export default {
|
||||||
: ''
|
: ''
|
||||||
|
|
||||||
const headerClasses = ['tab-content-label']
|
const headerClasses = ['tab-content-label']
|
||||||
if (this.childCollapsed) {
|
console.log(this.hideHeader)
|
||||||
|
if (this.hideHeader) {
|
||||||
headerClasses.push('-hidden')
|
headerClasses.push('-hidden')
|
||||||
}
|
}
|
||||||
const header = (
|
const header = (
|
||||||
<h1 class={headerClasses}>
|
<h1 class={headerClasses}>
|
||||||
<button type="button" onClick={() => this.navSide = 'tabs'}>LOL</button>
|
<button type="button" onClick={() => this.changeNavSide('tabs')}>LOL</button>
|
||||||
{props.label}
|
{props.label}
|
||||||
</h1>
|
</h1>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue