Skip to content

Commit

Permalink
Merge branch 'daniel-schwartz-k:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
danielschwartz85 authored Jul 27, 2023
2 parents 123cba2 + 7c76574 commit c9bddce
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/components/common/textFieldCopy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { useState } from 'react'

export type ITextFieldCopyProps = Omit<TextFieldProps, 'onChange'> & {
onChange: (value: string) => void
ariaLabel?: string
}

export default function TextFieldCopy(props: ITextFieldCopyProps) {
const { value, error, onChange, ...rest } = props
const { value, error, onChange, ariaLabel, ...rest } = props
const [isHovered, setIsHovered] = useState(false)

return (
Expand All @@ -25,7 +26,10 @@ export default function TextFieldCopy(props: ITextFieldCopyProps) {
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
sx={{ '& textarea.MuiInputBase-inputMultiline': { mr: 5 } }}
InputProps={{ endAdornment: <CopyButton value={value} visible={!error && isHovered} /> }}
inputProps={ariaLabel ? { 'aria-label': ariaLabel } : undefined}
InputProps={{
endAdornment: <CopyButton value={value} visible={!error && isHovered} />,
}}
/>
)
}
2 changes: 2 additions & 0 deletions src/components/decoded/decoded.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default function JwtInput(props: IDecodedProps) {
<StyledCard>
<Stack spacing={1}>
<TextFieldCopy
ariaLabel="decoded header input"
id="header"
minRows={4}
maxRows={8}
Expand All @@ -51,6 +52,7 @@ export default function JwtInput(props: IDecodedProps) {
onBlur={onBlur}
/>
<TextFieldCopy
ariaLabel="decoded payload input"
id="payload"
minRows={8}
maxRows={12}
Expand Down
9 changes: 8 additions & 1 deletion src/components/encoded/encoded.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ export default function Encoded(props: IEncodedProps) {
<>
<StyledHeader variant="h4">{'Encoded'}</StyledHeader>
<StyledCard>
<TextFieldCopy value={value} placeholder="Paste JWT.." rows={10} error={error} onChange={onChange} />
<TextFieldCopy
value={value}
placeholder="Paste JWT.."
rows={10}
error={error}
onChange={onChange}
ariaLabel="encoded input"
/>
</StyledCard>
</>
)
Expand Down

0 comments on commit c9bddce

Please sign in to comment.