ref: Little refactoring

This commit is contained in:
Maksim Eltyshev
2025-08-30 17:09:17 +02:00
parent 60a94f33fc
commit 4c5c7799f2
42 changed files with 89 additions and 19 deletions

View File

@@ -1,30 +0,0 @@
/*!
* Copyright (c) 2024 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
import React, { useCallback, useState } from 'react';
import PropTypes from 'prop-types';
import { Icon } from 'semantic-ui-react';
import styles from './Favicon.module.scss';
const Favicon = React.memo(({ url }) => {
const [isImageError, setIsImageError] = useState(false);
const handleImageError = useCallback(() => {
setIsImageError(true);
}, []);
return isImageError ? (
<Icon fitted name="linkify" className={styles.fallbackIcon} />
) : (
<img src={url} onError={handleImageError} /> // eslint-disable-line jsx-a11y/alt-text
);
});
Favicon.propTypes = {
url: PropTypes.string.isRequired,
};
export default Favicon;

View File

@@ -1,11 +0,0 @@
/*!
* Copyright (c) 2024 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
:global(#app) {
.fallbackIcon {
color: #5e6c84;
font-size: 18px;
}
}

View File

@@ -16,7 +16,7 @@ import { usePopupInClosableContext } from '../../../hooks';
import { isListArchiveOrTrash } from '../../../utils/record-helpers';
import { AttachmentTypes, BoardMembershipRoles } from '../../../constants/Enums';
import EditStep from './EditStep';
import Favicon from './Favicon';
import Favicon from '../../common/Favicon';
import TimeAgo from '../../common/TimeAgo';
import styles from './ItemContent.module.scss';
@@ -131,7 +131,11 @@ const ItemContent = React.forwardRef(({ id, onOpen }, ref) => {
<span className={styles.options}>
<button type="button" className={styles.option} onClick={handleDownloadClick}>
<Icon name="download" size="small" className={styles.optionIcon} />
<span className={styles.optionText}>Download</span>
<span className={styles.optionText}>
{t('action.download', {
context: 'title',
})}
</span>
</button>
{attachment.data.image && canEdit && (
<button type="button" className={styles.option} onClick={handleToggleCoverClick}>