From 6992787bcdc753123ec9012129a6d8236eace2a8 Mon Sep 17 00:00:00 2001 From: devklick Date: Sat, 21 Oct 2023 20:38:21 +0100 Subject: [PATCH 1/3] Refactor Calculator to use styled components --- src/programs/Calculator/Calculator.scss | 73 ------------------ src/programs/Calculator/Calculator.tsx | 37 ++++++---- .../CalculatorLauncher.scss | 0 .../CalculatorLauncher/CalculatorLauncher.tsx | 1 - src/programs/Calculator/styles.ts | 74 +++++++++++++++++++ 5 files changed, 95 insertions(+), 90 deletions(-) delete mode 100644 src/programs/Calculator/Calculator.scss delete mode 100644 src/programs/Calculator/CalculatorLauncher/CalculatorLauncher.scss create mode 100644 src/programs/Calculator/styles.ts diff --git a/src/programs/Calculator/Calculator.scss b/src/programs/Calculator/Calculator.scss deleted file mode 100644 index 5b30603..0000000 --- a/src/programs/Calculator/Calculator.scss +++ /dev/null @@ -1,73 +0,0 @@ -.calculator { - width: 100%; - height: 100%; - display: grid; - grid-template-rows: 1fr 1fr 3fr; - grid-template-areas: - "input" - "output" - "buttons"; - box-shadow: 0px 0px 4px rgb(0, 0, 0, 0.5) inset; - padding: 10px; - border-radius: 10px; - box-sizing: border-box; - gap: 10px; - - &__input, - &__output { - box-shadow: 0px 0px 4px rgb(0, 0, 0, 0.5) inset; - width: 100%; - height: 100%; - display: flex; - justify-content: flex-end; - align-items: center; - padding: 20px; - box-sizing: border-box; - &-contents { - text-shadow: 2px 2px 4px rgb(0, 0, 0, 0.5); - } - } - &__input { - grid-area: input; - } - &__output { - grid-area: output; - } - - &__buttons { - min-height: 0; - grid-area: buttons; - width: 100%; - height: 100%; - justify-self: center; - display: grid; - grid-template-columns: 1fr 1fr 1fr 1fr; - grid-template-rows: 1fr 1fr 1fr 1fr 1fr; - box-sizing: border-box; - } - - &__button { - text-align: center; - cursor: default; - border-radius: 20px; - justify-self: center; - width: 80%; - height: 80%; - box-shadow: 2px 2px 4px rgb(0, 0, 0, 0.5); - box-sizing: border-box; - display: flex; - justify-content: center; - align-items: center; - - &:hover { - backdrop-filter: brightness(150%); - transition: ease-in 0.2s; - } - &:active { - box-shadow: 2px 2px 4px rgb(0, 0, 0, 0.5) inset; - } - - &-contents { - } - } -} diff --git a/src/programs/Calculator/Calculator.tsx b/src/programs/Calculator/Calculator.tsx index 3e6afdb..413339b 100644 --- a/src/programs/Calculator/Calculator.tsx +++ b/src/programs/Calculator/Calculator.tsx @@ -1,6 +1,13 @@ import { useEffect, useState } from "react"; -import "./Calculator.scss"; +import { + StyledButton, + StyledButtonContent, + StyledButtons, + StyledCalc, + StyledInputOutput, + StyledInputOutputContents, +} from "./styles"; interface CalculatorProps {} @@ -55,24 +62,22 @@ function Calculator({}: CalculatorProps) { } return ( -
- {displayChar} -
+ + {displayChar} + ); } return ( -
-
-
{input}
-
-
-
{output}
-
-
+ + + {input} + + + {output} + +
-
+ + ); } diff --git a/src/programs/Calculator/CalculatorLauncher/CalculatorLauncher.scss b/src/programs/Calculator/CalculatorLauncher/CalculatorLauncher.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/programs/Calculator/CalculatorLauncher/CalculatorLauncher.tsx b/src/programs/Calculator/CalculatorLauncher/CalculatorLauncher.tsx index 48ce15c..6b322f6 100644 --- a/src/programs/Calculator/CalculatorLauncher/CalculatorLauncher.tsx +++ b/src/programs/Calculator/CalculatorLauncher/CalculatorLauncher.tsx @@ -1,6 +1,5 @@ import Calculator from ".."; import Launcher from "../../../components/BottomBar/Launcher"; -import "./CalculatorLauncher.scss"; interface CalculatorLauncherProps {} diff --git a/src/programs/Calculator/styles.ts b/src/programs/Calculator/styles.ts new file mode 100644 index 0000000..889dc89 --- /dev/null +++ b/src/programs/Calculator/styles.ts @@ -0,0 +1,74 @@ +import styled from "@emotion/styled"; + +export const StyledCalc = styled.div` + width: 100%; + height: 100%; + display: grid; + grid-template-rows: 1fr 1fr 3fr; + grid-template-areas: + "input" + "output" + "buttons"; + box-shadow: 0px 0px 4px rgb(0, 0, 0, 0.5) inset; + padding: 10px; + border-radius: 10px; + box-sizing: border-box; + gap: 10px; +`; + +export const StyledInputOutput = styled.div<{ + direction: "input" | "output"; +}>` + box-shadow: 0px 0px 4px rgb(0, 0, 0, 0.5) inset; + width: 100%; + height: 100%; + display: flex; + justify-content: flex-end; + align-items: center; + padding: 20px; + box-sizing: border-box; + grid-area: ${(props) => props.direction}; +`; + +export const StyledInputOutputContents = styled.div` + text-shadow: 2px 2px 4px rgb(0, 0, 0, 0.5); +`; + +export const StyledButtons = styled.div` + min-height: 0; + grid-area: buttons; + width: 100%; + height: 100%; + justify-self: center; + display: grid; + grid-template-columns: 1fr 1fr 1fr 1fr; + grid-template-rows: 1fr 1fr 1fr 1fr 1fr; + box-sizing: border-box; +`; + +export const StyledButton = styled.button` + text-align: center; + cursor: default; + border-radius: 20px; + justify-self: center; + width: 80%; + height: 80%; + box-shadow: 2px 2px 4px rgb(0, 0, 0, 0.5); + box-sizing: border-box; + display: flex; + justify-content: center; + align-items: center; + background-color: inherit; + color: inherit; + border-width: 1px; + + &:hover { + backdrop-filter: brightness(150%); + transition: ease-in 0.2s; + } + &:active { + box-shadow: 2px 2px 4px rgb(0, 0, 0, 0.5) inset; + } +`; + +export const StyledButtonContent = styled.span``; From 1c4c8a5ba90561a7be34749137613949df5b38ed Mon Sep 17 00:00:00 2001 From: devklick Date: Sat, 21 Oct 2023 20:52:32 +0100 Subject: [PATCH 2/3] Refactor Settings, TextEditor, WebBrowser to use styled components --- src/programs/Settings/Settings.scss | 34 ----------- src/programs/Settings/Settings.tsx | 57 +++++++++---------- .../SettingsLauncher/SettingsLauncher.scss | 0 .../SettingsLauncher/SettingsLauncher.tsx | 1 - src/programs/Settings/styles.ts | 38 +++++++++++++ src/programs/TextEditor/TextEditor.scss | 25 -------- src/programs/TextEditor/TextEditor.tsx | 8 +-- .../TextEditorLauncher.scss | 0 .../TextEditorLauncher/TextEditorLauncher.tsx | 1 - src/programs/TextEditor/styles.ts | 25 ++++++++ src/programs/WebBrowser/WebBrowser.scss | 11 ---- src/programs/WebBrowser/WebBrowser.tsx | 12 ++-- .../WebBrowserLauncher.scss | 0 .../WebBrowserLauncher/WebBrowserLauncher.tsx | 1 - .../WebBrowser/{indext.ts => index.ts} | 0 src/programs/WebBrowser/styles.ts | 13 +++++ 16 files changed, 112 insertions(+), 114 deletions(-) delete mode 100644 src/programs/Settings/Settings.scss delete mode 100644 src/programs/Settings/SettingsLauncher/SettingsLauncher.scss create mode 100644 src/programs/Settings/styles.ts delete mode 100644 src/programs/TextEditor/TextEditor.scss delete mode 100644 src/programs/TextEditor/TextEditorLauncher/TextEditorLauncher.scss create mode 100644 src/programs/TextEditor/styles.ts delete mode 100644 src/programs/WebBrowser/WebBrowser.scss delete mode 100644 src/programs/WebBrowser/WebBrowserLauncher/WebBrowserLauncher.scss rename src/programs/WebBrowser/{indext.ts => index.ts} (100%) create mode 100644 src/programs/WebBrowser/styles.ts diff --git a/src/programs/Settings/Settings.scss b/src/programs/Settings/Settings.scss deleted file mode 100644 index a55a303..0000000 --- a/src/programs/Settings/Settings.scss +++ /dev/null @@ -1,34 +0,0 @@ -.settings { - display: grid; - grid-template-columns: 150px auto; - grid-template-areas: "side-bar main-content"; - width: 100%; - height: 100%; - box-shadow: 0px 0px 4px rgb(0, 0, 0, 0.5) inset; - border-radius: 10px; - - &__page { - overflow: auto; - - &-sections { - margin: 20px; - display: flex; - flex-direction: column; - gap: 20px; - &:last-of-type ~ hr { - display: none; - } - } - - &-section { - h1 { - margin: 0; - font-size: 18px; - } - - &__value { - width: 100%; - } - } - } -} diff --git a/src/programs/Settings/Settings.tsx b/src/programs/Settings/Settings.tsx index 2b83cf5..10c56d4 100644 --- a/src/programs/Settings/Settings.tsx +++ b/src/programs/Settings/Settings.tsx @@ -4,7 +4,15 @@ import AppSideBar from "../../components/AppSideBar"; import { getPages } from "./settingsPageConfig"; import useSystemSettings from "../../stores/systemSettingsStore"; -import "./Settings.scss"; +import { + StyledPage, + StyledSection, + StyledSectionDescription, + StyledSectionTitle, + StyledSectionValue, + StyledSections, + StyledSettings, +} from "./styles"; interface SettingsSectionProps { title: string; @@ -55,18 +63,15 @@ function SettingsSection(section: SettingsSectionProps) { } return ( -
-

{section.title}

-

- {section.description} -

- + {section.title} + {section.description} + -
+ > + ); } @@ -77,13 +82,13 @@ export interface SettingsPageProps { function SettingsPage({ sections }: SettingsPageProps) { return ( -
-
+ + {sections.map((section) => ( ))} -
-
+ + ); } @@ -95,25 +100,19 @@ function Settings({}: SettingsProps) { const pages = getPages(systemSettings); const [currentPage, setCurrentPage] = useState(Object.keys(pages)[0]); - function getAppBar() { - return ( - (pages).map(([type, page]) => { - return { - title: page.name, - isActive: currentPage === type, - onClick: () => setCurrentPage(type), - }; - })} - /> - ); + function getItems(): Parameters[0]["items"] { + return Object.entries(pages).map(([type, page]) => ({ + title: page.name, + isActive: currentPage === type, + onClick: () => setCurrentPage(type), + })); } return ( -
- {getAppBar()} + + -
+ ); } diff --git a/src/programs/Settings/SettingsLauncher/SettingsLauncher.scss b/src/programs/Settings/SettingsLauncher/SettingsLauncher.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/programs/Settings/SettingsLauncher/SettingsLauncher.tsx b/src/programs/Settings/SettingsLauncher/SettingsLauncher.tsx index 054a9f2..0926fe6 100644 --- a/src/programs/Settings/SettingsLauncher/SettingsLauncher.tsx +++ b/src/programs/Settings/SettingsLauncher/SettingsLauncher.tsx @@ -1,6 +1,5 @@ import Settings from ".."; import Launcher from "../../../components/BottomBar/Launcher"; -import "./SettingsLauncher.scss"; interface SettingsLauncherProps {} diff --git a/src/programs/Settings/styles.ts b/src/programs/Settings/styles.ts new file mode 100644 index 0000000..b1dbea3 --- /dev/null +++ b/src/programs/Settings/styles.ts @@ -0,0 +1,38 @@ +import styled from "@emotion/styled"; + +export const StyledSettings = styled.div` + display: grid; + grid-template-columns: 150px auto; + grid-template-areas: "side-bar main-content"; + width: 100%; + height: 100%; + box-shadow: 0px 0px 4px rgb(0, 0, 0, 0.5) inset; + border-radius: 10px; +`; + +export const StyledPage = styled.div` + overflow: auto; +`; + +export const StyledSections = styled.div` + margin: 20px; + display: flex; + flex-direction: column; + gap: 20px; + &:last-of-type ~ hr { + display: none; + } +`; + +export const StyledSection = styled.div``; + +export const StyledSectionTitle = styled.h1` + margin: 0; + font-size: 18px; +`; + +export const StyledSectionDescription = styled.p``; + +export const StyledSectionValue = styled.input` + width: 100%; +`; diff --git a/src/programs/TextEditor/TextEditor.scss b/src/programs/TextEditor/TextEditor.scss deleted file mode 100644 index 12721f7..0000000 --- a/src/programs/TextEditor/TextEditor.scss +++ /dev/null @@ -1,25 +0,0 @@ -.text-editor { - height: 100%; - width: 100%; - - &__text-area { - width: 100%; - height: 100%; - border: none; - resize: none; - margin: 0; - padding: 0; - background-color: transparent; - color: white; - box-shadow: 0px 0px 4px rgb(0, 0, 0, 0.5) inset; - border-radius: 10px; - padding: 10px; - box-sizing: border-box; - - &:focus-visible { - outline: none; - } - } - - transform: translate(); -} diff --git a/src/programs/TextEditor/TextEditor.tsx b/src/programs/TextEditor/TextEditor.tsx index 696e822..b40e653 100644 --- a/src/programs/TextEditor/TextEditor.tsx +++ b/src/programs/TextEditor/TextEditor.tsx @@ -1,13 +1,13 @@ -import "./TextEditor.scss"; +import { StyledTextArea, StyledTextEditor } from "./styles"; interface TextEditorProps {} // eslint-disable-next-line no-empty-pattern function TextEditor({}: TextEditorProps) { return ( -
-