-
Notifications
You must be signed in to change notification settings - Fork 418
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
2,328 additions
and
588 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { XMarkIcon } from "@heroicons/react/20/solid"; | ||
import { ReactNode } from "react"; | ||
import { cn } from "~/utils/cn"; | ||
|
||
const variants = { | ||
"tertiary/small": { | ||
box: "h-6 bg-tertiary rounded pl-1.5 gap-1.5 text-xs divide-x divide-black/15 group-hover:bg-charcoal-600", | ||
clear: "size-6 text-text-dimmed hover:text-text-bright transition-colors", | ||
}, | ||
"minimal/small": { | ||
box: "h-6 hover:bg-tertiary rounded pl-1.5 gap-1.5 text-xs", | ||
clear: "size-6 text-text-dimmed hover:text-text-bright transition-colors", | ||
}, | ||
}; | ||
|
||
type Variant = keyof typeof variants; | ||
|
||
type AppliedFilterProps = { | ||
label: ReactNode; | ||
value: ReactNode; | ||
removable?: boolean; | ||
onRemove?: () => void; | ||
variant?: Variant; | ||
className?: string; | ||
}; | ||
|
||
export function AppliedFilter({ | ||
label, | ||
value, | ||
removable = true, | ||
onRemove, | ||
variant = "tertiary/small", | ||
className, | ||
}: AppliedFilterProps) { | ||
const variantClassName = variants[variant]; | ||
return ( | ||
<div className={cn("flex items-center transition", variantClassName.box, className)}> | ||
<div className="flex items-center gap-0.5"> | ||
<div className="text-text-dimmed"> | ||
<span>{label}</span>: | ||
</div> | ||
<div className="text-text-bright"> | ||
<div>{value}</div> | ||
</div> | ||
</div> | ||
{removable && ( | ||
<button | ||
className={cn("group flex size-6 items-center justify-center", variantClassName.clear)} | ||
onClick={onRemove} | ||
> | ||
<XMarkIcon className="size-3.5" /> | ||
</button> | ||
)} | ||
</div> | ||
); | ||
} |
Oops, something went wrong.