summaryrefslogtreecommitdiffhomepage
path: root/gui/src/renderer/components/ConnectionPanelDisclosure.tsx
blob: 11ec9a0136da352a4e1104cf209e5e9e026dd8a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import * as React from 'react';
import styled from 'styled-components';

import { colors } from '../../config.json';
import { normalText } from './common-styles';
import ImageView from './ImageView';

const Container = styled.div({
  display: 'flex',
  alignItems: 'center',
  width: '100%',
});

const Caption = styled.span(normalText, (props: { open: boolean }) => ({
  fontWeight: 600,
  lineHeight: '20px',
  minWidth: '0px',
  color: props.open ? colors.white : colors.white40,
  [Container + ':hover &']: {
    color: colors.white,
  },
}));

const Chevron = styled(ImageView)({
  [Container + ':hover &']: {
    backgroundColor: colors.white,
  },
});

interface IProps {
  pointsUp: boolean;
  onToggle?: () => void;
  children: React.ReactNode;
  className?: string;
}

export default function ConnectionPanelDisclosure(props: IProps) {
  return (
    <Container className={props.className} onClick={props.onToggle}>
      <Caption open={props.pointsUp}>{props.children}</Caption>
      <Chevron
        source={props.pointsUp ? 'icon-chevron-up' : 'icon-chevron-down'}
        width={22}
        height={22}
        tintColor={colors.white40}
      />
    </Container>
  );
}