Revert popover changes

This commit is contained in:
Eduard Heimbuch
2021-12-17 14:05:40 +01:00
committed by René Pfeuffer
parent 16960d742e
commit fb7aecd5e1
4 changed files with 51 additions and 31 deletions

View File

@@ -41,10 +41,29 @@ type ContainerProps = {
}; };
const PopoverContainer = styled.div<ContainerProps>` const PopoverContainer = styled.div<ContainerProps>`
position: absolute;
z-index: 100;
width: ${props => props.width}px; width: ${props => props.width}px;
display: block;
&:before { &:before {
position: absolute;
content: "";
border-style: solid;
pointer-events: none;
height: 0;
width: 0;
top: 100%;
left: ${props => props.width / 2}px; left: ${props => props.width / 2}px;
border-color: transparent;
border-bottom-color: white;
border-left-color: white;
border-width: 0.4rem;
margin-left: -0.4rem;
margin-top: -0.4rem;
-webkit-transform-origin: center;
transform-origin: center;
transform: rotate(-45deg);
} }
`; `;

View File

@@ -32,7 +32,7 @@ import { PrismAsyncLight as ReactSyntaxHighlighter, createElement } from "react-
// eslint-disable-next-line no-restricted-imports // eslint-disable-next-line no-restricted-imports
import highlightingTheme from "../../syntax-highlighting"; import highlightingTheme from "../../syntax-highlighting";
import { DateInput } from "../../useDateFormatter"; import { DateInput } from "../../useDateFormatter";
import Popover from "./Popover"; import AnnotatePopover from "./AnnotatePopover";
import AnnotateLine from "./AnnotateLine"; import AnnotateLine from "./AnnotateLine";
import { Action } from "./actions"; import { Action } from "./actions";
import { determineLanguage } from "../../languages"; import { determineLanguage } from "../../languages";
@@ -128,7 +128,7 @@ const Annotate: FC<Props> = ({ source, repository, baseDate }) => {
let popover = null; let popover = null;
if ((state.onPopover || state.onLine) && state.annotation) { if ((state.onPopover || state.onLine) && state.annotation) {
popover = ( popover = (
<Popover <AnnotatePopover
annotation={state.annotation} annotation={state.annotation}
dispatch={dispatch} dispatch={dispatch}
offsetTop={state.offset} offsetTop={state.offset}

View File

@@ -34,7 +34,32 @@ import { Action } from "./actions";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
const PopoverContainer = styled.div` const PopoverContainer = styled.div`
position: absolute;
left: 2.25em; left: 2.25em;
z-index: 100;
width: 30em;
display: block;
&:before {
position: absolute;
content: "";
border-style: solid;
pointer-events: none;
height: 0;
width: 0;
top: 100%;
left: 5.5em;
border-color: transparent;
border-bottom-color: white;
border-left-color: white;
border-width: 0.4rem;
margin-left: -0.4rem;
margin-top: -0.4rem;
-webkit-transform-origin: center;
transform-origin: center;
box-shadow: -1px 1px 2px rgba(10, 10, 10, 0.2);
transform: rotate(-45deg);
}
`; `;
const PopoverHeading = styled.div` const PopoverHeading = styled.div`
@@ -60,7 +85,7 @@ type PopoverProps = {
dispatch: Dispatch<Action>; dispatch: Dispatch<Action>;
}; };
const Popover: FC<PopoverProps> = ({ annotation, offsetTop, repository, baseDate, dispatch }) => { const AnnotatePopover: FC<PopoverProps> = ({ annotation, offsetTop, repository, baseDate, dispatch }) => {
const [t] = useTranslation("repos"); const [t] = useTranslation("repos");
const [height, setHeight] = useState(125); const [height, setHeight] = useState(125);
const ref = useRef<HTMLDivElement>(null); const ref = useRef<HTMLDivElement>(null);
@@ -72,13 +97,13 @@ const Popover: FC<PopoverProps> = ({ annotation, offsetTop, repository, baseDate
const onMouseEnter = () => { const onMouseEnter = () => {
dispatch({ dispatch({
type: "enter-popover" type: "enter-popover",
}); });
}; };
const OnMouseLeave = () => { const OnMouseLeave = () => {
dispatch({ dispatch({
type: "leave-popover" type: "leave-popover",
}); });
}; };
@@ -88,7 +113,7 @@ const Popover: FC<PopoverProps> = ({ annotation, offsetTop, repository, baseDate
ref={ref} ref={ref}
onMouseEnter={onMouseEnter} onMouseEnter={onMouseEnter}
onMouseLeave={OnMouseLeave} onMouseLeave={OnMouseLeave}
className="box popover" className="box"
style={{ top: `${top}px` }} style={{ top: `${top}px` }}
> >
<PopoverHeading className="is-clearfix"> <PopoverHeading className="is-clearfix">
@@ -110,4 +135,4 @@ const Popover: FC<PopoverProps> = ({ annotation, offsetTop, repository, baseDate
); );
}; };
export default Popover; export default AnnotatePopover;

View File

@@ -343,30 +343,6 @@ footer.footer {
} }
} }
.popover {
position: absolute;
z-index: 100;
width: 30em;
display: block;
&:before {
position: absolute;
content: "";
border-style: solid;
pointer-events: none;
height: 0;
width: 0;
top: 100%;
left: 5.5em;
border-color: transparent;
border-width: 0.4rem;
margin-left: -0.4rem;
margin-top: -0.4rem;
-webkit-transform-origin: center;
transform-origin: center;
transform: rotate(-45deg);
}
}
.notifications .dropdown-menu:before { .notifications .dropdown-menu:before {
border: 0.4rem solid transparent; border: 0.4rem solid transparent;