Files
suwayomi-material-you-webui/src/features/reader/components/settings/layout/ReaderSettingPageGap.tsx

56 lines
2.2 KiB
TypeScript
Raw Normal View History

2024-11-04 18:00:35 +01:00
/*
* Copyright (C) Contributors to the Suwayomi project
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { useTranslation } from 'react-i18next';
2025-08-15 22:02:58 +02:00
import { IReaderSettings, IReaderSettingsWithDefaultFlag, ReadingMode } from '@/features/reader/types/Reader.types.ts';
import { SliderInput } from '@/features/core/components/inputs/SliderInput.tsx';
import { DEFAULT_READER_SETTINGS, PAGE_GAP } from '@/features/reader/constants/ReaderSettings.constants.tsx';
import { isContinuousReadingMode } from '@/features/reader/utils/ReaderSettings.utils.tsx';
import { MultiValueButtonDefaultableProps } from '@/features/core/Core.types.ts';
2024-11-04 18:00:35 +01:00
export const ReaderSettingPageGap = ({
pageGap,
readingMode,
isDefaultable,
onDefault,
2024-11-04 18:00:35 +01:00
updateSetting,
}: Pick<IReaderSettingsWithDefaultFlag, 'pageGap' | 'readingMode'> &
Pick<MultiValueButtonDefaultableProps<IReaderSettings['pageGap']>, 'isDefaultable' | 'onDefault'> & {
updateSetting: (gap: number, commit: boolean) => void;
}) => {
2024-11-04 18:00:35 +01:00
const { t } = useTranslation();
2024-12-16 16:26:32 +01:00
const isChangeable = readingMode.value !== ReadingMode.WEBTOON && isContinuousReadingMode(readingMode.value);
2024-11-03 03:09:00 +01:00
if (!isChangeable) {
return null;
}
2024-11-04 18:00:35 +01:00
return (
2024-11-03 03:09:00 +01:00
<SliderInput
label={t('reader.settings.label.page_gap')}
value={t('global.value', { value: pageGap.value, unit: t('global.unit.px') })}
onDefault={isDefaultable ? onDefault : undefined}
2024-11-03 03:09:00 +01:00
slotProps={{
slider: {
defaultValue: DEFAULT_READER_SETTINGS.pageGap,
2024-11-03 03:09:00 +01:00
value: pageGap.value,
step: PAGE_GAP.step,
min: PAGE_GAP.min,
max: PAGE_GAP.max,
2024-11-03 03:09:00 +01:00
onChange: (_, value) => {
updateSetting(value as number, false);
},
onChangeCommitted: (_, value) => {
updateSetting(value as number, true);
},
},
}}
/>
2024-11-04 18:00:35 +01:00
);
};