index.tsx 785 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import React from 'react';
  2. import { WatermarkType } from '../../constants/type';
  3. import { TextWrapper, Img } from './styled';
  4. type Props = WatermarkType & {
  5. viewScale: number;
  6. };
  7. const index: React.FC<Props> = ({
  8. type,
  9. text,
  10. imagepath,
  11. viewScale,
  12. scale = 1,
  13. opacity,
  14. textcolor,
  15. rotation,
  16. }: Props) => (
  17. type === 'text' ? (
  18. <TextWrapper
  19. style={{
  20. fontSize: `${viewScale * scale * 24}px`,
  21. opacity: `${opacity}%`,
  22. color: textcolor,
  23. transform: `rotate(-${rotation}deg)`,
  24. }}
  25. >
  26. {text}
  27. </TextWrapper>
  28. ) : (
  29. <Img
  30. style={{
  31. opacity: `${opacity}%`,
  32. transform: `scale(${viewScale * scale}) rotate(-${rotation}deg)`,
  33. }}
  34. src={imagepath}
  35. />
  36. )
  37. );
  38. export default index;