|
| 1 | +import React from 'react'; |
| 2 | +import styled from 'styled-components'; |
| 3 | + |
| 4 | +import CrossIcon from 'react-icons/lib/md/clear'; |
| 5 | +import ChevronIcon from 'react-icons/lib/md/keyboard-arrow-right'; |
| 6 | +import Margin from 'app/components/spacing/Margin'; |
| 7 | +import Tooltip from 'app/components/Tooltip'; |
| 8 | + |
| 9 | +const Container = styled.div` |
| 10 | + display: inline-flex; |
| 11 | + border-radius: 4px; |
| 12 | + overflow: hidden; |
| 13 | +`; |
| 14 | + |
| 15 | +const IntegrationBlock = styled.div` |
| 16 | + display: inline-flex; |
| 17 | +
|
| 18 | + align-items: center; |
| 19 | +
|
| 20 | + background-color: ${props => props.bgColor}; |
| 21 | +
|
| 22 | + color: white; |
| 23 | +
|
| 24 | + font-size: 1.25rem; |
| 25 | +
|
| 26 | + padding: 1rem 1.5rem; |
| 27 | +`; |
| 28 | + |
| 29 | +const Details = styled.div` |
| 30 | + display: inline-flex; |
| 31 | + justify-content: center; |
| 32 | + align-items: center; |
| 33 | + padding: 0.75rem 1rem; |
| 34 | + background-color: rgba(0, 0, 0, 0.3); |
| 35 | +`; |
| 36 | + |
| 37 | +const Name = styled.span` |
| 38 | + margin-left: 0.75rem; |
| 39 | + font-size: 1.375rem; |
| 40 | +`; |
| 41 | + |
| 42 | +const Heading = styled.div` |
| 43 | + color: rgba(255, 255, 255, 0.5); |
| 44 | + font-size: 0.75rem; |
| 45 | + margin-bottom: 0.25rem; |
| 46 | +`; |
| 47 | + |
| 48 | +const Info = styled.div`font-weight: 400;`; |
| 49 | + |
| 50 | +const Action = styled.div` |
| 51 | + display: flex; |
| 52 | + transition: 0.3s ease all; |
| 53 | + border: 1px solid |
| 54 | + ${props => (props.red ? 'rgba(255, 0, 0, 0.4)' : props.theme.secondary)}; |
| 55 | + border-radius: 4px; |
| 56 | +
|
| 57 | + justify-content: center; |
| 58 | + align-items: center; |
| 59 | +
|
| 60 | + color: ${props => (props.red ? 'rgba(255, 0, 0, 0.6)' : 'white')}; |
| 61 | +
|
| 62 | + background-color: ${props => |
| 63 | + props.red ? 'transparent' : props.theme.secondary}; |
| 64 | +
|
| 65 | + opacity: 0.8; |
| 66 | + cursor: pointer; |
| 67 | +
|
| 68 | + height: 1.5rem; |
| 69 | + width: 1.5rem; |
| 70 | +
|
| 71 | + &:hover { |
| 72 | + opacity: 1; |
| 73 | +
|
| 74 | + color: white; |
| 75 | + background-color: ${props => |
| 76 | + props.red ? 'rgba(255, 0, 0, 0.6)' : props.theme.secondary}; |
| 77 | + } |
| 78 | +`; |
| 79 | + |
| 80 | +type DetailProps = { |
| 81 | + heading: string, |
| 82 | + info: string, |
| 83 | + signOut: ?Function, |
| 84 | + signIn: ?Function, |
| 85 | +}; |
| 86 | + |
| 87 | +const DetailInfo = ({ heading, info, signOut, signIn }: DetailProps) => ( |
| 88 | + <Details> |
| 89 | + <Margin right={2}> |
| 90 | + <Heading>{heading}</Heading> |
| 91 | + <Info>{info}</Info> |
| 92 | + </Margin> |
| 93 | + |
| 94 | + {signOut ? ( |
| 95 | + <Tooltip title="Sign out"> |
| 96 | + <Action onClick={signOut} red> |
| 97 | + <CrossIcon /> |
| 98 | + </Action> |
| 99 | + </Tooltip> |
| 100 | + ) : ( |
| 101 | + <Tooltip title="Sign in"> |
| 102 | + <Action onClick={signIn}> |
| 103 | + <ChevronIcon /> |
| 104 | + </Action> |
| 105 | + </Tooltip> |
| 106 | + )} |
| 107 | + </Details> |
| 108 | +); |
| 109 | + |
| 110 | +type Props = { |
| 111 | + Icon: React.CElement, |
| 112 | + name: string, |
| 113 | + color: string, |
| 114 | + description: string, |
| 115 | + loggedIn: boolean, |
| 116 | +}; |
| 117 | + |
| 118 | +export default ({ Icon, name, description, color, loggedIn }: Props) => ( |
| 119 | + <Container> |
| 120 | + <IntegrationBlock bgColor={color}> |
| 121 | + <Icon /> |
| 122 | + <Name>{name}</Name> |
| 123 | + </IntegrationBlock> |
| 124 | + {!loggedIn ? ( |
| 125 | + <DetailInfo |
| 126 | + signOut={() => {}} |
| 127 | + heading="Signed in as" |
| 128 | + |
| 129 | + /> |
| 130 | + ) : ( |
| 131 | + <DetailInfo signIn={() => {}} heading="Enables" info={description} /> |
| 132 | + )} |
| 133 | + </Container> |
| 134 | +); |
0 commit comments