Skip to content

feat(NcAppContent): add mobileLayout prop #6364

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

Open
wants to merge 3 commits into
base: stable8
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 5 additions & 5 deletions src/components/NcActionButton/NcActionButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,6 @@ export default {
ChevronRightIcon,
ChevronLeftIcon,
},
setup() {
return {
isRTL: isRTL(),
}
},
mixins: [ActionTextMixin],

inject: {
Expand Down Expand Up @@ -462,6 +457,11 @@ export default {
default: null,
},
},
setup() {
return {
isRTL: isRTL(),
}
},

computed: {
/**
Expand Down
53 changes: 42 additions & 11 deletions src/components/NcAppContent/NcAppContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,23 @@ The list size must be between the min and the max width value.

<template v-if="hasList">
<!-- Mobile view does not allow resizeable panes -->
<div v-if="isMobile || layout === 'no-split'"
<div v-if="currentLayout === 'no-split'"
class="app-content-wrapper app-content-wrapper--no-split"
:class="{
'app-content-wrapper--show-details': showDetails,
'app-content-wrapper--show-list': !showDetails,
'app-content-wrapper--mobile': isMobile,}">
'app-content-wrapper--mobile': isMobile}">
<NcAppDetailsToggle v-if="showDetails" @click.native.stop.prevent="hideDetails" />
<slot v-if="!showDetails" name="list" />

<slot v-else />
</div>
<div v-else-if="layout === 'vertical-split' || layout === 'horizontal-split'" class="app-content-wrapper">
<Splitpanes :horizontal="layout === 'horizontal-split'"
<div v-else-if="currentLayout === 'vertical-split' || currentLayout === 'horizontal-split'" class="app-content-wrapper">
<Splitpanes :horizontal="currentLayout === 'horizontal-split'"
class="default-theme"
:class="{ 'splitpanes--horizontal': layout === 'horizontal-split',
'splitpanes--vertical': layout === 'vertical-split'
:class="{ 'splitpanes--horizontal': currentLayout === 'horizontal-split',
'splitpanes--vertical': currentLayout === 'vertical-split',
'splitpanes--horizontal-mobile': currentLayout === 'horizontal-split' && isMobile
}"
:rtl="isRTL"
@resized="handlePaneResize">
Expand Down Expand Up @@ -175,7 +176,6 @@ export default {
},

/**
* When in mobile view, only the list or the details are shown
* If you provide a list, you need to provide a variable
* that will be set to true by the user when an element of
* the list gets selected. The details will then show a back
Expand All @@ -198,7 +198,6 @@ export default {
* - `vertical-split` - a 2-column layout with list and default content separated vertically
* - `no-split` - a single column layout; List is shown when `showDetails` is `false`, otherwise the default slot content is shown with a back button to return to the list.
* - 'horizontal-split' - a 2-column layout with list and default content separated horizontally
* On mobile screen `no-split` layout is forced.
*/
layout: {
type: String,
Expand All @@ -207,6 +206,18 @@ export default {
return ['no-split', 'vertical-split', 'horizontal-split'].includes(value)
},
},
/**
* Content layout used on mobile.
* - `no-split` - a single column layout; List is shown when `showDetails` is `false`, otherwise the default slot content is shown with a back button to return to the list.
* - 'horizontal-split' - a 2-column layout with list and default content separated horizontally
*/
mobileLayout: {
type: String,
default: 'no-split',
validator(value) {
return ['no-split', 'horizontal-split'].includes(value)
},
},
},

emits: [
Expand Down Expand Up @@ -274,6 +285,13 @@ export default {
},
}
},

currentLayout() {
if (this.isMobile && this.mobileLayout) {
return this.mobileLayout
}
return this.layout
},
},

updated() {
Expand Down Expand Up @@ -400,6 +418,22 @@ export default {
scrollbar-width: auto;
}

&:not(.splitpanes--horizontal-mobile) {
.splitpanes__pane-list {
@media only screen and (width < $breakpoint-mobile) {
display: none;
}
}
}

&.splitpanes--horizontal-mobile {
.splitpanes__pane-details {
@media only screen and (width < $breakpoint-mobile) {
min-height: 30%;
}
}
}

.splitpanes__pane {
background-color: transparent;
transition: none;
Expand All @@ -408,9 +442,6 @@ export default {
min-width: 300px;
position: sticky;

@media only screen and (width < $breakpoint-mobile) {
display: none;
}
}

&-details {
Expand Down