-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf8abc8
commit df71624
Showing
26 changed files
with
731 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { DynamicLink } from '@/components/DynamicLink'; | ||
import { DatasetCountsFragment, DatasetResultFragment } from '@/gql/graphql'; | ||
import { fragmentManager } from '@/services/FragmentManager'; | ||
import { isPositiveNumber } from '@/utils/isPositiveNumber'; | ||
import { FormattedMessage, FormattedNumber } from 'react-intl'; | ||
import { MapThumbnail } from '../resource/key/components/MapThumbnail'; | ||
|
||
fragmentManager.register(/* GraphQL */ ` | ||
fragment DatasetResult on DatasetSearchStub { | ||
key | ||
title | ||
excerpt | ||
type | ||
publishingOrganizationTitle | ||
recordCount | ||
license | ||
} | ||
`); | ||
|
||
fragmentManager.register(/* GraphQL */ ` | ||
fragment DatasetCounts on DatasetSearchStub { | ||
key | ||
occurrenceCount | ||
literatureCount | ||
} | ||
`); | ||
|
||
export function DatasetResult({ | ||
dataset, | ||
counts, | ||
}: { | ||
dataset: DatasetResultFragment; | ||
counts?: DatasetCountsFragment; | ||
}) { | ||
return ( | ||
<article className="bg-slate-50 p-4 rounded border mb-4 flex flex-row gap-4"> | ||
<div> | ||
<h3 className="text-base font-semibold mb-2"> | ||
<DynamicLink to={`/dataset/${dataset.key}`}>{dataset.title}</DynamicLink> | ||
</h3> | ||
<p className="font-normal text-slate-500 text-sm">{dataset.excerpt}</p> | ||
<div className="mt-2 flex items-center"> | ||
<Tag> | ||
<FormattedMessage id={`enums.datasetType.${dataset.type}`} /> | ||
</Tag> | ||
{isPositiveNumber(counts?.literatureCount) && ( | ||
<Tag> | ||
<FormattedMessage id="tableHeaders.citations" />:{' '} | ||
<FormattedNumber value={counts.literatureCount} /> | ||
</Tag> | ||
)} | ||
{isPositiveNumber(counts?.occurrenceCount) && ( | ||
<Tag> | ||
<FormattedMessage id="tableHeaders.occurrences" />:{' '} | ||
<FormattedNumber value={counts.occurrenceCount} /> | ||
</Tag> | ||
)} | ||
</div> | ||
</div> | ||
<MapThumbnail | ||
datasetKey={dataset.key} | ||
x={0} | ||
y={0} | ||
z={0} | ||
tileStyle="gbif-middle" | ||
mapStyle="classic-noborder.poly" | ||
format="@1x.png" | ||
srs="EPSG:3857" | ||
bin="square" | ||
squareSize={100} | ||
/> | ||
</article> | ||
); | ||
} | ||
|
||
function Tag({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<span className="align-middle bg-slate-300/50 text-slate-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-red-900 dark:text-red-300"> | ||
{children} | ||
</span> | ||
); | ||
} |
79 changes: 79 additions & 0 deletions
79
packages/gbif-org/src/routes/resource/key/components/FundingBanner.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { ProgrammeFundingBannerFragment, ProjectFundingBannerFragment } from '@/gql/graphql'; | ||
import { fragmentManager } from '@/services/FragmentManager'; | ||
import { notNull } from '@/utils/notNull'; | ||
import { FormattedMessage } from 'react-intl'; | ||
|
||
fragmentManager.register(/* GraphQL */ ` | ||
fragment FundingOrganisationDetails on FundingOrganisation { | ||
id | ||
title | ||
url | ||
logo { | ||
title | ||
file { | ||
url | ||
} | ||
} | ||
} | ||
`); | ||
|
||
fragmentManager.register(/* GraphQL */ ` | ||
fragment ProgrammeFundingBanner on Programme { | ||
__typename | ||
fundingOrganisations { | ||
...FundingOrganisationDetails | ||
} | ||
} | ||
`); | ||
|
||
fragmentManager.register(/* GraphQL */ ` | ||
fragment ProjectFundingBanner on GbifProject { | ||
__typename | ||
fundsAllocated | ||
programme { | ||
...ProgrammeFundingBanner | ||
} | ||
overrideProgrammeFunding { | ||
...FundingOrganisationDetails | ||
} | ||
} | ||
`); | ||
|
||
type Props = { | ||
resource: ProgrammeFundingBannerFragment | ProjectFundingBannerFragment; | ||
}; | ||
|
||
export function FundingBanner({ resource }: Props) { | ||
const fundingOrganisations = | ||
resource.__typename === 'GbifProject' | ||
? resource.overrideProgrammeFunding ?? resource.programme?.fundingOrganisations | ||
: resource.fundingOrganisations; | ||
|
||
const fundsAllocated = | ||
resource.__typename === 'GbifProject' ? resource.fundsAllocated : undefined; | ||
|
||
return ( | ||
<div className="bg-slate-100 mt-6 p-6 flex flex-col items-center"> | ||
<span className="text-gray-500 text-xs"> | ||
{fundsAllocated && `€ ${fundsAllocated} `} | ||
<FormattedMessage id="cms.project.fundedBy" /> | ||
</span> | ||
|
||
<div className="pt-6 flex gap-8 flex-wrap justify-center"> | ||
{fundingOrganisations?.filter(notNull).map((fundingOrganisation) => ( | ||
<div key={fundingOrganisation.id}> | ||
<a href={fundingOrganisation.url!} className="flex flex-col items-center group"> | ||
<img | ||
className="max-w-28" | ||
src={fundingOrganisation.logo?.file.url} | ||
/> | ||
<span className="text-gray-500 text-sm pt-2 group-hover:underline"> | ||
{fundingOrganisation.title} | ||
</span> | ||
</a> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} |
32 changes: 32 additions & 0 deletions
32
packages/gbif-org/src/routes/resource/key/components/HelpLine.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { MdInfoOutline } from 'react-icons/md'; | ||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'; | ||
import { fragmentManager } from '@/services/FragmentManager'; | ||
import { HelpLineDetailsFragment } from '@/gql/graphql'; | ||
|
||
fragmentManager.register(/* GraphQL */ ` | ||
fragment HelpLineDetails on Help { | ||
__typename | ||
title | ||
body | ||
} | ||
`); | ||
|
||
type Props = { | ||
help: HelpLineDetailsFragment; | ||
}; | ||
|
||
export function HelpLine({ help }: Props) { | ||
return ( | ||
<p className="pb-4 text-gray-600 text-sm text-right"> | ||
<Popover> | ||
<PopoverTrigger> | ||
{help.title} <MdInfoOutline /> | ||
</PopoverTrigger> | ||
<PopoverContent | ||
className="prose max-w-lg w-auto" | ||
dangerouslySetInnerHTML={{ __html: help.body ?? '' }} | ||
/> | ||
</Popover> | ||
</p> | ||
); | ||
} |
Oops, something went wrong.