Skip to content

Commit

Permalink
Retract #3161 due to broken placement styles (#3188)
Browse files Browse the repository at this point in the history
  • Loading branch information
imnasnainaec authored Jun 28, 2024
1 parent 2e5d278 commit 3f8db49
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 32 deletions.
6 changes: 2 additions & 4 deletions src/components/AnnouncementBanner/AnnouncementBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { topBarHeight } from "components/LandingPage/TopBar";
import { useAppSelector } from "rootRedux/hooks";
import { type StoreState } from "rootRedux/types";
import { Path } from "types/path";
import theme from "types/theme";
import theme, { themeColors } from "types/theme";

export default function AnnouncementBanner(): ReactElement {
const [banner, setBanner] = useState<string>("");
Expand Down Expand Up @@ -47,9 +47,7 @@ export default function AnnouncementBanner(): ReactElement {
}

return banner ? (
<Toolbar
sx={{ ...margins, backgroundColor: (t) => t.palette.warning.main }}
>
<Toolbar style={{ ...margins, backgroundColor: themeColors.warning }}>
<IconButton onClick={closeBanner} size="large">
<Cancel />
</IconButton>
Expand Down
6 changes: 4 additions & 2 deletions src/components/Buttons/LoadingButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Button, CircularProgress } from "@mui/material";
import { type ButtonProps } from "@mui/material/Button";
import { type ReactElement, type ReactNode } from "react";

import { themeColors } from "types/theme";

interface LoadingProps {
buttonProps?: ButtonProps & { "data-testid"?: string };
children?: ReactNode;
Expand All @@ -23,8 +25,8 @@ export default function LoadingButton(props: LoadingProps): ReactElement {
{props.loading && (
<CircularProgress
size={24}
sx={{
color: (t) => t.palette.success.main,
style={{
color: themeColors.success,
position: "absolute",
top: "50%",
left: "50%",
Expand Down
10 changes: 6 additions & 4 deletions src/components/Buttons/LoadingDoneButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { ButtonProps } from "@mui/material/Button";
import { ReactElement, ReactNode } from "react";
import { useTranslation } from "react-i18next";

import { themeColors } from "types/theme";

interface LoadingDoneProps {
buttonProps?: ButtonProps;
children?: ReactNode;
Expand All @@ -27,8 +29,8 @@ export default function LoadingDoneButton(
variant="contained"
{...props.buttonProps}
disabled={props.disabled || props.loading}
sx={{
backgroundColor: props.done ? (t) => t.palette.success.main : undefined,
style={{
backgroundColor: props.done ? themeColors.success : undefined,
color: props.done ? "white" : undefined,
...props.buttonProps?.style,
}}
Expand All @@ -44,8 +46,8 @@ export default function LoadingDoneButton(
{props.loading && !props.done && (
<CircularProgress
size={24}
sx={{
color: (t) => t.palette.success.main,
style={{
color: themeColors.success,
position: "absolute",
top: "50%",
left: "50%",
Expand Down
18 changes: 10 additions & 8 deletions src/components/ProjectExport/DownloadButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import { ExportStatus } from "components/ProjectExport/Redux/ExportProjectReduxTypes";
import { useAppDispatch, useAppSelector } from "rootRedux/hooks";
import { type StoreState } from "rootRedux/types";
import { themeColors } from "types/theme";
import { getDateTimeString } from "utilities/utilities";

function makeExportName(projectName: string): string {
Expand Down Expand Up @@ -111,6 +112,14 @@ export default function DownloadButton(
}
}

function iconColor(): `#${string}` {
return exportState.status === ExportStatus.Failure
? themeColors.error
: props.colorSecondary
? themeColors.secondary
: themeColors.primary;
}

function iconFunction(): () => void {
switch (exportState.status) {
case ExportStatus.Failure:
Expand All @@ -127,14 +136,7 @@ export default function DownloadButton(
<IconButton
tabIndex={-1}
onClick={iconFunction()}
sx={{
color:
exportState.status === ExportStatus.Failure
? (t) => t.palette.error.main
: props.colorSecondary
? (t) => t.palette.secondary.main
: (t) => t.palette.primary.main,
}}
style={{ color: iconColor() }}
size="large"
>
{icon()}
Expand Down
3 changes: 2 additions & 1 deletion src/components/ProjectSettings/ProjectArchive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useTranslation } from "react-i18next";

import { archiveProject, restoreProject } from "backend";
import { ButtonConfirmation } from "components/Dialogs";
import { themeColors } from "types/theme";

interface ProjectArchiveProps extends ButtonProps {
archive?: boolean;
Expand Down Expand Up @@ -39,7 +40,7 @@ export default function ProjectArchive(
color={props.warn ? "secondary" : "primary"}
onClick={() => setOpen(true)}
id={`proj-${props.projectId}-${props.archive ? "archive" : "restore"}`}
sx={props.warn ? { color: (t) => t.palette.error.main } : {}}
style={props.warn ? { color: themeColors.error } : {}}
>
{t(props.archive ? "buttons.archive" : "buttons.restore")}
</Button>
Expand Down
6 changes: 2 additions & 4 deletions src/components/Statistics/ProgressBar/LinearProgressBar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import Box from "@mui/material/Box";
import LinearProgress from "@mui/material/LinearProgress";
import Typography from "@mui/material/Typography";
import { ReactElement } from "react";
import { Box, LinearProgress, Typography } from "@mui/material";
import { type ReactElement } from "react";
import { useTranslation } from "react-i18next";

interface ProgressBarProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { type SxProps, type Theme, Typography } from "@mui/material";
import { Typography } from "@mui/material";
import { type ReactElement } from "react";
import { useTranslation } from "react-i18next";

import { CharacterStatus } from "goals/CharacterInventory/CharacterInventoryTypes";
import { themeColors } from "types/theme";

interface CharacterStatusTextProps {
status: CharacterStatus;
Expand All @@ -19,21 +20,21 @@ export default function CharacterStatusText(
variant="body2"
color="textSecondary"
component="p"
sx={CharacterStatusSx(props.status)}
style={CharacterStatusStyle(props.status)}
display={props.inline ? "inline" : "initial"}
>
{t(`buttons.${props.status}`)}
</Typography>
);
}

function CharacterStatusSx(status: CharacterStatus): SxProps<Theme> {
function CharacterStatusStyle(status: CharacterStatus): { color: string } {
switch (status) {
case CharacterStatus.Accepted:
return { color: (t) => t.palette.success.main };
return { color: themeColors.success };
case CharacterStatus.Rejected:
return { color: (t) => t.palette.error.main };
return { color: themeColors.error };
case CharacterStatus.Undecided:
return { color: (t) => t.palette.primary.main };
return { color: themeColors.primary };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
} from "goals/ReviewEntries/ReviewEntriesTable/Cells/EditCell/utilities";
import { useAppDispatch, useAppSelector } from "rootRedux/hooks";
import { type StoreState, type StoreStateDispatch } from "rootRedux/types";
import { themeColors } from "types/theme";
import {
type FileWithSpeakerId,
newPronunciation,
Expand Down Expand Up @@ -350,13 +351,13 @@ export default function EditDialog(props: EditDialogProps): ReactElement {
</Grid>
<Grid item>
<IconButton id={EditDialogId.ButtonSave} onClick={saveAndClose}>
<Check sx={{ color: (t) => t.palette.success.main }} />
<Check style={{ color: themeColors.success }} />
</IconButton>
<IconButton
id={EditDialogId.ButtonCancel}
onClick={conditionalCancel}
>
<Close sx={{ color: (t) => t.palette.error.main }} />
<Close style={{ color: themeColors.error }} />
</IconButton>
</Grid>
</Grid>
Expand Down Expand Up @@ -473,7 +474,7 @@ export default function EditDialog(props: EditDialogProps): ReactElement {
<CardContent>
<IconButton onClick={toggleFlag}>
{newWord.flag.active ? (
<FlagFilled sx={{ color: (t) => t.palette.error.main }} />
<FlagFilled sx={{ color: themeColors.error }} />
) : (
<FlagOutlined />
)}
Expand Down

0 comments on commit 3f8db49

Please sign in to comment.