Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADAPT 1445: Gallery Slideshow #192

Merged
merged 21 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
47f2f23
ADAPT-1445: Checkpoint commit for work on gallery slider.
Apr 27, 2021
fd6117d
ADAPT-1445: Cleaned up handling of pager thumbnails.
Apr 27, 2021
1aa44ad
ADAPT-1445: Added caption, counter, and expand link. Added slide-to b…
Apr 28, 2021
b2c190b
Added modal functionality to gallery slideshow. Style cleanup
Apr 29, 2021
814b159
ADAPT-1445: Style cleanup on gallery slideshow
Apr 30, 2021
7f7dd79
ADAPT-1445: Accessibility fixes, miscellaneous cleanup for Gallery Sl…
May 3, 2021
a76dfbe
ADAPT-1445: Code review fixes.
May 5, 2021
2f598b1
ADAPT-1445: Code review fixes
May 5, 2021
57f202e
ADAPT-1445: Added focus trap to modal. Added pointer cursor to galler…
May 6, 2021
1f7263f
ADAPT-1445: Adjusted container width settings.
May 14, 2021
3e596b9
ADAPT-1445: Fixed issue with tab focus failing on modal when child co…
May 18, 2021
778e4dd
ADAPT-2536: Accessibility fixes.
May 20, 2021
b58b99a
ADAPT-2536: Moved caption closer to image, to improve accessibility.
May 21, 2021
dd64c4a
ADAPT-1445: Added additional padding above modal container.
May 26, 2021
70e3d21
ADAPT-1445: Style adjustments to Gallery Slideshow based on feedback.
May 27, 2021
374f352
ADAPT-1445: Style fixes for gallery slideshow. (Support for backgroun…
May 28, 2021
1208cd2
Merge with main.
sherakama May 31, 2021
637c2ed
ADAPT-1445: Adjusted container width settings for gallery.
Jun 1, 2021
63bbf33
Merge branch 'ADAPT-1445' of github.com:SU-SWS/ood_giving_site into A…
Jun 2, 2021
e8403a5
ADAPT-1445: Style adjustments for modal version of gallery.
Jun 2, 2021
00e173b
ADAPT-1445: Style adjustments for Gallery Slideshow. (Constrain width…
Jun 3, 2021
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
45 changes: 45 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@
"react-loader-spinner": "^3.1.14",
"react-player": "^2.8.2",
"react-refresh": "^0.8.3",
"react-slick": "^0.28.1",
"sanitize-html": "^1.27.5",
"storyblok-react": "^0.1.1"
"slick-carousel": "^1.8.1",
"storyblok-react": "^0.1.1",
"tabbable": "^5.2.0"
},
"devDependencies": {
"prettier": "2.0.5"
Expand Down
2 changes: 2 additions & 0 deletions src/components/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import Accordion from "./composite/accordion";
import AccordionItem from "./composite/accordionItem";
import CtaGroup from "./composite/ctaGroup";
import SearchResults from "./search/searchResults";
import oodGallerySlideshow from './composite/oodGallerySlideshow';

const ComponentList = {
page: Page,
Expand Down Expand Up @@ -119,6 +120,7 @@ const ComponentList = {
searchResults: SearchResults,
alert: Alert,
alertPicker: AlertPicker,
oodGallerySlideshow: oodGallerySlideshow,
};

const Components = (type) => {
Expand Down
75 changes: 75 additions & 0 deletions src/components/composite/modal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import React, {useEffect, useRef, useState} from 'react';
import UseEscape from '../../hooks/useEscape';
import UseFocusTrap from '../../hooks/useFocusTrap';
import CenteredContainer from '../partials/centeredContainer';
import { tabbable } from 'tabbable';

export const Modal = ({children, isOpen, onClose, outerContainerClasses, innerContainerClasses, ariaLabel}) => {
const defaultOuterContainerClasses = 'centered-container flex-container su-pt-5';
const defaultInnerContainerClasses = '';
const closeButton = useRef();
const modalBodyRef = useRef();

// Find the last tabbable item within the modal body.
const getLastTabbableItem = () => {
if (!modalBodyRef.current) return null;
const focusableItems = tabbable(modalBodyRef.current);
return focusableItems[focusableItems.length - 1];
}

// Mimick the structure of a React ref so it works with UseFocusTrap hook.
const [lastTabbableRef, setLastTabbableRef] = useState({current: getLastTabbableItem()})

// Update focus trap when child content changes.
useEffect(() => {
setLastTabbableRef({current: getLastTabbableItem()});
}, [children])

UseFocusTrap(closeButton, lastTabbableRef, isOpen);

UseEscape(() => {
closeButton.current.click();
});

useEffect(() => {
if (isOpen) {
lockScroll();
closeButton.current.focus();
} else {
unlockScroll();
}
}, [isOpen]);

const lockScroll = () => {
const overlay = document.querySelector(".su-modal");
let scrollbarWidth =
overlay.offsetWidth - overlay.clientWidth + "px";

document.getElementsByTagName("html")[0].style.overflowY = "hidden";
document.getElementsByTagName(
"body"
)[0].style.paddingRight = scrollbarWidth;
}

const unlockScroll = () => {
document.getElementsByTagName("html")[0].style.overflowY = "scroll";
document.getElementsByTagName("body")[0].style.paddingRight = "0";
}

return (
<div className={`su-modal ${isOpen ? "visible" : "hidden"}`} aria-label={ariaLabel} aria-hidden={isOpen ? 'false' : 'true'} role='dialog' tabIndex="-1">
<CenteredContainer className={outerContainerClasses ? outerContainerClasses : defaultOuterContainerClasses}>
<div className={innerContainerClasses ? innerContainerClasses : defaultInnerContainerClasses}>
<div className="su-modal--header">
<button ref={closeButton} className="su-modal--close" onClick={onClose}>Close <i aria-hidden="true" className="fas fa-times"></i></button>
</div>
<div className="modal--body" ref={modalBodyRef}>
{children}
</div>
</div>
</CenteredContainer>
</div>
)
}

export default Modal;
Loading