index.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import React from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import { OptionPropsType } from '../../constants/type';
  4. import Icon from '../Icon';
  5. import Typography from '../Typography';
  6. import SliderWithTitle from '../SliderWithTitle';
  7. import ColorSelector from '../../containers/ColorSelector';
  8. import { Group, Item, Wrapper } from '../../global/toolStyled';
  9. import data from './data';
  10. const HighlightOption: React.SFC<OptionPropsType> = ({
  11. type,
  12. color,
  13. opacity,
  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. <Group>
  30. {data.lineType.map(ele => (
  31. <Item
  32. key={ele.key}
  33. selected={type === ele.key}
  34. onClick={(): void => {
  35. setDataState({ type: ele.key });
  36. }}
  37. >
  38. <Icon glyph={ele.icon} />
  39. </Item>
  40. ))}
  41. </Group>
  42. </Wrapper>
  43. <Wrapper>
  44. <ColorSelector
  45. title={t('color')}
  46. selectedColor={color}
  47. onClick={(selected: string): void => {
  48. setDataState({ color: selected });
  49. }}
  50. />
  51. </Wrapper>
  52. <Wrapper>
  53. <SliderWithTitle
  54. title={t('opacity')}
  55. value={opacity}
  56. tips={`${opacity}%`}
  57. onSlide={(val: number): void => {
  58. setDataState({ opacity: val });
  59. }}
  60. />
  61. </Wrapper>
  62. </>
  63. );
  64. };
  65. export default HighlightOption;