Skip to content

Commit

Permalink
feat(page): Add toggle for full width page view
Browse files Browse the repository at this point in the history
Fixes: #242

Signed-off-by: Jonas <jonas@freesources.org>
  • Loading branch information
mejo- committed Sep 12, 2023
1 parent c596f9e commit d870a84
Show file tree
Hide file tree
Showing 18 changed files with 147 additions and 39 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"dependencies": {
"@nextcloud/auth": "^2.1.0",
"@nextcloud/axios": "^2.4.0",
"@nextcloud/browser-storage": "^0.2.0",
"@nextcloud/dialogs": "^4.1.0",
"@nextcloud/event-bus": "^3.1.0",
"@nextcloud/files": "^3.0.0-beta.21",
Expand Down
2 changes: 0 additions & 2 deletions src/components/Collective.vue
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,6 @@ export default {
position: sticky;
top: 0;
padding: 8px 0px 2px 8px;
margin: auto;
max-width: 670px;
display: flex;
align-items: center;
background-color: var(--color-main-background);
Expand Down
9 changes: 7 additions & 2 deletions src/components/Page.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div>
<h1 id="titleform" class="page-title">
<h1 id="titleform" class="page-title" :class="{'sheet-view': !isFullWidthView}">
<!-- Page emoji or icon -->
<div class="page-title-icon"
:class="{ 'mobile': isMobile }">
Expand Down Expand Up @@ -121,7 +121,7 @@ import TextEditor from './Page/TextEditor.vue'
import { mapActions, mapGetters, mapMutations } from 'vuex'
import pageMixin from '../mixins/pageMixin.js'
import { showError } from '@nextcloud/dialogs'
import { GET_PAGES, RENAME_PAGE } from '../store/actions.js'
import { GET_PAGES, INIT_FULL_WIDTH_PAGEIDS, RENAME_PAGE } from '../store/actions.js'
export default {
name: 'Page',
Expand Down Expand Up @@ -160,6 +160,7 @@ export default {
'currentCollectiveCanEdit',
'isIndexPage',
'isPublic',
'isFullWidthView',
'isTemplatePage',
'isLandingPage',
'loading',
Expand Down Expand Up @@ -233,6 +234,7 @@ export default {
},
mounted() {
this.dispatchInitFullWidthPageids()
document.title = this.documentTitle
this.initTitleEntry()
},
Expand All @@ -248,6 +250,7 @@ export default {
...mapActions({
dispatchGetPages: GET_PAGES,
dispatchRenamePage: RENAME_PAGE,
dispatchInitFullWidthPageids: INIT_FULL_WIDTH_PAGEIDS,
}),
initTitleEntry() {
Expand Down Expand Up @@ -309,6 +312,8 @@ export default {
</style>

<style lang="scss">
@import '../css/editor.scss';
@media print {
/* Don't print emoticon button (if page doesn't have an emoji set) */
.edit-button, .action-item, .emoji-picker-emoticon {
Expand Down
8 changes: 2 additions & 6 deletions src/components/Page/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
:show-outline-outside="showOutline"
mime="text/markdown"
class="file-view active"
:class="{'sheet-view': !isFullWidthView}"
@ready="ready"
@outline-toggled="toggleOutlineFromText"
@add-image-node="onAddImageNode"
Expand All @@ -28,6 +29,7 @@ export default {
...mapGetters([
'currentPage',
'currentPageFilePath',
'isFullWidthView',
'shareTokenParam',
'showing',
]),
Expand Down Expand Up @@ -84,12 +86,6 @@ export default {
overflow: initial !important;
}
[data-text-el='editor-container'] .document-status {
max-width: 670px;
padding: 0 2px;
margin: auto;
}
[data-text-el='editor-container'] .editor--outline {
top: revert !important;
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/Page/LandingPageWidgets.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<div class="landing-page-widgets">
<div class="landing-page-widgets"
:class="{'sheet-view': !isFullWidthView}">
<RecentPagesWidget />
<MembersWidget v-if="!isPublic" />
</div>
Expand All @@ -21,15 +22,14 @@ export default {
computed: {
...mapGetters([
'isPublic',
'isFullWidthView',
]),
},
}
</script>

<style scoped>
.landing-page-widgets {
margin: auto;
padding-left: 12px;
max-width: 670px;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ export default {
flex-direction: row;
gap: 12px;
max-width: 670px;
overflow-x: auto;
scroll-snap-type: x mandatory;
// Hide scrollbar
Expand Down
32 changes: 28 additions & 4 deletions src/components/Page/PageActionMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
<OpenInNewIcon :size="20" />
</template>
</NcActionButton>
<NcActionCheckbox v-if="!inPageList && !isMobile"
:checked="isFullWidthView"
@check="onCheckFullWidthView"
@uncheck="onUncheckFullWidthView">
<template #icon>
<DeleteIcon :size="20" />
</template>
{{ t('collectives', 'Full width') }}
</NcActionCheckbox>
<NcActionButton v-if="!inPageList"
:close-after-click="true"
@click.native="toggle('outline')">
Expand All @@ -33,7 +42,7 @@
:close-after-click="true">
{{ t('collectives', 'Show in Files') }}
</NcActionLink>
<NcActionButton v-if="currentCollectiveCanEdit && !isTemplate && !isLandingPage"
<NcActionButton v-if="inPageList && currentCollectiveCanEdit && !isTemplate && !isLandingPage"
:close-after-click="true"
@click.native="show('details')"
@click="gotoPageEmojiPicker">
Expand All @@ -52,7 +61,7 @@
</template>
{{ editTemplateString }}
</NcActionButton>
<NcActionButton v-if="currentCollectiveCanEdit && !isLandingPage"
<NcActionButton v-if="inPageList && currentCollectiveCanEdit && !isLandingPage"
:close-after-click="true"
@click="onOpenMoveModal">
<template #icon>
Expand All @@ -79,9 +88,10 @@
</template>

<script>
import { mapGetters, mapMutations } from 'vuex'
import { mapActions, mapGetters, mapMutations } from 'vuex'
import { generateUrl } from '@nextcloud/router'
import { NcActions, NcActionButton, NcActionLink, NcActionSeparator } from '@nextcloud/vue'
import { SET_FULL_WIDTH_VIEW } from '../../store/actions.js'
import { NcActions, NcActionButton, NcActionCheckbox, NcActionLink, NcActionSeparator } from '@nextcloud/vue'
import isMobile from '@nextcloud/vue/dist/Mixins/isMobile.js'
import CollectiveActions from '../Collective/CollectiveActions.vue'
import DeleteIcon from 'vue-material-design-icons/Delete.vue'
Expand All @@ -101,6 +111,7 @@ export default {
MoveModal,
NcActions,
NcActionButton,
NcActionCheckbox,
NcActionLink,
NcActionSeparator,
DeleteIcon,
Expand Down Expand Up @@ -170,6 +181,7 @@ export default {
'currentCollective',
'currentCollectiveCanEdit',
'hasSubpages',
'isFullWidthView',
'loading',
'pagesTreeWalk',
'showing',
Expand Down Expand Up @@ -230,6 +242,18 @@ export default {
methods: {
...mapMutations(['show', 'toggle']),
...mapActions({
dispatchSetFullWidthView: SET_FULL_WIDTH_VIEW,
}),
onCheckFullWidthView() {
this.dispatchSetFullWidthView(true)
},
onUncheckFullWidthView() {
this.dispatchSetFullWidthView(false)
},
gotoPageEmojiPicker() {
if (this.pageUrl && (this.currentPage.id !== this.pageId)) {
this.$router.push(this.pageUrl)
Expand Down
12 changes: 9 additions & 3 deletions src/components/Page/PageInfoBar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<div class="text-menubar">
<div class="text-menubar"
:class="{'sheet-view': !isFullWidthView}">
<div v-if="currentPage.lastUserId" class="infobar-item infobar-lastupdate">
<div class="item-text">
<LastUserBubble :last-user-id="currentPage.lastUserId"
Expand All @@ -12,6 +13,7 @@
</template>

<script>
import { mapGetters } from 'vuex'
import LastUserBubble from '../LastUserBubble.vue'
export default {
Expand All @@ -27,6 +29,12 @@ export default {
required: true,
},
},
computed: {
...mapGetters([
'isFullWidthView',
]),
},
}
</script>

Expand All @@ -41,8 +49,6 @@ export default {
height: 44px;
padding: 3px 8px 3px 14px;
display: flex;
max-width: 670px;
margin: auto;
flex-wrap: nowrap;
align-items: center;
overflow: hidden;
Expand Down
5 changes: 0 additions & 5 deletions src/components/Page/RichText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,6 @@ export default {
</style>

<style lang="scss">
:root {
// Required for read-only view where only RichTextReader and no Editor gets loaded
--text-editor-max-width: 670px;
}
@media print {
h1, h2, h3 {
Expand Down
7 changes: 4 additions & 3 deletions src/components/Page/TextEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
<div>
<WidgetHeading v-if="isLandingPage"
:title="t('collectives', 'Landing page')"
class="text-container-heading" />
class="text-container-heading"
:class="{'sheet-view': !isFullWidthView}" />
<div v-show="showRichText"
id="text-container"
:key="'text-' + currentPage.id"
:class="{'sheet-view': !isFullWidthView}"
:aria-label="t('collectives', 'Page content')">
<RichText :key="`reader-${currentPage.id}`"
:current-page="currentPage"
Expand Down Expand Up @@ -65,6 +67,7 @@ export default {
'isTemplatePage',
'isTextEdit',
'isPublic',
'isFullWidthView',
'loading',
]),
Expand Down Expand Up @@ -258,8 +261,6 @@ export default {
<style lang="scss" scoped>
.text-container-heading {
max-width: 670px;
margin: auto;
padding-left: 14px;
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Page/Version.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div>
<h1 id="titleform" class="page-title">
<h1 id="titleform" class="page-title" :class="{'sheet-view': !isFullWidthView}">
<input class="title"
:class="{ 'mobile': isMobile }"
type="text"
Expand Down Expand Up @@ -67,6 +67,7 @@ export default {
computed: {
...mapGetters([
'currentPage',
'isFullWidthView',
'version',
'title',
]),
Expand Down
11 changes: 4 additions & 7 deletions src/components/PagePrint.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<template>
<div id="text-container" :key="'text-' + page.id" class="page">
<h1 v-if="page.parentId === 0" id="page-title-collective" class="page-title page-title-collective">
<h1 v-if="page.parentId === 0" id="page-title-collective" class="page-title sheet-view page-title-collective">
{{ currentCollectiveTitle }}
</h1>
<h1 v-else class="page-title page-title-subpage">
<h1 v-else class="page-title sheet-view page-title-subpage">
{{ pageTitleString }}
</h1>
<RichTextReader v-if="pageContent"
class="editor__content"
class="editor__content sheet-view"
:content="pageContent" />
</div>
</template>
Expand Down Expand Up @@ -89,14 +89,13 @@ export default {
</script>

<style lang="scss" scoped>
@import '../css/editor.scss';
@import '~@nextcloud/text/dist/style.css';
.page-title {
font-size: 30px;
line-height: 45px;
padding: 8px 2px 2px 8px;
margin: auto;
max-width: 670px;
overflow: hidden;
text-overflow: ellipsis;
Expand All @@ -115,8 +114,6 @@ export default {
}
.editor__content {
max-width: 670px;
margin: auto;
position: relative;
}
Expand Down
Loading

0 comments on commit d870a84

Please sign in to comment.