-
Notifications
You must be signed in to change notification settings - Fork 887
feat(site): move history into sidebar #11413
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
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e7d633d
WIP: Add base sidebar structure
BrunoQuaresma 72ed777
Refactor to only have history sidebar
BrunoQuaresma e66151a
Minor visual adjustments
BrunoQuaresma 1110997
Refactor timeline and group build by date
BrunoQuaresma dcf8f32
Change workspace build data
BrunoQuaresma ec87d6b
Reset timeline
BrunoQuaresma 1dacdd9
Add left bar to the sidebar
BrunoQuaresma 0f56e29
Fix tests
BrunoQuaresma 3449731
Fix lint
BrunoQuaresma df7f8b6
Resolve PR comments
BrunoQuaresma 4e8fbf9
Improve agent row
BrunoQuaresma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { Interpolation, Theme, useTheme } from "@mui/material/styles"; | ||
import { ComponentProps, HTMLAttributes } from "react"; | ||
import { Link, LinkProps } from "react-router-dom"; | ||
import { TopbarIconButton } from "./Topbar"; | ||
|
||
export const Sidebar = (props: HTMLAttributes<HTMLDivElement>) => { | ||
const theme = useTheme(); | ||
return ( | ||
<div | ||
css={{ | ||
width: 260, | ||
borderRight: `1px solid ${theme.palette.divider}`, | ||
height: "100%", | ||
overflow: "auto", | ||
flexShrink: 0, | ||
padding: "8px 0", | ||
display: "flex", | ||
flexDirection: "column", | ||
gap: 1, | ||
}} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
export const SidebarLink = (props: LinkProps) => { | ||
return <Link css={styles.sidebarItem} {...props} />; | ||
}; | ||
|
||
export const SidebarItem = (props: HTMLAttributes<HTMLButtonElement>) => { | ||
return <button css={styles.sidebarItem} {...props} />; | ||
}; | ||
|
||
export const SidebarCaption = (props: HTMLAttributes<HTMLSpanElement>) => { | ||
return ( | ||
<span | ||
css={{ | ||
fontSize: 10, | ||
lineHeight: 1.2, | ||
padding: "12px 16px", | ||
display: "block", | ||
textTransform: "uppercase", | ||
fontWeight: 500, | ||
letterSpacing: "0.1em", | ||
}} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
export const SidebarIconButton = ( | ||
props: { isActive: boolean } & ComponentProps<typeof TopbarIconButton>, | ||
) => { | ||
const theme = useTheme(); | ||
|
||
return ( | ||
<TopbarIconButton | ||
css={[ | ||
{ opacity: 0.75, "&:hover": { opacity: 1 } }, | ||
props.isActive && { | ||
opacity: 1, | ||
position: "relative", | ||
"&::before": { | ||
content: '""', | ||
position: "absolute", | ||
left: 0, | ||
top: 0, | ||
bottom: 0, | ||
width: 2, | ||
backgroundColor: theme.palette.primary.main, | ||
height: "100%", | ||
}, | ||
}, | ||
]} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
const styles = { | ||
sidebarItem: (theme) => ({ | ||
fontSize: 13, | ||
lineHeight: 1.2, | ||
color: theme.palette.text.primary, | ||
textDecoration: "none", | ||
padding: "8px 16px", | ||
display: "block", | ||
textAlign: "left", | ||
background: "none", | ||
border: 0, | ||
|
||
"&:hover": { | ||
backgroundColor: theme.palette.action.hover, | ||
}, | ||
}), | ||
} satisfies Record<string, Interpolation<Theme>>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { Interpolation, Theme, useTheme } from "@emotion/react"; | ||
import Skeleton from "@mui/material/Skeleton"; | ||
import { WorkspaceBuild } from "api/typesGenerated"; | ||
import { BuildIcon } from "components/BuildIcon/BuildIcon"; | ||
import { createDayString } from "utils/createDayString"; | ||
import { | ||
getDisplayWorkspaceBuildStatus, | ||
getDisplayWorkspaceBuildInitiatedBy, | ||
} from "utils/workspace"; | ||
|
||
export const WorkspaceBuildData = ({ build }: { build: WorkspaceBuild }) => { | ||
const theme = useTheme(); | ||
const statusType = getDisplayWorkspaceBuildStatus(theme, build).type; | ||
|
||
return ( | ||
<div css={styles.root}> | ||
<BuildIcon | ||
transition={build.transition} | ||
css={{ | ||
width: 16, | ||
height: 16, | ||
color: theme.palette[statusType].light, | ||
}} | ||
/> | ||
<div css={{ overflow: "hidden" }}> | ||
<div | ||
css={{ | ||
textTransform: "capitalize", | ||
color: theme.palette.text.primary, | ||
textOverflow: "ellipsis", | ||
overflow: "hidden", | ||
whiteSpace: "nowrap", | ||
}} | ||
> | ||
{build.transition} by{" "} | ||
<span css={{ fontWeight: 500 }}> | ||
{getDisplayWorkspaceBuildInitiatedBy(build)} | ||
</span> | ||
</div> | ||
<div | ||
css={{ | ||
fontSize: 12, | ||
color: theme.palette.text.secondary, | ||
marginTop: 2, | ||
}} | ||
> | ||
{createDayString(build.created_at)} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export const WorkspaceBuildDataSkeleton = () => { | ||
return ( | ||
<div css={styles.root}> | ||
<Skeleton variant="circular" width={16} height={16} /> | ||
<div> | ||
<Skeleton variant="text" width={94} height={16} /> | ||
<Skeleton | ||
variant="text" | ||
width={60} | ||
height={14} | ||
css={{ marginTop: 2 }} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
const styles = { | ||
root: { | ||
display: "flex", | ||
flexDirection: "row", | ||
alignItems: "center", | ||
gap: 12, | ||
lineHeight: "1.4", | ||
}, | ||
} satisfies Record<string, Interpolation<Theme>>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for future-proofing, do you think it's worth explicitly pulling the
type
attribute out and setting its default value tobutton
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I got it... do you have a code sample?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, just realized that the comment got garbled by a stray backtick
Now that I'm a little more awake, I think my suggestion would be overkill, but I was talking about this: