48 lines
962 B
Vue
48 lines
962 B
Vue
<template>
|
|
<th scope="col" :aria-sort="active ? (direction === 'asc' ? 'ascending' : 'descending') : 'none'">
|
|
<button class="sort-header" type="button" @click="$emit('sort')">
|
|
<span><slot /></span>
|
|
<span class="sort-indicator" :class="{ active }" aria-hidden="true">{{
|
|
active ? (direction === 'asc' ? '↑' : '↓') : '↕'
|
|
}}</span>
|
|
</button>
|
|
</th>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
props: {
|
|
active: { type: Boolean, default: false },
|
|
direction: { type: String, default: 'asc' },
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.sort-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 8px;
|
|
width: 100%;
|
|
padding: 0;
|
|
border: 0;
|
|
background: transparent;
|
|
color: inherit;
|
|
font: inherit;
|
|
text-align: left;
|
|
cursor: pointer;
|
|
}
|
|
.sort-header:hover,
|
|
.sort-header:focus-visible {
|
|
color: var(--primary, #28634c);
|
|
}
|
|
.sort-indicator {
|
|
flex-shrink: 0;
|
|
opacity: 0.45;
|
|
}
|
|
.sort-indicator.active {
|
|
opacity: 1;
|
|
}
|
|
</style>
|