Skip to content

chore(site): remove Typography component #10769

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 12 commits into from
Nov 20, 2023
3 changes: 3 additions & 0 deletions site/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ rules:
message:
"You should use the Popover component provided on
components/Popover/Popover"
- name: "@mui/material/Typography"
message:
"You should use the native HTML elements as span, p, h1, h2, h3..."
no-unused-vars: "off"
"object-curly-spacing": "off"
react-hooks/exhaustive-deps: warn
Expand Down
20 changes: 9 additions & 11 deletions site/src/components/Dashboard/Navbar/NavbarView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Button from "@mui/material/Button";
import MenuItem from "@mui/material/MenuItem";
import KeyboardArrowDownOutlined from "@mui/icons-material/KeyboardArrowDownOutlined";
import MenuIcon from "@mui/icons-material/Menu";
import Typography from "@mui/material/Typography";
import { css, type Interpolation, type Theme, useTheme } from "@emotion/react";
import { type FC, type ReactNode, useRef, useState } from "react";
import { NavLink, useLocation, useNavigate } from "react-router-dom";
Expand Down Expand Up @@ -360,31 +359,30 @@ const ProxyMenu: FC<{ proxyContextValue: ProxyContextValue }> = ({
lineHeight: "140%",
}}
>
<Typography
component="h4"
sx={{
<h4
css={{
fontSize: "inherit",
fontWeight: 600,
lineHeight: "inherit",
margin: 0,
marginBottom: 4,
}}
>
Select a region nearest to you
</Typography>
<Typography
component="p"
sx={{
</h4>
<p
css={(theme) => ({
fontSize: 13,
color: (theme) => theme.palette.text.secondary,
color: theme.palette.text.secondary,
lineHeight: "inherit",
marginTop: 0.5,
}}
})}
>
Workspace proxies improve terminal and web app connections to
workspaces. This does not apply to CLI connections. A region must be
manually selected, otherwise the default primary region will be
used.
</Typography>
</p>
</Box>
<Divider sx={{ borderColor: (theme) => theme.palette.divider }} />
{proxyContextValue.proxies
Expand Down
20 changes: 8 additions & 12 deletions site/src/components/EmptyState/EmptyState.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import type { FC, ReactNode } from "react";

export interface EmptyStateProps {
Expand Down Expand Up @@ -40,24 +39,21 @@ export const EmptyState: FC<React.PropsWithChildren<EmptyStateProps>> = (
}}
{...boxProps}
>
<Typography variant="h5" css={{ fontSize: 24 }}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect an <h5> to at least have a weight of 500

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I think this could be something we should set as a global style? Wondering if as part of the theme thing, we could include the TailwindCSS reset.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but my point was that here, you manually set it to 400. it should be a <p> or something instead, not a header.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh ok, but it is a title so I think makes sense to make it a heading element 🤔

{message}
</Typography>
<h5 css={{ fontSize: 24, fontWeight: 400, margin: 0 }}>{message}</h5>
{description && (
<Typography
variant="body2"
color="textSecondary"
css={{
marginTop: 12,
<p
css={(theme) => ({
marginTop: 16,
fontSize: 16,
lineHeight: "140%",
maxWidth: 480,
}}
color: theme.palette.text.secondary,
})}
>
{description}
</Typography>
</p>
)}
{cta && <div css={{ marginTop: 32 }}>{cta}</div>}
{cta && <div css={{ marginTop: 24 }}>{cta}</div>}
{image}
</Box>
);
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/GlobalSnackbar/EnterpriseSnackbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const EnterpriseSnackbar: FC<
action={
<div css={styles.actionWrapper}>
{action}
<IconButton onClick={onClose} css={{ padding: 0 }} size="large">
<IconButton onClick={onClose} css={{ padding: 0 }}>
<CloseIcon css={styles.closeIcon} aria-label="close" />
</IconButton>
</div>
Expand Down
19 changes: 5 additions & 14 deletions site/src/components/GlobalSnackbar/GlobalSnackbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { type FC, useState } from "react";
import { useCustomEvent } from "hooks/events";
import { EnterpriseSnackbar } from "./EnterpriseSnackbar";
import { ErrorIcon } from "../Icons/ErrorIcon";
import { Typography } from "../Typography/Typography";
import {
type AdditionalMessage,
isNotificationList,
Expand Down Expand Up @@ -52,9 +51,7 @@ export const GlobalSnackbar: FC = () => {
)}

<div css={styles.message}>
<Typography variant="body1" css={styles.messageTitle}>
{notification.msg}
</Typography>
<span css={styles.messageTitle}>{notification.msg}</span>

{notification.additionalMsgs &&
notification.additionalMsgs.map((msg, index) => (
Expand Down Expand Up @@ -92,18 +89,14 @@ const styles = {

function AdditionalMessageDisplay({ message }: { message: AdditionalMessage }) {
if (isNotificationText(message)) {
return (
<Typography gutterBottom variant="body2" css={styles.messageSubtitle}>
{message}
</Typography>
);
return <span css={styles.messageSubtitle}>{message}</span>;
}

if (isNotificationTextPrefixed(message)) {
return (
<Typography gutterBottom variant="body2" css={styles.messageSubtitle}>
<span css={styles.messageSubtitle}>
<strong>{message.prefix}:</strong> {message.text}
</Typography>
</span>
);
}

Expand All @@ -112,9 +105,7 @@ function AdditionalMessageDisplay({ message }: { message: AdditionalMessage }) {
<ul css={styles.list}>
{message.map((item, idx) => (
<li key={idx}>
<Typography variant="body2" css={styles.messageSubtitle}>
{item}
</Typography>
<span css={styles.messageSubtitle}>{item}</span>
</li>
))}
</ul>
Expand Down
25 changes: 9 additions & 16 deletions site/src/components/Paywall/Paywall.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import { type FC, type ReactNode } from "react";
import { type Interpolation, type Theme } from "@emotion/react";
import { EnterpriseBadge } from "components/Badges/Badges";
Expand All @@ -18,21 +17,11 @@ export const Paywall: FC<React.PropsWithChildren<PaywallProps>> = (props) => {
<Box css={styles.root}>
<div css={styles.header}>
<Stack direction="row" alignItems="center" justifyContent="center">
<Typography variant="h5" css={styles.title}>
{message}
</Typography>
<h5 css={styles.title}>{message}</h5>
<EnterpriseBadge />
</Stack>

{description && (
<Typography
variant="body2"
color="textSecondary"
css={styles.description}
>
{description}
</Typography>
)}
{description && <p css={styles.description}>{description}</p>}
</div>
{cta}
</Box>
Expand All @@ -58,13 +47,17 @@ const styles = {
title: {
fontWeight: 600,
fontFamily: "inherit",
fontSize: 24,
margin: 0,
},
description: {
marginTop: 8,
description: (theme) => ({
marginTop: 16,
fontFamily: "inherit",
maxWidth: 420,
lineHeight: "160%",
},
color: theme.palette.text.secondary,
fontSize: 14,
}),
enterpriseChip: (theme) => ({
background: theme.palette.success.dark,
color: theme.palette.success.contrastText,
Expand Down
22 changes: 11 additions & 11 deletions site/src/components/SettingsLayout/Section.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import Typography from "@mui/material/Typography";
import { type FC, type ReactNode, type PropsWithChildren } from "react";
import { SectionAction } from "./SectionAction";
import { type Interpolation, type Theme } from "@emotion/react";

type SectionLayout = "fixed" | "fluid";
Expand All @@ -17,9 +15,7 @@ export interface SectionProps {
children?: ReactNode;
}

type SectionFC = FC<PropsWithChildren<SectionProps>> & {
Action: typeof SectionAction;
};
type SectionFC = FC<PropsWithChildren<SectionProps>>;

export const Section: SectionFC = ({
id,
Expand All @@ -38,12 +34,19 @@ export const Section: SectionFC = ({
<div css={styles.header}>
<div>
{title && (
<Typography variant="h4" sx={{ fontSize: 24 }}>
<h4
css={{
fontSize: 24,
fontWeight: 500,
margin: 0,
marginBottom: 8,
}}
>
{title}
</Typography>
</h4>
)}
{description && typeof description === "string" && (
<Typography css={styles.description}>{description}</Typography>
<p css={styles.description}>{description}</p>
)}
{description && typeof description !== "string" && (
<div css={styles.description}>{description}</div>
Expand All @@ -59,9 +62,6 @@ export const Section: SectionFC = ({
);
};

// Sub-components
Section.Action = SectionAction;

const styles = {
header: {
marginBottom: 24,
Expand Down
11 changes: 0 additions & 11 deletions site/src/components/SettingsLayout/SectionAction.tsx

This file was deleted.

25 changes: 0 additions & 25 deletions site/src/components/Typography/Typography.stories.tsx

This file was deleted.

38 changes: 0 additions & 38 deletions site/src/components/Typography/Typography.tsx

This file was deleted.

30 changes: 15 additions & 15 deletions site/src/components/Welcome/Welcome.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Typography from "@mui/material/Typography";
import { type FC, type PropsWithChildren } from "react";
import { css, useTheme } from "@emotion/react";
import { useTheme } from "@emotion/react";
import { CoderIcon } from "../Icons/CoderIcon";

const Language = {
Expand Down Expand Up @@ -31,22 +30,23 @@ export const Welcome: FC<
}}
/>
</div>
<Typography
css={css`
text-align: center;
font-size: 32px;
font-weight: 400;
margin: 16px 0 32px;
line-height: 1.25;
<h1
css={{
textAlign: "center",
fontSize: 32,
fontWeight: 400,
margin: 0,
marginTop: 16,
marginBottom: 32,
lineHeight: 1.25,

& strong {
font-weight: 600;
}
`}
variant="h1"
"& strong": {
fontWeight: 600,
},
}}
Comment on lines +34 to +46
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aww, why get rid of the css? I kinda like those for when we have nested selectors

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto complete and formatting basically

>
{message}
</Typography>
</h1>
</div>
);
};
5 changes: 2 additions & 3 deletions site/src/pages/404Page/404Page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Typography from "@mui/material/Typography";
import { type FC } from "react";

export const NotFoundPage: FC = () => {
Expand All @@ -20,9 +19,9 @@ export const NotFoundPage: FC = () => {
borderRight: theme.palette.divider,
})}
>
<Typography variant="h4">404</Typography>
<h4>404</h4>
</div>
<Typography variant="body2">This page could not be found.</Typography>
<p>This page could not be found.</p>
</div>
);
};
Expand Down
Loading