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
@@ -0,0 +1,30 @@
/*!
* 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;
@@ -0,0 +1,11 @@
/*!
* 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;
}
}
@@ -0,0 +1,8 @@
/*!
* Copyright (c) 2024 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
import Favicon from './Favicon';
export default Favicon;
@@ -73,14 +73,14 @@ const Header = React.memo(() => {
const dispatch = useDispatch();
const handleToggleEditModeClick = useCallback(() => {
dispatch(entryActions.toggleEditMode(!isEditModeEnabled));
}, [isEditModeEnabled, dispatch]);
const handleToggleFavoritesClick = useCallback(() => {
dispatch(entryActions.toggleFavorites(!isFavoritesEnabled));
}, [isFavoritesEnabled, dispatch]);
const handleToggleEditModeClick = useCallback(() => {
dispatch(entryActions.toggleEditMode(!isEditModeEnabled));
}, [isEditModeEnabled, dispatch]);
const handleProjectSettingsClick = useCallback(() => {
if (!canEditProject) {
return;