Skip to content

chore: use emotion for styling (pt. 9) #10474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Nov 2, 2023
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
emotion: CreateWorkspacePageView
  • Loading branch information
aslilac committed Nov 1, 2023
commit 3212c58354d4fe67736d0fb2c134fa75339b6467
49 changes: 24 additions & 25 deletions site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { css } from "@emotion/css";
import { useTheme, type Interpolation, type Theme } from "@emotion/react";
import TextField from "@mui/material/TextField";
import * as TypesGen from "api/typesGenerated";
import type * as TypesGen from "api/typesGenerated";
import { UserAutocomplete } from "components/UserAutocomplete/UserAutocomplete";
import { FormikContextType, useFormik } from "formik";
import { FC, useEffect, useState } from "react";
import { type FC, useEffect, useState } from "react";
import {
getFormHelpers,
nameValidator,
Expand All @@ -17,7 +19,6 @@ import {
FormFooter,
HorizontalForm,
} from "components/Form/Form";
import { makeStyles } from "@mui/styles";
import {
getInitialRichParameterValues,
useValidationSchemaForRichParameters,
Expand All @@ -31,7 +32,7 @@ import { ErrorAlert } from "components/Alert/ErrorAlert";
import { Stack } from "components/Stack/Stack";
import { type ExternalAuthPollingState } from "./CreateWorkspacePage";
import { useSearchParams } from "react-router-dom";
import { CreateWSPermissions } from "./permissions";
import type { CreateWSPermissions } from "./permissions";

export interface CreateWorkspacePageViewProps {
error: unknown;
Expand Down Expand Up @@ -69,7 +70,7 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
onSubmit,
onCancel,
}) => {
const styles = useStyles();
const theme = useTheme();
const [owner, setOwner] = useState(defaultOwner);
const { verifyExternalAuth, externalAuthErrors } =
useExternalAuthVerification(externalAuth);
Expand Down Expand Up @@ -123,14 +124,14 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
<FormFields>
<SelectedTemplate template={template} />
{versionId && versionId !== template.active_version_id && (
<Stack spacing={1} className={styles.hasDescription}>
<Stack spacing={1} css={styles.hasDescription}>
<TextField
disabled
fullWidth
value={versionId}
label="Version ID"
/>
<span className={styles.description}>
<span css={styles.description}>
This parameter has been preset, and cannot be modified.
</span>
</Stack>
Expand Down Expand Up @@ -210,7 +211,16 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
/>
<ImmutableTemplateParametersSection
templateParameters={parameters}
classes={{ root: styles.warningSection }}
classes={{
root: css`
border: 1px solid ${theme.palette.warning.light};
border-radius: 8px;
background-color: ${theme.palette.background.paper};
padding: ${theme.spacing(10)};
margin-left: ${theme.spacing(-10)};
margin-right: ${theme.spacing(-10)};
`,
}}
getInputProps={(parameter, index) => {
return {
...getFieldHelpers(
Expand Down Expand Up @@ -279,23 +289,12 @@ const useExternalAuthVerification = (
};
};

const useStyles = makeStyles((theme) => ({
hasDescription: {
const styles = {
hasDescription: (theme) => ({
paddingBottom: theme.spacing(2),
},
description: {
}),
description: (theme) => ({
fontSize: 13,
color: theme.palette.text.secondary,
},
warningText: {
color: theme.palette.warning.light,
},
warningSection: {
border: `1px solid ${theme.palette.warning.light}`,
borderRadius: 8,
backgroundColor: theme.palette.background.paper,
padding: theme.spacing(10),
marginLeft: theme.spacing(-10),
marginRight: theme.spacing(-10),
},
}));
}),
} satisfies Record<string, Interpolation<Theme>>;