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

Add SEAL Links #460

Merged
merged 6 commits into from
May 2, 2024
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
1 change: 1 addition & 0 deletions src/fragmentarium/domain/FragmentDtos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export type ExternalNumbers = {
[K in ExternalNumber]?: string
} & {
oraccNumbers?: readonly string[]
sealNumbers?: readonly string[]
}

export default interface FragmentDto {
Expand Down
4 changes: 4 additions & 0 deletions src/fragmentarium/domain/fragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,13 @@ export class Fragment {
get oraccNumbers(): readonly string[] {
return this.externalNumbers['oraccNumbers'] || []
}
get sealNumbers(): readonly string[] {
return this.externalNumbers['sealNumbers'] || []
}
get hasExternalResources(): boolean {
return _.some([
...this.oraccNumbers,
...this.sealNumbers,
...ExternalNumberTypes.map((number) =>
this.getExternalNumber(number as ExternalNumber)
),
Expand Down
38 changes: 38 additions & 0 deletions src/fragmentarium/ui/info/ExternalNumberLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ export function alalahHpmLink({ number }: { number: string }): JSX.Element {
/>
)
}
export function sealLink({ number }: { number: string }): JSX.Element {
return (
<ExternalNumberLink
number={number}
baseUrl={'https://seal.huji.ac.il/node/'}
label={'SEAL Number'}
/>
)
}
export function australianinstituteofarchaeologyLink({
number,
}: {
Expand Down Expand Up @@ -187,6 +196,16 @@ function OraccLink({
</ExternalLink>
)
}
function SealLink({ sealTextNumber }: { sealTextNumber: string }): JSX.Element {
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 2 locations. Consider refactoring.

const url = `https://seal.huji.ac.il/node/${encodeURIComponent(
sealTextNumber
)}`
return (
<ExternalLink href={url} aria-label={`Seal text ${sealTextNumber}`}>
{sealTextNumber}
</ExternalLink>
)
}

export function OraccLinks({
projects,
Expand All @@ -208,3 +227,22 @@ export function OraccLinks({
</>
)
}

export function SealLinks({
sealTextNumbers,
}: {
sealTextNumbers: readonly string[]
}): JSX.Element {
return (
<>
{'SEAL ('}
{sealTextNumbers.map((sealTextNumber, index) => (
<Fragment key={index}>
{index !== 0 && ', '}
<SealLink sealTextNumber={sealTextNumber} />
</Fragment>
))}
{')'}
</>
)
}
6 changes: 6 additions & 0 deletions src/fragmentarium/ui/info/ExternalResources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
BmIdLink,
YalePeabodyLink,
OraccLinks,
SealLinks,
} from './ExternalNumberLink'
import _ from 'lodash'

Expand Down Expand Up @@ -77,6 +78,11 @@ export default function ExternalResources({
/>
</li>
)}
{!_.isEmpty(fragment.sealNumbers) && (
<li>
<SealLinks sealTextNumbers={fragment.sealNumbers} />
</li>
)}
</ul>
)
}
Loading