mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 11:23:10 +02:00
# Description of Changes <!-- Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --> --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details. --------- Co-authored-by: Claude <[email protected]> Co-authored-by: EthanHealy01 <[email protected]> Co-authored-by: EthanHealy01 <[email protected]>
89 lines
2.7 KiB
TypeScript
89 lines
2.7 KiB
TypeScript
import React from 'react';
|
|
import { Text } from '@mantine/core';
|
|
import { useTranslation } from 'react-i18next';
|
|
import HotkeyDisplay from '../../hotkeys/HotkeyDisplay';
|
|
import FavoriteStar from '../toolPicker/FavoriteStar';
|
|
import { ToolRegistryEntry, getSubcategoryColor } from '../../../data/toolsTaxonomy';
|
|
import { getIconBackground, getIconStyle, getItemClasses, useToolMeta } from './shared';
|
|
|
|
interface DetailedToolItemProps {
|
|
id: string;
|
|
tool: ToolRegistryEntry;
|
|
isSelected: boolean;
|
|
onClick: () => void;
|
|
}
|
|
|
|
const DetailedToolItem: React.FC<DetailedToolItemProps> = ({ id, tool, isSelected, onClick }) => {
|
|
const { t } = useTranslation();
|
|
const { binding, isFav, toggleFavorite, disabled } = useToolMeta(id, tool);
|
|
|
|
const categoryColor = getSubcategoryColor(tool.subcategoryId);
|
|
const iconBg = getIconBackground(categoryColor, true);
|
|
const iconClasses = 'tool-panel__fullscreen-icon';
|
|
|
|
let iconNode: React.ReactNode = null;
|
|
if (React.isValidElement<{ style?: React.CSSProperties }>(tool.icon)) {
|
|
const element = tool.icon as React.ReactElement<{ style?: React.CSSProperties }>;
|
|
iconNode = React.cloneElement(element, {
|
|
style: {
|
|
...(element.props.style || {}),
|
|
fontSize: '1.75rem',
|
|
},
|
|
});
|
|
} else {
|
|
iconNode = tool.icon;
|
|
}
|
|
|
|
return (
|
|
<button
|
|
type="button"
|
|
className={`tool-panel__fullscreen-item ${getItemClasses(true)} ${isSelected ? 'tool-panel__fullscreen-item--selected' : ''} tool-panel__fullscreen-item--with-star`}
|
|
onClick={onClick}
|
|
aria-disabled={disabled}
|
|
disabled={disabled}
|
|
>
|
|
{tool.icon ? (
|
|
<span
|
|
className={iconClasses}
|
|
aria-hidden
|
|
style={{
|
|
background: iconBg,
|
|
...getIconStyle(),
|
|
}}
|
|
>
|
|
{iconNode}
|
|
</span>
|
|
) : null}
|
|
<span className="tool-panel__fullscreen-body">
|
|
<Text fw={600} size="sm" className="tool-panel__fullscreen-name">
|
|
{tool.name}
|
|
</Text>
|
|
<Text size="sm" c="dimmed" className="tool-panel__fullscreen-description">
|
|
{tool.description}
|
|
</Text>
|
|
{binding && (
|
|
<div className="tool-panel__fullscreen-shortcut">
|
|
<span style={{ color: 'var(--mantine-color-dimmed)', fontSize: '0.75rem' }}>
|
|
{t('settings.hotkeys.shortcut', 'Shortcut')}
|
|
</span>
|
|
<HotkeyDisplay binding={binding} size="sm" />
|
|
</div>
|
|
)}
|
|
</span>
|
|
{!disabled && (
|
|
<div className="tool-panel__fullscreen-star">
|
|
<FavoriteStar
|
|
isFavorite={isFav}
|
|
onToggle={toggleFavorite}
|
|
size="sm"
|
|
/>
|
|
</div>
|
|
)}
|
|
</button>
|
|
);
|
|
};
|
|
|
|
export default DetailedToolItem;
|
|
|
|
|