-
Notifications
You must be signed in to change notification settings - Fork 914
fix(site): standardize headers for Admin Settings page #16911
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
Changes from 12 commits
de69ee3
a1da1c1
e5d581b
9b4928b
a35a9ae
9872c5d
1fe0022
7d0903a
a512bf5
734f59d
49b9dfe
840d6df
f169c4e
2325982
99c2dbc
50eddd0
2b77784
e2523cb
7f53666
daf6da9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,54 @@ | ||
import { useTheme } from "@emotion/react"; | ||
import { Button } from "components/Button/Button"; | ||
import { Stack } from "components/Stack/Stack"; | ||
import { SquareArrowOutUpRightIcon } from "lucide-react"; | ||
import type { FC, ReactNode } from "react"; | ||
import { twMerge } from "tailwind-merge"; | ||
|
||
interface HeaderProps { | ||
type HeaderHierarchy = "primary" | "secondary"; | ||
type HeaderLevel = `h${1 | 2 | 3 | 4 | 5 | 6}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Made it like this so that we can add additional variants over time There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For creating variants, I would recommend you to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I've used CVA before – I actually used it in the take-home that got me into Coder. I thought it was a bit too much overhead here, but if we're switching to CVA as a go-to, I can swap that in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because of shadcn, our base components are using CVA so I think it would be nice to use it but it is up to you. |
||
|
||
type HeaderProps = Readonly<{ | ||
title: ReactNode; | ||
description?: ReactNode; | ||
secondary?: boolean; | ||
titleVisualHierarchy?: HeaderHierarchy; | ||
titleHeaderLevel?: HeaderLevel; | ||
docsHref?: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know it is how we did before but since we are touching this, could we also improve the abstraction? I see something like: <SettingsHeader actions={[<SeeDocsButton />]}>
<SettingsHeaderTitle>Mytitle</SettingsHeaderTitle>
<SettingsHeaderSubtitle>Some text hear</SettingsHeaderSubtitle>
</SettingsHeader> |
||
tooltip?: ReactNode; | ||
} | ||
}>; | ||
|
||
export const SettingsHeader: FC<HeaderProps> = ({ | ||
title, | ||
description, | ||
docsHref, | ||
secondary, | ||
tooltip, | ||
titleHeaderLevel = "h1", | ||
titleVisualHierarchy = "primary", | ||
}) => { | ||
const theme = useTheme(); | ||
|
||
const HeaderTitle = titleHeaderLevel; | ||
return ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of doing this, we have access to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if that makes sense here. The current setup is a more restricted form of polymorphism |
||
<Stack alignItems="baseline" direction="row" justifyContent="space-between"> | ||
<div css={{ maxWidth: 420, marginBottom: 24 }}> | ||
<Stack direction="row" spacing={1} alignItems="center"> | ||
<h1 | ||
css={[ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a big accessibility/HTML validity issue. We were using this component multiple times on the same page, but only one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is why I decoupled the |
||
{ | ||
fontSize: 32, | ||
fontWeight: 700, | ||
display: "flex", | ||
alignItems: "baseline", | ||
lineHeight: "initial", | ||
margin: 0, | ||
marginBottom: 4, | ||
gap: 8, | ||
}, | ||
secondary && { | ||
fontSize: 24, | ||
fontWeight: 500, | ||
}, | ||
]} | ||
<hgroup className="flex flex-row justify-between align-baseline"> | ||
{/* | ||
* The text-sm class only adjusts the size of the description, but | ||
* we need to apply it here so that it combines with the max-w-prose | ||
* class and makes sure we have a predictable max width for the | ||
* entire section of text. | ||
*/} | ||
<div className="text-sm max-w-prose pb-6"> | ||
<div className="flex flex-row gap-2 align-middle"> | ||
<HeaderTitle | ||
className={twMerge( | ||
"m-0 pb-1 text-3xl font-bold flex items-center gap-2 leading-tight", | ||
titleVisualHierarchy === "secondary" && "text-2xl font-medium", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The different leading values for the header and description are intentional – leading needs to go down the larger your text is |
||
)} | ||
> | ||
{title} | ||
</h1> | ||
</HeaderTitle> | ||
{tooltip} | ||
</Stack> | ||
</div> | ||
|
||
{description && ( | ||
<span | ||
css={{ | ||
fontSize: 14, | ||
color: theme.palette.text.secondary, | ||
lineHeight: "160%", | ||
}} | ||
> | ||
<p className="m-0 text-sm text-content-secondary leading-relaxed"> | ||
{description} | ||
</span> | ||
</p> | ||
)} | ||
</div> | ||
|
||
|
@@ -66,9 +57,10 @@ export const SettingsHeader: FC<HeaderProps> = ({ | |
<a href={docsHref} target="_blank" rel="noreferrer"> | ||
<SquareArrowOutUpRightIcon /> | ||
Read the docs | ||
<span className="sr-only"> (link opens in new tab)</span> | ||
</a> | ||
</Button> | ||
)} | ||
</Stack> | ||
</hgroup> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,7 @@ export const NotificationsPage: FC = () => { | |
title={ | ||
<> | ||
Notifications | ||
<span css={{ position: "relative", top: "-6px" }}> | ||
<span css={{ position: "relative", top: "2px" }}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needed to adjust this slightly to account for the updated text leading There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it something we could use CSS variables and calc to make the top value more reliable and easier to understand? By understand I mean, why is it 2px? If not, a comment would be nice. |
||
<FeatureStageBadge | ||
contentType={"beta"} | ||
size="lg" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
import { useProxy } from "contexts/ProxyContext"; | ||
import type { FC } from "react"; | ||
import { Section } from "../Section"; | ||
import { WorkspaceProxyView } from "./WorkspaceProxyView"; | ||
|
||
export const WorkspaceProxyPage: FC = () => { | ||
const description = | ||
"Workspace proxies improve terminal and web app connections to workspaces."; | ||
|
||
const { | ||
proxyLatencies, | ||
proxies, | ||
|
@@ -17,29 +13,14 @@ export const WorkspaceProxyPage: FC = () => { | |
} = useProxy(); | ||
|
||
return ( | ||
<Section | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was deleted because the header is now located in the view, which I think is how it should've always been |
||
title="Workspace Proxies" | ||
css={(theme) => ({ | ||
"& code": { | ||
background: theme.palette.divider, | ||
fontSize: 12, | ||
padding: "2px 4px", | ||
color: theme.palette.text.primary, | ||
borderRadius: 2, | ||
}, | ||
Comment on lines
-23
to
-29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code seemed to be part of a previous version of the component. None of the styling ever applied to anything |
||
})} | ||
description={description} | ||
layout="fluid" | ||
> | ||
<WorkspaceProxyView | ||
proxyLatencies={proxyLatencies} | ||
proxies={proxies} | ||
isLoading={proxiesLoading} | ||
hasLoaded={proxiesFetched} | ||
getWorkspaceProxiesError={proxiesError} | ||
preferredProxy={proxy.proxy} | ||
/> | ||
</Section> | ||
<WorkspaceProxyView | ||
proxyLatencies={proxyLatencies} | ||
proxies={proxies} | ||
isLoading={proxiesLoading} | ||
hasLoaded={proxiesFetched} | ||
getWorkspaceProxiesError={proxiesError} | ||
preferredProxy={proxy.proxy} | ||
/> | ||
); | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a storybook for it covering the new variants?