Skip to content

refactor: Refactor page header spacing and stats #4750

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 1 commit into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion site/src/components/PageHeader/PageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const useStyles = makeStyles((theme) => ({
display: "flex",
alignItems: "center",
paddingTop: theme.spacing(6),
paddingBottom: theme.spacing(5),
paddingBottom: theme.spacing(6),

[theme.breakpoints.down("sm")]: {
flexDirection: "column",
Expand Down
5 changes: 1 addition & 4 deletions site/src/components/Pill/Pill.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { makeStyles, Theme } from "@material-ui/core/styles"
import { FC } from "react"
import { MONOSPACE_FONT_FAMILY } from "theme/constants"
import { PaletteIndex } from "theme/palettes"
import { combineClasses } from "util/combineClasses"

Expand Down Expand Up @@ -28,14 +27,12 @@ export const Pill: FC<PillProps> = (props) => {

const useStyles = makeStyles<Theme, PillProps>((theme) => ({
wrapper: {
fontFamily: MONOSPACE_FONT_FAMILY,
display: "inline-flex",
alignItems: "center",
borderWidth: 1,
borderStyle: "solid",
borderRadius: 99999,
fontSize: 14,
fontWeight: 500,
fontSize: 12,
color: "#FFF",
height: theme.spacing(3),
paddingLeft: ({ icon }) =>
Expand Down
39 changes: 11 additions & 28 deletions site/src/components/TemplateStats/TemplateStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
formatTemplateActiveDevelopers,
} from "util/templates"
import { Template, TemplateVersion } from "../../api/typesGenerated"
import { MONOSPACE_FONT_FAMILY } from "../../theme/constants"

const Language = {
usedByLabel: "Used by",
Expand All @@ -32,7 +31,7 @@ export const TemplateStats: FC<TemplateStatsProps> = ({
return (
<div className={styles.stats}>
<div className={styles.statItem}>
<span className={styles.statsLabel}>{Language.usedByLabel}</span>
<span className={styles.statsLabel}>{Language.usedByLabel}:</span>

<span className={styles.statsValue}>
{formatTemplateActiveDevelopers(template.active_user_count)}{" "}
Expand All @@ -41,29 +40,27 @@ export const TemplateStats: FC<TemplateStatsProps> = ({
: Language.developerPlural}
</span>
</div>
<div className={styles.statsDivider} />
<div className={styles.statItem}>
<span className={styles.statsLabel}>{Language.buildTimeLabel}</span>
<span className={styles.statsLabel}>{Language.buildTimeLabel}:</span>

<span className={styles.statsValue}>
{formatTemplateBuildTime(template.build_time_stats.start_ms)}{" "}
</span>
</div>
<div className={styles.statsDivider} />
<div className={styles.statItem}>
<span className={styles.statsLabel}>{Language.activeVersionLabel}</span>
<span className={styles.statsLabel}>
{Language.activeVersionLabel}:
</span>
<span className={styles.statsValue}>{activeVersion.name}</span>
</div>
<div className={styles.statsDivider} />
<div className={styles.statItem}>
<span className={styles.statsLabel}>{Language.lastUpdateLabel}</span>
<span className={styles.statsLabel}>{Language.lastUpdateLabel}:</span>
<span className={styles.statsValue} data-chromatic="ignore">
{createDayString(template.updated_at)}
</span>
</div>
<div className={styles.statsDivider} />
<div className={styles.statItem}>
<span className={styles.statsLabel}>{Language.createdByLabel}</span>
<span className={styles.statsLabel}>{Language.createdByLabel}:</span>
<span className={styles.statsValue}>{template.created_by_name}</span>
</div>
</div>
Expand All @@ -74,46 +71,32 @@ const useStyles = makeStyles((theme) => ({
stats: {
paddingLeft: theme.spacing(2),
paddingRight: theme.spacing(2),
backgroundColor: theme.palette.background.paper,
borderRadius: theme.shape.borderRadius,
display: "flex",
alignItems: "center",
color: theme.palette.text.secondary,
fontFamily: MONOSPACE_FONT_FAMILY,
border: `1px solid ${theme.palette.divider}`,
[theme.breakpoints.down("sm")]: {
display: "block",
},
},

statItem: {
minWidth: "15%",
padding: theme.spacing(2),
paddingTop: theme.spacing(1.75),
display: "flex",
alignItems: "baseline",
gap: theme.spacing(1),
},

statsLabel: {
fontSize: 12,
textTransform: "uppercase",
display: "block",
fontWeight: 600,
wordWrap: "break-word",
},

statsValue: {
fontSize: 16,
marginTop: theme.spacing(0.25),
display: "block",
wordWrap: "break-word",
},

statsDivider: {
width: 1,
height: theme.spacing(5),
backgroundColor: theme.palette.divider,
marginRight: theme.spacing(2),
[theme.breakpoints.down("sm")]: {
display: "none",
},
color: theme.palette.text.primary,
},
}))
2 changes: 1 addition & 1 deletion site/src/components/Workspace/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
<Stack
direction="column"
className={styles.firstColumnSpacer}
spacing={6}
spacing={4}
>
{buildError}
{cancellationError}
Expand Down
35 changes: 9 additions & 26 deletions site/src/components/WorkspaceStats/WorkspaceStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { combineClasses } from "util/combineClasses"
import { createDayString } from "util/createDayString"
import { getDisplayWorkspaceBuildInitiatedBy } from "util/workspace"
import { Workspace } from "../../api/typesGenerated"
import { MONOSPACE_FONT_FAMILY } from "../../theme/constants"

const Language = {
workspaceDetails: "Workspace Details",
Expand All @@ -17,7 +16,7 @@ const Language = {
lastBuiltLabel: "Last Built",
outdated: "Outdated",
upToDate: "Up to date",
byLabel: "Last Built by",
byLabel: "Last built by",
}

export interface WorkspaceStatsProps {
Expand All @@ -38,7 +37,7 @@ export const WorkspaceStats: FC<WorkspaceStatsProps> = ({
return (
<div className={styles.stats} aria-label={Language.workspaceDetails}>
<div className={styles.statItem}>
<span className={styles.statsLabel}>{Language.templateLabel}</span>
<span className={styles.statsLabel}>{Language.templateLabel}:</span>
<Link
component={RouterLink}
to={`/templates/${workspace.template_name}`}
Expand All @@ -47,9 +46,8 @@ export const WorkspaceStats: FC<WorkspaceStatsProps> = ({
{workspace.template_name}
</Link>
</div>
<div className={styles.statsDivider} />
<div className={styles.statItem}>
<span className={styles.statsLabel}>{Language.versionLabel}</span>
<span className={styles.statsLabel}>{Language.versionLabel}:</span>
<span className={styles.statsValue}>
{workspace.outdated ? (
<span className={styles.outdatedLabel}>
Expand All @@ -66,16 +64,14 @@ export const WorkspaceStats: FC<WorkspaceStatsProps> = ({
)}
</span>
</div>
<div className={styles.statsDivider} />
<div className={styles.statItem}>
<span className={styles.statsLabel}>{Language.lastBuiltLabel}</span>
<span className={styles.statsLabel}>{Language.lastBuiltLabel}:</span>
<span className={styles.statsValue} data-chromatic="ignore">
{createDayString(workspace.latest_build.created_at)}
</span>
</div>
<div className={styles.statsDivider} />
<div className={styles.statItem}>
<span className={styles.statsLabel}>{Language.byLabel}</span>
<span className={styles.statsLabel}>{Language.byLabel}:</span>
<span className={styles.statsValue}>{initiatedBy}</span>
</div>
</div>
Expand All @@ -86,48 +82,35 @@ const useStyles = makeStyles((theme) => ({
stats: {
paddingLeft: theme.spacing(2),
paddingRight: theme.spacing(2),
backgroundColor: theme.palette.background.paper,
borderRadius: theme.shape.borderRadius,
border: `1px solid ${theme.palette.divider}`,
display: "flex",
alignItems: "center",
color: theme.palette.text.secondary,
fontFamily: MONOSPACE_FONT_FAMILY,
margin: "0px",
[theme.breakpoints.down("sm")]: {
display: "block",
},
},

statItem: {
minWidth: "16%",
padding: theme.spacing(2),
paddingTop: theme.spacing(1.75),
display: "flex",
alignItems: "baseline",
gap: theme.spacing(1),
},

statsLabel: {
fontSize: 12,
textTransform: "uppercase",
display: "block",
fontWeight: 600,
wordWrap: "break-word",
},

statsValue: {
fontSize: 16,
marginTop: theme.spacing(0.25),
display: "block",
wordWrap: "break-word",
},

statsDivider: {
width: 1,
height: theme.spacing(5),
backgroundColor: theme.palette.divider,
marginRight: theme.spacing(2),
[theme.breakpoints.down("sm")]: {
display: "none",
},
color: theme.palette.text.primary,
},

capitalize: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ export const TemplateSummaryPageView: FC<
}

return (
<Stack spacing={2.5}>
<Stack spacing={4}>
{deleteError}
{templateDAUs && <DAUChart templateDAUs={templateDAUs} />}
<TemplateStats
template={template}
activeVersion={activeTemplateVersion}
/>
{templateDAUs && <DAUChart templateDAUs={templateDAUs} />}
<TemplateResourcesTable
resources={getStartedResources(templateResources)}
/>
Expand Down