All files / components/arrow-content arrow-content.styled.js

0% Statements 0/33
0% Branches 0/17
0% Functions 0/15
0% Lines 0/26
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85                                                                                                                                                                         
import styled from 'styled-components'
 
const ArrowContentStyled = styled.div`
  position: absolute;
  height: auto;
  ${p => {
    switch (p.hAlign) {
      case 'left':
        return 'left: 0px;'
      case 'right':
        return 'right: 0px;'
      default:
        return 'left: 0px;'
    }
  }};
  background-color: #ffffff;
  border: solid 1px ${p=>p.color};
  border-radius: 4px;
  box-sizing: border-box;
  z-index: 1;
 
  .content{
    position: relative;
    height: 100%;
    min-height: 50px;
    width: 100%;
  }
 
  .arrow::before{
      content: '';
      position: absolute;
      ${p => {
    switch (p.hAlign) {
      case 'center':
        const size = p.size / 2
        return `left: calc(50% - ${p.size / 2}px);`
      case 'left':
        return `left: ${p.hDistance};`
      case 'right':
        return `right: ${p.hDistance};`
    }
  }};
      ${p => {
    if (p.vAlign === 'top') {
      return `
              transform: rotate(180deg);
              top: -${p.size}px;
            `
    }
  }};
      border-left: ${p => p.size}px solid transparent;
      border-right: ${p => p.size}px solid transparent;
      border-top: ${p => p.size}px solid #ffffff;
      z-index: 3;
  }
  .arrow::after{
      content: '';
      position: absolute;
      ${p => {
    switch (p.hAlign) {
      case 'center':
        return `left: calc(50% - ${(p.size / 2) + 1}px);`
      case 'left':
        return `left: calc(${p.hDistance} - 1px);`
      case 'right':
        return `right: calc(${p.hDistance} - 1px);`
    }
  }};
      ${p => {
    if (p.vAlign === 'top') {
      return `
              top: -${p.size + 1}px;
              transform: rotate(180deg);
            `
    }
  }};
      border-left: ${p => p.size + 1}px solid transparent;
      border-right: ${p => p.size + 1}px solid transparent;
      border-top: ${p => p.size + 1}px solid ${p=>p.color};
      z-index: 2;
  }
`
 
export default ArrowContentStyled