Skip to content

Commit 5600873

Browse files
Updating table loader height issue after Vuetify 3.3.3 released fixed a loading height issue
1 parent f528494 commit 5600873

File tree

5 files changed

+127
-59
lines changed

5 files changed

+127
-59
lines changed

src/plugin/components/TableLoader.vue

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
<template>
2-
<tr class="v-drilldown-table--loader-tr text-center ma-0 pa-0">
2+
<tr
3+
:class="loaderContainerClasses"
4+
:style="loaderTrStyles"
5+
>
36
<td
47
class="px-0 ma-0"
58
:colspan="colspan"
6-
:style="loaderTrStyles"
9+
:style="loaderTdStyles"
710
>
811
<v-row
912
v-if="loading"
10-
:class="loaderContainerClasses"
13+
:class="loaderVRowClasses"
1114
no-gutters
1215
>
1316
<v-col
@@ -61,10 +64,16 @@
6164
</template>
6265

6366
<script setup lang="ts">
64-
import { componentName } from '@/plugin/utils/globals';
65-
import { useGetLevelColors } from '@/plugin/composables/levelColors';
6667
import { TableLoader } from '@/types';
67-
import { useIsOnlyLinearLoader, useLoaderHeight } from '@/plugin/composables/helpers';
68+
import {
69+
useIsOnlyLinearLoader,
70+
useLoaderContainerClasses,
71+
useLoaderHeight,
72+
useLoaderTdStyles,
73+
useLoaderTrStyles,
74+
useLoaderVRowClasses,
75+
} from '@/plugin/composables/loader';
76+
import { useGetLevelColors } from '@/plugin/composables/levelColors';
6877
6978
7079
const theme = useTheme();
@@ -90,30 +99,18 @@ const baseColors = computed(() => {
9099
return;
91100
});
92101
93-
const loaderTrStyles = computed<StyleValue>(() => {
94-
if (isLinearOnly.value) {
95-
return {
96-
height: loaderHeight.value,
97-
position: 'absolute',
98-
top: 0,
99-
width: '100%',
100-
};
101-
}
102+
const loaderTrStyles = computed<StyleValue>(() => useLoaderTrStyles({
103+
isLinearOnly,
104+
loaderHeight,
105+
}));
102106
103-
return {};
104-
});
107+
const loaderTdStyles = computed<StyleValue>(() => useLoaderTdStyles({
108+
isLinearOnly,
109+
loaderHeight,
110+
}));
105111
106-
const loaderContainerClasses = computed(() => {
107-
return {
108-
[`${componentName}--table-loader`]: true,
109-
'align-center': false,
110-
'd-grid': false,
111-
'flex-column': true,
112-
'ma-0': true,
113-
'pa-0': true,
114-
'text-center': true,
115-
};
116-
});
112+
const loaderContainerClasses = computed(() => useLoaderContainerClasses());
113+
const loaderVRowClasses = computed(() => useLoaderVRowClasses());
117114
118115
119116
// v-progress-linear //
@@ -205,7 +202,7 @@ const checkLoaderType = (type: string): boolean => {
205202
z-index: 99999;
206203
}
207204
208-
&--table-loader {
205+
&--loader-tr-vrow {
209206
background: rgb(var(--v-theme-surface));
210207
}
211208
}

src/plugin/composables/helpers.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,6 @@ export function useGetSortDirection(sortBy: Props['sortBy'], id: string): string
2020
}
2121

2222

23-
/**
24-
* Checks if the loader is only linear
25-
*/
26-
export function useIsOnlyLinearLoader(loaderType: string | string[]): boolean {
27-
let linearOnly = false;
28-
29-
if (loaderType === 'linear') {
30-
linearOnly = true;
31-
}
32-
33-
if (Array.isArray(loaderType)) {
34-
linearOnly = loaderType.length === 1 && loaderType[0] === 'linear';
35-
}
36-
37-
return linearOnly;
38-
};
39-
40-
41-
/**
42-
* Get's the loader height
43-
*/
44-
export function useLoaderHeight(loaderHeight: string | number): string | undefined {
45-
return useConvertToUnit(loaderHeight) || '2px';
46-
};
47-
48-
4923
/**
5024
* Converts a string to a number with a unit.
5125
*/

