Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/components/AssetDownload/AssetDownload.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { Meta, StoryObj } from "@storybook/react"

import AssetDownload from "."

import ethDiamondBlack from "@/public/images/assets/eth-diamond-black.png"

const meta = {
title: "Components/AssetDownload",
component: AssetDownload,
parameters: {
layout: "centered",
},
tags: ["autodocs"],
} satisfies Meta<typeof AssetDownload>

export default meta

type Story = StoryObj<typeof meta>

export const WithArtist: Story = {
args: {
title: "Ethereum hero",
alt: "Ethereum hero",
image: ethDiamondBlack,
artistName: "Liam Cobb",
artistUrl: "https://liamcobb.com/",
svgUrl: "/images/assets/svgs/eth-diamond-black.svg",
},
}

export const BrandAsset: Story = {
args: {
title: "ETH Diamond Glyph",
alt: "ETH Diamond Glyph",
image: ethDiamondBlack,
svgUrl: "/images/assets/svgs/eth-diamond-glyph.svg",
},
}
7 changes: 3 additions & 4 deletions src/components/AssetDownload/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { extname } from "path"

import { BaseHTMLAttributes } from "react"
import type { ImageProps, StaticImageData } from "next/image"

Expand Down Expand Up @@ -41,7 +39,8 @@ const AssetDownload = ({
eventName: title,
})
}
const imgSrc = (image as StaticImageData).src
const imgSrc =
typeof image === "string" ? image : (image as StaticImageData).src

return (
<Stack
Expand All @@ -58,7 +57,7 @@ const AssetDownload = ({
<Flex className="mt-4 gap-5">
<ButtonLink href={imgSrc} onClick={matomoHandler} target="_blank">
{t("page-assets-download-download")} (
{extname(imgSrc).slice(1).toUpperCase()})
{imgSrc.split(".").pop()?.toUpperCase()})
</ButtonLink>
{svgUrl && (
<ButtonLink href={svgUrl} onClick={matomoHandler} target="_blank">
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const BaseLink = forwardRef<HTMLAnchorElement, LinkProps>(function Link(

// Get proper download link for internally hosted files (ex: whitepaper.pdf)
// Opens in separate window.
if (isInternalFile && !href.startsWith("/")) {
if (isInternalFile && !href.startsWith("/") && pathname) {
href = "/" + getRelativePath(pathname, href)
}

Expand Down