mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
refactor: make table sticky scroll only when overflowing
This commit is contained in:
1 parent
cad6f3b1bf
commit
e108b9ac1b
3 files changed
+28
-3
No files matched your search
@@ -1,10 +1,30 @@
|
||||
<script lang="ts">
|
||||
import type { Action } from 'svelte/action';
|
||||
|
||||
export let isSticky = false;
|
||||
|
||||
const hasOverflow: Action<HTMLDivElement, (value: boolean) => void> = (node, callback) => {
|
||||
const observer = new ResizeObserver((entries) => {
|
||||
for (const entry of entries) {
|
||||
callback(entry.contentRect.width < entry.target.scrollWidth);
|
||||
}
|
||||
});
|
||||
|
||||
observer.observe(node);
|
||||
|
||||
return {
|
||||
destroy() {
|
||||
observer.disconnect();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
let isOverflowing = false;
|
||||
</script>
|
||||
|
||||
<div class="table-with-scroll u-margin-block-start-32" data-private>
|
||||
<div class="table-wrapper">
|
||||
<table class="table" class:is-sticky-scroll={isSticky}>
|
||||
<div class="table-wrapper" use:hasOverflow={(v) => (isOverflowing = v)}>
|
||||
<table class="table" class:is-sticky-scroll={isSticky && isOverflowing}>
|
||||
<slot />
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -81,9 +81,14 @@
|
||||
.main-side {
|
||||
z-index: 25;
|
||||
}
|
||||
|
||||
@media (max-width: 550.99px), (min-width: 551px) and (max-width: 1198.99px) {
|
||||
.main-side {
|
||||
top: 4.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.main-content {
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
+1
-1
@@ -91,7 +91,7 @@
|
||||
{#if data.documents.total}
|
||||
<TableScroll isSticky>
|
||||
<TableHeader>
|
||||
<TableCellHead eyebrow={false}>Document ID</TableCellHead>
|
||||
<TableCellHead width={200} eyebrow={false}>Document ID</TableCellHead>
|
||||
{#each columns as column}
|
||||
<TableCellHead eyebrow={false}>{column.title}</TableCellHead>
|
||||
{/each}
|
||||
|
||||
Reference in new issue
Block a user