Skip to content

Commit

Permalink
feat: fullscreen images slideshow (#1120)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleensd authored Jan 22, 2025
1 parent 53d8215 commit 6db0193
Show file tree
Hide file tree
Showing 6 changed files with 349 additions and 18 deletions.
53 changes: 53 additions & 0 deletions frontend/src/static/js/components/_shared/ToolTip.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React, { useEffect, useRef, useState } from 'react';
import './ToolTip.scss';

function Tooltip({ children, content, title, position = 'right', classNames = '' }) {
const [active, setActive] = useState(false);
const [tooltipDimensions, setTooltipDimensions] = useState({
height: 0,
width: 0,
});

const popUpRef = useRef(null);

const showTip = () => {
setActive(true);
};

const hideTip = () => {
setActive(false);
};

useEffect(() => {
if (popUpRef.current) {
setTooltipDimensions({
height: popUpRef.current.clientHeight || 0,
width: popUpRef.current.clientWidth || 0,
});
}
}, [active]);

const tooltipPositionStyles = {
right: { left: '100%', marginLeft: '10px', top: '-50%' },
left: { right: '100%', marginRight: '10px', top: '-50%' },
top: { left: '50%', top: `-${tooltipDimensions.height + 10}px`, transform: 'translateX(-50%)' },
center: { top: '50%', left: '50%', translate: 'x-[-50%]' },
'bottom-left': { left: `-${tooltipDimensions.width - 20}px`, top: '100%', marginTop: '10px' },
};

return (
<div onMouseEnter={showTip} onMouseLeave={hideTip}>
<div
ref={popUpRef}
className={`tooltip-box ${active ? 'show' : 'hide'} ${classNames}`}
style={tooltipPositionStyles[position]}
>
{title && <div className="tooltip-title">{title}</div>}
<div className="tooltip-content">{content}</div>
</div>
{children}
</div>
);
}

export default Tooltip;
31 changes: 31 additions & 0 deletions frontend/src/static/js/components/_shared/ToolTip.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.tooltip-box {
position: absolute;
padding: 10px;
z-index: 100;
background: #fff;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
opacity: 0;
transform: translateY(-10px);
transition: opacity 0.3s ease, transform 0.3s ease;
}
.tooltip-box.show {
opacity: 1;
transform: translateY(0);
}

.tooltip-box.hide {
opacity: 0;
transform: translateY(-10px);
}
.tooltip-title {
color: #333;
font-size: 14px;
margin-bottom: 5px;
}

.tooltip-content {
color: #666;
font-size: 12px;
}

130 changes: 130 additions & 0 deletions frontend/src/static/js/components/media-page/MediaPage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@
display: block;

img {
cursor: pointer;
position: relative;
display: block;
max-width: 100%;
Expand All @@ -530,6 +531,135 @@
}
}

.modal-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.8);
display: flex;
justify-content: center;
align-items: center;
z-index: 1000;
}

.slideshow-container {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: auto;
max-width: 90%;
}



.slideshow-image img {
display: block;
width: auto;
height: auto;
max-width: 100%; /* Ensure image doesn't exceed container width */
max-height: 90vh;
border-radius: 0;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
transition: transform 60s ease-in-out, opacity 60 ease-in-out;
}

.slideshow-title {
margin-top: 10px;
text-align: start;
font-size: 16px;
font-weight: bold;
color: #bdb6b6;
z-index: 1200;
}


.arrow {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
width: 40px;
height: 40px;
top: 50%;
transform: translateY(-50%);
border: none;
color: white;
font-size: 2rem;
background-color: rgba(0, 0, 0, 0.2);
cursor: pointer;
padding: 10px;
border-radius: 50%;
z-index: 1000;
transition: background-color 0.2s ease, transform 0.2s ease;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.arrow:hover {
background: rgba(92, 78, 78, 0.6);
transform: translateY(-50%) scale(1.1);
}

.arrow.left {
left: 10px;
}

.arrow.right {
right: 10px;
}

.thumbnail-navigation {
position: fixed;
display: flex;
align-items: center;
justify-content: center;
margin-top: 20px;
gap: 10px;
bottom: 10%;
left: 50%;
transform: translateX(-50%);
}

.thumbnail-container {
display: flex;
gap: 10px;
overflow-x: auto;
scroll-behavior: smooth;
max-width: 80%;
padding: 10px 0;
scrollbar-width: none; /* Hide scrollbar for Firefox */
}

.thumbnail-container.center-thumbnails {
display: flex;
justify-content: center;
overflow: visible; /* No scrollbars for fewer thumbnails */
}

.thumbnail-container::-webkit-scrollbar {
display: none; /* Hide scrollbar for Chrome/Safari */
}

.thumbnail {
width: 60px;
height: 60px;
object-fit: cover;
border: 2px solid transparent;
border-radius: 5px;
cursor: pointer;
transition: transform 0.3s ease;
}

.thumbnail.active {
border-color: white;
}

.thumbnail:hover {
transform: scale(1.1);
}

.viewer-container .player-container {
@media screen and (min-width: 480px) {
border-radius: 10px;
Expand Down
Loading

0 comments on commit 6db0193

Please sign in to comment.