Skip to content

Commit

Permalink
feat(Textarea): add align (#6434)
Browse files Browse the repository at this point in the history
- closed #6363
  • Loading branch information
SevereCloud authored Jan 23, 2024
1 parent a261ad2 commit b8a7a18
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ export const TextareaPlayground = (props: ComponentPlaygroundProps) => {
{
status: ['error', 'valid'],
},
{
align: ['center', 'right'],
defaultValue: [
'Музыка\nСпорт\nФотография\nПлавание\nПрограммирование\nПутешествия\nКниги\nСериалы\nФильмы\nНастольные игры',
],
},
]}
>
{(props: TextareaProps) => <Textarea {...props} />}
Expand Down
8 changes: 8 additions & 0 deletions packages/vkui/src/components/Textarea/Textarea.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,11 @@
.Textarea__el:disabled::placeholder {
color: var(--vkui--color_text_secondary);
}

.Textarea--align-center .Textarea__el {
text-align: center;
}

.Textarea--align-right .Textarea__el {
text-align: end;
}
6 changes: 5 additions & 1 deletion packages/vkui/src/components/Textarea/Textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { classNames } from '@vkontakte/vkjs';
import { useAdaptivity } from '../../hooks/useAdaptivity';
import { useEnsuredControl } from '../../hooks/useEnsuredControl';
import { useExternRef } from '../../hooks/useExternRef';
import { HasRef, HasRootRef } from '../../types';
import { HasAlign, HasRef, HasRootRef } from '../../types';
import { FormField, FormFieldProps } from '../FormField/FormField';
import { Text } from '../Typography/Text/Text';
import styles from './Textarea.module.css';
Expand All @@ -18,6 +18,7 @@ export interface TextareaProps
HasRef<HTMLTextAreaElement>,
HasRootRef<HTMLElement>,
Pick<React.CSSProperties, 'maxHeight'>,
HasAlign,
Pick<FormFieldProps, 'status'> {
grow?: boolean;
onResize?(el: HTMLTextAreaElement): void;
Expand All @@ -40,6 +41,7 @@ export const Textarea = ({
status,
onChange: onChangeProp,
value: valueProp,
align,
...restProps
}: TextareaProps) => {
const [value, onChange] = useEnsuredControl({
Expand Down Expand Up @@ -71,6 +73,8 @@ export const Textarea = ({
className={classNames(
styles['Textarea'],
sizeY !== 'regular' && sizeYClassNames[sizeY],
align === 'right' && styles['Textarea--align-right'],
align === 'center' && styles['Textarea--align-center'],
className,
)}
style={style}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b8a7a18

Please sign in to comment.