|
@@ -1,6 +1,5 @@
|
|
|
import React from 'react';
|
|
|
-import { WithTranslation } from 'next-i18next';
|
|
|
-import { withTranslation } from '../../i18n';
|
|
|
+import { useTranslation } from '../../i18n';
|
|
|
|
|
|
import { WatermarkType, SelectOptionType } from '../../constants/type';
|
|
|
import Button from '../Button';
|
|
@@ -17,11 +16,7 @@ import {
|
|
|
Container, Head, Body, Footer, IconWrapper,
|
|
|
} from '../../global/sidebarStyled';
|
|
|
|
|
|
-type i18nProps = {
|
|
|
- t: (key: string) => string;
|
|
|
-};
|
|
|
-
|
|
|
-type OwnerProps = WatermarkType & {
|
|
|
+type Props = WatermarkType & {
|
|
|
onClick: () => void;
|
|
|
isActive: boolean;
|
|
|
onSave: () => void;
|
|
@@ -29,10 +24,7 @@ type OwnerProps = WatermarkType & {
|
|
|
setDataState: (arg: Record<string, any>) => void;
|
|
|
};
|
|
|
|
|
|
-type Props = i18nProps & OwnerProps;
|
|
|
-
|
|
|
-const WatermarkOption: React.FC<Props> = ({
|
|
|
- t,
|
|
|
+const WatermarkOption: React.SFC<Props> = ({
|
|
|
onClick,
|
|
|
type,
|
|
|
opacity = 0,
|
|
@@ -45,91 +37,91 @@ const WatermarkOption: React.FC<Props> = ({
|
|
|
setDataState = (): void => {
|
|
|
// do nothing
|
|
|
},
|
|
|
-}: Props) => (
|
|
|
- <Container>
|
|
|
- <Head>
|
|
|
- <IconWrapper>
|
|
|
- <Icon glyph="left-back" onClick={onClick} />
|
|
|
- </IconWrapper>
|
|
|
- <Typography light>
|
|
|
- {t('watermark')}
|
|
|
- </Typography>
|
|
|
- </Head>
|
|
|
- <Body>
|
|
|
- <Typography variant="subtitle" align="left">
|
|
|
- {t('type')}
|
|
|
- </Typography>
|
|
|
- <Tabs
|
|
|
- options={[
|
|
|
- {
|
|
|
- key: 'text',
|
|
|
- content: t('text'),
|
|
|
- child: (
|
|
|
- <TextBox
|
|
|
- t={t}
|
|
|
- value={text}
|
|
|
- onChange={(value: string): void => { setDataState({ text: value }); }}
|
|
|
- />
|
|
|
- ),
|
|
|
- },
|
|
|
- ]}
|
|
|
- onChange={(option: SelectOptionType): void => { setDataState({ type: option.key }); }}
|
|
|
- />
|
|
|
- {
|
|
|
- type === 'text' ? (
|
|
|
- <>
|
|
|
- <Divider orientation="horizontal" style={{ margin: '20px 0' }} />
|
|
|
- <ColorSelect
|
|
|
- title={t('color')}
|
|
|
- mode="watermark"
|
|
|
- selectedColor={textcolor}
|
|
|
- onClick={(val: string): void => { setDataState({ textcolor: val }); }}
|
|
|
- />
|
|
|
- </>
|
|
|
- ) : null
|
|
|
- }
|
|
|
- <Box mt="20">
|
|
|
- <SliderWithTitle
|
|
|
- title={t('opacity')}
|
|
|
- value={opacity * 100}
|
|
|
- tips={`${(opacity * 100).toFixed(0)}%`}
|
|
|
- onSlide={(val: number): void => { setDataState({ opacity: val * 0.01 }); }}
|
|
|
- />
|
|
|
- </Box>
|
|
|
- <Box mt="20">
|
|
|
- <SliderWithTitle
|
|
|
- title={t('rotate')}
|
|
|
- value={rotation}
|
|
|
- maximum={360}
|
|
|
- tips={`${rotation}°`}
|
|
|
- onSlide={(val: number): void => { setDataState({ rotation: val }); }}
|
|
|
- />
|
|
|
- </Box>
|
|
|
- <Box mt="20">
|
|
|
- <SliderWithTitle
|
|
|
- title={t('scale')}
|
|
|
- value={scale * 100}
|
|
|
- tips={`${Math.round(scale * 100)}%`}
|
|
|
- minimum={50}
|
|
|
- maximum={250}
|
|
|
- onSlide={(val: number): void => { setDataState({ scale: val / 100 }); }}
|
|
|
- />
|
|
|
- </Box>
|
|
|
- <Divider orientation="horizontal" style={{ margin: '20px 0' }} />
|
|
|
- </Body>
|
|
|
- <Footer>
|
|
|
- <Button appearance="primary" onClick={onSave}>
|
|
|
- {t('save')}
|
|
|
- </Button>
|
|
|
- <Button appearance="danger-link" onClick={onDelete}>
|
|
|
- {t('removeWatermark')}
|
|
|
- </Button>
|
|
|
- </Footer>
|
|
|
- </Container>
|
|
|
-);
|
|
|
-
|
|
|
-const translator = withTranslation('sidebar');
|
|
|
+}: Props) => {
|
|
|
+ const { t } = useTranslation('sidebar');
|
|
|
|
|
|
-type TransProps = WithTranslation & OwnerProps;
|
|
|
+ return (
|
|
|
+ <Container>
|
|
|
+ <Head>
|
|
|
+ <IconWrapper>
|
|
|
+ <Icon glyph="left-back" onClick={onClick} />
|
|
|
+ </IconWrapper>
|
|
|
+ <Typography light>
|
|
|
+ {t('watermark')}
|
|
|
+ </Typography>
|
|
|
+ </Head>
|
|
|
+ <Body>
|
|
|
+ <Typography variant="subtitle" align="left">
|
|
|
+ {t('type')}
|
|
|
+ </Typography>
|
|
|
+ <Tabs
|
|
|
+ options={[
|
|
|
+ {
|
|
|
+ key: 'text',
|
|
|
+ content: t('text'),
|
|
|
+ child: (
|
|
|
+ <TextBox
|
|
|
+ t={t}
|
|
|
+ value={text}
|
|
|
+ onChange={(value: string): void => { setDataState({ text: value }); }}
|
|
|
+ />
|
|
|
+ ),
|
|
|
+ },
|
|
|
+ ]}
|
|
|
+ onChange={(option: SelectOptionType): void => { setDataState({ type: option.key }); }}
|
|
|
+ />
|
|
|
+ {
|
|
|
+ type === 'text' ? (
|
|
|
+ <>
|
|
|
+ <Divider orientation="horizontal" style={{ margin: '20px 0' }} />
|
|
|
+ <ColorSelect
|
|
|
+ title={t('color')}
|
|
|
+ mode="watermark"
|
|
|
+ selectedColor={textcolor}
|
|
|
+ onClick={(val: string): void => { setDataState({ textcolor: val }); }}
|
|
|
+ />
|
|
|
+ </>
|
|
|
+ ) : null
|
|
|
+ }
|
|
|
+ <Box mt="20">
|
|
|
+ <SliderWithTitle
|
|
|
+ title={t('opacity')}
|
|
|
+ value={opacity * 100}
|
|
|
+ tips={`${(opacity * 100).toFixed(0)}%`}
|
|
|
+ onSlide={(val: number): void => { setDataState({ opacity: val * 0.01 }); }}
|
|
|
+ />
|
|
|
+ </Box>
|
|
|
+ <Box mt="20">
|
|
|
+ <SliderWithTitle
|
|
|
+ title={t('rotate')}
|
|
|
+ value={rotation}
|
|
|
+ maximum={360}
|
|
|
+ tips={`${rotation}°`}
|
|
|
+ onSlide={(val: number): void => { setDataState({ rotation: val }); }}
|
|
|
+ />
|
|
|
+ </Box>
|
|
|
+ <Box mt="20">
|
|
|
+ <SliderWithTitle
|
|
|
+ title={t('scale')}
|
|
|
+ value={scale * 100}
|
|
|
+ tips={`${Math.round(scale * 100)}%`}
|
|
|
+ minimum={50}
|
|
|
+ maximum={250}
|
|
|
+ onSlide={(val: number): void => { setDataState({ scale: val / 100 }); }}
|
|
|
+ />
|
|
|
+ </Box>
|
|
|
+ <Divider orientation="horizontal" style={{ margin: '20px 0' }} />
|
|
|
+ </Body>
|
|
|
+ <Footer>
|
|
|
+ <Button appearance="primary" onClick={onSave}>
|
|
|
+ {t('save')}
|
|
|
+ </Button>
|
|
|
+ <Button appearance="danger-link" onClick={onDelete}>
|
|
|
+ {t('removeWatermark')}
|
|
|
+ </Button>
|
|
|
+ </Footer>
|
|
|
+ </Container>
|
|
|
+ );
|
|
|
+};
|
|
|
|
|
|
-export default translator<TransProps>(WatermarkOption);
|
|
|
+export default WatermarkOption;
|