Skip to content

Commit

Permalink
fix hydration bug
Browse files Browse the repository at this point in the history
  • Loading branch information
baktun14 committed Nov 6, 2023
1 parent 45b31d2 commit 0bdd336
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
7 changes: 2 additions & 5 deletions deploy-web/src/components/sdl/AdvancedConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Control } from "react-hook-form";
import { Box, Button, Collapse, Paper, Typography, useTheme } from "@mui/material";
import { RentGpusFormValues, Service } from "@src/types";
import { ExpandMore } from "../shared/ExpandMore";
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
import { EnvFormModal } from "./EnvFormModal";
import { CommandFormModal } from "./CommandFormModal";
import { ExposeFormModal } from "./ExposeFormModal";
Expand Down Expand Up @@ -56,7 +55,7 @@ export const AdvancedConfig: React.FunctionComponent<Props> = ({ control, curren
display: "flex",
alignItems: "center",
justifyContent: "space-between",
padding: ".5rem 1rem",
padding: "1rem",
borderBottom: expanded ? `1px solid ${theme.palette.mode === "dark" ? theme.palette.grey[800] : theme.palette.grey[200]}` : "none",
textTransform: "none"
}}
Expand All @@ -67,9 +66,7 @@ export const AdvancedConfig: React.FunctionComponent<Props> = ({ control, curren
<Typography variant="body2">Advanced Configuration</Typography>
</Box>

<ExpandMore expand={expanded} aria-expanded={expanded} aria-label="show more" sx={{ marginLeft: ".5rem" }}>
<ExpandMoreIcon />
</ExpandMore>
<ExpandMore expand={expanded} aria-expanded={expanded} aria-label="show more" sx={{ marginLeft: ".5rem" }} />
</Button>
<Collapse in={expanded}>
<Box sx={{ padding: "1rem" }}>
Expand Down
2 changes: 1 addition & 1 deletion deploy-web/src/components/sdl/GpuFormControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const GpuFormControl: React.FunctionComponent<Props> = ({ providerAttribu
{providerAttributesSchema ? (
<FormSelect
control={control}
label="GPU models"
label="GPU models (any if empty)"
optionName="hardware-gpu-model"
name={`services.${serviceIndex}.profile.gpuModels`}
providerAttributesSchema={providerAttributesSchema}
Expand Down
6 changes: 3 additions & 3 deletions deploy-web/src/components/sdl/SimpleServiceFormControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { makeStyles } from "tss-react/mui";
import { Dispatch, SetStateAction, useState } from "react";
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
import DeleteIcon from "@mui/icons-material/Delete";
import { ExpandMore } from "../shared/ExpandMore";
import { ExpandMoreButton } from "../shared/ExpandMore";
import { SdlBuilderFormValues, Service } from "@src/types";
import { CommandFormModal } from "./CommandFormModal";
import { EnvFormModal } from "./EnvFormModal";
Expand Down Expand Up @@ -218,9 +218,9 @@ export const SimpleServiceFormControl: React.FunctionComponent<Props> = ({
</IconButton>
)}

<ExpandMore expand={expanded} onClick={onExpandClick} aria-expanded={expanded} aria-label="show more" sx={{ marginLeft: ".5rem" }}>
<ExpandMoreButton expand={expanded} onClick={onExpandClick} aria-expanded={expanded} aria-label="show more" sx={{ marginLeft: ".5rem" }}>
<ExpandMoreIcon />
</ExpandMore>
</ExpandMoreButton>
</Box>
</Box>

Expand Down
24 changes: 22 additions & 2 deletions deploy-web/src/components/shared/ExpandMore.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
import { IconButton, IconButtonProps, styled } from "@mui/material";
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";

interface ExpandMoreProps extends IconButtonProps {
interface ExpandMoreButtonProps extends IconButtonProps {
expand: boolean;
}

export const ExpandMoreButton = styled((props: ExpandMoreButtonProps) => {
const { expand, children, ...other } = props;
return (
<IconButton {...other}>
<ExpandMoreIcon />
</IconButton>
);
})(({ theme, expand }) => ({
transform: !expand ? "rotate(0deg)" : "rotate(180deg)",
marginLeft: "auto",
transition: theme.transitions.create("transform", {
duration: theme.transitions.duration.shortest
})
}));

interface ExpandMoreProps {
expand: boolean;
}

export const ExpandMore = styled((props: ExpandMoreProps) => {
const { expand, ...other } = props;
return <IconButton {...other} />;
return <ExpandMoreIcon {...other} />;
})(({ theme, expand }) => ({
transform: !expand ? "rotate(0deg)" : "rotate(180deg)",
marginLeft: "auto",
Expand Down

0 comments on commit 0bdd336

Please sign in to comment.