generated from shuding/nextra-docs-template
-
Notifications
You must be signed in to change notification settings - Fork 38
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
7 changed files
with
1,419 additions
and
615 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// components/DownloadableImage.tsx | ||
import NextImage from 'next/image'; | ||
import styles from '../styles/DownloadableImage.module.css'; | ||
import { useState, useEffect } from 'react'; | ||
|
||
interface DownloadableImageProps { | ||
url: string; | ||
alt: string; | ||
name: string; | ||
downloadable?: boolean; | ||
} | ||
|
||
const DownloadableImage = ({ url, alt, name, downloadable = true }: DownloadableImageProps) => { | ||
const [imageDimensions, setImageDimensions] = useState({ width: 0, height: 0 }); | ||
const [showModal, setShowModal] = useState(false); | ||
|
||
useEffect(() => { | ||
const img = new window.Image(); | ||
img.src = url; | ||
img.onload = () => { | ||
setImageDimensions({ width: img.width, height: img.height }); | ||
}; | ||
}, [url]); | ||
|
||
const handleImageClick = (e: React.MouseEvent) => { | ||
if (downloadable) { | ||
e.preventDefault(); | ||
const link = document.createElement('a'); | ||
link.href = url; | ||
link.download = name; | ||
link.click(); | ||
} else { | ||
setShowModal(true); | ||
document.body.style.overflow = 'hidden'; | ||
} | ||
}; | ||
|
||
const closeModal = () => { | ||
setShowModal(false); | ||
document.body.style.overflow = 'auto'; | ||
}; | ||
|
||
return ( | ||
<> | ||
<div className={styles.imageWrapper}> | ||
<div className={styles.imageContainer}> | ||
<NextImage | ||
src={url} | ||
alt={alt} | ||
width={imageDimensions.width} | ||
height={imageDimensions.height} | ||
className={styles.image} | ||
onClick={handleImageClick} | ||
/> | ||
</div> | ||
{downloadable && ( | ||
<a href={url} download={name} className={styles.downloadButton} onClick={handleImageClick}> | ||
<i className="fas fa-download"></i> | ||
</a> | ||
)} | ||
</div> | ||
{showModal && ( | ||
<div className={styles.modal} onClick={closeModal}> | ||
<div className={styles.modalContent}> | ||
<NextImage src={url} alt={alt} layout="fill" objectFit="contain" /> | ||
</div> | ||
</div> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default DownloadableImage; |
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,23 @@ | ||
// src/imageData.ts | ||
export interface ImageData { | ||
url: string; | ||
alt: string; | ||
name: string; | ||
} | ||
|
||
const images: ImageData[] = [ | ||
{ url: 'https://cdn.sei.io/brand_/brand_01.png', alt: 'Logotype', name: 'brand_01' }, | ||
{ url: 'https://cdn.sei.io/brand_/brand_02.png', alt: 'Main Logo', name: 'brand_02' }, | ||
{ url: 'https://cdn.sei.io/brand_/brand_03.png', alt: 'Symbol Gradient', name: 'brand_03' }, | ||
{ url: 'https://cdn.sei.io/brand_/brand_04.png', alt: 'Symbol Clearspace', name: 'brand_04' }, | ||
{ url: 'https://cdn.sei.io/brand_/brand_05.png', alt: 'Logo Misuse', name: 'brand_05' }, | ||
{ url: 'https://cdn.sei.io/brand_/brand_06.png', alt: 'Sei Color Palette', name: 'brand_06' }, | ||
{ url: 'https://cdn.sei.io/brand_/brand_07.png', alt: 'Sei Gradient', name: 'brand_07' }, | ||
{ url: 'https://cdn.sei.io/brand_/brand_08.png', alt: 'Typography', name: 'brand_08' }, | ||
{ url: 'https://cdn.sei.io/brand_/brand_09.png', alt: 'Typography', name: 'brand_09' }, | ||
{ url: 'https://cdn.sei.io/brand_/brand_10.png', alt: 'Typography', name: 'brand_10' }, | ||
{ url: 'https://cdn.sei.io/brand_/brand_11.png', alt: 'Typography', name: 'brand_11' }, | ||
// Add more image entries as needed | ||
]; | ||
|
||
export default images; |
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 |
---|---|---|
@@ -1,6 +1,10 @@ | ||
const withNextra = require('nextra')({ | ||
theme: 'nextra-theme-docs', | ||
themeConfig: './theme.config.tsx', | ||
}) | ||
}); | ||
|
||
module.exports = withNextra() | ||
module.exports = withNextra({ | ||
images: { | ||
domains: ['cdn.sei.io'], | ||
}, | ||
}); |
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
Oops, something went wrong.