Skip to content

Commit

Permalink
Added sticky thead
Browse files Browse the repository at this point in the history
  • Loading branch information
mityaua committed Jan 20, 2025
1 parent 1d4957e commit bb33c54
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/components/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ const onSort = (columnName: string): void => {
</script>

<template>
<div class="relative shadow-md sm:rounded-lg dark:shadow-xl">
<div class="shadow-md sm:rounded-lg dark:shadow-xl">
<table class="w-full text-center text-sm text-gray-500 dark:text-gray-400">
<!-- Table caption -->

<caption
class="bg-blue-100 p-2 text-left text-lg font-semibold text-gray-900 md:rounded-t-lg dark:border dark:border-gray-700 dark:bg-gray-800 dark:text-white"
class="sticky top-0 z-20 bg-blue-100 p-2 text-left text-lg font-semibold text-gray-900 md:rounded-t-lg dark:border dark:border-gray-700 dark:bg-gray-800 dark:text-white"
>
<div class="flex flex-nowrap items-center">
<p class="mr-2 whitespace-nowrap text-sm uppercase">List of irregular verbs</p>
Expand All @@ -57,7 +58,7 @@ const onSort = (columnName: string): void => {
</caption>

<!-- Table head -->
<thead class="text-xs uppercase text-gray-700 dark:text-gray-400">
<thead class="w-full text-xs uppercase text-gray-700 dark:text-gray-400">
<tr>
<TableHead
v-for="(value, result) in searchResults[0]"
Expand Down
8 changes: 7 additions & 1 deletion src/components/TableHead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const onColumnClick = (): void => {
</script>

<template>
<th class="bg-gray-50 p-2 dark:bg-gray-700" width="33%" scope="col">
<th class="sticky z-10 bg-gray-50 p-2 dark:bg-gray-700" width="33%" scope="col">
<div class="flex items-center justify-center">
<p>{{ visibleColumnName }}</p>

Expand All @@ -44,3 +44,9 @@ const onColumnClick = (): void => {
</div>
</th>
</template>

<style scoped>
th {
top: 86px;
}
</style>

0 comments on commit bb33c54

Please sign in to comment.