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

Update styling for identification cards to fit some more information #702

Merged
merged 4 commits into from
Jan 28, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
padding: 4px 8px;
box-sizing: border-box;
@include paragraph-x-small();

span {
white-space: nowrap;
}
}

.count {
Expand All @@ -67,6 +71,12 @@
gap: 6px;
}

.time {
flex: 1;
color: $color-neutral-300;
text-align: right;
}

.blueprintLabel {
white-space: pre-wrap;
text-align: center;
Expand Down
17 changes: 7 additions & 10 deletions ui/src/components/blueprint-collection/blueprint-collection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,13 @@ const BlueprintItem = ({ item }: { item: BlueprintItem }) => {
return (
<div className={classNames(styles.blueprintItem, 'group')}>
<div className={styles.blueprintInfo} style={{ width: size.width }}>
<span className={styles.count}>
{item.countLabel?.length ? (
<>
<Icon type={IconType.Detections} size={12} />
<span>{item.countLabel}</span>
</>
) : null}
</span>
<span style={{ flex: 1 }} />
<span>{item.timeLabel}</span>
{item.countLabel?.length ? (
<span className={styles.count}>
<Icon type={IconType.Detections} size={12} />
<span>{item.countLabel}</span>
</span>
) : null}
<span className={styles.time}>{item.timeLabel}</span>
</div>
<div className={styles.blueprintImage}>
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@
color: $color-primary-1-600;
}
}

.details {
display: block;
@include mono();
color: $color-neutral-600;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Identification } from 'data-services/models/occurrence-details'
import { Tooltip } from 'design-system/components/tooltip/tooltip'
import { AlgorithmDetails } from 'pages/occurrence-details/algorithm-details/algorithm-details'
import { getFormatedDateTimeString } from 'utils/date/getFormatedDateTimeString/getFormatedDateTimeString'
import { STRING, translate } from 'utils/language'
import { Icon, IconTheme, IconType } from '../../icon/icon'
import styles from './identification-summary.module.scss'
Expand All @@ -17,54 +15,48 @@ interface IdentificationSummaryProps {
export const IdentificationSummary = ({
user,
identification,
}: IdentificationSummaryProps) => {
const formattedTime = getFormatedDateTimeString({
date: new Date(identification.createdAt),
})

return (
<div className={styles.wrapper}>
<div className={styles.user}>
{user ? (
<div className={styles.profileImage}>
{user.image ? (
<img src={user.image} alt="" />
) : (
<Icon
type={IconType.Photograph}
theme={IconTheme.Primary}
size={16}
/>
)}
</div>
) : (
<Icon type={IconType.BatchId} theme={IconTheme.Primary} size={16} />
)}
<Tooltip content={formattedTime}>
<span className={styles.username}>
{user?.name ?? translate(STRING.MACHINE_SUGGESTION)}
</span>
</Tooltip>
</div>
{identification.algorithm && (
<AlgorithmDetails algorithm={identification.algorithm} />
)}

{identification.score && (
<div className={styles.AlgorithmDetails}>
<span>{`${identification.score.toPrecision(4)}`}</span>
}: IdentificationSummaryProps) => (
<div className={styles.wrapper}>
<div className={styles.user}>
{user ? (
<div className={styles.profileImage}>
{user.image ? (
<img src={user.image} alt="" />
) : (
<Icon
type={IconType.Photograph}
theme={IconTheme.Primary}
size={16}
/>
)}
</div>
) : (
<Icon type={IconType.BatchId} theme={IconTheme.Primary} size={16} />
)}
{identification.terminal !== undefined && (
<div className={styles.AlgorithmDetails}>
{identification.terminal
? translate(STRING.TERMINAL_CLASSIFICATION)
: translate(STRING.INTERMEDIATE_CLASSIFICATION)}
</div>
)}
<div className={styles.AlgorithmDetails}>
<span>{formattedTime}</span>
</div>
<span className={styles.username}>
{user?.name ?? translate(STRING.MACHINE_SUGGESTION)}
</span>
</div>
)
}
{identification.algorithm && (
<Tooltip content={identification.algorithm.description}>
<div className={styles.details}>{identification.algorithm.name}</div>
</Tooltip>
)}
{identification.score && (
<div className={styles.details}>
<span>
{translate(STRING.FIELD_LABEL_SCORE)}{' '}
{`${identification.score.toPrecision(4)}`}
</span>
{identification.terminal !== undefined && (
<span>
{' | '}
{identification.terminal
? translate(STRING.TERMINAL_CLASSIFICATION)
: translate(STRING.INTERMEDIATE_CLASSIFICATION)}
</span>
)}
</div>
)}
</div>
)

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
overflow: hidden;
}

.timestamp {
display: block;
color: $color-neutral-300;
padding: 4px 8px;
text-align: right;
@include paragraph-x-small();
}

.header {
padding: 16px;
border-bottom: 1px solid $color-neutral-100;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { IdentificationSummary } from 'design-system/components/identification/i
import { useState } from 'react'
import { useParams } from 'react-router-dom'
import { APP_ROUTES } from 'utils/constants'
import { getFormatedDateTimeString } from 'utils/date/getFormatedDateTimeString/getFormatedDateTimeString'
import { getAppRoute } from 'utils/getAppRoute'
import { STRING, translate } from 'utils/language'
import { UserInfo, UserPermission } from 'utils/user/types'
Expand Down Expand Up @@ -42,6 +43,9 @@ export const IdentificationCard = ({
)
const showAgree = !byCurrentUser && canAgree
const showDelete = byCurrentUser && canDelete
const formattedTime = getFormatedDateTimeString({
date: new Date(identification.createdAt),
})

if (deleteIdOpen) {
return (
Expand All @@ -53,50 +57,53 @@ export const IdentificationCard = ({
}

return (
<div className={styles.identificationCard}>
<div className={styles.header}>
{identification.applied && (
<StatusLabel label={translate(STRING.ID_APPLIED)} />
)}
<IdentificationSummary user={user} identification={identification} />
</div>
<div className={styles.content}>
<TaxonInfo
overridden={identification.overridden}
taxon={identification.taxon}
getLink={(id: string) =>
getAppRoute({
to: APP_ROUTES.TAXON_DETAILS({
projectId: projectId as string,
taxonId: id,
}),
})
}
/>
{identification.comment && (
<div className={styles.comment}>"{identification.comment}"</div>
)}
<div className={styles.actions}>
{showAgree && (
<Agree
agreed={
currentUser ? occurrence.userAgreed(currentUser?.id) : false
}
agreeWith={
user
? { identificationId: identification.id }
: { predictionId: identification.id }
}
occurrenceId={occurrence.id}
taxonId={identification.taxon.id}
/>
<div>
<span className={styles.timestamp}>{formattedTime}</span>
<div className={styles.identificationCard}>
<div className={styles.header}>
{identification.applied && (
<StatusLabel label={translate(STRING.ID_APPLIED)} />
)}
{showDelete && (
<IconButton
icon={IconType.RadixTrash}
onClick={() => setDeleteIdOpen(true)}
/>
<IdentificationSummary user={user} identification={identification} />
</div>
<div className={styles.content}>
<TaxonInfo
overridden={identification.overridden}
taxon={identification.taxon}
getLink={(id: string) =>
getAppRoute({
to: APP_ROUTES.TAXON_DETAILS({
projectId: projectId as string,
taxonId: id,
}),
})
}
/>
{identification.comment && (
<div className={styles.comment}>"{identification.comment}"</div>
)}
<div className={styles.actions}>
{showAgree && (
<Agree
agreed={
currentUser ? occurrence.userAgreed(currentUser?.id) : false
}
agreeWith={
user
? { identificationId: identification.id }
: { predictionId: identification.id }
}
occurrenceId={occurrence.id}
taxonId={identification.taxon.id}
/>
)}
{showDelete && (
<IconButton
icon={IconType.RadixTrash}
onClick={() => setDeleteIdOpen(true)}
/>
)}
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
.identifications {
display: grid;
grid-template-columns: 1fr;
gap: 16px;
gap: 32px;
padding: 4px 0;
}

Expand Down
Loading