forked from quasarframework/quasar
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(QTabs): Detect changes in tre structure of the internal tabs and…
… recalculate scroll indicators ref quasarframework#5443
- Loading branch information
Showing
6 changed files
with
215 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<template> | ||
<div class="q-pa-md"> | ||
<div class="q-gutter-y-md" style="max-width: 600px"> | ||
<q-list> | ||
<q-item v-for="item in allTabs" :key="item.tab.name" tag="label" dense v-ripple> | ||
<q-item-section side> | ||
<q-checkbox :value="item.selected" @input="status => { setTabSelected(item.tab, status) }" /> | ||
</q-item-section> | ||
|
||
<q-item-section> | ||
<q-item-label>{{ item.tab.label }}</q-item-label> | ||
</q-item-section> | ||
|
||
<q-item-section side> | ||
<q-icon :name="item.tab.icon" /> | ||
</q-item-section> | ||
</q-item> | ||
</q-list> | ||
|
||
<q-toolbar class="bg-purple text-white shadow-2 rounded-borders"> | ||
<q-btn flat label="Homepage" /> | ||
<q-space /> | ||
|
||
<!-- | ||
notice shrink property since we are placing it | ||
as child of QToolbar | ||
--> | ||
<q-tabs | ||
v-model="tab" | ||
inline-label | ||
shrink | ||
stretch | ||
> | ||
<q-tab v-for="tab in tabs" :key="tab.name" v-bind="tab" /> | ||
</q-tabs> | ||
</q-toolbar> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
const allTabs = [ | ||
{ name: 'mails', icon: 'mail', label: 'Mails' }, | ||
{ name: 'alarms', icon: 'alarm', label: 'Alarms' }, | ||
{ name: 'movies', icon: 'movie', label: 'Movies' }, | ||
{ name: 'photos', icon: 'photo', label: 'Photos' }, | ||
{ name: 'videos', icon: 'slow_motion_video', label: 'Videos' }, | ||
{ name: 'addressbook', icon: 'people', label: 'Address Book' } | ||
] | ||
export default { | ||
data () { | ||
return { | ||
tab: 'mails', | ||
tabs: allTabs.slice(0, 1) | ||
} | ||
}, | ||
computed: { | ||
allTabs () { | ||
return allTabs.map(tab => ({ | ||
tab, | ||
selected: this.tabs.indexOf(tab) > -1 | ||
})) | ||
} | ||
}, | ||
methods: { | ||
setTabSelected (tab, status) { | ||
if (status === true) { | ||
this.tabs.push(tab) | ||
} | ||
else { | ||
const index = this.tabs.indexOf(tab) | ||
if (index > -1) { | ||
this.tabs.splice(index, 1) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<template> | ||
<q-card class="q-ma-md" :style="{ maxWidth: width + 'px' }"> | ||
<q-list> | ||
<q-item tag="label" dark class="bg-black" dense v-ripple no-refocus> | ||
<q-item-section> | ||
<q-item-label>Width</q-item-label> | ||
</q-item-section> | ||
<q-item-section side> | ||
<q-input dark dense borderless input-class="text-right" v-model.number="width" type="number" :min="300" /> | ||
</q-item-section> | ||
</q-item> | ||
<q-item v-for="item in allTabs" :key="item.tab.name" tag="label" dense v-ripple> | ||
<q-item-section side> | ||
<q-checkbox :value="item.selected" @input="status => { setTabSelected(item.tab, status) }" /> | ||
</q-item-section> | ||
|
||
<q-item-section> | ||
<q-item-label>{{ item.tab.label }}</q-item-label> | ||
</q-item-section> | ||
|
||
<q-item-section side> | ||
<q-icon :name="item.tab.icon" /> | ||
</q-item-section> | ||
</q-item> | ||
</q-list> | ||
|
||
<q-card-actions class="bg-black"> | ||
<q-toolbar class="bg-purple text-white"> | ||
<q-btn flat label="Homepage" /> | ||
<q-space /> | ||
|
||
<!-- | ||
notice shrink property since we are placing it | ||
as child of QToolbar | ||
--> | ||
<q-tabs | ||
v-model="tab" | ||
inline-label | ||
shrink | ||
stretch | ||
> | ||
<q-tab v-for="t in tabs" :key="t.name" v-bind="t" /> | ||
</q-tabs> | ||
</q-toolbar> | ||
</q-card-actions> | ||
|
||
<q-card-actions class="bg-black"> | ||
<q-tabs | ||
class="bg-primary text-white full-width" | ||
v-model="tab" | ||
inline-label | ||
shrink | ||
stretch | ||
> | ||
<q-tab v-for="t in tabs" :key="t.name" v-bind="t" /> | ||
</q-tabs> | ||
</q-card-actions> | ||
</q-card> | ||
</template> | ||
|
||
<script> | ||
const allTabs = [ | ||
{ name: 'mails', icon: 'mail', label: 'Mails' }, | ||
{ name: 'alarms', icon: 'alarm', label: 'Alarms' }, | ||
{ name: 'movies', icon: 'movie', label: 'Movies' }, | ||
{ name: 'photos', icon: 'photo', label: 'Photos' }, | ||
{ name: 'videos', icon: 'slow_motion_video', label: 'Videos' }, | ||
{ name: 'addressbook', icon: 'people', label: 'Address Book' } | ||
] | ||
export default { | ||
data () { | ||
return { | ||
tab: 'mails', | ||
width: 300, | ||
tabs: allTabs.slice(0, 1) | ||
} | ||
}, | ||
computed: { | ||
allTabs () { | ||
return allTabs.map(tab => ({ | ||
tab, | ||
selected: this.tabs.indexOf(tab) > -1 | ||
})) | ||
} | ||
}, | ||
methods: { | ||
setTabSelected (tab, status) { | ||
if (status === true) { | ||
this.tabs.push(tab) | ||
} | ||
else { | ||
const index = this.tabs.indexOf(tab) | ||
if (index > -1) { | ||
this.tabs.splice(index, 1) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters