Skip to content

Commit 0da5e7e

Browse files
committed
Make WorkspaceSection more reusable
1 parent b1cc9d6 commit 0da5e7e

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

site/src/components/WorkspaceSection/WorkspaceSection.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@ import React from "react"
55
import { CardRadius, CardPadding } from "../../theme/constants"
66

77
export interface WorkspaceSectionProps {
8-
title: string
8+
title?: string
99
}
1010

1111
export const WorkspaceSection: React.FC<WorkspaceSectionProps> = ({ title, children }) => {
1212
const styles = useStyles()
1313

1414
return (
1515
<Paper elevation={0} className={styles.root}>
16-
<div className={styles.headerContainer}>
17-
<div className={styles.header}>
18-
<Typography variant="h6">{title}</Typography>
16+
{title &&
17+
<div className={styles.headerContainer}>
18+
<div className={styles.header}>
19+
<Typography variant="h6">{title}</Typography>
20+
</div>
1921
</div>
20-
</div>
22+
}
2123

2224
<div className={styles.contents}>{children}</div>
2325
</Paper>

site/src/components/WorkspaceStatusBar/WorkspaceStatusBar.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { WorkspaceProps } from "../Workspace/Workspace"
77
import CloudCircleIcon from "@material-ui/icons/CloudCircle"
88
import { CardPadding, CardRadius, TitleIconSize } from "../../theme/constants"
99
import { makeStyles } from "@material-ui/core/styles"
10+
import { WorkspaceSection } from "../WorkspaceSection/WorkspaceSection"
1011

1112
/**
1213
* Component for the header at the top of the workspace page
@@ -17,7 +18,7 @@ export const WorkspaceStatusBar: React.FC<WorkspaceProps> = ({ organization, tem
1718
const templateLink = `/templates/${organization.name}/${template.name}`
1819

1920
return (
20-
<Paper elevation={0} className={styles.section}>
21+
<WorkspaceSection>
2122
<div className={styles.horizontal}>
2223
<Box mr="1em">
2324
<CloudCircleIcon width={TitleIconSize} height={TitleIconSize} />
@@ -29,7 +30,7 @@ export const WorkspaceStatusBar: React.FC<WorkspaceProps> = ({ organization, tem
2930
</Typography>
3031
</div>
3132
</div>
32-
</Paper>
33+
</WorkspaceSection>
3334
)
3435
}
3536

@@ -47,11 +48,5 @@ const useStyles = makeStyles((theme) => {
4748
display: "flex",
4849
flexDirection: "column",
4950
},
50-
section: {
51-
border: `1px solid ${theme.palette.divider}`,
52-
borderRadius: CardRadius,
53-
padding: CardPadding,
54-
margin: theme.spacing(1),
55-
},
5651
}
5752
})

0 commit comments

Comments
 (0)