|
| 1 | +import Box from "@material-ui/core/Box" |
| 2 | +import Paper from "@material-ui/core/Paper" |
| 3 | +import Typography from "@material-ui/core/Typography" |
| 4 | +import { makeStyles } from "@material-ui/core/styles" |
| 5 | +import CloudCircleIcon from "@material-ui/icons/CloudCircle" |
| 6 | +import Link from "next/link" |
| 7 | +import React from "react" |
| 8 | + |
| 9 | +import * as API from "../../api" |
| 10 | + |
| 11 | +export interface WorkspaceProps { |
| 12 | + workspace: API.Workspace |
| 13 | +} |
| 14 | + |
| 15 | +namespace Constants { |
| 16 | + export const TitleIconSize = 48 |
| 17 | + export const CardRadius = 8 |
| 18 | + export const CardPadding = 20 |
| 19 | +} |
| 20 | + |
| 21 | +/** |
| 22 | + * Workspace is the top-level component for viewing an individual workspace |
| 23 | + */ |
| 24 | +export const Workspace: React.FC<WorkspaceProps> = ({ workspace }) => { |
| 25 | + const styles = useStyles() |
| 26 | + |
| 27 | + return ( |
| 28 | + <div className={styles.root}> |
| 29 | + <WorkspaceHeader workspace={workspace} /> |
| 30 | + </div> |
| 31 | + ) |
| 32 | +} |
| 33 | + |
| 34 | +/** |
| 35 | + * Component for the header at the top of the workspace page |
| 36 | + */ |
| 37 | +export const WorkspaceHeader: React.FC<WorkspaceProps> = ({ workspace }) => { |
| 38 | + const styles = useStyles() |
| 39 | + |
| 40 | + return ( |
| 41 | + <Paper elevation={0} className={styles.section}> |
| 42 | + <div className={styles.horizontal}> |
| 43 | + <WorkspaceHeroIcon /> |
| 44 | + <div className={styles.vertical}> |
| 45 | + <Typography variant="h4">{workspace.name}</Typography> |
| 46 | + <Typography variant="body2" color="textSecondary"> |
| 47 | + <Link href="javascript:;">{workspace.project_id}</Link> |
| 48 | + </Typography> |
| 49 | + </div> |
| 50 | + </div> |
| 51 | + </Paper> |
| 52 | + ) |
| 53 | +} |
| 54 | + |
| 55 | +/** |
| 56 | + * Component to render the 'Hero Icon' in the header of a workspace |
| 57 | + */ |
| 58 | +export const WorkspaceHeroIcon: React.FC = () => { |
| 59 | + return ( |
| 60 | + <Box mr="1em"> |
| 61 | + <CloudCircleIcon width={Constants.TitleIconSize} height={Constants.TitleIconSize} /> |
| 62 | + </Box> |
| 63 | + ) |
| 64 | +} |
| 65 | + |
| 66 | +export const useStyles = makeStyles((theme) => { |
| 67 | + return { |
| 68 | + root: { |
| 69 | + display: "flex", |
| 70 | + flexDirection: "column", |
| 71 | + }, |
| 72 | + horizontal: { |
| 73 | + display: "flex", |
| 74 | + flexDirection: "row", |
| 75 | + }, |
| 76 | + vertical: { |
| 77 | + display: "flex", |
| 78 | + flexDirection: "column", |
| 79 | + }, |
| 80 | + section: { |
| 81 | + border: `1px solid ${theme.palette.divider}`, |
| 82 | + borderRadius: Constants.CardRadius, |
| 83 | + padding: Constants.CardPadding, |
| 84 | + }, |
| 85 | + icon: { |
| 86 | + width: Constants.TitleIconSize, |
| 87 | + height: Constants.TitleIconSize, |
| 88 | + }, |
| 89 | + } |
| 90 | +}) |
0 commit comments