-
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.
106 feature new artifact page (#118)
* Remove redundant PR type spec * Implemented routes, added pages * Comments * Link to artifact pages, use artifact id * Artifact page basic components * Artifact page responsive layout * Extract props and fixed prop names * Rich Link basic in place, fine-tuning sass * Rich links with style * Tweak margins, fixed back button styling * Installed photoswipe... * Added style and is rendering, but opening in new tab * Fixed gallery not opening * Set thumbnail width * Extra comments
- Loading branch information
Showing
23 changed files
with
615 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ name: Reformat and Lint | |
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
workflow_dispatch: | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,20 +1,26 @@ | ||
import "../styles/ArtifactCard.sass"; | ||
import { Artifact } from "../scripts/interfaces"; | ||
import { ArtifactData } from "../scripts/interfaces"; | ||
import { NavLink } from "react-router-dom"; | ||
|
||
/** | ||
* Artifact card component. Displays high-level information about an artifact (title, subtitle, 3D graphic). | ||
* @param props {Artifact} artifact - Artifact object | ||
* ArtifactPage card component. Displays high-level information about an artifact (title, subtitle, 3D graphic). | ||
* @param {{artifact: ArtifactData}} props - Artifact to display | ||
* @constructor | ||
* @return {JSX.Element} | ||
*/ | ||
export default function ArtifactCard(props: { | ||
artifact: Artifact; | ||
artifact: ArtifactData; | ||
}): JSX.Element { | ||
// Extract props | ||
const { id, title, subtitle } = props.artifact; | ||
|
||
// Render | ||
return ( | ||
<div className="artifact-card"> | ||
/* skipcq: JS-0394 */ | ||
<NavLink to={`/honors-portfolio/${id}`} className="artifact-card"> | ||
<div className="artifact-card__graphic-container" /> | ||
<h1 className="artifact-card__title">{props.artifact.title}</h1> | ||
<h3 className="artifact-card__subtitle">{props.artifact.subtitle}</h3> | ||
</div> | ||
<h1 className="artifact-card__title">{title}</h1> | ||
<h3 className="artifact-card__subtitle">{subtitle}</h3> | ||
</NavLink> | ||
); | ||
} |
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,3 @@ | ||
import { ImageData } from "../scripts/interfaces"; | ||
|
||
export default function Gallery(props: { images: ImageData[] }): JSX.Element; |
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,93 @@ | ||
// noinspection JSUnusedGlobalSymbols | ||
|
||
import "../styles/Gallery.sass"; | ||
import { useEffect } from "react"; | ||
import PhotoSwipeLightbox from "photoswipe/lightbox"; | ||
import "photoswipe/style.css"; | ||
import "photoswipe-dynamic-caption-plugin/photoswipe-dynamic-caption-plugin.css"; | ||
import PropTypes from "prop-types"; | ||
import PhotoSwipeDynamicCaption from "photoswipe-dynamic-caption-plugin"; | ||
|
||
/** | ||
* Gallery component, displays a gallery of images | ||
* @param {object} props - Images to display | ||
* @constructor | ||
* @returns {JSX.Element} | ||
*/ | ||
export default function Gallery(props) { | ||
// Extract prop data | ||
const { images } = props; | ||
const galleryID = images[0].artifact.replaceAll(" ", "-").toLowerCase(); | ||
|
||
// Initialize the gallery | ||
useEffect(() => { | ||
// Create lightbox | ||
let lightbox = new PhotoSwipeLightbox({ | ||
gallery: `#${galleryID}`, | ||
children: "a", | ||
padding: { top: 30, right: 70, bottom: 30, left: 70 }, | ||
preloaderDelay: 0, | ||
pswpModule: () => import("photoswipe"), | ||
}); | ||
|
||
// Add dynamic caption plugin | ||
// noinspection JSUnusedLocalSymbols | ||
const _photoSwipeDynamicCaption = new PhotoSwipeDynamicCaption(lightbox, { | ||
type: "auto", | ||
captionContent: ".pswp-caption-content", | ||
}); | ||
|
||
// Start the lightbox | ||
lightbox.init(); | ||
|
||
// Cleanup | ||
return () => { | ||
lightbox.destroy(); | ||
lightbox = null; | ||
}; | ||
}, []); | ||
|
||
// Render | ||
return ( | ||
<div className={"Gallery"} id={galleryID}> | ||
{images.map((image) => ( | ||
<a | ||
key={image.name} | ||
href={image.image} | ||
data-pswp-width={image.width} | ||
data-pswp-height={image.height} | ||
target={"_blank"} | ||
rel={"noopener noreferrer"} | ||
> | ||
{/* Thumbnail */} | ||
<img | ||
className={"Gallery__thumbnail"} | ||
src={image.thumbnail} | ||
alt={image.name} | ||
/> | ||
|
||
{/* Caption */} | ||
<span className={"pswp-caption-content"}> | ||
<h2>{image.name}</h2> | ||
<br /> | ||
{image.description} | ||
</span> | ||
</a> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
Gallery.propTypes = { | ||
images: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
artifact: PropTypes.string.isRequired, | ||
width: PropTypes.number.isRequired, | ||
height: PropTypes.number.isRequired, | ||
name: PropTypes.string.isRequired, | ||
description: PropTypes.string, | ||
thumbnail: PropTypes.string.isRequired, | ||
image: PropTypes.string.isRequired, | ||
}) | ||
), | ||
}; |
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.