index.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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, unknown>): void => {
  33. setDataState({ shape: item.key });
  34. }}
  35. />
  36. {shape !== 'line' && shape !== 'arrow' && (
  37. <SelectBox
  38. options={typeOptions}
  39. onChange={(item: Record<string, unknown>): 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. throughPortal
  54. />
  55. </Wrapper>
  56. <Wrapper>
  57. <SliderWithTitle
  58. title={t('opacity')}
  59. value={opacity}
  60. tips={`${opacity}%`}
  61. onSlide={(val: number): void => {
  62. setDataState({ opacity: val });
  63. }}
  64. />
  65. </Wrapper>
  66. <Wrapper>
  67. <SliderWithTitle
  68. title={t('width')}
  69. value={width}
  70. tips={`${width}pt`}
  71. onSlide={(val: number): void => {
  72. setDataState({ width: val });
  73. }}
  74. maximum={40}
  75. />
  76. </Wrapper>
  77. </>
  78. );
  79. };
  80. export default ShapeOption;