Skip to content

Commit

Permalink
chore(Popup): add border to popups' container and arrow
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisVorop committed Aug 29, 2023
1 parent 23a935d commit 15eb911
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions src/components/Popup.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { ComponentProps } from 'react';
import styled from 'styled-components';
import { backgroundColor, colorPrimary, danger0, gapXs, gray3, gray4, radiusS, warn0 } from '@taskany/colors';
import styled, { css } from 'styled-components';
import { backgroundColor, colorPrimary, danger0, gapXs, gray3, gray4, gray5, radiusS, warn0 } from '@taskany/colors';
import Tippy from '@tippyjs/react/headless';

/**
Expand All @@ -27,6 +27,25 @@ const colorsMap = {
warning: warn0,
};

const arrowDirectionStyles = {
top: `
border-top: none;
border-left: none;
`,
bottom: `
border-bottom: none;
border-right: none;
`,
left: `
border-bottom: none;
border-left: none;
`,
right: `
border-top: none;
border-right: none;
`,
};

const StyledPopupArrow = styled.div`
visibility: hidden;
position: absolute;
Expand All @@ -46,13 +65,24 @@ const StyledPopupArrow = styled.div`
height: 8px;
background: inherit;
border: 1px solid ${gray5};
content: '';
transform: rotate(45deg);
}
`;

const getArrowStyles = (direction: keyof typeof arrowDirectionStyles) => css`
&[data-placement|='${direction}'] {
${StyledPopupArrow} {
&::before {
${arrowDirectionStyles[direction]}
}
}
}
`;

const StyledPopupContent = styled.div`
position: relative;
z-index: 1;
Expand All @@ -68,6 +98,7 @@ const StyledPopupContainer = styled.div<{
position: relative;
background: ${backgroundColor};
border: 1px solid ${gray5};
border-radius: ${radiusS};
Expand Down Expand Up @@ -152,6 +183,11 @@ const StyledPopupContainer = styled.div<{
background: inherit;
border-radius: inherit;
}
${getArrowStyles('bottom')}
${getArrowStyles('left')}
${getArrowStyles('right')}
${getArrowStyles('top')}
`;

/**
Expand Down

0 comments on commit 15eb911

Please sign in to comment.