Skip to content

Commit

Permalink
Add SEAL Links (#460)
Browse files Browse the repository at this point in the history
* Add SEAL Links

* Update SEAL Links

* Correct mistakes

* Fix Errors

* Fixed remaining errors

* Fix issue with children prop
  • Loading branch information
ejimsan authored May 2, 2024
1 parent 269be23 commit f7fb269
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
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 {
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>
)
}

0 comments on commit f7fb269

Please sign in to comment.