import React from 'react' ; import styled from 'styled-components' ; import { Close as CloseIcon } from 'design/Icon' ; import { space } from 'design/system' ; import { Flex , Text } from 'design' ; import JoinedUsers from './JoinedUsers' ; export default function TabItem ( props ) { const { name , users , active , onClick , onClose , style } = props ; return ( < StyledTabItem alignItems = "center" active = { active } style = { style } > < StyledTabButton onClick = { onClick } > < JoinedUsers mr = "1" users = { users } active = { active } / > < Text mx = "auto" title = { name } > { name } < /Text> < /StyledTabButton> < StyledCloseButton title = "Close" onClick = { onClose } > < CloseIcon /> < /StyledCloseButton> < /StyledTabItem>); } type Props = { name : string ; users : { user : string ; } [ ] ; active : boolean ; onClick : ( ) => void ; onClose : ( ) => void ; style : any ; } ; function fromProps ( { theme , active } ) { let styles = { border : 'none' , borderRight : `1px solid ${ theme . colors . bgTerminal }` , '&:hover, &:focus' : { color : theme . colors . primary . contrastText , transition : 'color .3s' , } , } ; if ( active ) { styles = { ... styles , backgroundColor : theme . colors . bgTerminal , color : theme . colors . primary . contrastText , fontWeight : 'bold' , transition : 'none' , } ; } return styles ; } const StyledTabItem = styled ( Flex ) `
  max-width: 200px;
  height: 100%;
  ${ fromProps }
` ; const StyledTabButton = styled . button `
  display: flex;
  flex: 1;
  align-items: center;
  cursor: pointer;
  text-decoration: none;
  outline: none;
  margin: 0;
  text-decoration: none;
  color: inherit;
  line-height: 32px;
  background-color: transparent;
  white-space: nowrap;
  overflow: hidden;
  padding: 0 16px;
  text-overflow: ellipsis;
  border: none;
` ; const StyledCloseButton = styled . button `
  background: transparent;
  border-radius: 2px;
  border: none;
  cursor: pointer;
  height: 16px;
  width: 16px;
  outline: none;
  padding: 0;
  margin: 0 8px 0 0;
  transition: all 0.3s;

  &:hover {
    background: ${ props => props . theme . colors . danger };
  }
  ${ space }
` ;