Skip to content
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

fix(PasswordInput): Update placement of Show/Hide button on Large input size #1136

Merged
merged 8 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions .changeset/fix-passInputLarge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-magma-dom': patch
---

fix(PasswordInput): Update placement of Show/Hide button on Large input size
11 changes: 5 additions & 6 deletions packages/react-magma-dom/src/components/InputBase/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,8 @@ const PasswordButtonContainer = styled.span<{
background-color: transparent;
width: 0;
transform: translate(
-${props => (props.size === InputSize.large ? props.theme.spaceScale.spacing10 : '60px')},
${props =>
props.size === InputSize.large ? props.theme.spaceScale.spacing03 : '5px'}
-${props => (props.size === InputSize.large ? '58px' : '60px')},
${props => props.theme.spaceScale.spacing02}
);
`;

Expand Down Expand Up @@ -581,13 +580,13 @@ export const InputBase = React.forwardRef<HTMLInputElement, InputBaseProps>(
const [value, setValue] = React.useState<
string | ReadonlyArray<string> | number
>(
props.defaultValue !== undefined &&
props.defaultValue !== null
props.defaultValue !== undefined && props.defaultValue !== null
? props.defaultValue
: props.value || ''
);

const maxLengthNum = !hasCharacterCounter && maxLength ? maxLength : undefined;
const maxLengthNum =
!hasCharacterCounter && maxLength ? maxLength : undefined;

React.useEffect(() => {
if (props.value !== undefined && props.value !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { PasswordInput, PasswordInputProps } from '.';
import { Card, CardBody } from '../Card';
import { Story, Meta } from '@storybook/react/types-6-0';
import { LabelPosition } from '../Label';
import { InputSize } from '../InputBase';

const Template: Story<PasswordInputProps> = args => (
<PasswordInput {...args} labelText="Password" />
Expand Down Expand Up @@ -35,6 +36,12 @@ export default {
type: 'number',
},
},
inputSize: {
control: {
type: 'select',
options: InputSize,
}
}
},
} as Meta;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ export interface PasswordInputProps
* @default "Hide"
*/
hidePasswordButtonText?: string;
/**
* Relative size of the component
* @default InputSize.medium
*/
inputSize?: InputSize;
isInverse?: boolean;
/**
* If true, label text will be hidden visually, but will still be read by assistive technology
Expand Down