Skip to content

Commit

Permalink
Simplify table header definition
Browse files Browse the repository at this point in the history
  • Loading branch information
wkramer committed Oct 1, 2024
1 parent 98f07de commit ae0018b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
35 changes: 23 additions & 12 deletions src/components/table/TimeSeriesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@
<tr>
<template v-for="(column, index) in columns" :key="column.key">
<th
:class="[
(column as unknown as TableHeaders).class,
{
'table-header--editing': isEditingTimeSeries(
column.key as string,
),
},
]"
v-if="column.key === 'date'"
class="table-date sticky-column mb-4"
>
<span>{{ column.title }}</span>
</th>
<th
v-else
class="table-header"
:class="{
'table-header--editing': isEditingTimeSeries(
column.key as string,
),
}"
>
<div class="table-header-indicator">
<div class="table-header-indicator-text">
Expand Down Expand Up @@ -119,7 +124,7 @@
:class="{ highlighted: selected?.date === item.date }"
@click="(e) => handleRowClick(e, item)"
>
<td class="sticky-column">
<td class="table-date sticky-column">
<v-text-field
v-if="isEditing && item.isNewRow"
:modelValue="toISOString(item.date)"
Expand Down Expand Up @@ -482,22 +487,28 @@ function onUpdateItem(event: TableData) {
width: 100%;
}
.date-header {
th.table-date {
vertical-align: top;
min-width: 24ch;
width: 24ch;
border-right: thin solid rgba(var(--v-border-color), var(--v-border-opacity));
align-items: center;
}
th.sticky-column {
position: sticky;
border-right: thin solid rgba(var(--v-border-color), var(--v-border-opacity));
left: 0;
}
td.table-date {
border-right: thin solid rgba(var(--v-border-color), var(--v-border-opacity));
align-items: center;
}
td.sticky-column {
position: sticky;
left: 0;
background-color: rgb(var(--v-theme-surface));
border-right: thin solid rgba(var(--v-border-color), var(--v-border-opacity));
}
:deep(.v-select .v-select__selection-text) {
Expand Down
4 changes: 0 additions & 4 deletions src/lib/table/createTableHeaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export function createTableHeaders(
tableHeaders.push({
key: 'date',
title: 'Date',
class: 'table-header sticky-column date-header',
editable: false,
})
seriesIds.forEach((seriesId) => {
const chartSeries = chartSeriesArray.find((s) => s.id === seriesId)
Expand All @@ -20,8 +18,6 @@ export function createTableHeaders(
key: chartSeries.id,
title: formatHeader(chartSeries),
color: chartSeries.style.stroke?.toString(),
class: 'table-header',
editable: true,
})
}
})
Expand Down
2 changes: 0 additions & 2 deletions src/lib/table/types/TableHeaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ type ReadonlyDataTableHeader = (typeof VDataTable)['headers']

export interface TableHeaders extends ReadonlyDataTableHeader {
color?: string
class?: string
editable: boolean
}

0 comments on commit ae0018b

Please sign in to comment.