Skip to content

Commit 19d0452

Browse files
committed
Refactor AppPopup to use styled components
1 parent 66f908e commit 19d0452

3 files changed

Lines changed: 30 additions & 45 deletions

File tree

src/components/AppPopup/AppPopup.scss

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/components/AppPopup/AppPopup.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Rect } from "../../hooks/useDragToResize";
33
import useDetectMouseDownOutside from "../../hooks/useDetectMouseDownOutside";
44
import useSystemSettings from "../../stores/systemSettingsStore";
55

6-
import "./AppPopup.scss";
6+
import { StyledContent, StyledPopup } from "./Styled.AppPopup";
77

88
interface AppPopupProps<Element extends HTMLElement> {
99
appRef: React.RefObject<Element>;
@@ -44,21 +44,17 @@ function AppPopup<Element extends HTMLElement>({
4444
}
4545

4646
return (
47-
<div
48-
className="app-popup"
47+
<StyledPopup
48+
{...rect}
4949
ref={thisRef}
50-
style={{ ...rect }}
5150
onContextMenu={handleContextMenu}
5251
onClick={(e) => e.stopPropagation()}
5352
onDoubleClick={(e) => e.stopPropagation()}
5453
>
55-
<div
56-
className="app-popup__content"
57-
style={{ backgroundColor: settings.mainColor }}
58-
>
54+
<StyledContent backgroundColor={settings.mainColor}>
5955
{children}
60-
</div>
61-
</div>
56+
</StyledContent>
57+
</StyledPopup>
6258
);
6359
}
6460

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import styled from "@emotion/styled";
2+
import { Rect } from "../../hooks/useDragToResize";
3+
4+
export const StyledPopup = styled.div<Rect>`
5+
backdrop-filter: brightness(80%);
6+
position: fixed;
7+
z-index: 9999;
8+
display: flex;
9+
justify-content: center;
10+
align-items: center;
11+
top: ${(props) => props.top}px;
12+
left: ${(props) => props.left}px;
13+
width: ${(props) => props.width}px;
14+
height: ${(props) => props.height}px;
15+
`;
16+
17+
export const StyledContent = styled.div<{ backgroundColor: string }>`
18+
width: 300px;
19+
display: flex;
20+
flex-direction: column;
21+
box-shadow: 0 0 40px rgb(0, 0, 0, 0.5);
22+
border-radius: 10px;
23+
background-color: ${(props) => props.backgroundColor};
24+
`;

0 commit comments

Comments
 (0)