Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[atable] added background gradient to rows with changed content in atable #212

Merged
merged 9 commits into from
Jan 27, 2025
18 changes: 16 additions & 2 deletions atable/src/components/ACell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@input="updateCellData"
@click="showModal"
class="atable-cell"
:class="pinned ? 'sticky-column' : ''">
:class="cellClasses">
<component
v-if="column.cellComponent"
:is="column.cellComponent"
Expand All @@ -38,6 +38,7 @@ const {
store,
addNavigation = true,
tabIndex = 0,
pinned = false,
} = defineProps<{
colIndex: number
rowIndex: number
Expand Down Expand Up @@ -73,12 +74,18 @@ const cellStyle = computed((): CSSProperties => {
return {
textAlign,
width: cellWidth,
backgroundColor: !cellModified.value ? 'inherit' : 'var(--sc-cell-changed-color)',
fontWeight: !cellModified.value ? 'inherit' : 'bold',
paddingLeft: store.getIndent(colIndex, store.display[rowIndex]?.indent),
}
})

const cellClasses = computed(() => {
return {
'sticky-column': pinned,
'cell-modified': cellModified.value,
}
})

const showModal = () => {
if (column.mask) {
// TODO: add masking to cell values
Expand Down Expand Up @@ -210,4 +217,11 @@ const updateCellData = (payload: Event) => {
text-wrap: nowrap;
box-sizing: border-box;
}
.cell-modified {
font-weight: bold;
font-style: italic;
}
.cell-modified-highlight {
background-color: var(--sc-cell-changed-color);
}
</style>
7 changes: 7 additions & 0 deletions atable/src/components/AExpansionRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,10 @@ if (addNavigation) {
padding: 1.5rem;
}
</style>
<style scoped>
.expandable-row.changed-row-gradient:has(td.cell-modified) {
--cell-color-start: color-mix(in srgb, var(--sc-cell-changed-color), #fff 20%);
--cell-color-end: color-mix(in srgb, var(--sc-cell-changed-color), #fff 60%);
background: linear-gradient(90deg, var(--cell-color-start), var(--cell-color-end));
}
</style>
18 changes: 16 additions & 2 deletions atable/src/components/ARow.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<tr ref="rowEl" :tabindex="tabIndex" v-show="isRowVisible" class="table-row">
<tr ref="rowEl" :tabindex="tabIndex" v-show="isRowVisible" class="atable-row">
<!-- render numbered/tree view index; skip render for uncounted lists -->
<slot name="index" v-if="store.config.view !== 'uncounted'">
<td
Expand Down Expand Up @@ -68,7 +68,7 @@ if (addNavigation) {
<style>
@import url('@stonecrop/themes/default.css');

.table-row {
.atable-row {
border-top: 1px solid var(--sc-row-border-color);
display: flex;
background-color: white;
Expand Down Expand Up @@ -103,4 +103,18 @@ if (addNavigation) {
padding-top: var(--sc-atable-row-padding);
padding-bottom: var(--sc-atable-row-padding);
}
/* sticky cells in modified rows should be a solid color to properly hide non-sticky cells */
.atable-row:has(td.cell-modified) > td.sticky-column,
.atable-row:has(td.cell-modified) > th.sticky-column,
.atable-row:has(td.cell-modified) > td.sticky-index,
.atable-row:has(td.cell-modified) > th.sticky-index {
background: var(--sc-cell-changed-color);
}
</style>
<style scoped>
.atable-row.changed-row-gradient:has(td.cell-modified) {
--cell-color-start: color-mix(in srgb, var(--sc-cell-changed-color), #fff 20%);
--cell-color-end: color-mix(in srgb, var(--sc-cell-changed-color), #fff 60%);
background: linear-gradient(90deg, var(--cell-color-start), var(--cell-color-end));
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@stonecrop/atable",
"comment": "added gradient to changed rows in atable",
"type": "none"
}
],
"packageName": "@stonecrop/atable"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@stonecrop/themes",
"comment": "added cell change color variable",
"type": "none"
}
],
"packageName": "@stonecrop/themes"
}
2 changes: 1 addition & 1 deletion themes/default/_variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
--sc-input-label-color: var(--sc-gray-60);
--sc-required-border: #e63c28;
--sc-cell-changed-color: #d8edff;
--sc-form-border: var(--sc-gray-20);
--sc-form-border: var(--sc-gray-5);
--sc-form-background: #ffffff;
--sc-input-field-background: #ffffff;
--sc-input-field-disabled-background: var(--sc-gray-5);
Expand Down
Loading