Skip to content

Commit f12bbcb

Browse files
authored
Merge pull request #5 from devklick/dev
Refactor to use styled components
2 parents e372560 + 44d1d3c commit f12bbcb

67 files changed

Lines changed: 955 additions & 716 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package-lock.json

Lines changed: 287 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
13+
"@emotion/react": "^11.11.1",
14+
"@emotion/styled": "^11.11.0",
1315
"@types/pako": "^2.0.1",
1416
"@types/uuid": "^9.0.4",
1517
"base64-js": "^1.5.1",

src/App.css

Whitespace-only changes.

src/App.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
import Desktop from "./components/Desktop";
1+
import { Global, css } from "@emotion/react";
22

3-
import "./App.css";
3+
import Desktop from "./components/Desktop";
4+
import useSystemSettings from "./stores/systemSettingsStore";
45

56
function App() {
7+
const settings = useSystemSettings();
68
return (
79
<div className="App">
10+
<Global
11+
styles={css`
12+
body {
13+
color: ${settings.fontColor};
14+
}
15+
`}
16+
/>
817
<Desktop />
918
</div>
1019
);

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 "./styles";
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

src/components/AppPopup/styles.ts

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+
`;

src/components/AppSideBar/AppSideBar.scss

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

src/components/AppSideBar/AppSideBar.tsx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import "./AppSideBar.scss";
1+
import { StyledItem, StyledItemContainer, StyledSideBar } from "./styles";
22

33
interface SideBarItem {
44
title: string;
@@ -12,21 +12,15 @@ interface AppSideBarProps {
1212

1313
function AppSideBar({ items }: AppSideBarProps) {
1414
return (
15-
<div className="app-side-bar">
16-
<div className="app-side-bar__items">
17-
{items.map((item) => {
18-
return (
19-
<div
20-
className={`app-side-bar__item ${item.isActive ? "active" : ""} `}
21-
onClick={item.onClick}
22-
key={item.title}
23-
>
24-
{item.title}
25-
</div>
26-
);
27-
})}
28-
</div>
29-
</div>
15+
<StyledSideBar>
16+
<StyledItemContainer>
17+
{items.map((item) => (
18+
<StyledItem onClick={item.onClick} key={item.title}>
19+
{item.title}
20+
</StyledItem>
21+
))}
22+
</StyledItemContainer>
23+
</StyledSideBar>
3024
);
3125
}
3226

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import styled from "@emotion/styled";
2+
3+
export const StyledSideBar = styled.div`
4+
grid-area: side-bar;
5+
width: 100%;
6+
height: 100%;
7+
`;
8+
9+
export const StyledItemContainer = styled.div`
10+
width: 100%;
11+
box-sizing: border-box;
12+
`;
13+
14+
export const StyledItem = styled.div`
15+
border-radius: 10px;
16+
padding: 6px 10px;
17+
box-sizing: border-box;
18+
box-shadow: 2px 2px 4px rgb(0, 0, 0, 0);
19+
&:hover {
20+
backdrop-filter: brightness(150%);
21+
transition: ease-in 0.2s;
22+
}
23+
&:active {
24+
box-shadow: 2px 2px 4px rgb(0, 0, 0, 0.5) inset;
25+
}
26+
`;

0 commit comments

Comments
 (0)