Skip to content

Commit

Permalink
fix: remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
NasgulNexus committed Sep 6, 2024
1 parent 5cf8b31 commit 131354b
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 36 deletions.
5 changes: 0 additions & 5 deletions src/components/controls/PasswordInput/PasswordInput.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ $block: '.#{variables.$ns}password-input';
}
}

&__additional-end-content {
display: flex;
align-items: center;
}

&__copy-button {
margin-inline-end: 4px;
}
Expand Down
27 changes: 14 additions & 13 deletions src/components/controls/PasswordInput/PasswordInput.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import React from 'react';

import {Eye, EyeSlash} from '@gravity-ui/icons';
Expand All @@ -17,17 +19,16 @@ import './PasswordInput.scss';

const b = block('password-input');

export type PasswordInputProps = Required<Pick<TextInputProps, 'onUpdate' | 'value'>> &
Omit<TextInputProps, 'type'> & {
/** Show copy button */
showCopyButton?: boolean;
/** Show reveal button */
showRevealButton?: boolean;
/** Disable the tooltip for the copy button. The tooltip will not be displayed */
hasCopyTooltip?: boolean;
/** Disable the tooltip for the reveal button. The tooltip will not be displayed */
hasRevealTooltip?: boolean;
};
export type PasswordInputProps = Omit<TextInputProps, 'type'> & {
/** Show copy button */
showCopyButton?: boolean;
/** Show reveal button */
showRevealButton?: boolean;
/** Disable the tooltip for the copy button. The tooltip will not be displayed */
hasCopyTooltip?: boolean;
/** Disable the tooltip for the reveal button. The tooltip will not be displayed */
hasRevealTooltip?: boolean;
};

export const PasswordInput = (props: PasswordInputProps) => {
const {
Expand Down Expand Up @@ -57,7 +58,7 @@ export const PasswordInput = (props: PasswordInputProps) => {
const {actionButtonSize, iconSize} = getActionButtonSizeAndIconSize(size);

return (
<div className={b('additional-end-content')}>
<React.Fragment>
{endContent || rightContent}
{value && showCopyButton ? (
<ClipboardButton
Expand Down Expand Up @@ -89,7 +90,7 @@ export const PasswordInput = (props: PasswordInputProps) => {
</Button>
</ActionTooltip>
) : null}
</div>
</React.Fragment>
);
}, [
showRevealButton,
Expand Down
2 changes: 0 additions & 2 deletions src/components/controls/PasswordInput/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ LANDING_BLOCK-->

`TextInput` [properties](https://github.com/gravity-ui/uikit/blob/main/src/components/controls/TextInput/README.md#properties), with some exceptions and additions:

- `value` is required property;
- `onUpdate` is required property;
- `type` is omitted;

| Name | Description | Type | Default |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@ import React from 'react';
import type {Meta, StoryFn} from '@storybook/react';

import {Button} from '../../../Button';
import {Flex} from '../../../layout/Flex/Flex';
import {cn} from '../../../utils/cn';
import {Flex, spacing} from '../../../layout';
import type {PasswordInputProps} from '../PasswordInput';
import {PasswordInput} from '../PasswordInput';

import './PasswordInputStories.scss';

const b = cn('password-input-stories');

export default {
title: 'Components/Inputs/PasswordInput',
component: PasswordInput,
Expand Down Expand Up @@ -52,9 +47,9 @@ const WithGenerateRandomValueTemplate: StoryFn<PasswordInputProps> = (args) => {
return (
<Flex>
<PasswordInput {...args} onUpdate={setValue} value={value} />
<Button onClick={generateRandomValue} className={b('button-generate-random-value')}>
Generate random value
</Button>
<Flex className={spacing({ml: 2})}>
<Button onClick={generateRandomValue}>Generate random value</Button>
</Flex>
</Flex>
);
};
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {test} from '~playwright/core';

import {PasswordInputStories} from './helpersPlaywright';

test.describe('PasswordInputStories', () => {
test.describe('PasswordInput', () => {
test('render story: <Default>', async ({mount, expectScreenshot}) => {
await mount(<PasswordInputStories.Default />);

Expand Down
2 changes: 1 addition & 1 deletion src/components/controls/PasswordInput/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import {addComponentKeysets} from '../../../utils/addComponentKeysets';
import en from './en.json';
import ru from './ru.json';

const COMPONENT = 'passwordInput';
const COMPONENT = 'PasswordInput';

export const i18n = addComponentKeysets({en, ru}, COMPONENT);

0 comments on commit 131354b

Please sign in to comment.