src/plugin/composables/loader.ts

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import { componentName } from '../utils/globals';
2+
import {
3+
useConvertToUnit,
4+
} from './helpers';
5+
import {
6+
UseLoaderStyles
7+
} from '@/types';
8+
9+
10+
/**
11+
* Checks if the loader is only linear
12+
*/
13+
export function useIsOnlyLinearLoader(loaderType: string | string[]): boolean {
14+
let linearOnly = false;
15+
16+
if (loaderType === 'linear') {
17+
linearOnly = true;
18+
}
19+
20+
if (Array.isArray(loaderType)) {
21+
linearOnly = loaderType.length === 1 && loaderType[0] === 'linear';
22+
}
23+
24+
return linearOnly;
25+
};
26+
27+
28+
/**
29+
* Get's the loader height
30+
*/
31+
export function useLoaderHeight(loaderHeight: string | number): string | undefined {
32+
return useConvertToUnit(loaderHeight) || '2px';
33+
};
34+
35+
36+
// -------------------------------------------------- Styles //
37+
export const useLoaderTrStyles: UseLoaderStyles = (options) => {
38+
const { isLinearOnly, loaderHeight } = options;
39+
let styles = {};
40+
41+
if (unref(isLinearOnly)) {
42+
styles = {
43+
height: unref(loaderHeight),
44+
minHeight: unref(loaderHeight),
45+
};
46+
}
47+
48+
return styles;
49+
};
50+
51+
export const useLoaderTdStyles: UseLoaderStyles = (options) => {
52+
const { isLinearOnly, loaderHeight } = options;
53+
54+
if (unref(isLinearOnly)) {
55+
return {
56+
height: unref(loaderHeight),
57+
position: 'absolute',
58+
top: 0,
59+
width: '100%',
60+
};
61+
}
62+
63+
return {};
64+
};
65+
66+
67+
// -------------------------------------------------- Classes //
68+
export const useLoaderContainerClasses = () => {
69+
return {
70+
[`${componentName}--loader-tr`]: true,
71+
'ma-0': true,
72+
'pa-0': true,
73+
'text-center': true,
74+
};
75+
};
76+
77+
export const useLoaderVRowClasses = () => {
78+
return {
79+
[`${componentName}--loader-tr-vrow`]: true,
80+
'align-center': false,
81+
'd-grid': false,
82+
'flex-column': true,
83+
'ma-0': true,
84+
'pa-0': true,
85+
'text-center': true,
86+
};
87+
};
88+

src/plugin/styles/main.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
}
6262

6363
tbody {
64+
height: 2px;
65+
min-height: 2px;
6466
position: relative;
6567
}
6668
}

src/types/index.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
/* eslint-disable no-unused-vars */
3-
import { CSSProperties, JSXComponent, StyleValue } from 'vue';
3+
import { CSSProperties, JSXComponent, StyleValue, MaybeRef } from 'vue';
44
import { ThemeInstance } from 'vuetify';
55
import type { EventBusKey } from '@vueuse/core';
66
import type { VTextField, VProgressCircular, VProgressLinear } from 'vuetify/components';
@@ -295,9 +295,7 @@ export interface TFootSlotProps extends Omit<AllSlotProps, 'showSelect' | 'sortB
295295
}
296296

297297

298-
299-
300-
// -------------------------------------------------- Components //
298+
// -------------------------------------------------- Table Loader //
301299
export type TableLoader = {
302300
colors: Props['colors'];
303301
colspan: number;
@@ -311,6 +309,15 @@ export type TableLoader = {
311309
textLoader?: boolean;
312310
};
313311

312+
export interface UseLoaderStyles {
313+
(
314+
options: {
315+
isLinearOnly: MaybeRef<boolean>,
316+
loaderHeight: MaybeRef<Props['loaderHeight']>,
317+
}
318+
): CSSProperties;
319+
}
320+
314321

315322
// -------------------------------------------------- Composables //
316323
export interface UseSetLoadedDrilldown {

0 commit comments

Comments
 (0)