Skip to content

Commit

Permalink
DIGG-442: adding modal to showcases
Browse files Browse the repository at this point in the history
  • Loading branch information
Kopin1 committed Jan 13, 2025
1 parent c9cd4db commit 18c34ce
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 29 deletions.
34 changes: 10 additions & 24 deletions features/entryscape/organisation-page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { CustomLink } from "@/components/custom-link";
import { Container } from "@/components/layout/container";
import { Modal } from "@/components/modal";
import { Heading } from "@/components/typography/heading";
import Showcase from "@/features/entryscape/showcase";
import { EntrystoreContext } from "@/providers/entrystore-provider";
import { SettingsContext } from "@/providers/settings-provider";
import { DataInfo, TermInfo } from "@/types/organisation";
Expand Down Expand Up @@ -311,30 +312,15 @@ export const OrganisationPage: FC = () => {
</div>
{entry.organisationData?.showcases &&
entry.organisationData?.showcases.length > 0 && (
<div className="grid grid-cols-3 gap-xl">
{entry.organisationData?.showcases.map((showcase) => (
<div
className="block space-y-sm bg-white px-md py-lg no-underline"
key={showcase.title}
>
{showcase.date && (
<div className="text-sm text-textSecondary">
{showcase.date} |
</div>
)}
<div className="text-lg text-textPrimary">
{showcase.title}
</div>
<ButtonLink
href={showcase.url}
label={t("common|read-more")}
size="sm"
variant="plain"
icon={ArrowRightIcon}
iconPosition="right"
/>
</div>
))}
<div>
<Heading level={2} size={"md"} className="mb-lg md:mb-xl">
{t("pages|organisation_page$showcases_heading")}
</Heading>
<div className="grid grid-cols-3 gap-xl">
{entry.organisationData?.showcases.map((showcase) => (
<Showcase key={showcase.title} {...showcase} />
))}
</div>
</div>
)}
</div>
Expand Down
47 changes: 47 additions & 0 deletions features/entryscape/showcase/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import useTranslation from "next-translate/useTranslation";
import { FC, useState } from "react";

import ArrowRightIcon from "@/assets/icons/arrow-right.svg";
import { Button } from "@/components/button";
import { Modal } from "@/components/modal";
import { Showcase as ShowcaseType } from "@/types/organisation";
import { formatDate } from "@/utilities/date-helper";

const Showcase: FC<ShowcaseType> = ({ title, date, description }) => {
const { t, lang } = useTranslation();
const [showModal, setShowModal] = useState(false);
return (
<div
className="block space-y-sm bg-white px-md py-lg no-underline"
key={title}
>
<div className="text-sm text-textSecondary">
{t("common|example")}
{date && <> | {formatDate(lang, date)}</>}
</div>
<div className="text-lg text-textPrimary">{title}</div>
<Button
variant="plain"
label={t("common|read-more")}
size="sm"
icon={ArrowRightIcon}
iconPosition="right"
onClick={() => setShowModal(true)}
/>
<Modal
heading={title}
closeBtn={t("common|close")}
description={description}
text={`
${t("common|example")}
${date && ` | ${formatDate(lang, date)}`}
`}
textSize="md"
modalOpen={showModal}
setModalOpen={setShowModal}
></Modal>
</div>
);
};

export default Showcase;
3 changes: 2 additions & 1 deletion locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,6 @@
"toolbox-share-data": "Toolbox for sharing data",
"top-image": "View of Stockholm",
"training": "Training for managers and leaders",
"yes": "Yes"
"yes": "Yes",
"example": "Example"
}
3 changes: 2 additions & 1 deletion locales/sv/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,6 @@
"toolbox-share-data": "Verktygslåda för att dela data",
"top-image": "Vy över Stockholm",
"training": "Utbildning för chefer och ledare",
"yes": "Ja"
"yes": "Ja",
"example": "Exempel"
}
3 changes: 2 additions & 1 deletion locales/sv/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@
"protected-data": "Skyddade datamängder",
"spec-data": "Datamängder som följer specifikation",
"view-all-data": "Visa datamängderna",
"view-all-spec": "Visa specifikationerna"
"view-all-spec": "Visa specifikationerna",
"showcases_heading": "Exempel på användningsfall"
},
"organisations": {
"organisations": "organisationer",
Expand Down
1 change: 0 additions & 1 deletion providers/entrystore-provider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ export const EntrystoreProvider: FC<EntrystoreProviderProps> = ({

rawFacets = datasetCounts.getFacets();

// Rodret är ditt KOTSKI
data.showcases = await entrystoreService.getShowcases(entry);

if (rawFacets.length > 0) {
Expand Down
3 changes: 2 additions & 1 deletion types/organisation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ export interface TermsInfo {
total: number;
termsInfo: TermInfo[];
}
// Vem vet vad detta kommer att bli?

export interface Showcase {
date: string;
title: string;
url: string;
description: string;
}

export interface OrganisationData {
Expand Down
4 changes: 4 additions & 0 deletions utilities/entrystore/entrystore.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,10 @@ export class EntrystoreService {
.getContext()
.getId()}_${entry.getId()}`,
date: getLocalizedValue(entry.getAllMetadata(), "dcterms:issued"),
description: getLocalizedValue(
entry.getAllMetadata(),
"dcterms:description",
),
}));
}

Expand Down

0 comments on commit 18c34ce

Please sign in to comment.