diff --git a/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx b/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx index ed9562351167d..ed0921d70bb78 100644 --- a/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx +++ b/site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx @@ -14,6 +14,7 @@ import { AlertBanner } from "components/AlertBanner/AlertBanner" import { makeStyles } from "@material-ui/core/styles" import { FullPageHorizontalForm } from "components/FullPageForm/FullPageHorizontalForm" import { FullScreenLoader } from "components/Loader/FullScreenLoader" +import { SelectedTemplate } from "./SelectedTemplate" export enum CreateWorkspaceErrors { GET_TEMPLATES_ERROR = "getTemplatesError", @@ -171,28 +172,7 @@ export const CreateWorkspacePageView: FC< className={styles.formSectionFields} > {props.selectedTemplate && ( - -
- -
- - - {props.selectedTemplate.display_name.length > 0 - ? props.selectedTemplate.display_name - : props.selectedTemplate.name} - - {props.selectedTemplate.description && ( - - {props.selectedTemplate.description} - - )} - -
+ )} ({ formSectionFields: { width: "100%", }, - - template: { - padding: theme.spacing(2.5, 3), - borderRadius: theme.shape.borderRadius, - backgroundColor: theme.palette.background.paper, - border: `1px solid ${theme.palette.divider}`, - }, - - templateName: { - fontSize: 16, - }, - - templateDescription: { - fontSize: 14, - color: theme.palette.text.secondary, - }, - - templateIcon: { - width: theme.spacing(5), - lineHeight: 1, - - "& img": { - width: "100%", - }, - }, })) const useFormFooterStyles = makeStyles((theme) => ({ diff --git a/site/src/pages/CreateWorkspacePage/SelectedTemplate.stories.tsx b/site/src/pages/CreateWorkspacePage/SelectedTemplate.stories.tsx new file mode 100644 index 0000000000000..c2f72af1f5a10 --- /dev/null +++ b/site/src/pages/CreateWorkspacePage/SelectedTemplate.stories.tsx @@ -0,0 +1,25 @@ +import { ComponentMeta, Story } from "@storybook/react" +import { MockTemplate } from "../../testHelpers/entities" +import { SelectedTemplate, SelectedTemplateProps } from "./SelectedTemplate" + +export default { + title: "components/SelectedTemplate", + component: SelectedTemplate, +} as ComponentMeta + +const Template: Story = (args) => ( + +) + +export const WithIcon = Template.bind({}) +WithIcon.args = { + template: MockTemplate, +} + +export const WithoutIcon = Template.bind({}) +WithoutIcon.args = { + template: { + ...MockTemplate, + icon: "", + }, +} diff --git a/site/src/pages/CreateWorkspacePage/SelectedTemplate.tsx b/site/src/pages/CreateWorkspacePage/SelectedTemplate.tsx new file mode 100644 index 0000000000000..0dcb577cd77c4 --- /dev/null +++ b/site/src/pages/CreateWorkspacePage/SelectedTemplate.tsx @@ -0,0 +1,70 @@ +import Avatar from "@material-ui/core/Avatar" +import { makeStyles } from "@material-ui/core/styles" +import { Template } from "api/typesGenerated" +import { Stack } from "components/Stack/Stack" +import React, { FC } from "react" +import { firstLetter } from "util/firstLetter" + +export interface SelectedTemplateProps { + template: Template +} + +export const SelectedTemplate: FC = ({ template }) => { + const styles = useStyles() + + return ( + +
+ {template.icon === "" ? ( + {firstLetter(template.name)} + ) : ( + + )} +
+ + + {template.display_name.length > 0 + ? template.display_name + : template.name} + + {template.description && ( + + {template.description} + + )} + +
+ ) +} + +const useStyles = makeStyles((theme) => ({ + template: { + padding: theme.spacing(2.5, 3), + borderRadius: theme.shape.borderRadius, + backgroundColor: theme.palette.background.paper, + border: `1px solid ${theme.palette.divider}`, + }, + + templateName: { + fontSize: 16, + }, + + templateDescription: { + fontSize: 14, + color: theme.palette.text.secondary, + }, + + templateIcon: { + width: theme.spacing(4), + lineHeight: 1, + + "& img": { + width: "100%", + }, + }, +}))