summaryrefslogtreecommitdiff
path: root/src/components/CollapsibleSectionHeader.js
blob: 9c25d74904370587219d4fe66b7938648dd303a4 (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
import React from 'react';
import { ChevronDown } from 'react-feather';
import cx from 'clsx';

import { SectionNameType } from './shared/Basic';
import Button from './Button';

import s from './CollapsibleSectionHeader.module.css';

type Props = {
  name: string,
  type: string,
  qty?: number,
  toggle?: () => void,
  isOpen?: boolean,
};

export default function Header({ name, type, toggle, isOpen, qty }: Props) {
  return (
    <div className={s.header}>
      <div onClick={toggle} style={{ cursor: 'pointer' }}>
        <SectionNameType name={name} type={type} />
      </div>

      {typeof qty === 'number' ? <span className={s.qty}>{qty}</span> : null}

      <Button kind="minimal" onClick={toggle} className={s.btn}>
        <span className={cx(s.arrow, { [s.isOpen]: isOpen })}>
          <ChevronDown size={20} />
        </span>
      </Button>
    </div>
  );
}