Skip to content

refactor(site): Minor design refactoring on template version editor #6265

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 8 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add sidebar styles
  • Loading branch information
BrunoQuaresma committed Feb 17, 2023
commit 9d02bc5d55402c004141d6c47b28e8ea7fb20d73
32 changes: 20 additions & 12 deletions site/src/components/TemplateVersionEditor/FileTreeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import MenuItem from "@material-ui/core/MenuItem"
import { FC, useState } from "react"
import { FileTree } from "util/filetree"
import { DockerIcon } from "components/Icons/DockerIcon"
import { colors } from "theme/colors"

const sortFileTree = (fileTree: FileTree) => (a: string, b: string) => {
const contentA = fileTree[a]
Expand Down Expand Up @@ -98,7 +99,6 @@ export const FileTreeView: FC<{
defaultCollapseIcon={<ExpandMoreIcon />}
defaultExpandIcon={<ChevronRightIcon />}
aria-label="Files"
className={styles.fileTree}
>
{Object.keys(fileTree)
.sort(sortFileTree(fileTree))
Expand Down Expand Up @@ -156,23 +156,22 @@ export const FileTreeView: FC<{
}

const useStyles = makeStyles((theme) => ({
fileTree: {},
fileTreeItem: {
overflow: "hidden",
userSelect: "none",

"&:focus": {
"& > .MuiTreeItem-content": {
background: "rgba(255, 255, 255, 0.1)",
},
"&:focus:not(.active) > .MuiTreeItem-content": {
background: theme.palette.action.hover,
color: theme.palette.text.primary,
},
"& > .MuiTreeItem-content:hover": {
background: theme.palette.background.paperLight,

"&:not(:focus):not(.active) > .MuiTreeItem-content:hover": {
background: theme.palette.action.hover,
color: theme.palette.text.primary,
},

"& > .MuiTreeItem-content": {
padding: "1px 16px",
padding: theme.spacing(0.25, 2),
color: theme.palette.text.secondary,

"& svg": {
Expand All @@ -182,16 +181,25 @@ const useStyles = makeStyles((theme) => ({

"& > .MuiTreeItem-label": {
marginLeft: 4,
fontSize: 14,
fontSize: 13,
color: "inherit",
},
},

"&.active": {
background: theme.palette.background.paper,

"& > .MuiTreeItem-content": {
color: theme.palette.text.primary,
background: colors.gray[13],
pointerEvents: "none",
},
},

"& .MuiTreeItem-group": {
marginLeft: 0,

// We need to find a better way to recursive padding here
"& .MuiTreeItem-content": {
paddingLeft: theme.spacing(5),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Button from "@material-ui/core/Button"
import IconButton from "@material-ui/core/IconButton"
import { makeStyles, Theme } from "@material-ui/core/styles"
import Tooltip from "@material-ui/core/Tooltip"
import CreateIcon from "@material-ui/icons/AddBoxOutlined"
import CreateIcon from "@material-ui/icons/AddOutlined"
import BuildIcon from "@material-ui/icons/BuildOutlined"
import PreviewIcon from "@material-ui/icons/VisibilityOutlined"
import {
Expand Down Expand Up @@ -200,7 +200,7 @@ export const TemplateVersionEditor: FC<TemplateVersionEditorProps> = ({
<div className={styles.sidebarAndEditor}>
<div className={styles.sidebar}>
<div className={styles.sidebarTitle}>
Template Editor
Template files
<div className={styles.sidebarActions}>
<Tooltip title="Create File" placement="top">
<IconButton
Expand Down Expand Up @@ -420,19 +420,23 @@ const useStyles = makeStyles<
},
sidebar: {
minWidth: 256,
backgroundColor: theme.palette.background.paper,
borderRight: `1px solid ${theme.palette.divider}`,
},
sidebarTitle: {
fontSize: 12,
fontSize: 10,
textTransform: "uppercase",
padding: "8px 16px",
color: theme.palette.text.hint,
padding: theme.spacing(1, 2),
color: theme.palette.text.primary,
fontWeight: 500,
letterSpacing: "0.5px",
display: "flex",
alignItems: "center",
},
sidebarActions: {
marginLeft: "auto",
"& svg": {
fill: theme.palette.text.hint,
fill: theme.palette.text.primary,
},
},
editorPane: {
Expand Down