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(plasma-*): Fix padding on textarea #1209

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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.
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.
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.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export const config = {
${textAreaTokens.labelInnerFontWeight}: var(--plasma-typo-body-xxs-font-weight);
${textAreaTokens.labelInnerLetterSpacing}: var(--plasma-typo-body-xxs-letter-spacing);
${textAreaTokens.labelInnerLineHeight}: var(--plasma-typo-body-xxs-line-height);
${textAreaTokens.labelInnerTop}: 0rem;
${textAreaTokens.labelInnerMarginBottom}: 0rem;
${textAreaTokens.inputFontFamily}: var(--plasma-typo-body-xs-font-family);
${textAreaTokens.inputFontSize}: var(--plasma-typo-body-xs-font-size);
${textAreaTokens.inputFontStyle}: var(--plasma-typo-body-xs-font-style);
Expand Down Expand Up @@ -72,6 +74,8 @@ export const config = {
${textAreaTokens.labelInnerFontWeight}: var(--plasma-typo-body-xs-font-weight);
${textAreaTokens.labelInnerLetterSpacing}: var(--plasma-typo-body-xs-letter-spacing);
${textAreaTokens.labelInnerLineHeight}: var(--plasma-typo-body-xs-line-height);
${textAreaTokens.labelInnerTop}: 0.375rem;
${textAreaTokens.labelInnerMarginBottom}: 0.125rem;
${textAreaTokens.inputFontFamily}: var(--plasma-typo-body-s-font-family);
${textAreaTokens.inputFontSize}: var(--plasma-typo-body-s-font-size);
${textAreaTokens.inputFontStyle}: var(--plasma-typo-body-s-font-style);
Expand Down Expand Up @@ -111,6 +115,8 @@ export const config = {
${textAreaTokens.labelInnerFontWeight}: var(--plasma-typo-body-xs-font-weight);
${textAreaTokens.labelInnerLetterSpacing}: var(--plasma-typo-body-xs-letter-spacing);
${textAreaTokens.labelInnerLineHeight}: var(--plasma-typo-body-xs-line-height);
${textAreaTokens.labelInnerTop}: 0.375rem;
${textAreaTokens.labelInnerMarginBottom}: 0.125rem;
${textAreaTokens.inputFontFamily}: var(--plasma-typo-body-m-font-family);
${textAreaTokens.inputFontSize}: var(--plasma-typo-body-m-font-size);
${textAreaTokens.inputFontStyle}: var(--plasma-typo-body-m-font-style);
Expand Down Expand Up @@ -150,6 +156,8 @@ export const config = {
${textAreaTokens.labelInnerFontWeight}: var(--plasma-typo-body-xs-font-weight);
${textAreaTokens.labelInnerLetterSpacing}: var(--plasma-typo-body-xs-letter-spacing);
${textAreaTokens.labelInnerLineHeight}: var(--plasma-typo-body-xs-line-height);
${textAreaTokens.labelInnerTop}: 0.5625rem;
${textAreaTokens.labelInnerMarginBottom}: 0.125rem;
${textAreaTokens.inputFontFamily}: var(--plasma-typo-body-l-font-family);
${textAreaTokens.inputFontSize}: var(--plasma-typo-body-l-font-size);
${textAreaTokens.inputFontStyle}: var(--plasma-typo-body-l-font-style);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const meta: Meta<TextAreaProps> = {
...disableProps([
'helperBlock',
'$isFocused',
'label',
'contentRight',
'autoComplete',
'autoFocus',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ export const tokens = {
labelInnerLetterSpacing: '--plasma-textarea-label-inner-letter-spacing',
/** Высота строки для элемента label, когда он внутри и уменьшен */
labelInnerLineHeight: '--plasma-textarea-label-inner-line-height',
/** Отступ сверху для элемента textarea при фокусе */
labelInnerTop: '--plasma-textarea-label-inner-top',
/** Отступ между Label и TextArea */
labelInnerMarginBottom: '--plasma-textarea-label-inner-margin-bottom',
/** Шрифт для элемента textarea */
inputFontFamily: '--plasma-textarea-input-font-family',
/** Размер шрифта для элемента textarea */
Expand Down
18 changes: 14 additions & 4 deletions packages/plasma-new-hope/src/components/TextArea/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const fallbackStatusMap = {

// TODO: Перенести этот метод в файл applyDynamicLabel.ts
export const getDynamicLabelClasses = (props: TextAreaProps, focused: boolean) => {
const { readOnly, label, labelPlacement, autoResize, rows, value } = props;
const { readOnly, label, labelPlacement, autoResize, rows, value, size } = props;

// Добавить класс отвечающий за изменение цвета плейсхолдера при фокусе
const withFocusedOuterUpPlaceholder =
Expand All @@ -64,6 +64,7 @@ export const getDynamicLabelClasses = (props: TextAreaProps, focused: boolean) =
label &&
!autoResize &&
!rows &&
size !== 'xs' &&
((!readOnly && (value || focused)) || (readOnly && value))
? innerPlaceholderUp
: undefined;
Expand All @@ -72,7 +73,8 @@ export const getDynamicLabelClasses = (props: TextAreaProps, focused: boolean) =
const withHidePlaceholder =
(value && !label) ||
(labelPlacement === 'inner' && ((focused && !readOnly) || value) && label && (rows || autoResize)) ||
(labelPlacement === 'outer' && value)
(labelPlacement === 'outer' && value) ||
(labelPlacement === 'inner' && size === 'xs' && value)
? hidePlaceHolder
: undefined;

Expand Down Expand Up @@ -120,7 +122,7 @@ export const textAreaRoot = (Root: RootProps<HTMLTextAreaElement, TextAreaProps>
const overriddenView = status !== undefined ? fallbackStatusMap[status] : view;
const textareaHelperId = id ? `${id}-helper` : undefined;
const applyCustomWidth = resize !== 'horizontal' && resize !== 'both' && !cols;
const placeLabel = labelPlacement === 'inner' && label ? label : placeholder;
const placeLabel = labelPlacement === 'inner' && label && size !== 'xs' ? label : placeholder;

useResizeObserver(outerRef, (currentElement) => {
const { width: inlineWidth, height: inlineHeight } = currentElement.style;
Expand Down Expand Up @@ -153,7 +155,15 @@ export const textAreaRoot = (Root: RootProps<HTMLTextAreaElement, TextAreaProps>
);

const dynamicLabelClasses = getDynamicLabelClasses(
{ readOnly, label, labelPlacement, autoResize, rows, value: value || uncontrolledValue || defaultValue },
{
size,
readOnly,
label,
labelPlacement,
autoResize,
rows,
value: value || uncontrolledValue || defaultValue,
},
focused,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ const {
export const applyDynamicLabel = `
.${String(innerPlaceholderUp)} {
.${String(styledTextArea)} {
height: calc(var(--plasma_private-textarea-input-actual-height) - 1rem);
height: calc(var(--plasma_private-textarea-input-actual-height) - var(${tokens.labelInnerTop}));
}

.${String(styledTextAreaWrapper)} {
padding-top: calc(var(${tokens.inputPaddingTop}) + 1rem);
padding-top: calc(calc(var(${tokens.labelInnerTop}) + var(${tokens.labelInnerFontSize})) + var(${
tokens.labelInnerMarginBottom
}));
}

.${String(styledPlaceholder)} {
Expand All @@ -26,6 +28,7 @@ export const applyDynamicLabel = `
font-weight: var(${tokens.labelInnerFontWeight});
letter-spacing: var(${tokens.labelInnerLetterSpacing});
line-height: var(${tokens.labelInnerLineHeight});
top: var(${tokens.labelInnerTop});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export const config = {
${textAreaTokens.labelInnerFontWeight}: var(--plasma-typo-body-xxs-font-weight);
${textAreaTokens.labelInnerLetterSpacing}: var(--plasma-typo-body-xxs-letter-spacing);
${textAreaTokens.labelInnerLineHeight}: var(--plasma-typo-body-xxs-line-height);
${textAreaTokens.labelInnerTop}: 0rem;
${textAreaTokens.labelInnerMarginBottom}: 0rem;
${textAreaTokens.inputFontFamily}: var(--plasma-typo-body-xs-font-family);
${textAreaTokens.inputFontSize}: var(--plasma-typo-body-xs-font-size);
${textAreaTokens.inputFontStyle}: var(--plasma-typo-body-xs-font-style);
Expand Down Expand Up @@ -74,6 +76,8 @@ export const config = {
${textAreaTokens.labelInnerFontWeight}: var(--plasma-typo-body-xs-font-weight);
${textAreaTokens.labelInnerLetterSpacing}: var(--plasma-typo-body-xs-letter-spacing);
${textAreaTokens.labelInnerLineHeight}: var(--plasma-typo-body-xs-line-height);
${textAreaTokens.labelInnerTop}: 0.375rem;
${textAreaTokens.labelInnerMarginBottom}: 0.125rem;
${textAreaTokens.inputFontFamily}: var(--plasma-typo-body-s-font-family);
${textAreaTokens.inputFontSize}: var(--plasma-typo-body-s-font-size);
${textAreaTokens.inputFontStyle}: var(--plasma-typo-body-s-font-style);
Expand Down Expand Up @@ -113,6 +117,8 @@ export const config = {
${textAreaTokens.labelInnerFontWeight}: var(--plasma-typo-body-xs-font-weight);
${textAreaTokens.labelInnerLetterSpacing}: var(--plasma-typo-body-xs-letter-spacing);
${textAreaTokens.labelInnerLineHeight}: var(--plasma-typo-body-xs-line-height);
${textAreaTokens.labelInnerTop}: 0.375rem;
${textAreaTokens.labelInnerMarginBottom}: 0.125rem;
${textAreaTokens.inputFontFamily}: var(--plasma-typo-body-m-font-family);
${textAreaTokens.inputFontSize}: var(--plasma-typo-body-m-font-size);
${textAreaTokens.inputFontStyle}: var(--plasma-typo-body-m-font-style);
Expand Down Expand Up @@ -152,6 +158,8 @@ export const config = {
${textAreaTokens.labelInnerFontWeight}: var(--plasma-typo-body-xs-font-weight);
${textAreaTokens.labelInnerLetterSpacing}: var(--plasma-typo-body-xs-letter-spacing);
${textAreaTokens.labelInnerLineHeight}: var(--plasma-typo-body-xs-line-height);
${textAreaTokens.labelInnerTop}: 0.5625rem;
${textAreaTokens.labelInnerMarginBottom}: 0.125rem;
${textAreaTokens.inputFontFamily}: var(--plasma-typo-body-l-font-family);
${textAreaTokens.inputFontSize}: var(--plasma-typo-body-l-font-size);
${textAreaTokens.inputFontStyle}: var(--plasma-typo-body-l-font-style);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const config = {
${textAreaTokens.inputMinHeight}: 0.625rem;
${textAreaTokens.borderRadius}: 0.5rem;
${textAreaTokens.borderRadiusWithHelpers}: 0.5rem;
${textAreaTokens.inputPaddingTop}: 0.563rem;
${textAreaTokens.inputPaddingTop}: 0.5625rem;
${textAreaTokens.inputPaddingRight}: 0.625rem;
${textAreaTokens.inputPaddingRightWithRightContent}: 2.125rem;
${textAreaTokens.inputPaddingBottom}: 0.563rem;
Expand All @@ -36,6 +36,8 @@ export const config = {
${textAreaTokens.labelInnerFontWeight}: var(--plasma-typo-body-xxs-font-weight);
${textAreaTokens.labelInnerLetterSpacing}: var(--plasma-typo-body-xxs-letter-spacing);
${textAreaTokens.labelInnerLineHeight}: var(--plasma-typo-body-xxs-line-height);
${textAreaTokens.labelInnerTop}: 0rem;
${textAreaTokens.labelInnerMarginBottom}: 0rem;
${textAreaTokens.inputFontFamily}: var(--plasma-typo-body-xs-font-family);
${textAreaTokens.inputFontSize}: var(--plasma-typo-body-xs-font-size);
${textAreaTokens.inputFontStyle}: var(--plasma-typo-body-xs-font-style);
Expand All @@ -55,7 +57,7 @@ export const config = {
${textAreaTokens.inputMinHeight}: 0.625rem;
${textAreaTokens.borderRadius}: 0.625rem;
${textAreaTokens.borderRadiusWithHelpers}: 0.625rem;
${textAreaTokens.inputPaddingTop}: 0.688rem;
${textAreaTokens.inputPaddingTop}: 0.6875rem;
${textAreaTokens.inputPaddingRight}: 0.875rem;
${textAreaTokens.inputPaddingRightWithRightContent}: 3.125rem;
${textAreaTokens.inputPaddingBottom}: 0.75rem;
Expand All @@ -76,6 +78,8 @@ export const config = {
${textAreaTokens.labelInnerFontWeight}: var(--plasma-typo-body-xs-font-weight);
${textAreaTokens.labelInnerLetterSpacing}: var(--plasma-typo-body-xs-letter-spacing);
${textAreaTokens.labelInnerLineHeight}: var(--plasma-typo-body-xs-line-height);
${textAreaTokens.labelInnerTop}: 0.375rem;
${textAreaTokens.labelInnerMarginBottom}: 0.125rem;
${textAreaTokens.inputFontFamily}: var(--plasma-typo-body-s-font-family);
${textAreaTokens.inputFontSize}: var(--plasma-typo-body-s-font-size);
${textAreaTokens.inputFontStyle}: var(--plasma-typo-body-s-font-style);
Expand Down Expand Up @@ -116,6 +120,8 @@ export const config = {
${textAreaTokens.labelInnerFontWeight}: var(--plasma-typo-body-xs-font-weight);
${textAreaTokens.labelInnerLetterSpacing}: var(--plasma-typo-body-xs-letter-spacing);
${textAreaTokens.labelInnerLineHeight}: var(--plasma-typo-body-xs-line-height);
${textAreaTokens.labelInnerTop}: 0.375rem;
${textAreaTokens.labelInnerMarginBottom}: 0.125rem;
${textAreaTokens.inputFontFamily}: var(--plasma-typo-body-m-font-family);
${textAreaTokens.inputFontSize}: var(--plasma-typo-body-m-font-size);
${textAreaTokens.inputFontStyle}: var(--plasma-typo-body-m-font-style);
Expand All @@ -135,7 +141,7 @@ export const config = {
${textAreaTokens.inputMinHeight}: 1.625rem;
${textAreaTokens.borderRadius}: 0.875rem;
${textAreaTokens.borderRadiusWithHelpers}: 0.875rem;
${textAreaTokens.inputPaddingTop}: 1.063rem;
${textAreaTokens.inputPaddingTop}: 1rem;
${textAreaTokens.inputPaddingRight}: 1.125rem;
${textAreaTokens.inputPaddingRightWithRightContent}: 3.625rem;
${textAreaTokens.inputPaddingBottom}: 0.75rem;
Expand All @@ -156,6 +162,8 @@ export const config = {
${textAreaTokens.labelInnerFontWeight}: var(--plasma-typo-body-xs-font-weight);
${textAreaTokens.labelInnerLetterSpacing}: var(--plasma-typo-body-xs-letter-spacing);
${textAreaTokens.labelInnerLineHeight}: var(--plasma-typo-body-xs-line-height);
${textAreaTokens.labelInnerTop}: 0.5625rem;
${textAreaTokens.labelInnerMarginBottom}: 0.125rem;
${textAreaTokens.inputFontFamily}: var(--plasma-typo-body-l-font-family);
${textAreaTokens.inputFontSize}: var(--plasma-typo-body-l-font-size);
${textAreaTokens.inputFontStyle}: var(--plasma-typo-body-l-font-style);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export const config = {
${textAreaTokens.labelInnerFontWeight}: 400;
${textAreaTokens.labelInnerLetterSpacing}: -0.02em;
${textAreaTokens.labelInnerLineHeight}: 0.75rem;
${textAreaTokens.labelInnerTop}: 0rem;
${textAreaTokens.labelInnerMarginBottom}: 0rem;
${textAreaTokens.inputFontFamily}: var(--plasma-typo-caption-font-family);
${textAreaTokens.inputFontSize}: var(--plasma-typo-caption-font-size);
${textAreaTokens.inputFontStyle}: var(--plasma-typo-caption-font-style);
Expand Down Expand Up @@ -74,6 +76,8 @@ export const config = {
${textAreaTokens.labelInnerFontWeight}: var(--plasma-typo-caption-font-weight);
${textAreaTokens.labelInnerLetterSpacing}: var(--plasma-typo-caption-letter-spacing);
${textAreaTokens.labelInnerLineHeight}: var(--plasma-typo-caption-line-height);
${textAreaTokens.labelInnerTop}: 0.375rem;
${textAreaTokens.labelInnerMarginBottom}: 0.125rem;
${textAreaTokens.inputFontFamily}: var(--plasma-typo-footnote1-font-family);
${textAreaTokens.inputFontSize}: var(--plasma-typo-footnote1-font-size);
${textAreaTokens.inputFontStyle}: var(--plasma-typo-footnote1-font-style);
Expand Down Expand Up @@ -114,6 +118,8 @@ export const config = {
${textAreaTokens.labelInnerFontWeight}: var(--plasma-typo-caption-font-weight);
${textAreaTokens.labelInnerLetterSpacing}: var(--plasma-typo-caption-letter-spacing);
${textAreaTokens.labelInnerLineHeight}: var(--plasma-typo-caption-line-height);
${textAreaTokens.labelInnerTop}: 0.375rem;
${textAreaTokens.labelInnerMarginBottom}: 0.125rem;
${textAreaTokens.inputFontFamily}: var(--plasma-typo-body1-font-family);
${textAreaTokens.inputFontSize}: var(--plasma-typo-body1-font-size);
${textAreaTokens.inputFontStyle}: var(--plasma-typo-body1-font-style);
Expand All @@ -133,7 +139,7 @@ export const config = {
${textAreaTokens.inputMinHeight}: 1.625rem;
${textAreaTokens.borderRadius}: 0.875rem;
${textAreaTokens.borderRadiusWithHelpers}: 0.875rem;
${textAreaTokens.inputPaddingTop}: 1.063rem;
${textAreaTokens.inputPaddingTop}: 1rem;
${textAreaTokens.inputPaddingRight}: 1.125rem;
${textAreaTokens.inputPaddingRightWithRightContent}: 3.625rem;
${textAreaTokens.inputPaddingBottom}: 0.75rem;
Expand All @@ -154,6 +160,8 @@ export const config = {
${textAreaTokens.labelInnerFontWeight}: var(--plasma-typo-caption-font-weight);
${textAreaTokens.labelInnerLetterSpacing}: var(--plasma-typo-caption-letter-spacing);
${textAreaTokens.labelInnerLineHeight}: var(--plasma-typo-caption-line-height);
${textAreaTokens.labelInnerTop}: 0.5625rem;
${textAreaTokens.labelInnerMarginBottom}: 0.125rem;
${textAreaTokens.inputFontFamily}: 'SB Sans Text','SBSansText',sans-serif;
${textAreaTokens.inputFontSize}: 1.125rem;
${textAreaTokens.inputFontStyle}: normal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const meta: Meta<TextAreaProps> = {
},
...disableProps([
'$isFocused',
'label',
'contentRight',
'autoComplete',
'autoFocus',
Expand Down
Loading