Skip to content

Commit

Permalink
Show preview image in folder content on hover
Browse files Browse the repository at this point in the history
  • Loading branch information
iRohitSingh committed Dec 19, 2024
1 parent 09b88e6 commit 69c0f64
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 9 deletions.
53 changes: 44 additions & 9 deletions packages/volto/src/components/manage/Contents/ContentsItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
*/

import React from 'react';
import { Button, Table, Menu, Divider } from 'semantic-ui-react';
import {
Button,
Table,
Menu,
Divider,
Popup as SemanticUiPopup,
} from 'semantic-ui-react';
import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';
import map from 'lodash/map';
Expand Down Expand Up @@ -97,6 +103,8 @@ export const ContentsItemComponent = ({
order,
}) => {
const intl = useIntl();
const previewImageUrl = `${item['@id']}/${item.image_scales?.image?.[0]?.scales?.teaser?.download}`;
const previewIconUrl = `${item['@id']}/${item.image_scales?.image?.[0]?.scales?.thumb?.download}`;

return connectDropTarget(
connectDragPreview(
Expand Down Expand Up @@ -156,14 +164,41 @@ export const ContentsItemComponent = ({
to={`${item['@id']}${item.is_folderish ? '/contents' : ''}`}
>
<div className="expire-align">
<Icon
name={getContentIcon(item['@type'], item.is_folderish)}
size="20px"
className="icon-margin"
color="#878f93"
title={item['Type'] || item['@type']}
/>{' '}
<span title={item.title}> {item.title}</span>
{item['@type'] === 'Image' ? (
<SemanticUiPopup
trigger={
<div className="preview-image-container">
<img
className="popup-image-icon"
src={previewIconUrl}
alt=""
/>{' '}
<span title={item.title}> {item.title}</span>
</div>
}
>
<SemanticUiPopup.Content>
<div>
<img
className="popup-preview-image"
src={previewImageUrl}
alt=""
/>
</div>
</SemanticUiPopup.Content>
</SemanticUiPopup>
) : (
<div className="preview-image-container">
<Icon
name={getContentIcon(item['@type'], item.is_folderish)}
size="20px"
className="icon-margin"
color="#878f93"
title={item['Type'] || item['@type']}
/>
<span title={item.title}> {item.title}</span>
</div>
)}
</div>
{item.ExpirationDate !== 'None' &&
new Date(item.ExpirationDate).getTime() <
Expand Down
16 changes: 16 additions & 0 deletions packages/volto/theme/themes/pastanaga/extras/contents.less
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,17 @@
.ui.table .expire-align {
display: flex;
align-items: center;

.preview-image-container {
display: flex;
align-items: center;

.popup-image-icon {
width: 20px;
height: 20px;
margin-right: 4px;
}
}
}

.ui.table .icon-margin {
Expand All @@ -153,6 +164,11 @@
color: white;
}
}
/* Folder contents preview image on title hover */
.popup-preview-image {
width: 100%;
height: 100%;
}

.contents-pagination {
.ui.secondary.menu .item {
Expand Down

0 comments on commit 69c0f64

Please sign in to comment.