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
|