Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/seven-ties-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"sit-onyx": minor
---

fix(DataGrid): ajusted empty state alginment.
39 changes: 28 additions & 11 deletions packages/sit-onyx/src/components/OnyxTable/OnyxTable.vue
Comment thread
ChristianBusshoff marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,25 @@ const isEmptyMessage = computed(() => t.value("table.empty"));

const table = useTemplateRef("table");
const { height, width } = useResizeObserver(table);
const tableWrapper = useTemplateRef("tableWrapper");
const { width: tableWrapperWidth } = useResizeObserver(tableWrapper);

const style = computed(() => ({
"--onyx-table-observed-height": `${height.value}px`,
"--onyx-table-observed-width": `${width.value}px`,
"--onyx-table-wrapper-observed-width": `${tableWrapperWidth.value}px`,
}));

const _headlineId = useId();
const headlineId = computed(() => (slots.headline ? _headlineId : undefined));
</script>

<template>
<div :class="['onyx-component', 'onyx-table-wrapper', densityClass]" :style>
<div
ref="tableWrapper"
:class="['onyx-component', 'onyx-table-wrapper', densityClass]"
:style="style"
>
<div v-if="!!slots.headline || !!slots.actions" class="onyx-table-wrapper__top">
<div :id="headlineId">
<slot name="headline"></slot>
Expand Down Expand Up @@ -197,7 +204,6 @@ const headlineId = computed(() => (slots.headline ? _headlineId : undefined));
align-items: center;
justify-content: space-between;
gap: var(--onyx-density-xs) var(--onyx-density-xl);
container-type: inline-size;
}

&__actions {
Expand All @@ -221,13 +227,6 @@ const headlineId = computed(() => (slots.headline ? _headlineId : undefined));

@include define-borders();

&__empty {
&-content {
display: flex;
justify-content: center;
}
}

&__header {
position: sticky;
top: 0;
Expand All @@ -239,7 +238,7 @@ const headlineId = computed(() => (slots.headline ? _headlineId : undefined));
> tr {
// row hover styles
// hover styles are disabled when the table is empty.
&:hover:not(.onyx-table__empty) > td::before {
&:hover:not(.onyx-table__empty, .onyx-table__standalone-row) > td::before {
background-color: var(--onyx-color-base-neutral-200);
}

Expand Down Expand Up @@ -371,7 +370,8 @@ const headlineId = computed(() => (slots.headline ? _headlineId : undefined));

&--striped {
> tbody {
> tr:nth-child(even) > td::before {
// support skipping stripes, see: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/:nth-child#parameters
> tr:nth-child(even of :not(.onyx-table__standalone-row)):not(:hover) > td::before {
background-color: var(
--onyx-table-row-background-color,
var(--onyx-color-base-background-tinted)
Expand All @@ -385,5 +385,22 @@ const headlineId = computed(() => (slots.headline ? _headlineId : undefined));
color: var(--onyx-color-text-icons-primary-intense);
}
}
&__empty {
> td {
padding: 0;
}
&-content {
display: flex;
justify-content: center;
align-items: center;

position: sticky;
left: 0;
// table width - borders
width: calc(var(--onyx-table-wrapper-observed-width) - 2 * var(--onyx-1px-in-rem));
padding: var(--onyx-density-xl);
box-sizing: border-box;
}
}
}
</style>
Loading