Skip to content

Commit

Permalink
feat: unify header
Browse files Browse the repository at this point in the history
Signed-off-by: Luka Trovic <[email protected]>
  • Loading branch information
luka-nextcloud committed Aug 18, 2022
1 parent 3585168 commit 8845929
Show file tree
Hide file tree
Showing 9 changed files with 221 additions and 25 deletions.
13 changes: 11 additions & 2 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@
<MenuBar v-if="renderMenus"
ref="menubar"
:autohide="autohide"
:loaded.sync="menubarLoaded">
:loaded.sync="menubarLoaded"
:relative-path="relativePath">
<Status :document="document"
:dirty="dirty"
:sessions="filteredSessions"
:sync-error="syncError"
:has-connection-issue="hasConnectionIssue"
:last-saved-string="lastSavedString" />
<RightSideActions :relative-path="relativePath"
:basename="basename" />
<slot name="header" />
</MenuBar>
<div v-if="!menubarLoaded" class="menubar-placeholder" />
Expand Down Expand Up @@ -102,6 +105,7 @@ import Content from './Editor/Content.vue'
import Status from './Editor/Status.vue'
import Main from './Editor/Main.vue'
import Wrapper from './Editor/Wrapper.vue'
import RightSideActions from './Editor/RightSideActions.vue'

const EDITOR_PUSH_DEBOUNCE = 200

