Skip to content

Commit 3407134

Browse files
committed
Refactors history card highlighting to use prop-based approach
Replaces CSS class-based highlighting with a dedicated highlighted prop for better component encapsulation and maintainability. Removes hardcoded styling logic from the parent component and moves the highlighting responsibility to the card component itself.
1 parent e7830bc commit 3407134

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

client/src/components/History/HistoryCard.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ interface Props {
100100
* @default false
101101
*/
102102
clickable?: boolean;
103+
104+
/**
105+
* Whether this card is highlighted (for example, as a range selection anchor)
106+
* @type {boolean}
107+
* @default false
108+
*/
109+
highlighted?: boolean;
103110
}
104111
105112
const props = withDefaults(defineProps<Props>(), {
@@ -110,6 +117,7 @@ const props = withDefaults(defineProps<Props>(), {
110117
selected: false,
111118
sharedView: false,
112119
clickable: false,
120+
highlighted: false,
113121
});
114122
115123
const router = useRouter();
@@ -260,6 +268,7 @@ function onKeyDown(event: KeyboardEvent) {
260268
:max-visible-tags="props.gridView ? 2 : 8"
261269
:update-time="history.update_time"
262270
:clickable="props.clickable"
271+
:highlighted="props.highlighted"
263272
@titleClick="onTitleClick"
264273
@rename="() => router.push(`/histories/rename?id=${history.id}`)"
265274
@select="isMyHistory(history) && emit('select', history)"

client/src/components/History/HistoryCardList.vue

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ const emit = defineEmits<{
167167
:selectable="props.selectable"
168168
:selected="props.selectedHistoryIds.some((selected) => selected.id === history.id)"
169169
:clickable="props.clickable"
170+
:highlighted="props.rangeSelectAnchor?.id === history.id"
170171
class="history-card-in-list"
171-
:class="{ 'range-select-anchor-history': props.rangeSelectAnchor?.id === history.id }"
172172
@select="isMyHistory(history) && emit('select', history)"
173173
@tagClick="(...args) => emit('tagClick', ...args)"
174174
@refreshList="(...args) => emit('refreshList', ...args)"
@@ -183,13 +183,5 @@ const emit = defineEmits<{
183183
184184
.history-card-list {
185185
container: cards-list / inline-size;
186-
187-
.history-card-in-list {
188-
&.range-select-anchor-history {
189-
&:deep(.g-card-content) {
190-
box-shadow: 0 0 0 0.2rem transparentize($brand-primary, 0.75);
191-
}
192-
}
193-
}
194186
}
195187
</style>

0 commit comments

Comments
 (0)