diff --git a/site/src/components/TemplateExampleCard/TemplateExampleCard.tsx b/site/src/components/TemplateExampleCard/TemplateExampleCard.tsx index cc5199f4a72c6..e5151880eb753 100644 --- a/site/src/components/TemplateExampleCard/TemplateExampleCard.tsx +++ b/site/src/components/TemplateExampleCard/TemplateExampleCard.tsx @@ -1,86 +1,123 @@ -import { type Interpolation, type Theme } from "@emotion/react"; +import Button from "@mui/material/Button"; +import Link from "@mui/material/Link"; import type { TemplateExample } from "api/typesGenerated"; -import { type FC } from "react"; -import { Link } from "react-router-dom"; +import { Pill } from "components/Pill/Pill"; +import { HTMLProps } from "react"; +import { Link as RouterLink } from "react-router-dom"; -export interface TemplateExampleCardProps { +type TemplateExampleCardProps = { example: TemplateExample; - className?: string; -} + activeTag?: string; +} & HTMLProps; -export const TemplateExampleCard: FC = ({ - example, - className, -}) => { +export const TemplateExampleCard = (props: TemplateExampleCardProps) => { + const { example, activeTag, ...divProps } = props; return ( - ({ + width: "320px", + padding: 24, + borderRadius: 6, + border: `1px solid ${theme.palette.divider}`, + textAlign: "left", + textDecoration: "none", + color: "inherit", + display: "flex", + flexDirection: "column", + })} + {...divProps} > -
- -
-
- {example.name} - {example.description} -
- - ); -}; - -const styles = { - template: (theme) => ({ - border: `1px solid ${theme.palette.divider}`, - borderRadius: 8, - background: theme.palette.background.paper, - textDecoration: "none", - textAlign: "left", - color: "inherit", - display: "flex", - alignItems: "center", - height: "fit-content", - - "&:hover": { - backgroundColor: theme.palette.background.paperLight, - }, - }), +
+
+ +
- templateIcon: { - width: 96, - height: 96, - display: "flex", - alignItems: "center", - justifyContent: "center", - flexShrink: 0, +
+ {example.tags.map((tag) => { + const isActive = activeTag === tag; - "& img": { - height: 32, - }, - }, - - templateInfo: { - padding: "16px 16px 16px 0", - display: "flex", - flexDirection: "column", - overflow: "hidden", - }, + return ( + + ({ + borderColor: isActive + ? theme.palette.primary.main + : theme.palette.divider, + cursor: "pointer", + backgroundColor: isActive + ? theme.palette.primary.dark + : undefined, + "&: hover": { + borderColor: theme.palette.primary.main, + }, + })} + /> + + ); + })} +
+
- templateName: { - fontSize: 16, - textOverflow: "ellipsis", - width: "100%", - overflow: "hidden", - whiteSpace: "nowrap", - }, +
+

+ {example.name} +

