Skip to content

Commit 1c4c8a5

Browse files
committed
Refactor Settings, TextEditor, WebBrowser to use styled components
1 parent 6992787 commit 1c4c8a5

16 files changed

Lines changed: 112 additions & 114 deletions

File tree

src/programs/Settings/Settings.scss

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

src/programs/Settings/Settings.tsx

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@ import AppSideBar from "../../components/AppSideBar";
44
import { getPages } from "./settingsPageConfig";
55
import useSystemSettings from "../../stores/systemSettingsStore";
66

7-
import "./Settings.scss";
7+
import {
8+
StyledPage,
9+
StyledSection,
10+
StyledSectionDescription,
11+
StyledSectionTitle,
12+
StyledSectionValue,
13+
StyledSections,
14+
StyledSettings,
15+
} from "./styles";
816

917
interface SettingsSectionProps {
1018
title: string;
@@ -55,18 +63,15 @@ function SettingsSection(section: SettingsSectionProps) {
5563
}
5664

5765
return (
58-
<div className="settings__page-section">
59-
<h1 className="settings__page-section__title">{section.title}</h1>
60-
<p className="settings__page-section__description">
61-
{section.description}
62-
</p>
63-
<input
64-
className="settings__page-section__value"
66+
<StyledSection>
67+
<StyledSectionTitle>{section.title}</StyledSectionTitle>
68+
<StyledSectionDescription>{section.description}</StyledSectionDescription>
69+
<StyledSectionValue
6570
type={getInputType(section.type)}
6671
value={String(value)}
6772
onChange={handleChange}
68-
></input>
69-
</div>
73+
></StyledSectionValue>
74+
</StyledSection>
7075
);
7176
}
7277

@@ -77,13 +82,13 @@ export interface SettingsPageProps {
7782

7883
function SettingsPage({ sections }: SettingsPageProps) {
7984
return (
80-
<div className="settings__page">
81-
<div className="settings__page-sections">
85+
<StyledPage>
86+
<StyledSections>
8287
{sections.map((section) => (
8388
<SettingsSection {...section} key={section.title} />
8489
))}
85-
</div>
86-
</div>
90+
</StyledSections>
91+
</StyledPage>
8792
);
8893
}
8994

@@ -95,25 +100,19 @@ function Settings({}: SettingsProps) {
95100
const pages = getPages(systemSettings);
96101
const [currentPage, setCurrentPage] = useState<string>(Object.keys(pages)[0]);
97102

98-
function getAppBar() {
99-
return (
100-
<AppSideBar
101-
items={Object.entries<SettingsPageProps>(pages).map(([type, page]) => {
102-
return {
103-
title: page.name,
104-
isActive: currentPage === type,
105-
onClick: () => setCurrentPage(type),
106-
};
107-
})}
108-
/>
109-
);
103+
function getItems(): Parameters<typeof AppSideBar>[0]["items"] {
104+
return Object.entries<SettingsPageProps>(pages).map(([type, page]) => ({
105+
title: page.name,
106+
isActive: currentPage === type,
107+
onClick: () => setCurrentPage(type),
108+
}));
110109
}
111110

112111
return (
113-
<div className="settings">
114-
{getAppBar()}
112+
<StyledSettings>
113+
<AppSideBar items={getItems()} />
115114
<SettingsPage {...pages[currentPage]} />
116-
</div>
115+
</StyledSettings>
117116
);
118117
}
119118

src/programs/Settings/SettingsLauncher/SettingsLauncher.scss

Whitespace-only changes.

src/programs/Settings/SettingsLauncher/SettingsLauncher.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Settings from "..";
22
import Launcher from "../../../components/BottomBar/Launcher";
3-
import "./SettingsLauncher.scss";
43

54
interface SettingsLauncherProps {}
65

src/programs/Settings/styles.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import styled from "@emotion/styled";
2+
3+
export const StyledSettings = styled.div`
4+
display: grid;
5+
grid-template-columns: 150px auto;
6+
grid-template-areas: "side-bar main-content";
7+
width: 100%;
8+
height: 100%;
9+
box-shadow: 0px 0px 4px rgb(0, 0, 0, 0.5) inset;
10+
border-radius: 10px;
11+
`;
12+
13+
export const StyledPage = styled.div`
14+
overflow: auto;
15+
`;
16+
17+
export const StyledSections = styled.div`
18+
margin: 20px;
19+
display: flex;
20+
flex-direction: column;
21+
gap: 20px;
22+
&:last-of-type ~ hr {
23+
display: none;
24+
}
25+
`;
26+
27+
export const StyledSection = styled.div``;
28+
29+
export const StyledSectionTitle = styled.h1`
30+
margin: 0;
31+
font-size: 18px;
32+
`;
33+
34+
export const StyledSectionDescription = styled.p``;
35+
36+
export const StyledSectionValue = styled.input`
37+
width: 100%;
38+
`;

src/programs/TextEditor/TextEditor.scss

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

src/programs/TextEditor/TextEditor.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import "./TextEditor.scss";
1+
import { StyledTextArea, StyledTextEditor } from "./styles";
22

33
interface TextEditorProps {}
44

55
// eslint-disable-next-line no-empty-pattern
66
function TextEditor({}: TextEditorProps) {
77
return (
8-
<div className="text-editor">
9-
<textarea className="text-editor__text-area" />
10-
</div>
8+
<StyledTextEditor>
9+
<StyledTextArea />
10+
</StyledTextEditor>
1111
);
1212
}
1313

src/programs/TextEditor/TextEditorLauncher/TextEditorLauncher.scss

Whitespace-only changes.

src/programs/TextEditor/TextEditorLauncher/TextEditorLauncher.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import TextEditor from "..";
22
import Launcher from "../../../components/BottomBar/Launcher";
33
import { MenuItemProps } from "../../../components/MenuItems";
4-
import "./TextEditorLauncher.scss";
54
import icon from "./text-editor-launcher-icon.svg";
65

76
const windowType = "text-editor";

src/programs/TextEditor/styles.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import styled from "@emotion/styled";
2+
3+
export const StyledTextEditor = styled.div`
4+
height: 100%;
5+
width: 100%;
6+
`;
7+
8+
export const StyledTextArea = styled.textarea`
9+
width: 100%;
10+
height: 100%;
11+
border: none;
12+
resize: none;
13+
margin: 0;
14+
padding: 0;
15+
background-color: transparent;
16+
color: white;
17+
box-shadow: 0px 0px 4px rgb(0, 0, 0, 0.5) inset;
18+
border-radius: 10px;
19+
padding: 10px;
20+
box-sizing: border-box;
21+
22+
&:focus-visible {
23+
outline: none;
24+
}
25+
`;

0 commit comments

Comments
 (0)