From 00cdf7fc7b76f35628383d3329e00e0b87501531 Mon Sep 17 00:00:00 2001 From: Jake Howell Date: Mon, 15 Dec 2025 08:19:25 +0000 Subject: [PATCH 1/2] feat: first implementation of templates `css` removal --- .../TemplateExampleCard.tsx | 102 ++---- .../TemplateFileTree.stories.tsx | 10 +- .../templates/TemplateFiles/TemplateFiles.tsx | 77 ++-- .../CreateTemplateGalleryPageView.tsx | 75 +--- .../StarterTemplates.tsx | 66 +--- .../CreateTemplatePage/CreateTemplateForm.tsx | 20 +- .../StarterTemplatePageView.tsx | 24 +- .../TemplateDocsPage/TemplateDocsPage.tsx | 25 +- .../TemplateEmbedPage/TemplateEmbedPage.tsx | 35 +- .../TemplateInsightsPage/IntervalMenu.tsx | 4 +- .../TemplateInsightsPage.tsx | 219 +++-------- .../TemplateInsightsPage/WeekPicker.tsx | 4 +- .../TemplateVersionsPage/VersionsTable.tsx | 2 +- .../TemplateSettingsForm.tsx | 2 +- .../TemplateSchedulePage/ScheduleDialog.tsx | 71 ++-- .../TemplateSettingsLayout.tsx | 4 +- .../TemplateVariablesPageView.tsx | 2 +- .../ProvisionerTagsPopover.tsx | 18 +- .../TemplateVersionEditor.tsx | 339 +++++------------- .../pages/TemplatesPage/EmptyTemplates.tsx | 2 +- .../pages/TemplatesPage/TemplatesPageView.tsx | 75 ++-- 21 files changed, 297 insertions(+), 879 deletions(-) diff --git a/site/src/modules/templates/TemplateExampleCard/TemplateExampleCard.tsx b/site/src/modules/templates/TemplateExampleCard/TemplateExampleCard.tsx index 6ecdc11ed84d9..39b17aa803e2a 100644 --- a/site/src/modules/templates/TemplateExampleCard/TemplateExampleCard.tsx +++ b/site/src/modules/templates/TemplateExampleCard/TemplateExampleCard.tsx @@ -1,4 +1,3 @@ -import type { Interpolation, Theme } from "@emotion/react"; import Link from "@mui/material/Link"; import type { TemplateExample } from "api/typesGenerated"; import { Button } from "components/Button/Button"; @@ -6,6 +5,7 @@ import { ExternalImage } from "components/ExternalImage/ExternalImage"; import { Pill } from "components/Pill/Pill"; import type { FC, HTMLAttributes } from "react"; import { Link as RouterLink } from "react-router"; +import { cn } from "utils/cn"; type TemplateExampleCardProps = HTMLAttributes & { example: TemplateExample; @@ -18,19 +18,24 @@ export const TemplateExampleCard: FC = ({ ...divProps }) => { return ( -
-
-
+
+
+
-
+
{example.tags.map((tag) => ( - + {tag} @@ -39,22 +44,20 @@ export const TemplateExampleCard: FC = ({
-

- {example.name} -

- +

{example.name}

+ {example.description}{" "} Read more
-
+
diff --git a/site/src/pages/StarterTemplatePage/StarterTemplatePageView.tsx b/site/src/pages/StarterTemplatePage/StarterTemplatePageView.tsx index c4bb59f7717ab..2bdd049a4f05c 100644 --- a/site/src/pages/StarterTemplatePage/StarterTemplatePageView.tsx +++ b/site/src/pages/StarterTemplatePage/StarterTemplatePageView.tsx @@ -60,19 +60,7 @@ export const StarterTemplatePageView: FC = ({ } > -
+
@@ -88,17 +76,11 @@ export const StarterTemplatePageView: FC = ({ css={{ background: theme.palette.background.paper, border: `1px solid ${theme.palette.divider}`, - borderRadius: 8, }} + className="bg-content-primary border border-solid border-zinc-700 rounded-lg" id="readme" > -
+
{starterTemplate.markdown}
diff --git a/site/src/pages/TemplatePage/TemplateDocsPage/TemplateDocsPage.tsx b/site/src/pages/TemplatePage/TemplateDocsPage/TemplateDocsPage.tsx index c4961acf6c9a9..aacb431344aba 100644 --- a/site/src/pages/TemplatePage/TemplateDocsPage/TemplateDocsPage.tsx +++ b/site/src/pages/TemplatePage/TemplateDocsPage/TemplateDocsPage.tsx @@ -1,4 +1,3 @@ -import { useTheme } from "@emotion/react"; import { MemoizedMarkdown } from "components/Markdown/Markdown"; import frontMatter from "front-matter"; import { useTemplateLayoutContext } from "pages/TemplatePage/TemplateLayout"; @@ -7,7 +6,6 @@ import { pageTitle } from "utils/page"; export default function TemplateDocsPage() { const { template, activeVersion } = useTemplateLayoutContext(); - const theme = useTheme(); const readme = frontMatter(activeVersion.readme); @@ -16,30 +14,13 @@ export default function TemplateDocsPage() { {pageTitle(template.name, "Documentation")}
-
+
README.md
-
+
{readme.body}
diff --git a/site/src/pages/TemplatePage/TemplateEmbedPage/TemplateEmbedPage.tsx b/site/src/pages/TemplatePage/TemplateEmbedPage/TemplateEmbedPage.tsx index 8b50ef2447652..3ead3ccad91e7 100644 --- a/site/src/pages/TemplatePage/TemplateEmbedPage/TemplateEmbedPage.tsx +++ b/site/src/pages/TemplatePage/TemplateEmbedPage/TemplateEmbedPage.tsx @@ -15,6 +15,7 @@ import { CheckIcon, CopyIcon } from "lucide-react"; import { useTemplateLayoutContext } from "pages/TemplatePage/TemplateLayout"; import { type FC, useEffect, useId, useState } from "react"; import { useQuery } from "react-query"; +import { cn } from "utils/cn"; import { nameValidator } from "utils/formUtils"; import { pageTitle } from "utils/page"; import { getInitialRichParameterValues } from "utils/richParameters"; @@ -174,9 +175,7 @@ export const TemplateEmbedPageView: FC = ({
{templateParameters.length > 0 && ( -
+
{templateParameters.map((parameter) => { const parameterValue = buttonValues[`param.${parameter.name}`] ?? ""; @@ -201,34 +200,16 @@ export const TemplateEmbedPageView: FC = ({
({ + className={cn( // 80px for padding, 36px is for the status bar. We want to use `vh` // so that it will be relative to the screen and not the parent layout. - height: "calc(100vh - (80px + 36px))", - top: 40, - position: "sticky", - display: "flex", - padding: 64, - flex: 1, - alignItems: "center", - justifyContent: "center", - borderRadius: 8, - backgroundColor: theme.palette.background.paper, - border: `1px solid ${theme.palette.divider}`, - })} + "h-[calc(100vh_-(80px+36px))]", + "sticky top-10 flex p-16 flex-1 items-center justify-center rounded-lg", + "bg-surface-primary border border-solid border-zinc-700", + )} > Open in Coder button -
+
-
+
{publishedVersion && (
= ({ )} -
- - Files - +
+ Files -
+
= ({ /> -
-
+
+
{activePath ? ( isEditorValueBinary ? (
-
+
-

+

The file is not displayed in the text editor because it is either binary or uses an unsupported text encoding.

@@ -527,40 +441,28 @@ export const TemplateVersionEditor: FC = ({ )}
-
+
{selectedTab === "logs" && ( -
+
{templateVersion.job.error ? (
= ({ tags={templateVersion.job.tags} variant={AlertVariant.Inline} /> - + ) )} {gotBuildLogs && ( @@ -639,7 +538,9 @@ export const TemplateVersionEditor: FC = ({ )} {selectedTab === "resources" && ( -
+
{resources && ( = ({
+
+ { }); }; -const styles = { - tab: (theme) => ({ - "&:not(:disabled)": { - cursor: "pointer", - }, - padding: 12, - fontSize: 10, - textTransform: "uppercase", - letterSpacing: "0.5px", - fontWeight: 500, - background: "transparent", - fontFamily: "inherit", - border: 0, - color: theme.palette.text.secondary, - transition: "150ms ease all", - display: "flex", - gap: 8, - alignItems: "center", - justifyContent: "center", - position: "relative", - - "& svg": { - maxWidth: 12, - maxHeight: 12, - }, - - "&.active": { - color: theme.palette.text.primary, - "&:after": { - content: '""', - display: "block", - width: "100%", - height: 1, - backgroundColor: theme.palette.primary.main, - bottom: -1, - position: "absolute", - }, - }, - - "&:not(:disabled):hover": { - color: theme.palette.text.primary, - }, - - "&:disabled": { - color: theme.palette.text.disabled, - }, - }), - - tabBar: (theme) => ({ - padding: "8px 16px", - position: "sticky", - top: 0, - background: theme.palette.background.default, - borderBottom: `1px solid ${theme.palette.divider}`, - color: theme.palette.text.primary, - textTransform: "uppercase", - fontSize: 12, - - "&.top": { - borderTop: `1px solid ${theme.palette.divider}`, - }, - }), - - tabContent: { - height: 280, - overflowY: "auto", - }, - - logs: { - display: "flex", - height: "100%", - flexDirection: "column", - }, - - buildLogs: { - borderRadius: 0, - border: 0, - +const classNames = { + tab: cn( + "p-3 text-xs uppercase spacing-[0.5px]", + "text-regular bg-transparent font-[inherit] border-0", + "text-content-secondary transition-all duration-150", + "flex gap-2 items-center justify-center relative", + "[&:not(:disabled)]:cursor-pointer", + "[&_svg]:max-w-3 [&_svg]:max-h-3", + "[&.active]:text-content-primary [&.active]:after:content-[''] [&.active]:after:block", + "[&.active]:after:bg-surface-primary [&.active]:after:bottom-[-1px] [&.active]:after:absolute", + "[&.active]:after:w-full [&.active]:after:h-1", + "[&:not(:disabled):hover]:text-content-primary", + "[&:disabled]:text-content-disabled", + ), + tabBar: cn( + "py-2 px-4 sticky top-0 bg-content-primary", + "border-0 border-b border-solid border-border", + "text-content-primary text-xs uppercase", + "[&.top]:border-0 [&.top]:border-t [&.top]:border-solid [&.top]:border-border", + ), + tabContent: "h-70 overflow-y-auto", + logs: "flex flex-col h-full", + buildLogs: cn( + "border-0 rounded-[0px]", // Hack to update logs header and lines - "& .logs-header": { - border: 0, - padding: "8px 16px", - fontFamily: MONOSPACE_FONT_FAMILY, - - "&:first-of-type": { - paddingTop: 16, - }, - - "&:last-child": { - paddingBottom: 16, - }, - }, - - "& .logs-line": { - paddingLeft: 16, - }, - - "& .logs-container": { - border: "0 !important", - }, - }, - - resources: { + "[&_.logs-header]:border-0 [&_.logs-header]:py-2", + "[&_.logs-header]:px-4 [&_.logs-header]:font-mono", + // Hack to update logs header and lines + "[&_.logs-header]:first-of-type:pt-4 [&_.logs-header]:last-child:pb-4", + "[&_.logs-line]:pl-4 [&_.logs-container]:!border-0", + ), + resources: cn( // Hack to access customize resource-card from here - "& .resource-card": { - borderLeft: 0, - borderRight: 0, - - "&:first-of-type": { - borderTop: 0, - }, - - "&:last-child": { - borderBottom: 0, - }, - }, - }, -} satisfies Record>; + "[&_.resource-card]:border-l-0 [&_.resource-card]:border-r-0", + "[&_.resource-card]:first-of-type:border-t-0", + "[&_.resource-card]:last-child:border-b-0", + ), +}; diff --git a/site/src/pages/TemplatesPage/EmptyTemplates.tsx b/site/src/pages/TemplatesPage/EmptyTemplates.tsx index 72a47c3417d5e..8ba04d0f0505d 100644 --- a/site/src/pages/TemplatesPage/EmptyTemplates.tsx +++ b/site/src/pages/TemplatesPage/EmptyTemplates.tsx @@ -78,7 +78,7 @@ export const EmptyTemplates: FC = ({ ))}
-