ref: Little refactoring
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user