From f94340e242b6553e040e2ab46759be297a9ff46b Mon Sep 17 00:00:00 2001 From: Nikhil Narayana Date: Tue, 23 Jan 2024 21:45:46 -0800 Subject: [PATCH] refactor: use stylex in support_box and network_diagnostics --- .../cgnat_command_section.tsx | 54 ++++++++++--------- .../network_diagnostics/nat_type_section.tsx | 46 +++++++++------- .../network_diagnostics_button.tsx | 20 +++++-- .../network_diagnostics_result.tsx | 14 ++--- .../pages/settings/help_page/support_box.tsx | 53 +++++++++--------- 5 files changed, 108 insertions(+), 79 deletions(-) diff --git a/src/renderer/pages/settings/help_page/network_diagnostics/cgnat_command_section.tsx b/src/renderer/pages/settings/help_page/network_diagnostics/cgnat_command_section.tsx index 82e2a3624..cf3557698 100644 --- a/src/renderer/pages/settings/help_page/network_diagnostics/cgnat_command_section.tsx +++ b/src/renderer/pages/settings/help_page/network_diagnostics/cgnat_command_section.tsx @@ -1,29 +1,31 @@ -import { css } from "@emotion/react"; -import styled from "@emotion/styled"; import Button from "@mui/material/Button"; import InputBase from "@mui/material/InputBase"; import Typography from "@mui/material/Typography"; +import * as stylex from "@stylexjs/stylex"; import React from "react"; -const buttonStyle = { marginLeft: "8px", width: "96px" }; const hiddenIpAddress = "···.···.···.···"; -const inputBaseCss = css` - padding: 4px 8px; - border-radius: 10px; - background-color: rgba(0, 0, 0, 0.4); - font-size: 1em; - margin: 8px 0; -`; -// This is used to correct an observed 1px vertical misalignment -const AlignCenterDiv = styled.div` - display: flex; - align-items: center; -`; - -const DialogBody = styled.div` - margin-bottom: 1em; -`; +const styles = stylex.create({ + button: { + marginLeft: "8px", + width: "96px", + }, + cgnatCmd: { + padding: "4px 8px", + borderRadius: "10px", + backgroundColor: "rgba(0, 0, 0, 0.4)", + fontSize: "1em", + margin: "8px 0", + }, + body: { + marginBottom: "1em", + }, + alignCenterDiv: { + display: "flex", + alignItems: "center", + }, +}); type CgnatCommandSectionProps = { address: string; @@ -46,16 +48,18 @@ export const CgnatCommandSection = ({ address }: CgnatCommandSectionProps) => { return (
Run this command - - - - - - More than one hop to your external IP address indicates CGNAT or Double NAT (or VPN). +
+
+ More than one hop to your external IP address indicates CGNAT or Double NAT (or VPN). +
); }; diff --git a/src/renderer/pages/settings/help_page/network_diagnostics/nat_type_section.tsx b/src/renderer/pages/settings/help_page/network_diagnostics/nat_type_section.tsx index 0b3481260..33c39ec85 100644 --- a/src/renderer/pages/settings/help_page/network_diagnostics/nat_type_section.tsx +++ b/src/renderer/pages/settings/help_page/network_diagnostics/nat_type_section.tsx @@ -1,24 +1,28 @@ import { NatType } from "@common/types"; -import { css } from "@emotion/react"; -import styled from "@emotion/styled"; import Button from "@mui/material/Button"; import InputBase from "@mui/material/InputBase"; import Typography from "@mui/material/Typography"; +import * as stylex from "@stylexjs/stylex"; import React from "react"; -const buttonStyle = { marginLeft: "8px", width: "96px" }; const hiddenIpAddress = "···.···.···.···"; -const inputBaseCss = css` - padding: 4px 8px; - border-radius: 10px; - background-color: rgba(0, 0, 0, 0.4); - font-size: 1em; - margin: 8px 0; -`; -const DialogBody = styled.div` - margin-bottom: 1em; -`; +const styles = stylex.create({ + button: { + marginLeft: "8px", + width: "96px", + }, + ipAddress: { + padding: "4px 8px", + borderRadius: "10px", + backgroundColor: "rgba(0, 0, 0, 0.4)", + fontSize: "1em", + margin: "8px 0", + }, + body: { + marginBottom: "1em", + }, +}); const getIpAddressTitle = (natType: NatType) => { if (natType === NatType.FAILED) { @@ -49,18 +53,22 @@ export const NatTypeSection = ({ address, description, natType, title }: NatType
{ipAddressTitle} {natType !== NatType.FAILED && ( - - - - - +
)} {title} - {description} +
{description}
); }; diff --git a/src/renderer/pages/settings/help_page/network_diagnostics/network_diagnostics_button.tsx b/src/renderer/pages/settings/help_page/network_diagnostics/network_diagnostics_button.tsx index 3fd7c7e26..9e62c7280 100644 --- a/src/renderer/pages/settings/help_page/network_diagnostics/network_diagnostics_button.tsx +++ b/src/renderer/pages/settings/help_page/network_diagnostics/network_diagnostics_button.tsx @@ -6,6 +6,7 @@ import CircularProgress from "@mui/material/CircularProgress"; import Dialog from "@mui/material/Dialog"; import DialogContent from "@mui/material/DialogContent"; import DialogTitle from "@mui/material/DialogTitle"; +import * as stylex from "@stylexjs/stylex"; import React from "react"; import { Button as ActionButton } from "@/components/form/button"; @@ -19,6 +20,19 @@ type NetworkInformation = { portMapping: PortMapping; }; +const styles = stylex.create({ + container: { + textAlign: "center", + }, + text: { + marginTop: 20, + }, + icon: { + height: 18, + width: 18, + }, +}); + export const NetworkDiagnosticsButton = React.memo(() => { const [dialogOpen, setDialogOpen] = React.useState(false); const [isLoading, setIsLoading] = React.useState(false); @@ -45,9 +59,9 @@ export const NetworkDiagnosticsButton = React.memo(() => { const networkDiagnosticsContent = React.useMemo(() => { if (isLoading) { return ( -
+
-
Running network diagnostics...
+
Running network diagnostics...
); } @@ -63,7 +77,7 @@ export const NetworkDiagnosticsButton = React.memo(() => { return (
} + startIcon={} color="secondary" variant="contained" onClick={openDialog} diff --git a/src/renderer/pages/settings/help_page/network_diagnostics/network_diagnostics_result.tsx b/src/renderer/pages/settings/help_page/network_diagnostics/network_diagnostics_result.tsx index 1cb901abf..06723b194 100644 --- a/src/renderer/pages/settings/help_page/network_diagnostics/network_diagnostics_result.tsx +++ b/src/renderer/pages/settings/help_page/network_diagnostics/network_diagnostics_result.tsx @@ -1,17 +1,19 @@ import type { PortMapping } from "@common/types"; import { NatType, Presence } from "@common/types"; -import styled from "@emotion/styled"; import Button from "@mui/material/Button"; import DialogActions from "@mui/material/DialogActions"; import Typography from "@mui/material/Typography"; +import * as stylex from "@stylexjs/stylex"; import React from "react"; import { CgnatCommandSection } from "./cgnat_command_section"; import { NatTypeSection } from "./nat_type_section"; -const ContentBody = styled.div` - margin-bottom: 1em; -`; +const styles = stylex.create({ + contentBody: { + marginBottom: "1em", + }, +}); const getNatTypeTitle = (natType: NatType) => { if (natType === NatType.FAILED) { @@ -117,9 +119,9 @@ export const NetworkDiagnosticsResult = React.memo(
{portMappingTitle} - {portMappingDescription} +
{portMappingDescription}
{cgnatTitle} - {cgnatDescription} +
{cgnatDescription}
{cgnat === Presence.FAILED && ipAddress && }
diff --git a/src/renderer/pages/settings/help_page/support_box.tsx b/src/renderer/pages/settings/help_page/support_box.tsx index 251761975..80fb17191 100644 --- a/src/renderer/pages/settings/help_page/support_box.tsx +++ b/src/renderer/pages/settings/help_page/support_box.tsx @@ -1,9 +1,9 @@ import { colors } from "@common/colors"; import { socials } from "@common/constants"; import { css } from "@emotion/react"; -import styled from "@emotion/styled"; import FileCopyIcon from "@mui/icons-material/FileCopy"; import LiveHelpIcon from "@mui/icons-material/LiveHelp"; +import * as stylex from "@stylexjs/stylex"; import log from "electron-log"; import { ExternalLink as A } from "@/components/external_link"; @@ -13,6 +13,27 @@ import { ReactComponent as DiscordIcon } from "@/styles/images/discord.svg"; import { NetworkDiagnosticsButton } from "./network_diagnostics/network_diagnostics_button"; +const styles = stylex.create({ + container: (backgroundColor: string, color: string) => ({ + backgroundColor, + color, + borderRadius: "10px", + padding: "15px", + }), + iconContainer: { + display: "flex", + alignItems: "center", + margin: 0, + marginBottom: "10px", + }, + helpIcon: { + marginRight: 8, + }, + link: { + textDecoration: "underline", + }, +}); + export const SupportBox = () => { const { showError, showSuccess } = useToasts(); @@ -30,27 +51,14 @@ export const SupportBox = () => { }; return ( - -

- +
+

+ Need help?

The best way to get support is to first{" "} - + join the Slippi Discord , then read the information in the #support-portal channel before posting your issue in the appropriate @@ -86,13 +94,6 @@ export const SupportBox = () => {
- +

); }; - -const Outer = styled.div` - background-color: ${colors.purpleLight}; - color: ${colors.offWhite}; - border-radius: 10px; - padding: 15px; -`;