Skip to content

Commit

Permalink
feat: outline tooltips (#3230)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzmp authored Feb 3, 2022
1 parent ee32418 commit 5c0246c
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/lib/components/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const BoundaryProvider = BoundaryContext.Provider

const PopoverContainer = styled.div<{ show: boolean }>`
background-color: ${({ theme }) => theme.dialog};
border: 1px solid ${({ theme }) => theme.outline};
border-radius: 0.5em;
opacity: ${(props) => (props.show ? 1 : 0)};
padding: 8px;
Expand All @@ -23,15 +24,14 @@ const Reference = styled.div`
display: inline-block;
`

const SQRT_8 = Math.sqrt(8)

const Arrow = styled.div`
height: 8px;
width: 8px;
z-index: ${Layer.TOOLTIP};
::before {
background: ${({ theme }) => theme.dialog};
border: 1px solid ${({ theme }) => theme.outline};
content: '';
height: 8px;
position: absolute;
Expand All @@ -40,30 +40,38 @@ const Arrow = styled.div`
}
&.arrow-top {
bottom: -${SQRT_8}px;
bottom: -4px;
::before {
border-bottom-right-radius: 1px;
border-radius: 1px;
border-left: none;
border-top: none;
}
}
&.arrow-bottom {
top: -${SQRT_8}px;
top: -5px; // includes -1px from border
::before {
border-top-left-radius: 1px;
border-bottom: none;
border-right: none;
border-radius: 1px;
}
}
&.arrow-left {
right: -${SQRT_8}px;
right: -4px;
::before {
border-top-right-radius: 1px;
border-bottom: none;
border-left: none;
border-radius: 1px;
}
}
&.arrow-right {
left: -${SQRT_8}px;
left: -5px; // includes -1px from border
::before {
border-bottom-left-radius: 1px;
border-radius: 1px;
border-right: none;
border-top: none;
}
}
`
Expand Down

0 comments on commit 5c0246c

Please sign in to comment.