index.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. throughPortal
  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;