Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/spotty-suits-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hyperdx/app": minor
---

Feat: add highlight animation for recently moved filter checkboxes
43 changes: 40 additions & 3 deletions packages/app/src/components/DBSearchPageFilters.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import { memo, useCallback, useEffect, useId, useMemo, useState } from 'react';
import {
memo,
useCallback,
useEffect,
useId,
useMemo,
useRef,
useState,
} from 'react';
import cx from 'classnames';
import {
TableMetadata,
tcFromSource,
Expand Down Expand Up @@ -50,6 +59,7 @@ type FilterCheckboxProps = {
onClickOnly?: VoidFunction;
onClickExclude?: VoidFunction;
onClickPin: VoidFunction;
className?: string;
};

export const TextButton = ({
Expand Down Expand Up @@ -85,9 +95,10 @@ export const FilterCheckbox = ({
onClickOnly,
onClickExclude,
onClickPin,
className,
}: FilterCheckboxProps) => {
return (
<div className={classes.filterCheckbox}>
<div className={cx(classes.filterCheckbox, className)}>
<Group
gap={8}
onClick={() => onChange?.(!value)}
Expand Down Expand Up @@ -189,6 +200,8 @@ export const FilterGroup = ({
const [shouldShowMore, setShowMore] = useState(false);
// Accordion expanded state
const [isExpanded, setExpanded] = useState(isDefaultExpanded ?? false);
// Track recently moved items for highlight animation
const [recentlyMoved, setRecentlyMoved] = useState<Set<string>>(new Set());

useEffect(() => {
if (isDefaultExpanded) {
Expand Down Expand Up @@ -263,6 +276,27 @@ export const FilterGroup = ({
totalFiltersSize,
]);

// Simple highlight animation when checkbox is checked
const handleChange = useCallback(
(value: string) => {
const wasIncluded = selectedValues.included.has(value);

// If checking (not unchecking), trigger highlight animation
if (!wasIncluded) {
setRecentlyMoved(prev => new Set(prev).add(value));
setTimeout(() => {
setRecentlyMoved(prev => {
const newSet = new Set(prev);
newSet.delete(value);
return newSet;
});
}, 600);
}

onChange(value);
},
[onChange, selectedValues],
);
const showShowMoreButton =
!search &&
augmentedOptions.length > MAX_FILTER_GROUP_ITEMS &&
Expand Down Expand Up @@ -367,14 +401,17 @@ export const FilterGroup = ({
key={option.value}
label={option.label}
pinned={isPinned(option.value)}
className={
recentlyMoved.has(option.value) ? classes.recentlyMoved : ''
}
value={
selectedValues.included.has(option.value)
? 'included'
: selectedValues.excluded.has(option.value)
? 'excluded'
: false
}
onChange={() => onChange(option.value)}
onChange={() => handleChange(option.value)}
onClickOnly={() => onOnlyClick(option.value)}
onClickExclude={() => onExcludeClick(option.value)}
onClickPin={() => onPinClick(option.value)}
Expand Down
21 changes: 21 additions & 0 deletions packages/app/styles/SearchPage.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,24 @@
transform: rotate(0deg);
}
}

.recentlyMoved {
animation: highlight 0.6s ease-out;
}

@keyframes highlight {
0% {
background-color: $slate-950;
transform: scale(1.02);
}

50% {
background-color: $slate-900;
transform: scale(1.01);
}

100% {
background-color: transparent;
transform: scale(1);
}
}
Loading