Expand All @@ -117,6 +121,7 @@ export default {
Reader: () => import(/* webpackChunkName: "editor" */'./Reader.vue'),
Status,
CollisionResolveDialog: () => import(/* webpackChunkName: "editor" */'./CollisionResolveDialog.vue'),
RightSideActions,
},
mixins: [
isMobile,
Expand Down Expand Up @@ -176,6 +181,10 @@ export default {
type: Number,
default: null,
},
basename: {
type: String,
default: null,
},
active: {
type: Boolean,
default: false,
Expand Down Expand Up @@ -811,4 +820,4 @@ export default {
100% { transform: rotate(360deg); }
}

</style>
</style>
126 changes: 126 additions & 0 deletions src/components/Editor/RightSideActions.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<template>
<div class="right-side-actions">
<div class="user-avatar__icon user-avatar__icon--with-avatar"
:style="avatarUrl ? { backgroundImage: `url(${avatarUrl})` } : null">
</div>
<a :download="basename"
:href="fullPathToFile">
<Button class="download__button"
type="primary">
Download
</Button>
</a>
<Actions>
<ActionButton icon="icon-edit"
:close-after-click="true"
@click="showSidebar">
Open sidebar
</ActionButton>
<ActionButton icon="icon-delete"
:close-after-click="true"
@click="onDelete">
Delete
</ActionButton>
</Actions>
</div>
</template>

<script>
import axios from '@nextcloud/axios'
import { getCurrentUser } from '@nextcloud/auth'
import Actions from '@nextcloud/vue/dist/Components/Actions'
import ActionButton from '@nextcloud/vue/dist/Components/ActionButton'
import Button from '@nextcloud/vue/dist/Components/Button'
import { getRootPath } from '../../helpers/files.js'
import { getAvatarUrl } from '../../helpers'
export default {
name: 'RightSideActions',
components: {
Actions,
ActionButton,
Button,
},
props: {
basename: {
type: String,
default: null,
},
relativePath: {
type: String,
default: '',
},
},
computed: {
avatarUrl() {
let currentUser = getCurrentUser()
return currentUser ? getAvatarUrl(currentUser?.uid, 44) : null
},
fullPathToFile() {
return getRootPath() + this.relativePath
}
},
methods: {
async onDelete() {
try {
const url = this.fullPathToFile
await axios.delete(url)
this.closeEditor()
} catch (error) {
showError(error)
}
},
async showSidebar() {
// Open the sidebar sharing tab
if (OCA?.Files?.Sidebar) {
await OCA.Files.Sidebar.open(this.relativePath)
}
},
}
}
</script>
<style scoped lang="scss">
$clickable-area: 35px;
$usericon-padding: 10px;
.right-side-actions {
display: flex;
}
.user-avatar__icon {
position: relative;
top: 5px;
width: $clickable-area;
min-width: $clickable-area;
height: $clickable-area;
margin: 0 5px !important;
border-radius: $clickable-area;
background-color: var(--color-background-darker);
background-repeat: no-repeat;
background-position: center;
background-size: $clickable-area - 2 * $usericon-padding;
&--with-avatar {
color: inherit;
background-size: cover;
}
}
.download__button {
border: 1px solid white !important;
}
</style>
<style lang="scss">
// It makes the app right sidebar appear under the Menubar instead
// of Hiding a part of it
// The value used is the max-length of the Menubar
#app-sidebar-vue {
top: 44px !important;
}
</style>
7 changes: 4 additions & 3 deletions src/components/Editor/SessionList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,17 @@ export default {
<style scoped lang="scss">
.avatar-list {
border: none;
background-color: var(--color-main-background);
/* background-color: var(--color-main-background); */
background-color: unset;
padding: 0;
margin: 0;
padding-left: 6px;
display: inline-flex;
flex-direction: row-reverse;

&:focus {
/* &:focus {
background-color: #eee;
}
} */

.avatar-wrapper {
margin: 0 -18px 0 0;
Expand Down
13 changes: 4 additions & 9 deletions src/components/Editor/Status.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,14 @@

<template>
<div class="text-editor__session-list">
<div v-if="$isMobile" v-tooltip="lastSavedStatusTooltip" :class="saveStatusClass" />
<div v-if="$isMobile" v-tooltip="lastSavedStatusTooltip" :class="saveStatusClass"/>
<div v-else
v-tooltip="lastSavedStatusTooltip"
class="save-status"
:aria-label="t('text', 'Document save status')"
:class="lastSavedStatusClass">
{{ lastSavedStatus }}
{{ lastSavedString }}
</div>
<SessionList :sessions="sessions">
<p slot="lastSaved" class="last-saved">
{{ t('text', 'Last saved') }}: {{ lastSavedString }}
</p>
<GuestNameDialog v-if="$isPublic && !currentSession.userId" :session="currentSession" />
</SessionList>
</div>
</template>

Expand Down Expand Up @@ -148,10 +142,11 @@ export default {
}

.save-status {
--color-text-white: white;
display: inline-flex;
padding: 0;
text-overflow: ellipsis;
color: var(--color-text-lighter);
color: var(--color-text-white);
position: relative;
top: 9px;
min-width: 85px;
Expand Down
13 changes: 11 additions & 2 deletions src/components/Menu/ActionEntry.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$text-menubar-action-white-color: white;

%text__is-active-item-btn {
opacity: 1;
background-color: var(--color-primary-light);
Expand All @@ -14,7 +16,7 @@
border: 0;
// opacity: 0.5;
position: relative;
color: var(--color-main-text);
color: $text-menubar-action-white-color;
background-color: transparent;
vertical-align: top;
box-shadow: none;
Expand Down Expand Up @@ -67,7 +69,14 @@

.button-vue {
svg {
fill: var(--color-main-text);
fill: $text-menubar-action-white-color;
}
&:hover,
&:focus,
&:active {
svg {
fill: var(--color-main-text);
}
}
}

Expand Down
49 changes: 41 additions & 8 deletions src/components/Menu/MenuBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
'text-menubar--is-workspace': $isRichWorkspace
}">
<HelpModal v-if="displayHelp" @close="hideHelp" />
<div class="text-menubar--logo">
<a href="/">
<img src="http://nextcloud.local/core/img/logo/logo.svg">
</a>
<p>{{ fileName }}</p>
</div>

<div v-if="$isRichEditor"
ref="menubar"
Expand Down Expand Up @@ -77,6 +83,10 @@ export default {
type: Boolean,
default: false,
},
relativePath: {
type: String,
default: '',
},
},
data() {
return {
Expand Down Expand Up @@ -142,6 +152,9 @@ export default {
children: this.hiddenEntries,
}
},
fileName() {
return this.relativePath.substring(this.relativePath.lastIndexOf('/') + 1)
},
},
mounted() {
window.addEventListener('resize', this.getWindowWidth)
Expand Down Expand Up @@ -215,22 +228,37 @@ export default {
}
</script>

<style scoped lang="scss">
<style lang="scss">
$color-white: white;
.text-menubar {
--background-blur: blur(10px);
position: sticky;
position: fixed;
top: 0;
width: 100%;
display: flex;
justify-content: flex-end;
background-color: var(--color-primary);
z-index: 10021; // above modal-header and menububble so menubar is always on top
background-color: var(--color-main-background-translucent);
backdrop-filter: var(--background-blur);
max-height: 44px; // important for mobile so that the buttons are always inside the container
padding-top:3px;
padding-bottom: 3px;

visibility: hidden;

display: flex;
justify-content: flex-end;
.text-menubar--logo {
display: flex;
align-items: center;
min-width: 200px;
color: white;
font-weight: bold;

img {
width: 62px;
height: 48px;
margin-right: 10px;
margin-left: 10px;
}
}

&.text-menubar--ready:not(.text-menubar--autohide) {
visibility: visible;
Expand All @@ -249,13 +277,18 @@ export default {
.text-menubar__entries {
display: flex;
flex-grow: 1;
margin-left: calc((100% - var(--text-editor-max-width)) / 2);
margin-left: calc((100% - var(--text-editor-max-width) - 25%) / 2);
button, .icon, .entry-action {
color: $color-white !important;
}
}

.text-menubar__slot {
// width: 100%;
justify-content: flex-end;
display: flex;
.action-item svg {
fill: $color-white;
}
}

&.text-menubar--is-workspace {
Expand Down
5 changes: 5 additions & 0 deletions src/components/ViewerComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<template>
<Editor :file-id="fileid"
:relative-path="filename"
:basename="basename"
:active="active"
:autofocus="autofocus"
:share-token="shareToken"
Expand All @@ -40,6 +41,10 @@ export default {
type: String,
default: null,
},
basename: {
type: String,
default: null,
},
fileid: {
type: Number,
default: null,
Expand Down
Loading

0 comments on commit 8845929

Please sign in to comment.