Skip to content

Commit ced869a

Browse files
committed
style(table): align sort on table header
1 parent 5cd111e commit ced869a

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

.changeset/short-experts-pull.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@indielayer/ui": patch
3+
---
4+
5+
style(table): align sort on table header

packages/ui/src/components/table/TableHeader.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
const validators = {
33
sort: [1, -1, undefined] as const,
4-
textAlign: ['left', 'center', 'right', 'justify'] as const,
4+
textAlign: ['left', 'center', 'right'] as const,
55
}
66
77
const tableHeaderProps = {
@@ -41,15 +41,17 @@ const { styles, classes, className } = useTheme('TableHeader', {}, props)
4141
<template>
4242
<th :style="styles" :class="[className, classes.th, 'group/th']">
4343
<div :class="classes.header">
44-
<slot></slot>
45-
46-
<x-toggle-tip v-if="tooltip" :content="tooltip"/>
44+
<div class="flex items-center gap-1">
45+
<slot></slot>
46+
<x-toggle-tip v-if="tooltip" :content="tooltip"/>
47+
</div>
4748

4849
<svg
4950
v-if="sortable"
5051
class="shrink-0"
5152
:class="[
5253
classes.sortIcon,
54+
textAlign === 'right' ? '-mr-4 -translate-x-4' : '-ml-4 translate-x-4',
5355
[sort && [1, -1].includes(sort) ? '' : 'invisible group-hover/th:visible'],
5456
[sort !== -1 && sort !== 1 ? 'text-secondary-400 dark:text-secondary-500' : 'text-primary-700 dark:text-primary-400']
5557
]"

packages/ui/src/components/table/theme/TableHeader.base.theme.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ const theme: TableHeaderTheme = {
1414
const classes = ['flex items-center gap-1 select-none']
1515

1616
if (props.textAlign === 'left') classes.push('justify-start')
17-
if (props.textAlign === 'right') classes.push('justify-end')
18-
if (props.textAlign === 'center') classes.push('justify-center')
19-
if (props.textAlign === 'justify') classes.push('justify-center')
17+
else if (props.textAlign === 'right') {
18+
if (props.sortable) classes.push('flex-row-reverse')
19+
else classes.push('justify-end')
20+
} else if (props.textAlign === 'center') classes.push('justify-center')
2021

2122
return classes
2223
},

0 commit comments

Comments
 (0)