+ ({ + fontSize: 13, + color: theme.palette.text.secondary, + lineHeight: "1.6", + display: "block", + })} + > + {example.description}{" "} + + Read more + + +
- templateDescription: (theme) => ({ - fontSize: 14, - color: theme.palette.text.secondary, - textOverflow: "ellipsis", - width: "100%", - overflow: "hidden", - whiteSpace: "nowrap", - }), -} satisfies Record>; +
+ +
+ + ); +}; diff --git a/site/src/pages/SetupPage/SetupPage.test.tsx b/site/src/pages/SetupPage/SetupPage.test.tsx index 7a6718cff740e..8609293220a99 100644 --- a/site/src/pages/SetupPage/SetupPage.test.tsx +++ b/site/src/pages/SetupPage/SetupPage.test.tsx @@ -87,8 +87,8 @@ describe("Setup Page", () => { element: , }, { - path: "/", - element:

Workspaces

, + path: "/templates", + element:

Templates

, }, ], { initialEntries: ["/setup"] }, @@ -96,6 +96,6 @@ describe("Setup Page", () => { ); await waitForLoaderToBeRemoved(); await fillForm(); - await waitFor(() => screen.findByText("Workspaces")); + await waitFor(() => screen.findByText("Templates")); }); }); diff --git a/site/src/pages/SetupPage/SetupPage.tsx b/site/src/pages/SetupPage/SetupPage.tsx index 7dae420224546..0da1e0ea549b5 100644 --- a/site/src/pages/SetupPage/SetupPage.tsx +++ b/site/src/pages/SetupPage/SetupPage.tsx @@ -35,7 +35,7 @@ export const SetupPage: FC = () => { onSubmit={async (firstUser) => { await createFirstUserMutation.mutateAsync(firstUser); await signIn(firstUser.email, firstUser.password); - navigate("/"); + navigate("/templates"); }} /> diff --git a/site/src/pages/StarterTemplatesPage/StarterTemplatesPageView.tsx b/site/src/pages/StarterTemplatesPage/StarterTemplatesPageView.tsx index 5aa8ef6f1d224..f1f160f813882 100644 --- a/site/src/pages/StarterTemplatesPage/StarterTemplatesPageView.tsx +++ b/site/src/pages/StarterTemplatesPage/StarterTemplatesPageView.tsx @@ -60,9 +60,11 @@ export const StarterTemplatesPageView: FC = ({ {Boolean(!starterTemplatesByTag) && } - + {starterTemplatesByTag && tags && ( - + Filter {tags.map((tag) => ( = ({ )} -
+
{visibleTemplates && visibleTemplates.map((example) => ( - + ({ + backgroundColor: theme.palette.background.paper, + })} + example={example} + key={example.id} + activeTag={activeTag} + /> ))}
@@ -91,11 +107,6 @@ export const StarterTemplatesPageView: FC = ({ }; const styles = { - filter: { - width: 208, - flexShrink: 0, - }, - filterCaption: (theme) => ({ textTransform: "uppercase", fontWeight: 600, @@ -119,12 +130,4 @@ const styles = { color: theme.palette.text.primary, fontWeight: 600, }), - - templates: { - flex: "1", - display: "grid", - gridTemplateColumns: "repeat(2, minmax(0, 1fr))", - gap: 16, - gridAutoRows: "min-content", - }, } satisfies Record>; diff --git a/site/src/pages/TemplatesPage/EmptyTemplates.tsx b/site/src/pages/TemplatesPage/EmptyTemplates.tsx index 4446ecef63b45..511d536fc17a9 100644 --- a/site/src/pages/TemplatesPage/EmptyTemplates.tsx +++ b/site/src/pages/TemplatesPage/EmptyTemplates.tsx @@ -44,12 +44,11 @@ export const EmptyTemplates: FC<{ if (canCreateTemplates) { return ( Templates are written in Terraform and describe the infrastructure - for workspaces (e.g., docker_container, aws_instance, - kubernetes_pod). Select a starter template below or + for workspaces. You can start using a starter template below or{" "}
{featuredExamples.map((example) => ( - + ))}
@@ -76,7 +71,7 @@ export const EmptyTemplates: FC<{ size="small" component={RouterLink} to="/starter-templates" - css={styles.viewAllButton} + css={{ borderRadius: 9999 }} > View all starter templates @@ -117,23 +112,10 @@ const styles = { }, }, - featuredExamples: { - maxWidth: 800, - display: "grid", - gridTemplateColumns: "repeat(2, minmax(0, 1fr))", - gap: 16, - gridAutoRows: "min-content", - }, - - template: (theme) => ({ - backgroundColor: theme.palette.background.paperLight, - - "&:hover": { - backgroundColor: theme.palette.divider, - }, + featuredExamples: (theme) => ({ + display: "flex", + flexWrap: "wrap", + justifyContent: "center", + gap: theme.spacing(2), }), - - viewAllButton: { - borderRadius: 9999, - }, } satisfies Record>; diff --git a/site/src/pages/WorkspacesPage/WorkspacesEmpty.tsx b/site/src/pages/WorkspacesPage/WorkspacesEmpty.tsx index 8b328ba6f53ee..a6b09376af0a1 100644 --- a/site/src/pages/WorkspacesPage/WorkspacesEmpty.tsx +++ b/site/src/pages/WorkspacesPage/WorkspacesEmpty.tsx @@ -122,7 +122,7 @@ export const WorkspacesEmpty = (props: {

- {t.display_name} + {t.display_name.length > 0 ? t.display_name : t.name}

({