index.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import React from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import Icon from '../Icon';
  4. import Typography from '../Typography';
  5. import SliderWithTitle from '../SliderWithTitle';
  6. import ColorSelector from '../../containers/ColorSelector';
  7. import { Group, Item, Wrapper } from '../../global/toolStyled';
  8. import data from './data';
  9. const HighlightOption: React.SFC<OptionPropsType> = ({
  10. type,
  11. color,
  12. opacity,
  13. setDataState = (): void => {
  14. // do nothing
  15. },
  16. }: OptionPropsType) => {
  17. const { t } = useTranslation('sidebar');
  18. return (
  19. <>
  20. <Wrapper>
  21. <Typography
  22. variant="subtitle"
  23. style={{ marginTop: '8px' }}
  24. align="left"
  25. >
  26. {t('style')}
  27. </Typography>
  28. <Group>
  29. {data.lineType.map(ele => (
  30. <Item
  31. key={ele.key}
  32. selected={type === ele.key}
  33. onClick={(): void => {
  34. setDataState({ type: ele.key, color: ele.color });
  35. }}
  36. >
  37. <Icon glyph={ele.icon} />
  38. </Item>
  39. ))}
  40. </Group>
  41. </Wrapper>
  42. <Wrapper>
  43. <ColorSelector
  44. title={t('color')}
  45. selectedColor={color}
  46. onClick={(selected: string): void => {
  47. setDataState({ color: selected });
  48. }}
  49. />
  50. </Wrapper>
  51. <Wrapper>
  52. <SliderWithTitle
  53. title={t('opacity')}
  54. value={opacity}
  55. tips={`${opacity}%`}
  56. onSlide={(val: number): void => {
  57. setDataState({ opacity: val });
  58. }}
  59. />
  60. </Wrapper>
  61. </>
  62. );
  63. };
  64. export default HighlightOption;