|
@@ -1,99 +1,43 @@
|
|
|
import React from 'react';
|
|
|
|
|
|
-import Button from '../Button';
|
|
|
-import Icon from '../Icon';
|
|
|
-import Drawer from '../Drawer';
|
|
|
-import Typography from '../Typography';
|
|
|
-import Tabs from '../Tabs';
|
|
|
-import Sliders from '../Sliders';
|
|
|
-import Divider from '../Divider';
|
|
|
-import ColorSelect from '../ColorSelector';
|
|
|
-import TextField from '../TextField';
|
|
|
+import { WatermarkType } from '../../constants/type';
|
|
|
|
|
|
-import { BtnWrapper, ContentWrapper } from './styled';
|
|
|
-import {
|
|
|
- Container, Head, Body, Footer, IconWrapper,
|
|
|
-} from '../../global/sidebarStyled';
|
|
|
-import { Group, SliderWrapper } from '../../global/toolStyled';
|
|
|
+import { TextWrapper, Img } from './styled';
|
|
|
|
|
|
-type Props = {
|
|
|
- onClick: () => void;
|
|
|
- isActive: boolean;
|
|
|
+type Props = WatermarkType & {
|
|
|
+ viewScale: number;
|
|
|
};
|
|
|
|
|
|
-const TextContent = (): React.ReactElement => (
|
|
|
- <>
|
|
|
- <ContentWrapper>
|
|
|
- <Typography variant="subtitle">Content</Typography>
|
|
|
- </ContentWrapper>
|
|
|
- <TextField variant="multiline" shouldFitContainer />
|
|
|
- </>
|
|
|
-);
|
|
|
-
|
|
|
-const ImageContent = (): React.ReactElement => (
|
|
|
- <ContentWrapper>
|
|
|
- <Icon glyph="add-image" />
|
|
|
- <Button appearance="link" style={{ marginLeft: '10px' }}>Select Image</Button>
|
|
|
- </ContentWrapper>
|
|
|
-);
|
|
|
-
|
|
|
-const Watermark: React.FunctionComponent<Props> = ({
|
|
|
- onClick,
|
|
|
- isActive,
|
|
|
+const index: React.FC<Props> = ({
|
|
|
+ type,
|
|
|
+ text,
|
|
|
+ imagepath,
|
|
|
+ viewScale,
|
|
|
+ scale = 1,
|
|
|
+ opacity,
|
|
|
+ textcolor,
|
|
|
+ rotation,
|
|
|
}: Props) => (
|
|
|
- <>
|
|
|
- <BtnWrapper>
|
|
|
- <Button shouldFitContainer align="left" onClick={onClick}>
|
|
|
- <Icon glyph="watermark" style={{ marginRight: '10px' }} />
|
|
|
- Watermark
|
|
|
- </Button>
|
|
|
- </BtnWrapper>
|
|
|
- <Drawer open={isActive} anchor="left" zIndex={4}>
|
|
|
- <Container>
|
|
|
- <Head>
|
|
|
- <IconWrapper>
|
|
|
- <Icon glyph="left-back" onClick={onClick} />
|
|
|
- </IconWrapper>
|
|
|
- <Typography light>Watermark</Typography>
|
|
|
- </Head>
|
|
|
- <Body>
|
|
|
- <Typography variant="subtitle">Type</Typography>
|
|
|
- <Tabs
|
|
|
- options={[
|
|
|
- {
|
|
|
- key: 'text',
|
|
|
- content: 'Text',
|
|
|
- child: <TextContent />,
|
|
|
- },
|
|
|
- {
|
|
|
- key: 'image',
|
|
|
- content: 'Image',
|
|
|
- child: <ImageContent />,
|
|
|
- },
|
|
|
- ]}
|
|
|
- />
|
|
|
- <Divider orientation="horizontal" style={{ margin: '20px 0' }} />
|
|
|
- <ColorSelect showTitle color="" onClick={(): void => {}} />
|
|
|
- <Typography variant="subtitle">Opacity</Typography>
|
|
|
- <Group>
|
|
|
- <SliderWrapper>
|
|
|
- <Sliders />
|
|
|
- </SliderWrapper>
|
|
|
- 40%
|
|
|
- </Group>
|
|
|
- <Divider orientation="horizontal" style={{ margin: '20px 0' }} />
|
|
|
- <Group>
|
|
|
- <Typography variant="subtitle">Page Range</Typography>
|
|
|
- <Button appearance="primary-hollow" style={{ width: '50%' }}>All Pages</Button>
|
|
|
- </Group>
|
|
|
- </Body>
|
|
|
- <Footer>
|
|
|
- <Button appearance="primary">Save</Button>
|
|
|
- <Button appearance="danger-link">Remove watermark</Button>
|
|
|
- </Footer>
|
|
|
- </Container>
|
|
|
- </Drawer>
|
|
|
- </>
|
|
|
+ type === 'text' ? (
|
|
|
+ <TextWrapper
|
|
|
+ style={{
|
|
|
+ fontSize: `${viewScale * scale * 24}px`,
|
|
|
+ opacity: `${opacity}%`,
|
|
|
+ color: textcolor,
|
|
|
+ transform: `rotate(-${rotation}deg)`,
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {text}
|
|
|
+ </TextWrapper>
|
|
|
+ ) : (
|
|
|
+ <Img
|
|
|
+ style={{
|
|
|
+ opacity: `${opacity}%`,
|
|
|
+ transform: `scale(${viewScale * scale}) rotate(-${rotation}deg)`,
|
|
|
+ }}
|
|
|
+ src={imagepath}
|
|
|
+ />
|
|
|
+ )
|
|
|
);
|
|
|
|
|
|
-export default Watermark;
|
|
|
+export default index;
|