Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[next] feat(NcAppSidebar): force show navigation for a single tab #5751

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/components/NcAppSidebar/NcAppSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@
```vue
<template>
<div>
<NcCheckboxRadioSwitch :checked.sync="forceTabs">Force tab navigation</NcCheckboxRadioSwitch>
<NcAppSidebar
name="cat-picture.jpg"
:force-tabs="forceTabs"
subname="last edited 3 weeks ago">
<NcAppSidebarTab name="Settings" id="settings-tab">
<template #icon>
Expand All @@ -95,6 +97,11 @@
components: {
Cog,
},
data() {
return {
forceTabs: false,
}
},
}
</script>
```
Expand Down Expand Up @@ -682,6 +689,7 @@
<NcAppSidebarTabs v-show="!loading"
ref="tabs"
:active="active"
:force-tabs="forceTabs"
@update:active="onUpdateActive">
<slot />
</NcAppSidebarTabs>
Expand Down Expand Up @@ -838,6 +846,13 @@
type: Boolean,
default: false,
},
/**
* Force the tab navigation to display even if there is only one tab
*/
forceTabs: {
type: Boolean,
default: false,
},
/**
* Linkify the name
*/
Expand Down Expand Up @@ -1087,7 +1102,7 @@
* @type {Event}
*/
// eslint-disable-next-line vue/require-explicit-emits
this.$emit('figure-click', e)

Check warning on line 1105 in src/components/NcAppSidebar/NcAppSidebar.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Custom event name 'figure-click' must be camelCase
},

/**
Expand Down Expand Up @@ -1178,7 +1193,7 @@
*
* @type {Event}
*/
this.$emit('submit-name', event)

Check warning on line 1196 in src/components/NcAppSidebar/NcAppSidebar.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Custom event name 'submit-name' must be camelCase
},
onDismissEditing() {
// Disable editing
Expand All @@ -1188,7 +1203,7 @@
*
* @type {Event}
*/
this.$emit('dismiss-editing')

Check warning on line 1206 in src/components/NcAppSidebar/NcAppSidebar.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Custom event name 'dismiss-editing' must be camelCase
},
onUpdateActive(activeTab) {
/**
Expand Down
13 changes: 12 additions & 1 deletion src/components/NcAppSidebar/NcAppSidebarTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="app-sidebar-tabs">
<!-- tabs navigation -->
<!-- 33 and 34 code is for page up and page down -->
<div v-if="hasMultipleTabs"
<div v-if="hasMultipleTabs || showForSingleTab"
role="tablist"
class="app-sidebar-tabs__nav"
@keydown.left.exact.prevent.stop="focusPreviousTab"
Expand Down Expand Up @@ -84,6 +84,13 @@ export default {
type: String,
default: '',
},
/**
* Force the tab navigation to display even if there is only one tab
*/
forceTabs: {
type: Boolean,
default: false,
},
},

emits: ['update:active'],
Expand Down Expand Up @@ -111,6 +118,10 @@ export default {
return this.tabs.length > 1
},

showForSingleTab() {
return this.forceTabs && this.tabs.length === 1
},

currentTabIndex() {
return this.tabs.findIndex((tab) => tab.id === this.activeTab)
},
Expand Down
Loading