Skip to content

Commit

Permalink
Add optional border for Image component (#1091)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dmatthews authored Jun 20, 2024
1 parent 811c7ea commit 168950f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 5 additions & 3 deletions components/blocks/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import classNames from "classnames";

import styles from "./image.module.css";

const Image = ({ caption, pure, src, alt, clean }) => {
const Image = ({ caption, pure, src, alt, clean, frame }) => {
const [isOpen, setIsOpen] = useState(false);

const openModal = () => {
Expand All @@ -14,6 +14,8 @@ const Image = ({ caption, pure, src, alt, clean }) => {
setIsOpen(false);
};

const borderStyle = frame ? styles.ImageBorder : "";

useEffect(() => {
const handleEsc = (event) => {
if (event.keyCode === 27) closeModal();
Expand Down Expand Up @@ -46,7 +48,7 @@ const Image = ({ caption, pure, src, alt, clean }) => {
onClick={openModal}
src={src}
alt={alt}
className={classNames(captionClass, styles.Image)}
className={classNames(captionClass, styles.Image, borderStyle)}
/>
{customCaption}
</section>
Expand Down Expand Up @@ -78,7 +80,7 @@ const Image = ({ caption, pure, src, alt, clean }) => {
<section className={styles.InnerContainer}>
<img
onClick={openModal}
className={classNames(captionClass, styles.Image)}
className={classNames(captionClass, styles.Image, borderStyle)}
src={src}
alt={alt}
/>
Expand Down
8 changes: 8 additions & 0 deletions components/blocks/image.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
@apply max-w-full max-h-screen transition duration-100 ease-in-out hover:opacity-80 cursor-pointer;
}

.ImageBorder {
@apply border-solid border border-gray-90;
}

:global(.dark) .ImageBorder {
@apply border-gray-20;
}

.Caption {
@apply italic text-gray-90 pt-2 md:pt-4 text-sm tracking-tight;
}
Expand Down

0 comments on commit 168950f

Please sign in to comment.