-
Notifications
You must be signed in to change notification settings - Fork 937
chore: use emotion for styling (pt. 5) #10261
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
37 commits
Select commit
Hold shift + click to select a range
8ef2a58
emotion: `RuntimeErrorState`
aslilac c455b38
emotion: `FileUpload`
aslilac 4e033c6
🧹
aslilac 8d7e9a8
emotion: `FullPageForm`
aslilac eeb1b93
emotion: `EnterpriseSnackbar`
aslilac 04adebe
emotion: `GlobalSnackbar`
aslilac 2b49f62
emotion: `FullWidthPageHeader`
aslilac 57b1f68
emotion: `PageButton`
aslilac 715282c
emotion: `PaginationWidgetBase`
aslilac 8927e23
emotion: `Paywall`
aslilac 1857b71
emotion: `AgentLatency`
aslilac 5bacdda
emotion: `AgentOutdatedTooltip`
aslilac 9924a32
emotion: `PortForwardButton`
aslilac d49898c
emotion: `Section`
aslilac f4373dd
emotion: `AppLink`
aslilac 351e310
🧹
aslilac 196c7a8
emotion: `SensitiveValue`
aslilac 3d14e1b
emotion: `BuildRow`
aslilac 58daeaf
emotion: `ResetPasswordDialog`
aslilac 8a5e35f
emotion: `UsersTableBody`
aslilac c8a94a5
emotion: `Workspace`
aslilac 7058b7f
emotion: `UpdateBuildParametersDialog`
aslilac 0972a1c
emotion: `SignInLayout`
aslilac 2481674
emotion: `SSHButton`
aslilac f09e627
emotion: `TableLoader`
aslilac 7135de3
emotion: `Welcome`
aslilac 193c364
emotion: `TimelineDateRow`
aslilac 007e048
emotion: `SSHKeysPageView`
aslilac 10f041c
emotion: `WorkspaceSettingsLayout`
aslilac ec8cc6e
emotion: `TemplateLayout`
aslilac da1a641
emotion: `EmptyTemplates`
aslilac 69fd068
emotion: `TemplateVariablesPageView`
aslilac fcc868b
Merge branch 'main' into emotional-damage-5
aslilac 4b92f61
Revert "emotion: `AgentOutdatedTooltip`"
aslilac c2abccb
Revert "emotion: `PortForwardButton`"
aslilac 9f73611
Revert "emotion: `Section`"
aslilac e3986d2
Revert "emotion: `AppLink`"
aslilac 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
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 |
---|---|---|
@@ -1,13 +1,12 @@ | ||
import { makeStyles } from "@mui/styles"; | ||
import { Stack } from "components/Stack/Stack"; | ||
import { FC, DragEvent, useRef, ReactNode } from "react"; | ||
import { type FC, type DragEvent, useRef, type ReactNode } from "react"; | ||
import UploadIcon from "@mui/icons-material/CloudUploadOutlined"; | ||
import { useClickable } from "hooks/useClickable"; | ||
import CircularProgress from "@mui/material/CircularProgress"; | ||
import { combineClasses } from "utils/combineClasses"; | ||
import IconButton from "@mui/material/IconButton"; | ||
import RemoveIcon from "@mui/icons-material/DeleteOutline"; | ||
import FileIcon from "@mui/icons-material/FolderOutlined"; | ||
import { css, type Interpolation, type Theme } from "@emotion/react"; | ||
|
||
const useFileDrop = ( | ||
callback: (file: File) => void, | ||
|
@@ -62,7 +61,6 @@ export const FileUpload: FC<FileUploadProps> = ({ | |
extension, | ||
fileTypeRequired, | ||
}) => { | ||
const styles = useStyles(); | ||
const inputRef = useRef<HTMLInputElement>(null); | ||
const tarDrop = useFileDrop(onUpload, fileTypeRequired); | ||
|
||
|
@@ -75,7 +73,7 @@ export const FileUpload: FC<FileUploadProps> = ({ | |
if (!isUploading && file) { | ||
return ( | ||
<Stack | ||
className={styles.file} | ||
css={styles.file} | ||
direction="row" | ||
justifyContent="space-between" | ||
alignItems="center" | ||
|
@@ -95,23 +93,20 @@ export const FileUpload: FC<FileUploadProps> = ({ | |
return ( | ||
<> | ||
<div | ||
className={combineClasses({ | ||
[styles.root]: true, | ||
[styles.disabled]: isUploading, | ||
})} | ||
css={[styles.root, isUploading && styles.disabled]} | ||
{...clickable} | ||
{...tarDrop} | ||
> | ||
<Stack alignItems="center" spacing={1}> | ||
{isUploading ? ( | ||
<CircularProgress size={32} /> | ||
) : ( | ||
<UploadIcon className={styles.icon} /> | ||
<UploadIcon css={styles.icon} /> | ||
)} | ||
|
||
<Stack alignItems="center" spacing={0.5}> | ||
<span className={styles.title}>{title}</span> | ||
<span className={styles.description}>{description}</span> | ||
<span css={styles.title}>{title}</span> | ||
<span css={styles.description}>{description}</span> | ||
</Stack> | ||
</Stack> | ||
</div> | ||
|
@@ -120,7 +115,7 @@ export const FileUpload: FC<FileUploadProps> = ({ | |
type="file" | ||
data-testid="file-upload" | ||
ref={inputRef} | ||
className={styles.input} | ||
css={styles.input} | ||
accept={extension} | ||
onChange={(event) => { | ||
const file = event.currentTarget.files?.[0]; | ||
|
@@ -133,48 +128,48 @@ export const FileUpload: FC<FileUploadProps> = ({ | |
); | ||
}; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
root: { | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "center", | ||
borderRadius: theme.shape.borderRadius, | ||
border: `2px dashed ${theme.palette.divider}`, | ||
padding: theme.spacing(6), | ||
cursor: "pointer", | ||
|
||
"&:hover": { | ||
backgroundColor: theme.palette.background.paper, | ||
}, | ||
}, | ||
const styles = { | ||
root: (theme) => css` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a question for my own understanding: is there a difference between an interpolation function returning an object, vs a tagged css template literal? Is the main use case to enable the const styles = {
"&:hover": (theme) => ({
background-color: ${theme.palette.background.paper};
})
}; |
||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
border-radius: ${theme.shape.borderRadius}px; | ||
border: 2px dashed ${theme.palette.divider}; | ||
padding: ${theme.spacing(6)}; | ||
cursor: pointer; | ||
|
||
&:hover { | ||
background-color: ${theme.palette.background.paper}; | ||
} | ||
`, | ||
|
||
disabled: { | ||
pointerEvents: "none", | ||
opacity: 0.75, | ||
}, | ||
|
||
icon: { | ||
icon: (theme) => ({ | ||
fontSize: theme.spacing(8), | ||
}, | ||
}), | ||
|
||
title: { | ||
title: (theme) => ({ | ||
fontSize: theme.spacing(2), | ||
}, | ||
}), | ||
|
||
description: { | ||
description: (theme) => ({ | ||
color: theme.palette.text.secondary, | ||
textAlign: "center", | ||
maxWidth: theme.spacing(50), | ||
}, | ||
}), | ||
|
||
input: { | ||
display: "none", | ||
}, | ||
|
||
file: { | ||
file: (theme) => ({ | ||
borderRadius: theme.shape.borderRadius, | ||
border: `1px solid ${theme.palette.divider}`, | ||
padding: theme.spacing(2), | ||
background: theme.palette.background.paper, | ||
}, | ||
})); | ||
}), | ||
} 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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
I think there's some nuance that I'm missing. Is there anything stopping this style from being defined outside the component, and being defined via the interpolation function syntax that some of the other styles are using?
I don't expect it to matter much performance-wise – just curious