Skip to content

Commit

Permalink
Remove ReaderModal and Introduce MaterialSecondaryLink
Browse files Browse the repository at this point in the history
After the `Reader` is no longer an app, the `ReaderModal` is no longer in use and has been removed.

A new component, `MaterialSecondaryLink`, has been added. It follows the same structure as `MaterialSecondaryButton` but is designed for links instead.

I considered reverting the `MaterialSecondaryButton` introduced in an earlier commit, but I believe the new structure is more readable. Additionally, it may be useful for the `Player` app/component in the future.

- Remove unnecessary `isFullScreen`  from `Modal`

With `Reader` now functioning as an  app on its own page, this property is no longer required.
  • Loading branch information
kasperbirch1 committed Nov 22, 2024
1 parent dfe424b commit ac4ac32
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 73 deletions.
8 changes: 0 additions & 8 deletions src/apps/material/material.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,11 @@ import {
getBestMaterialTypeForWork,
getDetailsListData,
getInfomediaIds,
getManifestationIsbn,
getManifestationsOrderByTypeAndYear,
isParallelReservation
} from "./helper";
import MaterialDisclosure from "./MaterialDisclosure";
import ReservationFindOnShelfModals from "./ReservationFindOnShelfModals";
import ReaderModal from "../../components/material/Reader-modal/ReaderModal";
import { hasReaderTeaser } from "../reader/helper";

export interface MaterialProps {
wid: WorkId;
Expand Down Expand Up @@ -196,11 +193,6 @@ const Material: React.FC<MaterialProps> = ({ wid }) => {
setSelectedPeriodical={setSelectedPeriodical}
/>
)}
{hasReaderTeaser(selectedManifestations) && (
<ReaderModal
identifier={getManifestationIsbn(selectedManifestations[0])}
/>
)}
</MaterialHeader>
<MaterialDescription pid={pid} work={work} />
{/* Since we cannot trust the editions for global manifestations */}
Expand Down
48 changes: 0 additions & 48 deletions src/components/material/Reader-modal/ReaderModal.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React, { FC } from "react";
import { ButtonSize } from "../../../../core/utils/types/button";
import LinkButton from "../../../Buttons/LinkButton";

interface MaterialSecondaryLinkProps {
label: string;
size: ButtonSize;
url: URL;
dataCy?: string;
}

const MaterialSecondaryLink: FC<MaterialSecondaryLinkProps> = ({
label,
size,
url,
dataCy
}) => {
if (size !== "small") {
return (
<LinkButton
url={url}
buttonType="none"
variant="outline"
size="large"
dataCy={dataCy}
>
{label}
</LinkButton>
);
}

return (
<a
href={url.toString()}
className="link-tag text-small-caption material-manifestation-item__find capitalize-all btn-ui"
data-cy={dataCy}
>
{label}
</a>
);
};

export default MaterialSecondaryLink;
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from "react";
import { useModalButtonHandler } from "../../../../core/utils/modal";
import { useText } from "../../../../core/utils/text";
import { ButtonSize } from "../../../../core/utils/types/button";
import MaterialSecondaryButton from "../generic/MaterialSecondaryButton";
import MaterialSecondaryLink from "../generic/MaterialSecondaryLink";

type MaterialButtonOnlineTeaserType = {
identifier: string;
Expand All @@ -16,19 +15,13 @@ const MaterialButtonReaderTeaser = ({
dataCy = "material-buttons-reader-teaser"
}: MaterialButtonOnlineTeaserType) => {
const t = useText();
const { open } = useModalButtonHandler();

const onClick = () => {
open(`reader-modal-${identifier}`);
};

return (
<MaterialSecondaryButton
<MaterialSecondaryLink
url={new URL(`/reader?identifier=${identifier}`, window.location.href)}
label={t("onlineMaterialTeaserText")}
size={size}
onClick={onClick}
dataCy={dataCy}
ariaDescribedBy={t("onlineMaterialTeaserText")}
/>
);
};
Expand Down
8 changes: 1 addition & 7 deletions src/core/utils/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ type ModalProps = {
eventCallbacks?: {
close?: () => void;
};
isFullScreen?: boolean;
};

export interface ModalIdsProps {
Expand All @@ -41,8 +40,7 @@ function Modal({
classNames,
isSlider,
dataCy = "modal",
eventCallbacks,
isFullScreen
eventCallbacks
}: ModalProps) {
const dispatch = useDispatch();
const { modalIds } = useSelector((s: ModalIdsProps) => s.modal);
Expand Down Expand Up @@ -82,10 +80,6 @@ function Modal({
dispatch(closeModal({ modalId }));
};

if (isFullScreen) {
return <div className="modal-fullscreen">{children}</div>;
}

return (
<FocusTrap
focusTrapOptions={{
Expand Down

0 comments on commit ac4ac32

Please sign in to comment.