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

fix: Make table header sticky #786

Merged
merged 1 commit into from
Feb 15, 2024
Merged
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
159 changes: 55 additions & 104 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 @@ -37,6 +37,7 @@
"@tiptap/extension-task-list": "^2.2.2",
"@tiptap/starter-kit": "^2.2.2",
"@tiptap/vue-2": "^2.2.2",
"@vueuse/core": "^10.7.2",
"debounce": "^1.2.1",
"vue": "^2.7.16",
"vue-material-design-icons": "^5.3.0",
Expand Down
9 changes: 9 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { NcContent, NcAppContent } from '@nextcloud/vue'
import Navigation from './modules/navigation/sections/Navigation.vue'
import { mapState } from 'vuex'
import Sidebar from './modules/sidebar/sections/Sidebar.vue'
import { useResizeObserver } from '@vueuse/core'

export default {
name: 'App',
Expand Down Expand Up @@ -51,6 +52,7 @@ export default {
await this.$store.dispatch('loadTablesFromBE')
await this.$store.dispatch('loadViewsSharedWithMeFromBE')
this.routing(this.$router.currentRoute)
this.observeAppContent()
},
methods: {
routing(currentRoute) {
Expand Down Expand Up @@ -84,6 +86,13 @@ export default {
}
window.document.title = newTitle
},
observeAppContent() {
useResizeObserver(document.getElementById('app-content-vue'), (entries) => {
const entry = entries[0]
const { width } = entry.contentRect
document.documentElement.style.setProperty('--app-content-width', `${width}px`)
})
},
},
}
</script>
Expand Down
8 changes: 7 additions & 1 deletion src/modules/main/sections/Dashboard.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div>
<div class="table-dashboard">
<div class="row space-T space-B">
<div class="col-4 space-L">
<h2>
Expand Down Expand Up @@ -264,6 +264,12 @@ export default {
</script>

<style lang="scss" scoped>

.table-dashboard {
display: sticky;
left: 0;
}

.table {
border-collapse: collapse;
width: 670px;
Expand Down
4 changes: 4 additions & 0 deletions src/modules/main/sections/DataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ export default {
</script>
<style lang="scss" scoped>

.row {
width: auto;
}

h2 {
display: inline-flex;
align-items: center;
Expand Down
1 change: 1 addition & 0 deletions src/modules/main/sections/ElementDescription.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export default {
}

.row.first-row {
width: var(--app-content-width, auto);
position: sticky;
left: 0;
top: 0;
Expand Down
4 changes: 2 additions & 2 deletions src/modules/navigation/sections/Navigation.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<template>
<NcAppNavigation>
<template #list>
<div v-if="tablesLoading" class="icon-loading" />

<div class="filter-box">
<NcTextField :value.sync="filterString"
:label="t('tables', 'Filter tables')"
Expand All @@ -13,6 +11,8 @@
</NcTextField>
</div>

<div v-if="tablesLoading" class="icon-loading" />

<ul v-if="!tablesLoading">
<NcAppNavigationCaption :name="t('tables', 'My tables')">
<template #actions>
Expand Down
8 changes: 7 additions & 1 deletion src/pages/Table.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div>
<div class="main-table-view">
<MainWrapper :element="activeTable" :is-view="false" />
<MainModals />
</div>
Expand Down Expand Up @@ -38,3 +38,9 @@ export default {
},
}
</script>
<style lang="scss">
.main-table-view {
width: max-content;
min-width: var(--app-content-width, 100%);
}
</style>
8 changes: 7 additions & 1 deletion src/pages/View.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div>
<div class="main-view-view">
<MainWrapper :element="activeView" :is-view="true" />
<MainModals />
</div>
Expand Down Expand Up @@ -33,3 +33,9 @@ export default {
},
}
</script>
<style lang="scss">
.main-view-view {
width: max-content;
min-width: var(--app-content-width, 100%);
}
</style>
3 changes: 2 additions & 1 deletion src/shared/components/ncTable/NcTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,9 @@ export default {

<style scoped lang="scss">
.options.row {
width: var(--app-content-width, auto);
position: sticky;
top: 52px;
top: 60px;
left: 0;
z-index: 15;
background-color: var(--color-main-background-translucent);
Expand Down
37 changes: 13 additions & 24 deletions src/shared/components/ncTable/sections/CustomTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,6 @@ export default {
</script>

<style lang="scss" scoped>

.container {
//margin: auto;
overflow-x: auto;
}

:deep(table) {
position: relative;
border-collapse: collapse;
Expand Down Expand Up @@ -325,25 +319,20 @@ export default {
background-color: var(--color-main-background);
}

thead tr {
// text-align: left;

th {
vertical-align: middle;
color: var(--color-text-maxcontrast);

// sticky head
// position: -webkit-sticky;
// position: sticky;
// top: 80px;
box-shadow: inset 0 -1px 0 var(--color-border); // use box-shadow instead of border to be compatible with sticky heads
background-color: var(--color-main-background-translucent);
z-index: 5;

// always fit to title
// min-width: max-content;
thead {
position: sticky;
top: 118px;
z-index: 6;

tr {
th {
vertical-align: middle;
color: var(--color-text-maxcontrast);
box-shadow: inset 0 -1px 0 var(--color-border); // use box-shadow instead of border to be compatible with sticky heads
background-color: var(--color-main-background-translucent);
z-index: 5;
}
}

}

tbody {
Expand Down
Loading
Loading