mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-18 09:29:24 +00:00
Stack options
This commit is contained in:
parent
4f67aca9e4
commit
91821f805f
@ -1,26 +1,15 @@
|
|||||||
import { Grid, Card, Stack, Text } from '@mantine/core';
|
import { Stack, Card, Text } from '@mantine/core';
|
||||||
import { Tooltip } from '../../shared/Tooltip';
|
import { Tooltip } from '../../shared/Tooltip';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { SPLIT_METHODS, type SplitMethod } from '../../../constants/splitConstants';
|
import { type SplitMethod, METHOD_OPTIONS } from '../../../constants/splitConstants';
|
||||||
import { useSplitSettingsTips } from '../../tooltips/useSplitSettingsTips';
|
import { useSplitSettingsTips } from '../../tooltips/useSplitSettingsTips';
|
||||||
|
|
||||||
export interface SplitMethodSelectorProps {
|
export interface SplitMethodSelectorProps {
|
||||||
selectedMethod: SplitMethod | '';
|
|
||||||
onMethodSelect: (method: SplitMethod) => void;
|
onMethodSelect: (method: SplitMethod) => void;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MethodOption {
|
|
||||||
method: SplitMethod;
|
|
||||||
icon: string;
|
|
||||||
prefixKey: string;
|
|
||||||
nameKey: string;
|
|
||||||
descKey: string;
|
|
||||||
tooltipKey: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const SplitMethodSelector = ({
|
const SplitMethodSelector = ({
|
||||||
selectedMethod,
|
|
||||||
onMethodSelect,
|
onMethodSelect,
|
||||||
disabled = false
|
disabled = false
|
||||||
}: SplitMethodSelectorProps) => {
|
}: SplitMethodSelectorProps) => {
|
||||||
@ -32,65 +21,6 @@ const SplitMethodSelector = ({
|
|||||||
return tooltipContent?.tips || [];
|
return tooltipContent?.tips || [];
|
||||||
};
|
};
|
||||||
|
|
||||||
const methodOptions: MethodOption[] = [
|
|
||||||
{
|
|
||||||
method: SPLIT_METHODS.BY_PAGES,
|
|
||||||
icon: "format-list-numbered-rounded",
|
|
||||||
prefixKey: "split.methods.prefix.splitAt",
|
|
||||||
nameKey: "split.methods.byPages.name",
|
|
||||||
descKey: "split.methods.byPages.desc",
|
|
||||||
tooltipKey: "split.methods.byPages.tooltip"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
method: SPLIT_METHODS.BY_CHAPTERS,
|
|
||||||
icon: "bookmark-rounded",
|
|
||||||
prefixKey: "split.methods.prefix.splitBy",
|
|
||||||
nameKey: "split.methods.byChapters.name",
|
|
||||||
descKey: "split.methods.byChapters.desc",
|
|
||||||
tooltipKey: "split.methods.byChapters.tooltip"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
method: SPLIT_METHODS.BY_SECTIONS,
|
|
||||||
icon: "grid-on-rounded",
|
|
||||||
prefixKey: "split.methods.prefix.splitBy",
|
|
||||||
nameKey: "split.methods.bySections.name",
|
|
||||||
descKey: "split.methods.bySections.desc",
|
|
||||||
tooltipKey: "split.methods.bySections.tooltip"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
method: SPLIT_METHODS.BY_SIZE,
|
|
||||||
icon: "storage-rounded",
|
|
||||||
prefixKey: "split.methods.prefix.splitBy",
|
|
||||||
nameKey: "split.methods.bySize.name",
|
|
||||||
descKey: "split.methods.bySize.desc",
|
|
||||||
tooltipKey: "split.methods.bySize.tooltip"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
method: SPLIT_METHODS.BY_PAGE_COUNT,
|
|
||||||
icon: "numbers-rounded",
|
|
||||||
prefixKey: "split.methods.prefix.splitBy",
|
|
||||||
nameKey: "split.methods.byPageCount.name",
|
|
||||||
descKey: "split.methods.byPageCount.desc",
|
|
||||||
tooltipKey: "split.methods.byPageCount.tooltip"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
method: SPLIT_METHODS.BY_DOC_COUNT,
|
|
||||||
icon: "content-copy-rounded",
|
|
||||||
prefixKey: "split.methods.prefix.splitBy",
|
|
||||||
nameKey: "split.methods.byDocCount.name",
|
|
||||||
descKey: "split.methods.byDocCount.desc",
|
|
||||||
tooltipKey: "split.methods.byDocCount.tooltip"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
method: SPLIT_METHODS.BY_PAGE_DIVIDER,
|
|
||||||
icon: "auto-awesome-rounded",
|
|
||||||
prefixKey: "split.methods.prefix.splitBy",
|
|
||||||
nameKey: "split.methods.byPageDivider.name",
|
|
||||||
descKey: "split.methods.byPageDivider.desc",
|
|
||||||
tooltipKey: "split.methods.byPageDivider.tooltip"
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
const handleMethodClick = (method: SplitMethod) => {
|
const handleMethodClick = (method: SplitMethod) => {
|
||||||
if (!disabled) {
|
if (!disabled) {
|
||||||
onMethodSelect(method);
|
onMethodSelect(method);
|
||||||
@ -98,67 +28,66 @@ const SplitMethodSelector = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid>
|
<Stack gap="sm">
|
||||||
{methodOptions.map((option) => (
|
{METHOD_OPTIONS.map((option) => (
|
||||||
<Grid.Col key={option.method} span={{ base: 12, sm: 6 }}>
|
<Tooltip
|
||||||
<Tooltip
|
key={option.method}
|
||||||
sidebarTooltip
|
sidebarTooltip
|
||||||
tips={getMethodTooltip(option.method)}
|
tips={getMethodTooltip(option.method)}
|
||||||
|
>
|
||||||
|
<Card
|
||||||
|
radius="md"
|
||||||
|
w="100%"
|
||||||
|
h={'3.5rem'}
|
||||||
|
style={{
|
||||||
|
cursor: disabled ? 'default' : 'pointer',
|
||||||
|
backgroundColor: 'var(--mantine-color-gray-2)',
|
||||||
|
borderColor: 'var(--mantine-color-gray-3)',
|
||||||
|
opacity: disabled ? 0.6 : 1,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'row',
|
||||||
|
transition: 'all 0.2s ease',
|
||||||
|
}}
|
||||||
|
onMouseEnter={(e) => {
|
||||||
|
if (!disabled) {
|
||||||
|
e.currentTarget.style.backgroundColor = 'var(--mantine-color-gray-3)';
|
||||||
|
e.currentTarget.style.transform = 'translateY(-1px)';
|
||||||
|
e.currentTarget.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.1)';
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onMouseLeave={(e) => {
|
||||||
|
if (!disabled) {
|
||||||
|
e.currentTarget.style.backgroundColor = 'var(--mantine-color-gray-2)';
|
||||||
|
e.currentTarget.style.transform = 'translateY(0px)';
|
||||||
|
e.currentTarget.style.boxShadow = 'none';
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onClick={() => handleMethodClick(option.method)}
|
||||||
>
|
>
|
||||||
<Card
|
<div style={{ width: '100%', position: 'relative', display: 'flex', flexDirection: 'row' }}>
|
||||||
shadow="sm"
|
{/* Prefix in top left corner */}
|
||||||
radius="md"
|
<Text size="xs" c="dimmed" ta="center" fw={400} style={{
|
||||||
withBorder
|
|
||||||
|
|
||||||
h={120}
|
}}>
|
||||||
style={{
|
{t(option.prefixKey, "Split by")}
|
||||||
cursor: disabled ? 'default' : 'pointer',
|
</Text>
|
||||||
backgroundColor: selectedMethod === option.method ? 'var(--mantine-color-blue-light)' : 'var(--mantine-color-gray-2)',
|
|
||||||
borderColor: selectedMethod === option.method ? 'var(--mantine-color-blue-filled)' : 'var(--mantine-color-gray-3)',
|
|
||||||
opacity: disabled ? 0.6 : 1,
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column'
|
|
||||||
}}
|
|
||||||
onClick={() => handleMethodClick(option.method)}
|
|
||||||
>
|
|
||||||
<Stack align="center" gap={0} p="xs" h="100%" justify="Center">
|
|
||||||
{/* Prefix section */}
|
|
||||||
<Stack align="center" style={{ justifyContent: 'center' }}>
|
|
||||||
<Text
|
|
||||||
size="xs"
|
|
||||||
c="dimmed"
|
|
||||||
ta="center"
|
|
||||||
fw={400}
|
|
||||||
>
|
|
||||||
{t(option.prefixKey, "Split by")}
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
|
|
||||||
{/* Title section */}
|
<div style={{ }}>
|
||||||
<Stack align="center" style={{ justifyContent: 'center' }}>
|
<Text
|
||||||
<Text
|
fw={500}
|
||||||
fw={selectedMethod === option.method ? 600 : 500}
|
size="sm"
|
||||||
size="sm"
|
c={undefined}
|
||||||
ta="center"
|
ta="center"
|
||||||
c={selectedMethod === option.method ? 'blue' : undefined}
|
style={{ marginLeft: '0.25rem' }}
|
||||||
style={{ lineHeight: 1.2 }}
|
>
|
||||||
>
|
{t(option.nameKey, "Method Name")}
|
||||||
{t(option.nameKey, "Method Name")}
|
</Text>
|
||||||
</Text>
|
</div>
|
||||||
</Stack>
|
</div>
|
||||||
|
</Card>
|
||||||
{/* Description section - fixed height
|
</Tooltip>
|
||||||
<Stack align="center" style={{ height: '60px', justifyContent: 'flex-start' }}>
|
|
||||||
<Text size="xs" c="dimmed" ta="center" style={{ lineHeight: 1.3 }}>
|
|
||||||
{t(option.descKey, "Method description")}
|
|
||||||
</Text>
|
|
||||||
</Stack> */}
|
|
||||||
</Stack>
|
|
||||||
</Card>
|
|
||||||
</Tooltip>
|
|
||||||
</Grid.Col>
|
|
||||||
))}
|
))}
|
||||||
</Grid>
|
</Stack>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24,4 +24,72 @@ export const isSplitMethod = (value: string | null): value is SplitMethod => {
|
|||||||
return Object.values(SPLIT_METHODS).includes(value as SplitMethod);
|
return Object.values(SPLIT_METHODS).includes(value as SplitMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MethodOption {
|
||||||
|
method: SplitMethod;
|
||||||
|
icon: string;
|
||||||
|
prefixKey: string;
|
||||||
|
nameKey: string;
|
||||||
|
descKey: string;
|
||||||
|
tooltipKey: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const METHOD_OPTIONS: MethodOption[] = [
|
||||||
|
{
|
||||||
|
method: SPLIT_METHODS.BY_PAGES,
|
||||||
|
icon: "format-list-numbered-rounded",
|
||||||
|
prefixKey: "split.methods.prefix.splitAt",
|
||||||
|
nameKey: "split.methods.byPages.name",
|
||||||
|
descKey: "split.methods.byPages.desc",
|
||||||
|
tooltipKey: "split.methods.byPages.tooltip"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
method: SPLIT_METHODS.BY_CHAPTERS,
|
||||||
|
icon: "bookmark-rounded",
|
||||||
|
prefixKey: "split.methods.prefix.splitBy",
|
||||||
|
nameKey: "split.methods.byChapters.name",
|
||||||
|
descKey: "split.methods.byChapters.desc",
|
||||||
|
tooltipKey: "split.methods.byChapters.tooltip"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
method: SPLIT_METHODS.BY_SECTIONS,
|
||||||
|
icon: "grid-on-rounded",
|
||||||
|
prefixKey: "split.methods.prefix.splitBy",
|
||||||
|
nameKey: "split.methods.bySections.name",
|
||||||
|
descKey: "split.methods.bySections.desc",
|
||||||
|
tooltipKey: "split.methods.bySections.tooltip"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
method: SPLIT_METHODS.BY_SIZE,
|
||||||
|
icon: "storage-rounded",
|
||||||
|
prefixKey: "split.methods.prefix.splitBy",
|
||||||
|
nameKey: "split.methods.bySize.name",
|
||||||
|
descKey: "split.methods.bySize.desc",
|
||||||
|
tooltipKey: "split.methods.bySize.tooltip"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
method: SPLIT_METHODS.BY_PAGE_COUNT,
|
||||||
|
icon: "numbers-rounded",
|
||||||
|
prefixKey: "split.methods.prefix.splitBy",
|
||||||
|
nameKey: "split.methods.byPageCount.name",
|
||||||
|
descKey: "split.methods.byPageCount.desc",
|
||||||
|
tooltipKey: "split.methods.byPageCount.tooltip"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
method: SPLIT_METHODS.BY_DOC_COUNT,
|
||||||
|
icon: "content-copy-rounded",
|
||||||
|
prefixKey: "split.methods.prefix.splitBy",
|
||||||
|
nameKey: "split.methods.byDocCount.name",
|
||||||
|
descKey: "split.methods.byDocCount.desc",
|
||||||
|
tooltipKey: "split.methods.byDocCount.tooltip"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
method: SPLIT_METHODS.BY_PAGE_DIVIDER,
|
||||||
|
icon: "auto-awesome-rounded",
|
||||||
|
prefixKey: "split.methods.prefix.splitBy",
|
||||||
|
nameKey: "split.methods.byPageDivider.name",
|
||||||
|
descKey: "split.methods.byPageDivider.desc",
|
||||||
|
tooltipKey: "split.methods.byPageDivider.tooltip"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,7 +77,6 @@ const Split = (props: BaseToolProps) => {
|
|||||||
tooltip: methodTips,
|
tooltip: methodTips,
|
||||||
content: (
|
content: (
|
||||||
<SplitMethodSelector
|
<SplitMethodSelector
|
||||||
selectedMethod={base.params.parameters.method}
|
|
||||||
onMethodSelect={(method) => base.params.updateParameter('method', method)}
|
onMethodSelect={(method) => base.params.updateParameter('method', method)}
|
||||||
disabled={base.endpointLoading}
|
disabled={base.endpointLoading}
|
||||||
/>
|
/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user