Skip to content

Commit ff884e1

Browse files
committed
emotion: Stack
1 parent 0bfa16a commit ff884e1

File tree

2 files changed

+34
-50
lines changed

2 files changed

+34
-50
lines changed

site/src/components/Stack/Stack.tsx

Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,45 @@
1-
import { makeStyles } from "@mui/styles";
2-
import { CSSProperties } from "@mui/styles/withStyles";
3-
import { FC } from "react";
4-
import { ReactNode } from "react-markdown/lib/react-markdown";
5-
import { combineClasses } from "utils/combineClasses";
6-
7-
type Direction = "column" | "row";
1+
import type { FC } from "react";
2+
import type { CSSObject } from "@emotion/react";
83

94
export type StackProps = {
105
className?: string;
11-
direction?: Direction;
6+
direction?: "column" | "row";
127
spacing?: number;
13-
alignItems?: CSSProperties["alignItems"];
14-
justifyContent?: CSSProperties["justifyContent"];
15-
maxWidth?: CSSProperties["maxWidth"];
16-
wrap?: CSSProperties["flexWrap"];
8+
alignItems?: CSSObject["alignItems"];
9+
justifyContent?: CSSObject["justifyContent"];
10+
maxWidth?: CSSObject["maxWidth"];
11+
wrap?: CSSObject["flexWrap"];
1712
} & React.HTMLProps<HTMLDivElement>;
1813

19-
type StyleProps = Omit<StackProps, "className">;
20-
21-
const useStyles = makeStyles((theme) => ({
22-
stack: {
23-
display: "flex",
24-
flexDirection: ({ direction }: StyleProps) => direction,
25-
gap: ({ spacing }: StyleProps) => spacing && theme.spacing(spacing),
26-
alignItems: ({ alignItems }: StyleProps) => alignItems,
27-
justifyContent: ({ justifyContent }: StyleProps) => justifyContent,
28-
flexWrap: ({ wrap }: StyleProps) => wrap,
29-
maxWidth: ({ maxWidth }: StyleProps) => maxWidth,
30-
31-
[theme.breakpoints.down("md")]: {
32-
width: "100%",
33-
},
34-
},
35-
}));
36-
37-
export const Stack: FC<StackProps & { children: ReactNode | ReactNode[] }> = ({
38-
children,
39-
className,
40-
direction = "column",
41-
spacing = 2,
42-
alignItems,
43-
justifyContent,
44-
maxWidth,
45-
wrap,
46-
...divProps
47-
}) => {
48-
const styles = useStyles({
49-
spacing,
50-
direction,
14+
export const Stack: FC<StackProps> = (props) => {
15+
const {
16+
children,
17+
direction = "column",
18+
spacing = 2,
5119
alignItems,
5220
justifyContent,
53-
wrap,
5421
maxWidth,
55-
});
22+
wrap,
23+
...divProps
24+
} = props;
5625

5726
return (
58-
<div {...divProps} className={combineClasses([styles.stack, className])}>
27+
<div
28+
{...divProps}
29+
css={(theme) => ({
30+
display: "flex",
31+
flexDirection: direction,
32+
gap: spacing && theme.spacing(spacing),
33+
alignItems: alignItems,
34+
justifyContent: justifyContent,
35+
flexWrap: wrap,
36+
maxWidth: maxWidth,
37+
38+
[theme.breakpoints.down("md")]: {
39+
width: "100%",
40+
},
41+
})}
42+
>
5943
{children}
6044
</div>
6145
);

site/src/pages/TemplatePage/TemplateSummaryPage/TemplateSummaryPageView.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import {
1+
import { type FC, useEffect } from "react";
2+
import { useLocation, useNavigate } from "react-router-dom";
3+
import type {
24
Template,
35
TemplateVersion,
46
WorkspaceResource,
@@ -7,8 +9,6 @@ import { Loader } from "components/Loader/Loader";
79
import { Stack } from "components/Stack/Stack";
810
import { TemplateResourcesTable } from "components/TemplateResourcesTable/TemplateResourcesTable";
911
import { TemplateStats } from "./TemplateStats";
10-
import { FC, useEffect } from "react";
11-
import { useLocation, useNavigate } from "react-router-dom";
1212
import { TemplateVersionWarnings } from "components/TemplateVersionWarnings/TemplateVersionWarnings";
1313

1414
export interface TemplateSummaryPageViewProps {

0 commit comments

Comments
 (0)