import React, { useState } from "react";
import styled from "styled-components";
import { border } from "styled-system";
import Flex from "../../layout/Flex";
const Pill = styled.div `
  display: inline-flex;
  & > :first-child {
    border-top-left-radius: 20px;
    border-bottom-left-radius: 20px;
    padding-left: 12px;
  }
  & > :last-child {
    border-top-right-radius: 20px;
    border-bottom-right-radius: 20px;
    padding-right: 12px;
  }
  & > :not(:first-child) {
    border-left-width: 0;
  }
  ${border};
`;
const Item = styled(Flex).attrs({ flex: 1, justifyContent: "center", alignItems: "center" }) `
  cursor: pointer;
  padding: 8px 10px 8px 10px;
  border: 1px solid;
  &[data-active="false"] {
    color: ${p => p.theme.colors.neutral.c80};
    background-color: ${p => p.theme.colors.neutral.c00};
    border-color: ${p => p.theme.colors.neutral.c40};
  }
  &[data-active="true"] {
    color: ${p => p.theme.colors.neutral.c00};
    background-color: ${p => p.theme.colors.neutral.c100};
    border-color: ${p => p.theme.colors.neutral.c100};

    &:not(:last-child) {
      border-right-width: 0;
    }
  }
  &[data-active="true"] + div {
    border-left-width: 1px;
  }
`;
export default function PillTabs({ children, onTabChange, initialActiveIndex, }) {
    const [activeIndex, setActiveIndex] = useState(initialActiveIndex);
    return (React.createElement(Pill, null, React.Children.toArray(children).map((child, index) => (React.createElement(Item, { key: index, "data-active": index === activeIndex, onClick: () => {
            setActiveIndex(index);
            onTabChange && onTabChange(index);
        } }, child)))));
}
//# sourceMappingURL=index.js.map