Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Changed
---

Enhance MUI Adornments: Unify Theme for Autocomplete and TextField Components via InputBase Styling ([#11807](https://github.com/linode/manager/pull/11807))
3 changes: 3 additions & 0 deletions packages/manager/src/assets/icons/chevron-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/manager/src/assets/icons/close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import {
InputAdornment,
TextField,
} from '@linode/ui';
import Clear from '@mui/icons-material/Clear';
import Search from '@mui/icons-material/Search';
import { styled } from '@mui/material/styles';
import * as React from 'react';
import { debounce } from 'throttle-debounce';

import type { TextFieldProps } from '@linode/ui';
import Close from 'src/assets/icons/close.svg';
import Search from 'src/assets/icons/search.svg';

import type { InputProps, TextFieldProps } from '@linode/ui';

export interface DebouncedSearchProps extends TextFieldProps {
/**
* Class name to apply to the component.
*/
className?: string;
/**
* Whether to show a clear button at the end of the input.
Expand All @@ -23,9 +26,18 @@ export interface DebouncedSearchProps extends TextFieldProps {
* @default 400
*/
debounceTime?: number;
/**
* Default value of the input.
*/
defaultValue?: string;
/**
* Whether to hide the label.
*/
hideLabel?: boolean;

/**
* Custom props to apply to the input element.
*/
inputSlotProps?: InputProps;
/**
* Determines if the textbox is currently searching for inputted query
*/
Expand All @@ -34,19 +46,25 @@ export interface DebouncedSearchProps extends TextFieldProps {
* Function to perform when searching for query
*/
onSearch: (query: string) => void;
/**
* Placeholder text for the input.
*/
placeholder?: string;
/**
* Value of the input.
*/
value: string;
}

export const DebouncedSearchTextField = React.memo(
(props: DebouncedSearchProps) => {
const {
InputProps,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecated - using slotProps

className,
clearable,
debounceTime,
defaultValue,
hideLabel,
inputSlotProps,
isSearching,
label,
onSearch,
Expand Down Expand Up @@ -76,38 +94,35 @@ export const DebouncedSearchTextField = React.memo(

return (
<TextField
InputProps={{
endAdornment: isSearching ? (
<InputAdornment position="end">
<CircleProgress size="sm" />
</InputAdornment>
) : (
clearable &&
textFieldValue && (
<IconButton
onClick={() => {
setTextFieldValue('');
onSearch('');
}}
aria-label="Clear"
size="small"
>
<Clear
sx={(theme) => ({
'&&': {
color: theme.color.grey1,
},
})}
/>
</IconButton>
)
),
startAdornment: (
<InputAdornment position="end">
<StyledSearchIcon />
</InputAdornment>
),
...InputProps,
slotProps={{
input: {
endAdornment: (
<InputAdornment position="end">
{isSearching && <CircleProgress noPadding size="xs" />}
{clearable && Boolean(textFieldValue) && (
<IconButton
onClick={() => {
setTextFieldValue('');
onSearch('');
}}
sx={{
padding: 0,
}}
aria-label="Clear"
size="small"
>
<Close />
</IconButton>
)}
</InputAdornment>
),
startAdornment: (
<InputAdornment position="start">
<Search data-testid="SearchIcon" />
</InputAdornment>
),
...inputSlotProps,
},
}}
className={className}
data-qa-debounced-search
Expand All @@ -122,9 +137,3 @@ export const DebouncedSearchTextField = React.memo(
);
}
);

const StyledSearchIcon = styled(Search)(({ theme }) => ({
'&&, &&:hover': {
color: theme.color.grey1,
},
}));
27 changes: 17 additions & 10 deletions packages/manager/src/components/ImageSelect/ImageSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { Autocomplete, Box, Notice, Stack, Typography } from '@linode/ui';
import {
Autocomplete,
Box,
InputAdornment,
Notice,
Stack,
Typography,
} from '@linode/ui';
import { DateTime } from 'luxon';
import React, { useMemo } from 'react';

Expand Down Expand Up @@ -178,15 +185,15 @@ export const ImageSelect = (props: Props) => {
InputProps: {
startAdornment:
!multiple && value && !Array.isArray(value) ? (
<OSIcon
fontSize="24px"
height="24px"
os={value.vendor ?? ''}
pl={1}
position="relative"
pr={2}
top={1}
/>
<InputAdornment position="start">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using adornments, let's ensure we use InputAdornment to wrap things for proper theme-level styling.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we create a ticket for this? Found several adornments not wrapped in InputAdornment in the codebase:

  • CopyableTextField
  • RegionSelect
  • DatabaseEngineSelect
  • StackScriptLandingTable

<OSIcon
fontSize="20px"
height="20px"
os={value.vendor ?? ''}
position="relative"
top={1}
/>
</InputAdornment>
) : null,
},
}}
Expand Down
22 changes: 14 additions & 8 deletions packages/manager/src/components/PasswordInput/HideShowText.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { InputAdornment } from '@linode/ui';
import { TextField } from '@linode/ui';
import Visibility from '@mui/icons-material/Visibility';
import VisibilityOff from '@mui/icons-material/VisibilityOff';
import * as React from 'react';

import type { TextFieldProps } from '@linode/ui';

export const HideShowText = (props: TextFieldProps) => {
const [hidden, setHidden] = React.useState(true);

Expand All @@ -13,16 +13,22 @@ export const HideShowText = (props: TextFieldProps) => {
return (
<TextField
{...props}
InputProps={{
startAdornment: hidden ? (
<Visibility onClick={toggle} style={{ marginLeft: 14 }} />
) : (
<VisibilityOff onClick={toggle} style={{ marginLeft: 14 }} />
),
}}
dataAttrs={{
'data-qa-hide': hidden,
}}
slotProps={{
input: {
startAdornment: (
<InputAdornment position="start">
{hidden ? (
<Visibility onClick={toggle} />
) : (
<VisibilityOff onClick={toggle} />
)}
</InputAdornment>
),
},
}}
autoComplete="off"
type={hidden ? 'password' : 'text'}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const useStyles = makeStyles()((theme: Theme) => ({
[theme.breakpoints.down('sm')]: {
textAlign: 'center',
},
top: 2,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed since alignItems: 'center' made more sense.

},
}));

Expand All @@ -53,15 +52,14 @@ export const StrengthIndicator = (props: Props) => {

return (
<Grid
className={classes.root}
container
data-qa-strength={strength}
spacing={1}
sx={{
alignItems: 'flex-end',
alignItems: 'center',
paddingLeft: 0,
paddingRight: 0,
}}
className={classes.root}
container
data-qa-strength={strength}
>
{Array.from(Array(3), (v, idx) => idx + 1).map((idx) => (
<Grid className={classes.blockOuter} key={idx} size={3}>
Expand All @@ -76,7 +74,7 @@ export const StrengthIndicator = (props: Props) => {
/>
</Grid>
))}
<Grid className="py0" size={3}>
<Grid paddingLeft={1} size={3}>
<Typography
className={classes.strengthText}
data-qa-password-strength
Expand Down
48 changes: 4 additions & 44 deletions packages/manager/src/features/Help/Panels/AlgoliaSearchBar.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Autocomplete, InputAdornment, Notice } from '@linode/ui';
import Search from '@mui/icons-material/Search';
import * as React from 'react';
import { withRouter } from 'react-router-dom';
import { debounce } from 'throttle-debounce';

import Search from 'src/assets/icons/search.svg';

import withSearch from '../SearchHOC';
import { SearchItem } from './SearchItem';

Expand Down Expand Up @@ -82,8 +83,7 @@ const AlgoliaSearchBar = (props: AlgoliaSearchBarProps) => {
<Notice
sx={(theme) => ({
'& p': {
color: theme.color.white,
fontFamily: 'LatoWeb',
color: theme.tokens.color.Neutrals.White,
},
})}
spacingTop={8}
Expand All @@ -102,32 +102,6 @@ const AlgoliaSearchBar = (props: AlgoliaSearchBarProps) => {
/>
);
}}
slotProps={{
paper: {
sx: (theme) => ({
'& .MuiAutocomplete-listbox': {
'&::-webkit-scrollbar': {
display: 'none',
},
border: 'none !important',
msOverflowStyle: 'none',
scrollbarWidth: 'none',
},
'& .MuiAutocomplete-option': {
':hover': {
backgroundColor:
theme.name == 'light'
? `${theme.tokens.color.Brand[10]} !important`
: `${theme.tokens.color.Neutrals[80]} !important`,
color: theme.color.black,
transition: 'background-color 0.2s',
},
},
boxShadow: '0px 2px 8px 0px rgba(58, 59, 63, 0.18)',
marginTop: 0.5,
}),
},
}}
sx={(theme) => ({
maxHeight: 500,
[theme.breakpoints.up('md')]: {
Expand All @@ -139,23 +113,9 @@ const AlgoliaSearchBar = (props: AlgoliaSearchBarProps) => {
InputProps: {
startAdornment: (
<InputAdornment position="start">
<Search
sx={(theme) => ({
color: `${theme.tokens.search.Default.SearchIcon} !important`,
})}
data-qa-search-icon
/>
<Search data-qa-search-icon />
</InputAdornment>
),
sx: (theme) => ({
'&.Mui-focused': {
borderColor: `${theme.tokens.color.Brand[70]} !important`,
boxShadow: 'none',
},
':hover': {
borderColor: theme.tokens.search.Hover.Border,
},
}),
},
hideLabel: true,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,11 @@ export const ImagesLanding = () => {
InputProps={{
endAdornment: query && (
<InputAdornment position="end">
{isFetching && <CircleProgress size="sm" />}
{isFetching && <CircleProgress noPadding size="xs" />}
<IconButton
sx={{
padding: 0,
}}
aria-label="Clear"
data-testid="clear-images-search"
onClick={resetSearch}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ export const AppSelect = (props: Props) => {
)}
<Stack direction="row" flexWrap="wrap" gap={1}>
<DebouncedSearchTextField
InputProps={{ sx: { maxWidth: 'unset !important' } }}
containerProps={{ flexGrow: 1 }}
disabled={isLoading}
fullWidth
hideLabel
inputSlotProps={{ sx: { maxWidth: 'unset !important' } }}
label="Search marketplace"
loading={isLoading}
noMarginTop
Expand Down
Loading