Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/menu-radix-pubInfo' into menu-ra…
Browse files Browse the repository at this point in the history
…dix-pubInfo
  • Loading branch information
arthur-lemeur committed Oct 16, 2023
2 parents 75edbfa + 9d620ef commit c8d37c8
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 30 deletions.
1 change: 0 additions & 1 deletion src/renderer/common/components/Cover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,3 @@ export const CoverWithForwardedRef = React.forwardRef<HTMLImageElement, IProps>(
});

CoverWithForwardedRef.displayName = "CoverWithForwardedRef";

98 changes: 71 additions & 27 deletions src/renderer/library/components/publication/PublicationCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import CatalogMenu from "./menu/CatalogMenu";
import OpdsMenu from "./menu/OpdsMenu";

import { convertMultiLangStringToString, langStringIsRTL } from "readium-desktop/renderer/common/language-string";
import { PublicationInfoOpdsWithRadix, PublicationInfoOpdsWithRadixContent, PublicationInfoOpdsWithRadixTrigger } from "../dialog/publicationInfos/PublicationInfo";

// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface IBaseProps extends TranslatorProps {
Expand Down Expand Up @@ -65,30 +66,72 @@ class PublicationCard extends React.Component<IProps> {
// aria-controls="dialog"
return (
<div className={stylesPublications.publication_wrapper}>
<a
onClick={(e) => this.handleBookClick(e)}
onKeyPress={
(e) =>
(e.key === "Enter") && this.handleBookClick(e)
}
title={`${publicationViewMaybeOpds.documentTitle} - ${authors}`}
className={stylesPublications.publication_image_wrapper}
tabIndex={0}
>
<Cover publicationViewMaybeOpds={publicationViewMaybeOpds} />
</a>
<div className={stylesPublications.publication_infos_wrapper}>
<a aria-hidden onClick={(e) => this.handleBookClick(e)}
className={stylesPublications.publication_infos}

{
this.props.isOpds ?
<PublicationInfoOpdsWithRadix
opdsPublicationView={publicationViewMaybeOpds as IOpdsPublicationView}
>
<PublicationInfoOpdsWithRadixTrigger asChild>
<a
title={`${publicationViewMaybeOpds.documentTitle} - ${authors}`}
className={stylesPublications.publication_image_wrapper}
tabIndex={0}
>
<Cover publicationViewMaybeOpds={publicationViewMaybeOpds} />
</a>
</PublicationInfoOpdsWithRadixTrigger>
<PublicationInfoOpdsWithRadixContent />
</PublicationInfoOpdsWithRadix>
:
<a
onClick={(e) => this.handleBookClick(e)}
onKeyPress={
(e) =>
(e.key === "Enter") && this.handleBookClick(e)
}
title={`${publicationViewMaybeOpds.documentTitle} - ${authors}`}
className={stylesPublications.publication_image_wrapper}
tabIndex={0}
>
<p aria-hidden className={stylesPublications.publication_title}
dir={pubTitleIsRTL ? "rtl" : undefined}>
{pubTitleStr}
</p>
<p aria-hidden className={stylesPublications.publication_description}>
{this.truncateAuthors(authors)}
</p>
</a>
<Cover publicationViewMaybeOpds={publicationViewMaybeOpds} />
</a>
}

<div className={stylesPublications.publication_infos_wrapper}>
{
this.props.isOpds ?
<PublicationInfoOpdsWithRadix
opdsPublicationView={publicationViewMaybeOpds as IOpdsPublicationView}
>
<PublicationInfoOpdsWithRadixTrigger asChild>
<a aria-hidden style={{cursor: "pointer"}}
className={stylesPublications.publication_infos}
>
<p aria-hidden className={stylesPublications.publication_title}
dir={pubTitleIsRTL ? "rtl" : undefined}>
{pubTitleStr}
</p>
<p aria-hidden className={stylesPublications.publication_description}>
{this.truncateAuthors(authors)}
</p>
</a>
</PublicationInfoOpdsWithRadixTrigger>
<PublicationInfoOpdsWithRadixContent />
</PublicationInfoOpdsWithRadix>
:
<a aria-hidden onClick={(e) => this.handleBookClick(e)} style={{cursor: "pointer"}}
className={stylesPublications.publication_infos}
>
<p aria-hidden className={stylesPublications.publication_title}
dir={pubTitleIsRTL ? "rtl" : undefined}>
{pubTitleStr}
</p>
<p aria-hidden className={stylesPublications.publication_description}>
{this.truncateAuthors(authors)}
</p>
</a>
}
<Menu
button={(
<SVG title={`${__("accessibility.bookMenu")} (${publicationViewMaybeOpds.documentTitle})`} svg={MenuIcon} />
Expand All @@ -111,11 +154,12 @@ class PublicationCard extends React.Component<IProps> {
e.preventDefault();
const { publicationViewMaybeOpds } = this.props;

if (this.props.isOpds) {
this.props.openInfosDialog(publicationViewMaybeOpds as IOpdsPublicationView);
} else {
// if (this.props.isOpds) {
// this.props.openInfosDialog(publicationViewMaybeOpds as IOpdsPublicationView);
// console.error("ERROR DO NOT ")
// } else {
this.props.openReader(publicationViewMaybeOpds as PublicationView);
}
// }
}

/* function Truncate very long titles at 60 characters */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ const CellCoverImage: React.FC<ITableCellProps_Column & ITableCellProps_GenericC
<PublicationInfoLibWithRadixTrigger asChild>
<a
style={{
cursor: "cross",
cursor: "pointer",
}}
tabIndex={0}
// onClick={(e) => {
Expand Down Expand Up @@ -1322,7 +1322,7 @@ const CellTitle: React.FC<ITableCellProps_Column & ITableCellProps_GenericCell &
<PublicationInfoLibWithRadix
publicationView={{ identifier: props.value.publicationViewIdentifier }}
>
<PublicationInfoLibWithRadixTrigger>
<PublicationInfoLibWithRadixTrigger asChild>
<a
style={{ cursor: "pointer", paddingTop: "0.4em", paddingBottom: "0.4em" }}
tabIndex={0}
Expand Down

0 comments on commit c8d37c8

Please sign in to comment.