Skip to content

Commit

Permalink
Merge pull request #1941 from okta/ee/icon-button
Browse files Browse the repository at this point in the history
refactor(odyssey-react-mui): use IconButton within Form Fields
  • Loading branch information
edburyenegren-okta authored Aug 22, 2023
2 parents 267aeab + 2e4825c commit 58611b2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
14 changes: 6 additions & 8 deletions packages/odyssey-react-mui/src/PasswordField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* See the License for the specific language governing permissions and limitations under the License.
*/

import { InputAdornment, InputBase } from "@mui/material";
import { InputAdornment, InputBase, IconButton } from "@mui/material";
import {
ChangeEventHandler,
FocusEventHandler,
Expand All @@ -21,7 +21,6 @@ import {
} from "react";

import { ShowIcon, HideIcon } from "./icons.generated";
import { Button } from "./Button";
import { Field } from "./Field";

export type PasswordFieldProps = {
Expand Down Expand Up @@ -122,13 +121,12 @@ const PasswordField = forwardRef<HTMLInputElement, PasswordFieldProps>(
autoFocus={hasInitialFocus}
endAdornment={
<InputAdornment position="end">
<Button
ariaLabel="toggle password visibility"
endIcon={inputType === "password" ? <ShowIcon /> : <HideIcon />}
<IconButton
aria-label="toggle password visibility"
onClick={togglePasswordVisibility}
size="small"
variant="floating"
/>
>
{inputType === "password" ? <ShowIcon /> : <HideIcon />}
</IconButton>
</InputAdornment>
}
id={id}
Expand Down
16 changes: 7 additions & 9 deletions packages/odyssey-react-mui/src/SearchField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

import { useState, useEffect } from "react";
import { InputAdornment, InputBase } from "@mui/material";
import { InputAdornment, InputBase, IconButton } from "@mui/material";
import {
ChangeEventHandler,
FocusEventHandler,
Expand All @@ -23,7 +23,6 @@ import {

import { CloseCircleFilledIcon, SearchIcon } from "./icons.generated";
import { Field } from "./Field";
import { Button } from "./Button";

export type SearchFieldProps = {
/**
Expand Down Expand Up @@ -123,15 +122,14 @@ const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(
endAdornment={
uncontrolledValue && (
<InputAdornment position="end">
<Button
ariaLabel="Clear"
isDisabled={isDisabled}
label=""
<IconButton
aria-label="Clear"
disabled={isDisabled}
onClick={onClear}
size="small"
startIcon={<CloseCircleFilledIcon />}
variant="floating"
/>
>
<CloseCircleFilledIcon />
</IconButton>
</InputAdornment>
)
}
Expand Down
7 changes: 7 additions & 0 deletions packages/odyssey-react-mui/src/theme/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,13 @@ export const components = (
},
},
},
MuiIconButton: {
styleOverrides: {
root: {
padding: odysseyTokens.Spacing1,
},
},
},
MuiInput: {
defaultProps: {
disableUnderline: true,
Expand Down

0 comments on commit 58611b2

Please sign in to comment.