From e40d930509c7362a4adb59bf08e0e2f5f0563525 Mon Sep 17 00:00:00 2001 From: John Leider Date: Fri, 26 Apr 2024 20:46:22 -0500 Subject: [PATCH] refactor(VDataTableRow): update how styles are applied for mobile --- .../src/components/VDataTable/VDataTable.sass | 55 +++++++------------ .../VDataTable/VDataTableHeaders.tsx | 6 +- .../components/VDataTable/VDataTableRow.tsx | 22 ++++---- .../src/components/VDataTable/_variables.scss | 3 - 4 files changed, 32 insertions(+), 54 deletions(-) diff --git a/packages/vuetify/src/components/VDataTable/VDataTable.sass b/packages/vuetify/src/components/VDataTable/VDataTable.sass index 6325d20b804..2d9dab6ffb3 100644 --- a/packages/vuetify/src/components/VDataTable/VDataTable.sass +++ b/packages/vuetify/src/components/VDataTable/VDataTable.sass @@ -127,50 +127,33 @@ .v-data-table-rows-no-data text-align: center - .v-data-table__mobile - &-tr - > td - align-items: center - border-bottom: 0 !important - display: grid - grid-template-columns: repeat(2, 1fr) + .v-data-table__tr--mobile + > .v-data-table__td--expanded-row + grid-template-columns: 0 + justify-content: center - &:last-child - border-bottom: thin solid rgba(var(--v-border-color), var(--v-border-opacity)) !important + > .v-data-table__td--select-row + grid-template-columns: 0 + justify-content: start - &-td + > td + align-items: center column-gap: 4px - height: auto !important + display: grid + grid-template-columns: repeat(2, 1fr) min-height: var(--v-table-row-height) - &-title - font-weight: bold - text-align: left - - &-value - text-align: right - text-overflow: unset !important - white-space: unset !important - - &-expanded-row, - &-select-row - display: flex !important - width: 100% !important - - &-expanded-row - justify-content: center - - .v-data-table-footer - justify-content: center - row-gap: 8px + &:not(:last-child) + border-bottom: 0 !important - &__pagination - margin-inline-start: 0 + .v-data-table__td-title + font-weight: bold + text-align: left - &__info - justify-content: $data-table-footer-mobile-info-justify - padding: $data-table-footer-mobile-info-padding + .v-data-table__td-value + text-align: right + .v-data-table__td &-sort-icon color: $data-table-header-mobile-chip-icon-color diff --git a/packages/vuetify/src/components/VDataTable/VDataTableHeaders.tsx b/packages/vuetify/src/components/VDataTable/VDataTableHeaders.tsx index ed484cc96a2..7ac7a09a680 100644 --- a/packages/vuetify/src/components/VDataTable/VDataTableHeaders.tsx +++ b/packages/vuetify/src/components/VDataTable/VDataTableHeaders.tsx @@ -239,7 +239,7 @@ export const VDataTableHeaders = genericComponent()({
()({ { props.item.title } ( props: makeVDataTableRowProps(), setup (props, { slots }) { - const { mobile } = useDisplay(props) + const { displayClasses, mobile } = useDisplay(props, 'v-data-table__tr') const { isSelected, toggleSelect, someSelected, allSelected, selectAll } = useSelection() const { isExpanded, toggleExpand } = useExpanded() const { toggleSort, sortBy, isSorted } = useSort() @@ -65,8 +65,8 @@ export const VDataTableRow = genericComponent( 'v-data-table__tr', { 'v-data-table__tr--clickable': !!(props.onClick || props.onContextmenu || props.onDblclick), - 'v-data-table__mobile-tr': mobile.value, }, + displayClasses.value, ]} onClick={ props.onClick as any } onContextmenu={ props.onContextmenu as any } @@ -120,19 +120,17 @@ export const VDataTableRow = genericComponent( return ( @@ -165,11 +163,11 @@ export const VDataTableRow = genericComponent( return !mobile.value ? displayValue : ( <> -
+
{ slots[headerSlotName]?.(columnSlotProps) ?? column.title }
-
+
{ slots[slotName]?.(slotProps) ?? displayValue }
diff --git a/packages/vuetify/src/components/VDataTable/_variables.scss b/packages/vuetify/src/components/VDataTable/_variables.scss index 61eaf597fe5..d3cda1e370c 100644 --- a/packages/vuetify/src/components/VDataTable/_variables.scss +++ b/packages/vuetify/src/components/VDataTable/_variables.scss @@ -13,8 +13,5 @@ $data-table-footer-pagination-margin-inline-start: 16px !default; $data-table-footer-select-width: 90px !default; $data-table-footer-items-per-page-padding: 8px !default; -$data-table-footer-mobile-info-padding: 0 0 0 16px !default; -$data-table-footer-mobile-info-justify: flex-start !default; - $data-table-header-mobile-chip-icon-color: rgba(var(--v-theme-on-surface), var(--v-disabled-opacity)) !default; $data-table-header-mobile-chip-icon-color-active: rgba(var(--v-theme-on-surface)) !default;