Skip to content

Commit cd65755

Browse files
BrunoQuaresmaammario
authored andcommitted
refactor(site): Improve and fix loading buttons (coder#7719)
1 parent 6b2e2bd commit cd65755

File tree

4 files changed

+33
-15
lines changed

4 files changed

+33
-15
lines changed

site/src/components/Navbar/NavbarView.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import Divider from "@mui/material/Divider"
2323
import HelpOutline from "@mui/icons-material/HelpOutline"
2424
import Tooltip from "@mui/material/Tooltip"
2525
import Skeleton from "@mui/material/Skeleton"
26+
import { BUTTON_SM_HEIGHT } from "theme/theme"
2627

2728
export const USERS_LINK = `/users?filter=${encodeURIComponent("status:active")}`
2829

@@ -195,7 +196,7 @@ const ProxyMenu: FC<{ proxyContextValue: ProxyContextValue }> = ({
195196
return (
196197
<Skeleton
197198
width="160px"
198-
height={30}
199+
height={BUTTON_SM_HEIGHT}
199200
sx={{ borderRadius: "4px", transform: "none" }}
200201
/>
201202
)

site/src/components/UserDropdown/UsersDropdown.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { BorderedMenu } from "../BorderedMenu/BorderedMenu"
99
import { CloseDropdown, OpenDropdown } from "../DropdownArrows/DropdownArrows"
1010
import { UserAvatar } from "../UserAvatar/UserAvatar"
1111
import { UserDropdownContent } from "../UserDropdownContent/UserDropdownContent"
12+
import { BUTTON_SM_HEIGHT } from "theme/theme"
1213

1314
export interface UserDropdownProps {
1415
user: TypesGen.User
@@ -42,7 +43,15 @@ export const UserDropdown: FC<PropsWithChildren<UserDropdownProps>> = ({
4243
>
4344
<div className={styles.inner}>
4445
<Badge overlap="circular">
45-
<UserAvatar username={user.username} avatarURL={user.avatar_url} />
46+
<UserAvatar
47+
sx={{
48+
width: BUTTON_SM_HEIGHT,
49+
height: BUTTON_SM_HEIGHT,
50+
fontSize: 16,
51+
}}
52+
username={user.username}
53+
avatarURL={user.avatar_url}
54+
/>
4655
</Badge>
4756
{anchorEl ? (
4857
<CloseDropdown color={colors.gray[6]} />

site/src/components/WorkspaceActions/WorkspaceActions.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,7 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
102102
? buttonMapping[ButtonTypesEnum.updating]
103103
: buttonMapping[ButtonTypesEnum.update])}
104104
{isRestarting && buttonMapping[ButtonTypesEnum.restarting]}
105-
{!isRestarting &&
106-
actionsByStatus.map((action) => (
107-
<span key={action}>{buttonMapping[action]}</span>
108-
))}
105+
{!isRestarting && actionsByStatus.map((action) => buttonMapping[action])}
109106
{canCancel && <CancelButton handleAction={handleCancel} />}
110107
<div>
111108
<IconButton

site/src/theme/theme.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { ThemeOptions, createTheme, Theme } from "@mui/material/styles"
33
import { BODY_FONT_FAMILY, borderRadius } from "./constants"
44

55
// MUI does not have aligned heights for buttons and inputs so we have to "hack" it a little bit
6-
const BUTTON_LG_HEIGHT = 42
7-
const BUTTON_MD_HEIGHT = 36
8-
const BUTTON_SM_HEIGHT = 30
6+
export const BUTTON_LG_HEIGHT = 40
7+
export const BUTTON_MD_HEIGHT = 36
8+
export const BUTTON_SM_HEIGHT = 32
99

1010
export type PaletteIndex = keyof Theme["palette"]
1111
export type PaletteStatusIndex = Extract<
@@ -110,6 +110,8 @@ dark = createTheme(dark, {
110110
},
111111
},
112112
},
113+
// Button styles are based on
114+
// https://tailwindui.com/components/application-ui/elements/buttons
113115
MuiButtonBase: {
114116
defaultProps: {
115117
disableRipple: true,
@@ -127,20 +129,26 @@ dark = createTheme(dark, {
127129
fontWeight: 500,
128130
height: BUTTON_MD_HEIGHT,
129131
padding: theme.spacing(1, 2),
132+
borderRadius: "6px",
133+
fontSize: 14,
130134

131135
whiteSpace: "nowrap",
132136
":focus-visible": {
133137
outline: `2px solid ${theme.palette.primary.main}`,
134138
},
139+
140+
"& .MuiLoadingButton-loadingIndicator": {
141+
width: 14,
142+
height: 14,
143+
},
144+
145+
"& .MuiLoadingButton-loadingIndicator .MuiCircularProgress-root": {
146+
width: "inherit !important",
147+
height: "inherit !important",
148+
},
135149
}),
136150
sizeSmall: {
137-
borderRadius: 6,
138151
height: BUTTON_SM_HEIGHT,
139-
140-
"& .MuiCircularProgress-root": {
141-
width: "14px !important",
142-
height: "14px !important",
143-
},
144152
},
145153
sizeLarge: {
146154
height: BUTTON_LG_HEIGHT,
@@ -174,6 +182,9 @@ dark = createTheme(dark, {
174182
fontSize: 13,
175183
},
176184
},
185+
startIcon: {
186+
marginLeft: "-2px",
187+
},
177188
},
178189
},
179190
MuiTableContainer: {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy