Skip to content

Commit

Permalink
Add match percent to search list (#1412)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkst authored Jan 22, 2025
1 parent c364a68 commit c3f4c4a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions frontend/src/components/Nav/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import PlatformLink from "../PlatformLink";
import AnonymousFrogAvatar from "../user/AnonymousFrog";
import verticalMenuStyles from "../VerticalMenu.module.scss"; // eslint-disable-line css-modules/no-unused-class

import { getMatchPercentString } from "../ScratchList";

import styles from "./Search.module.scss";

function MountedSearch({ className }: { className?: string }) {
Expand Down Expand Up @@ -165,6 +167,9 @@ function MountedSearch({ className }: { className?: string }) {
<span className={styles.itemName}>
{scratch.name}
</span>
<span>
{getMatchPercentString(scratch)}
</span>
{scratch.owner &&
(!api.isAnonUser(scratch.owner) ? (
userAvatarUrl(scratch.owner) && (
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/ScratchList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ export default function ScratchList({
}

export function getMatchPercentString(scratch: api.TerseScratch) {
if (scratch.score === -1) {
return "0%";
}
if (scratch.match_override) {
return "100%";
}
Expand Down

0 comments on commit c3f4c4a

Please sign in to comment.