index.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import React from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import { OptionPropsType } from '../../constants/type';
  4. import Typography from '../Typography';
  5. import SelectBox from '../SelectBox';
  6. import SliderWithTitle from '../SliderWithTitle';
  7. import ColorSelector from '../../containers/ColorSelector';
  8. import {
  9. Wrapper,
  10. } from '../../global/toolStyled';
  11. import {
  12. shapeOptions, typeOptions,
  13. } from './data';
  14. const ShapeOption: React.SFC<OptionPropsType> = ({
  15. shape,
  16. color,
  17. opacity,
  18. width,
  19. setDataState = (): void => {
  20. // do nothing
  21. },
  22. }: OptionPropsType) => {
  23. const { t } = useTranslation('sidebar');
  24. return (
  25. <>
  26. <Wrapper>
  27. <Typography
  28. variant="subtitle"
  29. style={{ marginTop: '8px' }}
  30. align="left"
  31. >
  32. {t('style')}
  33. </Typography>
  34. <SelectBox
  35. options={shapeOptions}
  36. style={{ marginRight: '10px' }}
  37. onChange={(item: Record<string, any>): void => { setDataState({ shape: item.key }); }}
  38. />
  39. {
  40. shape !== 'line' && shape !== 'arrow' && (
  41. <SelectBox
  42. options={typeOptions}
  43. onChange={(item: Record<string, any>): void => { setDataState({ type: item.key }); }}
  44. />
  45. )
  46. }
  47. </Wrapper>
  48. <Wrapper>
  49. <ColorSelector
  50. title={t('color')}
  51. mode="shape"
  52. selectedColor={color}
  53. onClick={(selected: string): void => { setDataState({ color: selected }); }}
  54. />
  55. </Wrapper>
  56. <Wrapper>
  57. <SliderWithTitle
  58. title={t('opacity')}
  59. value={opacity}
  60. tips={`${opacity}%`}
  61. onSlide={(val: number): void => { setDataState({ opacity: val }); }}
  62. />
  63. </Wrapper>
  64. <Wrapper>
  65. <SliderWithTitle
  66. title={t('width')}
  67. value={width}
  68. tips={`${width}pt`}
  69. onSlide={(val: number): void => { setDataState({ width: val }); }}
  70. maximum={40}
  71. />
  72. </Wrapper>
  73. </>
  74. );
  75. };
  76. export default ShapeOption;