index.tsx 2.1 KB

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