-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
22 changed files
with
284 additions
and
137 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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
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,61 @@ | ||
"use client"; | ||
import { FC, useState } from "react"; | ||
import { Popover } from "@headlessui/react"; | ||
import { usePopper } from "react-popper"; | ||
import { useTranslation } from "react-i18next"; | ||
import IconComposer from "@rubin-epo/epo-react-lib/IconComposer"; | ||
import { isAbsoluteUrl } from "@/helpers"; | ||
import ShareButtons from "@/atomic/Share"; | ||
import styles from "./styles.module.css"; | ||
|
||
const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL; | ||
|
||
function createFinalUrl(url: string) { | ||
if (isAbsoluteUrl(url)) return url; | ||
|
||
const urlObj = new URL(url, BASE_URL); | ||
return urlObj.toString(); | ||
} | ||
|
||
interface SharePopupProps { | ||
title: string; | ||
url: string; | ||
className?: string; | ||
} | ||
|
||
const SharePopup: FC<SharePopupProps> = ({ title, url, className }) => { | ||
const { t } = useTranslation(); | ||
const [referenceElement, setReferenceElement] = | ||
useState<HTMLButtonElement | null>(null); | ||
const [popperElement, setPopperElement] = useState<HTMLDivElement | null>( | ||
null | ||
); | ||
const { styles: popperStyles, attributes } = usePopper( | ||
referenceElement, | ||
popperElement, | ||
{ | ||
modifiers: [{ name: "offset", options: { offset: [0, 10] } }], | ||
} | ||
); | ||
|
||
return ( | ||
<Popover className={className}> | ||
<Popover.Button ref={setReferenceElement} className={styles.button}> | ||
<IconComposer size="0.75em" icon="shareToggle" /> | ||
<span className="a-hidden">{t("share.label_item", { title })}</span> | ||
</Popover.Button> | ||
<Popover.Panel | ||
ref={setPopperElement} | ||
style={popperStyles.popper} | ||
{...attributes.popper} | ||
className={styles.panel} | ||
> | ||
<ShareButtons title={title} url={createFinalUrl(url)} /> | ||
</Popover.Panel> | ||
</Popover> | ||
); | ||
}; | ||
|
||
SharePopup.displayName = "Layout.SharePopup"; | ||
|
||
export default SharePopup; |
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,33 @@ | ||
.button { | ||
aspect-ratio: 1; | ||
background-color: var( | ||
--color-background-button, | ||
var(--color-background-tile-light) | ||
); | ||
border-radius: calc(var(--size-spacing-m) / 2); | ||
border: 1px solid transparent; | ||
box-shadow: 0px 0px 15px 0px rgba(0, 0, 0, 16%); | ||
color: var(--color-font-button, #313333); | ||
font-size: var(--size-spacing-m); | ||
width: var(--size-spacing-m); | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
|
||
&:not(:disabled):hover, | ||
&[data-headlessui-state="open"] { | ||
border-color: var(--color-border-button-hover, #707070); | ||
outline: none; | ||
} | ||
|
||
&:focus-visible { | ||
outline: none; | ||
} | ||
} | ||
|
||
.panel { | ||
padding: var(--size-spacing-2xs); | ||
background-color: var(--white); | ||
border-radius: 5px; | ||
box-shadow: 5px 15px 35px 8px rgba(0, 0, 0, 13%); | ||
} |
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,51 @@ | ||
import { FC } from "react"; | ||
import { DigitalDocument } from "schema-dts"; | ||
import Image from "next/image"; | ||
import StructuredData from "@/components/atomic/StructuredData"; | ||
import { CantoAssetDetailed } from "@/lib/api/galleries/schema"; | ||
import { assetAlt } from "@/lib/api/canto/metadata"; | ||
import { tokens } from "@rubin-epo/epo-react-lib/styles"; | ||
import { resizeCantoImage } from "@/lib/api/canto/resize"; | ||
|
||
interface CantoDocumentProps { | ||
locale: string; | ||
asset: CantoAssetDetailed; | ||
} | ||
|
||
const CantoDocument: FC<CantoDocumentProps> = ({ locale, asset }) => { | ||
const { additional, url, width, height } = asset; | ||
|
||
const aspectRatio = width / height; | ||
const landscapeSizes = `(max-width: ${tokens.BREAK_TABLET}) 100vw, 1435px`; | ||
const portraitSizes = `(max-width: ${tokens.BREAK_TABLET}) 100vw, 700px`; | ||
|
||
const structuredData: DigitalDocument = { | ||
"@type": "DigitalDocument", | ||
size: asset.size, | ||
url: url.directUrlOriginal, | ||
creditText: asset.additional.Credit || undefined, | ||
encodingFormat: asset.default.ContentType, | ||
dateCreated: asset.default.DateCreated, | ||
thumbnailUrl: resizeCantoImage(url.directUrlPreview, 100), | ||
}; | ||
|
||
return ( | ||
<> | ||
<StructuredData jsonLd={structuredData} /> | ||
<Image | ||
{...{ width, height }} | ||
data-cy="canto-image" | ||
alt={assetAlt(additional, locale)} | ||
src={resizeCantoImage(url.directUrlPreview, 2050)} | ||
sizes={aspectRatio < 1 ? portraitSizes : landscapeSizes} | ||
quality={85} | ||
priority | ||
title={asset.name} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
CantoDocument.displayName = "Organism.Gallery.CantoDocument"; | ||
|
||
export default CantoDocument; |
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
Oops, something went wrong.