Skip to content

Made digital specimen cards more specific and according to their UI#258

Open
MelanieTheLion wants to merge 6 commits into
mainfrom
feature/ds-cards
Open

Made digital specimen cards more specific and according to their UI#258
MelanieTheLion wants to merge 6 commits into
mainfrom
feature/ds-cards

Conversation

@MelanieTheLion

@MelanieTheLion MelanieTheLion commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

In this PR:
The DigitalSpecimenCard was first a reusable component for all 5 dataCards. But I ran into issues that made the reusable component become way too complicated. So I decided to separate concerns and create separate components for each data card. More code and more components, but easier to maintain in the long run.

UI still needs tweaks, but I have outstanding questions I have to solve first.

This page is not officially live yet. Because it is so big, we are working in iterations.

UX Design

Not in this pr:

  • Image functionality
  • A11y test
  • Testing

What it looks like now:
image

@sonarqubecloud

sonarqubecloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

@MelanieTheLion MelanieTheLion marked this pull request as ready for review July 2, 2026 07:07
Comment thread src/components/Cards/Cards.scss Outdated
Comment thread src/components/Cards/Cards.scss
Comment thread src/components/Cards/Cards.scss Outdated
Comment thread src/components/Cards/CitationLicenseCard.tsx Outdated
Comment thread src/components/Cards/CitationLicenseCard.tsx
Comment thread src/components/Cards/CitationLicenseCard.tsx Outdated
Comment thread src/components/Cards/CitationLicenseCard.tsx
Comment thread src/components/LabelValuePair/LabelValuePair.scss Outdated
hidden: boolean;
}
},
extraItem?: {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the way to go here?

Comment thread src/components/LabelValuePair/LabelValuePair.tsx Outdated
Comment thread src/utils/DataMappers/schemas/DigitalSpecimenSchema.ts Outdated
@MelanieTheLion MelanieTheLion marked this pull request as draft July 2, 2026 07:18
@sonarqubecloud

sonarqubecloud Bot commented Jul 6, 2026

Copy link
Copy Markdown

@MelanieTheLion MelanieTheLion marked this pull request as ready for review July 6, 2026 11:29

a {
color: inherit;
text-decoration: underline;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this actually be the default? It is probably removed because a is also styled as a button?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, color: inherit means the color is black, instead of the normal link color --indigo-11, and our links have text-decoration: none, but this citation has text-decoration: underline. It breaks with our normal link styling, because it is styled as a citation box now :)

type FragmentType = 'verbatim' | 'copy' | 'default' | 'url';

interface Props {
fragment: {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if isHtml is always false why even include it?. This is the case for multiple interfaces across files

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In IdentificationCard and GeoreferenceCard isHtml can be true (or false) or should be true, so I have included it.

const { copy } = useClipboard();

if (!item.value || item.hidden) return null;
if (item.value === undefined || item.value === null || item.value === '' || item.hidden) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

item.value === undefined || item.value === null || item.value === ''

This seems like a problem that should be solved when fetching this kind of data. As in, that you should transform the data before using it in the render components. There shouldn't be 3 ways to indicate that a value is empty. There will probably be more times in the future that you need to check if it is empty, then there is a change that you will forget 1 or more of the empty options

import './Cards.scss';

type FragmentType = 'verbatim' | 'copy' | 'default' | 'url';
type isHtmlFragmentType = 'verbatim' | 'copy' | 'default';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use Type Utilities and/or extending and merging types for creating new types from others.

type isHtmlFragmentType = Exclude<FragmentType, 'url'>;


interface Props {
fragment: {
scientificName: { label: string, value: string, isHtml: true, type: isHtmlFragmentType, hidden: boolean },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of repetition going on with these types (in multiple files). There's the rule of three: When you're repeating the same (kind of) code 3 times, it's time for an abstraction.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe that's something for a larger refactor later?

</Button>
</div>
<div className="digital-specimen-card-content">
<LabelValuePair item={fragment['scientificName']} ></LabelValuePair>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a description list (<dl>) to me. Also when taking the design into consideration.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here we have the term <dt> and description <dd> elements for the parent <dl>.

You are allowed to wrap them in a <div> to make rows:
https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dl#wrapping_name-value_groups_in_div_elements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants