-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat(files): responsive design for mobile and narrow screens #37642
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| <!-- | ||
| - @copyright Copyright (c) 2019 Gary Kim <[email protected]> | ||
| - @copyright Copyright (c) 2023 John Molakvoæ <[email protected]> | ||
| - | ||
| - @author Gary Kim <[email protected]> | ||
| - @author John Molakvoæ <[email protected]> | ||
| - | ||
| - @license GNU AGPL version 3 or any later version | ||
| - | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| <!-- | ||
| - @copyright Copyright (c) 2019 Gary Kim <[email protected]> | ||
| - @copyright Copyright (c) 2023 John Molakvoæ <[email protected]> | ||
| - | ||
| - @author Gary Kim <[email protected]> | ||
| - @author John Molakvoæ <[email protected]> | ||
| - | ||
| - @license GNU AGPL version 3 or any later version | ||
| - | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| <!-- | ||
| - @copyright Copyright (c) 2019 Gary Kim <[email protected]> | ||
| - @copyright Copyright (c) 2023 John Molakvoæ <[email protected]> | ||
| - | ||
| - @author Gary Kim <[email protected]> | ||
| - @author John Molakvoæ <[email protected]> | ||
| - | ||
| - @license GNU AGPL version 3 or any later version | ||
| - | ||
|
|
@@ -115,6 +115,7 @@ import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js' | |
| import NcActions from '@nextcloud/vue/dist/Components/NcActions.js' | ||
| import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js' | ||
| import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js' | ||
| import isMobileMixin from '@nextcloud/vue/dist/Mixins/isMobile.js' | ||
| import Vue from 'vue' | ||
|
|
||
| import { getFileActions } from '../services/FileAction.ts' | ||
|
|
@@ -146,6 +147,10 @@ export default Vue.extend({ | |
| NcLoadingIcon, | ||
| }, | ||
|
|
||
| mixins: [ | ||
| isMobileMixin, | ||
| ], | ||
|
|
||
| props: { | ||
| active: { | ||
| type: Boolean, | ||
|
|
@@ -295,13 +300,20 @@ export default Vue.extend({ | |
| }, | ||
|
|
||
| enabledInlineActions() { | ||
| if (this.isMobile) { | ||
| return [] | ||
| } | ||
| return this.enabledActions.filter(action => action?.inline?.(this.source, this.currentView)) | ||
| }, | ||
|
|
||
| enabledMenuActions() { | ||
| if (this.isMobile) { | ||
| return this.enabledActions | ||
| } | ||
|
|
||
| return [ | ||
| ...this.enabledInlineActions, | ||
| ...actions.filter(action => !action.inline), | ||
| ...this.enabledActions.filter(action => !action.inline), | ||
| ] | ||
| }, | ||
|
|
||
|
|
@@ -311,10 +323,10 @@ export default Vue.extend({ | |
|
|
||
| openedMenu: { | ||
| get() { | ||
| return this.actionsMenuStore.opened === this | ||
| return this.actionsMenuStore.opened === this.uniqueId | ||
| }, | ||
| set(opened) { | ||
| this.actionsMenuStore.opened = opened ? this : null | ||
| this.actionsMenuStore.opened = opened ? this.uniqueId : null | ||
| }, | ||
| }, | ||
| }, | ||
|
|
@@ -515,7 +527,7 @@ export default Vue.extend({ | |
|
|
||
| // If the clicked row is in the selection, open global menu | ||
| const isMoreThanOneSelected = this.selectedFiles.length > 1 | ||
| this.actionsMenuStore.opened = this.isSelected && isMoreThanOneSelected ? 'global' : this | ||
| this.actionsMenuStore.opened = this.isSelected && isMoreThanOneSelected ? 'global' : this.uniqueId | ||
|
|
||
| // Prevent any browser defaults | ||
| event.preventDefault() | ||
|
|
@@ -529,8 +541,6 @@ export default Vue.extend({ | |
| </script> | ||
|
|
||
| <style scoped lang='scss'> | ||
| @import '../mixins/fileslist-row.scss'; | ||
|
|
||
| /* Hover effect on tbody lines only */ | ||
| tr { | ||
| &:hover, | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| <!-- | ||
| - @copyright Copyright (c) 2019 Gary Kim <[email protected]> | ||
| - @copyright Copyright (c) 2023 John Molakvoæ <[email protected]> | ||
| - | ||
| - @author Gary Kim <[email protected]> | ||
| - @author John Molakvoæ <[email protected]> | ||
| - | ||
| - @license GNU AGPL version 3 or any later version | ||
| - | ||
|
|
@@ -140,8 +140,6 @@ export default Vue.extend({ | |
| </script> | ||
|
|
||
| <style scoped lang="scss"> | ||
| @import '../mixins/fileslist-row.scss'; | ||
|
|
||
| // Scoped row | ||
| tr { | ||
| padding-bottom: 300px; | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| <!-- | ||
| - @copyright Copyright (c) 2019 Gary Kim <[email protected]> | ||
| - @copyright Copyright (c) 2023 John Molakvoæ <[email protected]> | ||
| - | ||
| - @author Gary Kim <[email protected]> | ||
| - @author John Molakvoæ <[email protected]> | ||
| - | ||
| - @license GNU AGPL version 3 or any later version | ||
| - | ||
|
|
@@ -207,7 +207,6 @@ export default Vue.extend({ | |
| </script> | ||
|
|
||
| <style scoped lang="scss"> | ||
| @import '../mixins/fileslist-row.scss'; | ||
| .files-list__column { | ||
| user-select: none; | ||
| // Make sure the cell colors don't apply to column headers | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| <!-- | ||
| - @copyright Copyright (c) 2019 Gary Kim <[email protected]> | ||
| - @copyright Copyright (c) 2023 John Molakvoæ <[email protected]> | ||
| - | ||
| - @author Gary Kim <[email protected]> | ||
| - @author John Molakvoæ <[email protected]> | ||
| - | ||
| - @license GNU AGPL version 3 or any later version | ||
| - | ||
|
|
@@ -24,7 +24,8 @@ | |
| <NcActions ref="actionsMenu" | ||
| :disabled="!!loading || areSomeNodesLoading" | ||
| :force-title="true" | ||
| :inline="3" | ||
| :inline="inlineActions" | ||
| :menu-title="inlineActions === 0 ? t('files', 'Actions') : null" | ||
| :open.sync="openedMenu"> | ||
| <NcActionButton v-for="action in enabledActions" | ||
| :key="action.id" | ||
|
|
@@ -43,15 +44,16 @@ | |
| <script lang="ts"> | ||
| import { showError, showSuccess } from '@nextcloud/dialogs' | ||
| import { translate } from '@nextcloud/l10n' | ||
| import NcActions from '@nextcloud/vue/dist/Components/NcActions.js' | ||
| import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js' | ||
| import NcActions from '@nextcloud/vue/dist/Components/NcActions.js' | ||
| import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js' | ||
| import Vue from 'vue' | ||
|
|
||
| import { getFileActions } from '../services/FileAction.ts' | ||
| import { useActionsMenuStore } from '../store/actionsmenu.ts' | ||
| import { useFilesStore } from '../store/files.ts' | ||
| import { useSelectionStore } from '../store/selection.ts' | ||
| import clientWidthMixin from '../mixins/clientWidth.ts' | ||
| import CustomSvgIconRender from './CustomSvgIconRender.vue' | ||
| import logger from '../logger.js' | ||
|
|
||
|
|
@@ -68,6 +70,10 @@ export default Vue.extend({ | |
| NcLoadingIcon, | ||
| }, | ||
|
|
||
| mixins: [ | ||
| clientWidthMixin, | ||
| ], | ||
|
|
||
| props: { | ||
| currentView: { | ||
| type: Object, | ||
|
|
@@ -122,6 +128,16 @@ export default Vue.extend({ | |
| this.actionsMenuStore.opened = opened ? 'global' : null | ||
| }, | ||
| }, | ||
|
|
||
| inlineActions() { | ||
| if (this.clientWidth < 480) { | ||
| return 1 | ||
| } | ||
| if (this.clientWidth < 768) { | ||
| return 2 | ||
| } | ||
| return 3 | ||
| }, | ||
skjnldsv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
|
|
||
| methods: { | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| <!-- | ||
| - @copyright Copyright (c) 2019 Gary Kim <[email protected]> | ||
| - @copyright Copyright (c) 2023 John Molakvoæ <[email protected]> | ||
| - | ||
| - @author Gary Kim <[email protected]> | ||
| - @author John Molakvoæ <[email protected]> | ||
| - | ||
| - @license GNU AGPL version 3 or any later version | ||
| - | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this behaving with the sidebar opened ?
Could we use the container width instead of the client's width?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, would it make sense to have the hiding logic inside nc/vue instead of here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the values files had before.
It's fair to raise the question a bit more widely I think yes :)
When you say sidebar, you mean navigation or sidebar? (because I've seen it being used for both)
Peek.12-04-2023.17-46.mp4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would merge this and improve the sidebar after raising the topic in another PR? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sidebar is splitting on
1024/2https://github.com/nextcloud/nextcloud-vue/blob/50f344487828c33dc9b0f7c5012abb4fd045512e/src/components/NcAppSidebar/NcAppSidebar.vue#L1064
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I meant the right Sidebar. I am asking for the number of displayed actions. The sidebar reduce the width of the container, but the logic is based on the width of the client window, so it might not work as expected.
My advice would be to use a resize observer on the list container instead of the resize event on the window.
https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you which, the current behavior is still better than nothing ;)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After looking around, WOW, you're 100% right Louis, we can do better 👍
I will prepare an issue with RFC and screenshots,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#37692