mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
feat: add margins to pages (#1217)
* Add Margin, use constants * Change throughout * Add to a page, lint * Format
This commit is contained in:
@ -2,6 +2,7 @@ import { makeStyles } from "@material-ui/core/styles"
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import { FormCloseButton } from "../FormCloseButton/FormCloseButton"
|
import { FormCloseButton } from "../FormCloseButton/FormCloseButton"
|
||||||
import { FormTitle } from "../FormTitle/FormTitle"
|
import { FormTitle } from "../FormTitle/FormTitle"
|
||||||
|
import { Margins } from "../Margins/Margins"
|
||||||
|
|
||||||
export interface FullPageFormProps {
|
export interface FullPageFormProps {
|
||||||
title: string
|
title: string
|
||||||
@ -11,7 +12,6 @@ export interface FullPageFormProps {
|
|||||||
|
|
||||||
const useStyles = makeStyles(() => ({
|
const useStyles = makeStyles(() => ({
|
||||||
root: {
|
root: {
|
||||||
maxWidth: "1380px",
|
|
||||||
width: "100%",
|
width: "100%",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
@ -23,10 +23,12 @@ export const FullPageForm: React.FC<FullPageFormProps> = ({ title, detail, onCan
|
|||||||
const styles = useStyles()
|
const styles = useStyles()
|
||||||
return (
|
return (
|
||||||
<main className={styles.root}>
|
<main className={styles.root}>
|
||||||
|
<Margins>
|
||||||
<FormTitle title={title} detail={detail} />
|
<FormTitle title={title} detail={detail} />
|
||||||
<FormCloseButton onClose={onCancel} />
|
<FormCloseButton onClose={onCancel} />
|
||||||
|
|
||||||
{children}
|
{children}
|
||||||
|
</Margins>
|
||||||
</main>
|
</main>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import Box from "@material-ui/core/Box"
|
|||||||
import { makeStyles } from "@material-ui/core/styles"
|
import { makeStyles } from "@material-ui/core/styles"
|
||||||
import Typography from "@material-ui/core/Typography"
|
import Typography from "@material-ui/core/Typography"
|
||||||
import React from "react"
|
import React from "react"
|
||||||
|
import { maxWidth, sidePadding } from "../../theme/constants"
|
||||||
import { HeaderButton } from "../HeaderButton/HeaderButton"
|
import { HeaderButton } from "../HeaderButton/HeaderButton"
|
||||||
|
|
||||||
export interface HeaderAction {
|
export interface HeaderAction {
|
||||||
@ -66,18 +67,19 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
position: "relative",
|
position: "relative",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
height: 150,
|
height: 126,
|
||||||
background: theme.palette.hero.main,
|
background: theme.palette.hero.main,
|
||||||
boxShadow: theme.shadows[3],
|
boxShadow: theme.shadows[3],
|
||||||
},
|
},
|
||||||
topInner: {
|
topInner: {
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
maxWidth: "1380px",
|
maxWidth,
|
||||||
margin: "0 auto",
|
margin: "0 auto",
|
||||||
flex: 1,
|
flex: 1,
|
||||||
height: 68,
|
height: 68,
|
||||||
minWidth: 0,
|
minWidth: 0,
|
||||||
|
padding: `0 ${sidePadding}`,
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
display: "flex",
|
display: "flex",
|
||||||
|
16
site/src/components/Margins/Margins.stories.tsx
Normal file
16
site/src/components/Margins/Margins.stories.tsx
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { ComponentMeta, Story } from "@storybook/react"
|
||||||
|
import React from "react"
|
||||||
|
import { Margins } from "./Margins"
|
||||||
|
|
||||||
|
export default {
|
||||||
|
title: "components/Margins",
|
||||||
|
component: Margins,
|
||||||
|
} as ComponentMeta<typeof Margins>
|
||||||
|
|
||||||
|
const Template: Story = (args) => (
|
||||||
|
<Margins {...args}>
|
||||||
|
<div style={{ width: "100%", background: "lightgrey" }}>Here is some content that will not get too wide!</div>
|
||||||
|
</Margins>
|
||||||
|
)
|
||||||
|
|
||||||
|
export const Example = Template.bind({})
|
21
site/src/components/Margins/Margins.tsx
Normal file
21
site/src/components/Margins/Margins.tsx
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { makeStyles } from "@material-ui/core/styles"
|
||||||
|
import React from "react"
|
||||||
|
import { maxWidth, sidePadding } from "../../theme/constants"
|
||||||
|
|
||||||
|
const useStyles = makeStyles(() => ({
|
||||||
|
margins: {
|
||||||
|
margin: "0 auto",
|
||||||
|
maxWidth,
|
||||||
|
padding: `0 ${sidePadding}`,
|
||||||
|
flex: 1,
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
|
||||||
|
export const Margins: React.FC = ({ children }) => {
|
||||||
|
const styles = useStyles()
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className={styles.margins}>{children}</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
@ -2,6 +2,7 @@ import Box from "@material-ui/core/Box"
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import { Outlet } from "react-router-dom"
|
import { Outlet } from "react-router-dom"
|
||||||
import { AuthAndFrame } from "../AuthAndFrame/AuthAndFrame"
|
import { AuthAndFrame } from "../AuthAndFrame/AuthAndFrame"
|
||||||
|
import { Margins } from "../Margins/Margins"
|
||||||
import { TabPanel } from "../TabPanel/TabPanel"
|
import { TabPanel } from "../TabPanel/TabPanel"
|
||||||
|
|
||||||
export const Language = {
|
export const Language = {
|
||||||
@ -23,11 +24,11 @@ export const PreferencesLayout: React.FC = () => {
|
|||||||
return (
|
return (
|
||||||
<AuthAndFrame>
|
<AuthAndFrame>
|
||||||
<Box display="flex" flexDirection="column">
|
<Box display="flex" flexDirection="column">
|
||||||
<Box style={{ maxWidth: "1380px", margin: "1em auto" }}>
|
<Margins>
|
||||||
<TabPanel title={Language.preferencesLabel} menuItems={menuItems}>
|
<TabPanel title={Language.preferencesLabel} menuItems={menuItems}>
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
</Box>
|
</Margins>
|
||||||
</Box>
|
</Box>
|
||||||
</AuthAndFrame>
|
</AuthAndFrame>
|
||||||
)
|
)
|
||||||
|
@ -10,6 +10,7 @@ import { FormSection } from "../components/FormSection/FormSection"
|
|||||||
import { FormTextField } from "../components/FormTextField/FormTextField"
|
import { FormTextField } from "../components/FormTextField/FormTextField"
|
||||||
import { FormTitle } from "../components/FormTitle/FormTitle"
|
import { FormTitle } from "../components/FormTitle/FormTitle"
|
||||||
import { LoadingButton } from "../components/LoadingButton/LoadingButton"
|
import { LoadingButton } from "../components/LoadingButton/LoadingButton"
|
||||||
|
import { maxWidth } from "../theme/constants"
|
||||||
|
|
||||||
export interface CreateTemplateFormProps {
|
export interface CreateTemplateFormProps {
|
||||||
provisioners: Provisioner[]
|
provisioners: Provisioner[]
|
||||||
@ -121,7 +122,7 @@ export const CreateTemplateForm: React.FC<CreateTemplateFormProps> = ({
|
|||||||
|
|
||||||
const useStyles = makeStyles(() => ({
|
const useStyles = makeStyles(() => ({
|
||||||
root: {
|
root: {
|
||||||
maxWidth: "1380px",
|
maxWidth,
|
||||||
width: "100%",
|
width: "100%",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
|
@ -9,6 +9,7 @@ import { FormSection } from "../components/FormSection/FormSection"
|
|||||||
import { FormTextField } from "../components/FormTextField/FormTextField"
|
import { FormTextField } from "../components/FormTextField/FormTextField"
|
||||||
import { FormTitle } from "../components/FormTitle/FormTitle"
|
import { FormTitle } from "../components/FormTitle/FormTitle"
|
||||||
import { LoadingButton } from "../components/LoadingButton/LoadingButton"
|
import { LoadingButton } from "../components/LoadingButton/LoadingButton"
|
||||||
|
import { maxWidth } from "../theme/constants"
|
||||||
|
|
||||||
export interface CreateWorkspaceForm {
|
export interface CreateWorkspaceForm {
|
||||||
template: Template
|
template: Template
|
||||||
@ -82,7 +83,7 @@ export const CreateWorkspaceForm: React.FC<CreateWorkspaceForm> = ({ template, o
|
|||||||
|
|
||||||
const useStyles = makeStyles(() => ({
|
const useStyles = makeStyles(() => ({
|
||||||
root: {
|
root: {
|
||||||
maxWidth: "1380px",
|
maxWidth,
|
||||||
width: "100%",
|
width: "100%",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import Paper from "@material-ui/core/Paper"
|
|
||||||
import { makeStyles } from "@material-ui/core/styles"
|
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { Link, useNavigate, useParams } from "react-router-dom"
|
import { Link, useNavigate, useParams } from "react-router-dom"
|
||||||
import useSWR from "swr"
|
import useSWR from "swr"
|
||||||
@ -8,12 +6,13 @@ import { EmptyState } from "../../../../components/EmptyState/EmptyState"
|
|||||||
import { ErrorSummary } from "../../../../components/ErrorSummary/ErrorSummary"
|
import { ErrorSummary } from "../../../../components/ErrorSummary/ErrorSummary"
|
||||||
import { Header } from "../../../../components/Header/Header"
|
import { Header } from "../../../../components/Header/Header"
|
||||||
import { FullScreenLoader } from "../../../../components/Loader/FullScreenLoader"
|
import { FullScreenLoader } from "../../../../components/Loader/FullScreenLoader"
|
||||||
|
import { Margins } from "../../../../components/Margins/Margins"
|
||||||
|
import { Stack } from "../../../../components/Stack/Stack"
|
||||||
import { Column, Table } from "../../../../components/Table/Table"
|
import { Column, Table } from "../../../../components/Table/Table"
|
||||||
import { unsafeSWRArgument } from "../../../../util"
|
import { unsafeSWRArgument } from "../../../../util"
|
||||||
import { firstOrItem } from "../../../../util/array"
|
import { firstOrItem } from "../../../../util/array"
|
||||||
|
|
||||||
export const TemplatePage: React.FC = () => {
|
export const TemplatePage: React.FC = () => {
|
||||||
const styles = useStyles()
|
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const { template: templateName, organization: organizationName } = useParams()
|
const { template: templateName, organization: organizationName } = useParams()
|
||||||
|
|
||||||
@ -82,7 +81,7 @@ export const TemplatePage: React.FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.root}>
|
<Stack spacing={4}>
|
||||||
<Header
|
<Header
|
||||||
title={firstOrItem(templateName, "")}
|
title={firstOrItem(templateName, "")}
|
||||||
description={firstOrItem(organizationName, "")}
|
description={firstOrItem(organizationName, "")}
|
||||||
@ -93,25 +92,9 @@ export const TemplatePage: React.FC = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Paper style={{ maxWidth: "1380px", margin: "1em auto", width: "100%" }}>
|
<Margins>
|
||||||
<Table {...tableProps} />
|
<Table {...tableProps} />
|
||||||
</Paper>
|
</Margins>
|
||||||
</div>
|
</Stack>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
|
||||||
root: {
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
},
|
|
||||||
header: {
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "row-reverse",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
margin: "1em auto",
|
|
||||||
maxWidth: "1380px",
|
|
||||||
padding: theme.spacing(2, 6.25, 0),
|
|
||||||
width: "100%",
|
|
||||||
},
|
|
||||||
}))
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import Paper from "@material-ui/core/Paper"
|
|
||||||
import { makeStyles } from "@material-ui/core/styles"
|
import { makeStyles } from "@material-ui/core/styles"
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { Link } from "react-router-dom"
|
import { Link } from "react-router-dom"
|
||||||
@ -9,6 +8,8 @@ import { EmptyState } from "../../components/EmptyState/EmptyState"
|
|||||||
import { ErrorSummary } from "../../components/ErrorSummary/ErrorSummary"
|
import { ErrorSummary } from "../../components/ErrorSummary/ErrorSummary"
|
||||||
import { Header } from "../../components/Header/Header"
|
import { Header } from "../../components/Header/Header"
|
||||||
import { FullScreenLoader } from "../../components/Loader/FullScreenLoader"
|
import { FullScreenLoader } from "../../components/Loader/FullScreenLoader"
|
||||||
|
import { Margins } from "../../components/Margins/Margins"
|
||||||
|
import { Stack } from "../../components/Stack/Stack"
|
||||||
import { Column, Table } from "../../components/Table/Table"
|
import { Column, Table } from "../../components/Table/Table"
|
||||||
|
|
||||||
export const TemplatesPage: React.FC = () => {
|
export const TemplatesPage: React.FC = () => {
|
||||||
@ -68,20 +69,16 @@ export const TemplatesPage: React.FC = () => {
|
|||||||
const subTitle = `${templates.length} total`
|
const subTitle = `${templates.length} total`
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.root}>
|
<Stack spacing={4}>
|
||||||
<Header title="Templates" subTitle={subTitle} />
|
<Header title="Templates" subTitle={subTitle} />
|
||||||
<Paper style={{ maxWidth: "1380px", margin: "1em auto", width: "100%" }}>
|
<Margins>
|
||||||
<Table {...tableProps} />
|
<Table {...tableProps} />
|
||||||
</Paper>
|
</Margins>
|
||||||
</div>
|
</Stack>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
root: {
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
},
|
|
||||||
descriptionLabel: {
|
descriptionLabel: {
|
||||||
marginBottom: theme.spacing(1),
|
marginBottom: theme.spacing(1),
|
||||||
},
|
},
|
||||||
|
@ -3,6 +3,7 @@ import React, { useContext } from "react"
|
|||||||
import { useNavigate } from "react-router"
|
import { useNavigate } from "react-router"
|
||||||
import { CreateUserRequest } from "../../../api/types"
|
import { CreateUserRequest } from "../../../api/types"
|
||||||
import { CreateUserForm } from "../../../components/CreateUserForm/CreateUserForm"
|
import { CreateUserForm } from "../../../components/CreateUserForm/CreateUserForm"
|
||||||
|
import { Margins } from "../../../components/Margins/Margins"
|
||||||
import { selectOrgId } from "../../../xServices/auth/authSelectors"
|
import { selectOrgId } from "../../../xServices/auth/authSelectors"
|
||||||
import { XServiceContext } from "../../../xServices/StateContext"
|
import { XServiceContext } from "../../../xServices/StateContext"
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ export const CreateUserPage: React.FC = () => {
|
|||||||
createUserError || createUserFormErrors?.organization_id || !myOrgId ? Language.unknownError : undefined
|
createUserError || createUserFormErrors?.organization_id || !myOrgId ? Language.unknownError : undefined
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<Margins>
|
||||||
<CreateUserForm
|
<CreateUserForm
|
||||||
formErrors={createUserFormErrors}
|
formErrors={createUserFormErrors}
|
||||||
onSubmit={(user: CreateUserRequest) => usersSend({ type: "CREATE", user })}
|
onSubmit={(user: CreateUserRequest) => usersSend({ type: "CREATE", user })}
|
||||||
@ -29,5 +31,6 @@ export const CreateUserPage: React.FC = () => {
|
|||||||
error={genericError}
|
error={genericError}
|
||||||
myOrgId={myOrgId ?? ""}
|
myOrgId={myOrgId ?? ""}
|
||||||
/>
|
/>
|
||||||
|
</Margins>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import Paper from "@material-ui/core/Paper"
|
|
||||||
import { makeStyles } from "@material-ui/core/styles"
|
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { UserResponse } from "../../api/types"
|
import { UserResponse } from "../../api/types"
|
||||||
import { Header } from "../../components/Header/Header"
|
import { Header } from "../../components/Header/Header"
|
||||||
|
import { Margins } from "../../components/Margins/Margins"
|
||||||
|
import { Stack } from "../../components/Stack/Stack"
|
||||||
import { UsersTable } from "../../components/UsersTable/UsersTable"
|
import { UsersTable } from "../../components/UsersTable/UsersTable"
|
||||||
|
|
||||||
export const Language = {
|
export const Language = {
|
||||||
@ -16,21 +16,12 @@ export interface UsersPageViewProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const UsersPageView: React.FC<UsersPageViewProps> = ({ users, openUserCreationDialog }) => {
|
export const UsersPageView: React.FC<UsersPageViewProps> = ({ users, openUserCreationDialog }) => {
|
||||||
const styles = useStyles()
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.flexColumn}>
|
<Stack spacing={4}>
|
||||||
<Header title={Language.pageTitle} action={{ text: Language.newUserButton, onClick: openUserCreationDialog }} />
|
<Header title={Language.pageTitle} action={{ text: Language.newUserButton, onClick: openUserCreationDialog }} />
|
||||||
<Paper style={{ maxWidth: "1380px", margin: "1em auto", width: "100%" }}>
|
<Margins>
|
||||||
<UsersTable users={users} />
|
<UsersTable users={users} />
|
||||||
</Paper>
|
</Margins>
|
||||||
</div>
|
</Stack>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const useStyles = makeStyles(() => ({
|
|
||||||
flexColumn: {
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
},
|
|
||||||
}))
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
import { makeStyles } from "@material-ui/core/styles"
|
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { useParams } from "react-router-dom"
|
import { useParams } from "react-router-dom"
|
||||||
import useSWR from "swr"
|
import useSWR from "swr"
|
||||||
import * as Types from "../../api/types"
|
import * as Types from "../../api/types"
|
||||||
import { ErrorSummary } from "../../components/ErrorSummary/ErrorSummary"
|
import { ErrorSummary } from "../../components/ErrorSummary/ErrorSummary"
|
||||||
import { FullScreenLoader } from "../../components/Loader/FullScreenLoader"
|
import { FullScreenLoader } from "../../components/Loader/FullScreenLoader"
|
||||||
|
import { Margins } from "../../components/Margins/Margins"
|
||||||
|
import { Stack } from "../../components/Stack/Stack"
|
||||||
import { Workspace } from "../../components/Workspace/Workspace"
|
import { Workspace } from "../../components/Workspace/Workspace"
|
||||||
import { unsafeSWRArgument } from "../../util"
|
import { unsafeSWRArgument } from "../../util"
|
||||||
import { firstOrItem } from "../../util/array"
|
import { firstOrItem } from "../../util/array"
|
||||||
|
|
||||||
export const WorkspacePage: React.FC = () => {
|
export const WorkspacePage: React.FC = () => {
|
||||||
const styles = useStyles()
|
|
||||||
const { workspace: workspaceQueryParam } = useParams()
|
const { workspace: workspaceQueryParam } = useParams()
|
||||||
|
|
||||||
const { data: workspace, error: workspaceError } = useSWR<Types.Workspace, Error>(() => {
|
const { data: workspace, error: workspaceError } = useSWR<Types.Workspace, Error>(() => {
|
||||||
@ -45,22 +45,10 @@ export const WorkspacePage: React.FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.root}>
|
<Margins>
|
||||||
<div className={styles.inner}>
|
<Stack spacing={4}>
|
||||||
<Workspace organization={organization} template={template} workspace={workspace} />
|
<Workspace organization={organization} template={template} workspace={workspace} />
|
||||||
</div>
|
</Stack>
|
||||||
</div>
|
</Margins>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const useStyles = makeStyles(() => ({
|
|
||||||
root: {
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
},
|
|
||||||
inner: {
|
|
||||||
maxWidth: "1380px",
|
|
||||||
margin: "1em auto",
|
|
||||||
width: "100%",
|
|
||||||
},
|
|
||||||
}))
|
|
||||||
|
@ -7,3 +7,5 @@ export const BODY_FONT_FAMILY = `"Inter", sans-serif`
|
|||||||
export const lightButtonShadow = "0 2px 2px rgba(0, 23, 121, 0.08)"
|
export const lightButtonShadow = "0 2px 2px rgba(0, 23, 121, 0.08)"
|
||||||
export const emptyBoxShadow = "none"
|
export const emptyBoxShadow = "none"
|
||||||
export const navHeight = 56
|
export const navHeight = 56
|
||||||
|
export const maxWidth = 1380
|
||||||
|
export const sidePadding = "50px"
|
||||||
|
Reference in New Issue
Block a user