Skip to content

Commit

Permalink
fix(text-input-label-background): custom component background height (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
seb-zabielski authored Jul 27, 2024
1 parent 2c721ef commit d9db02e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/components/TextInput/Label/InputLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const InputLabel = (props: InputLabelProps) => {
focused,
opacity,
labelLayoutWidth,
labelLayoutHeight,
labelBackground,
label,
labelError,
Expand Down Expand Up @@ -157,6 +158,7 @@ const InputLabel = (props: InputLabelProps) => {
{labelBackground?.({
labeled,
labelLayoutWidth,
labelLayoutHeight,
labelStyle,
placeholderStyle,
baseLabelTranslateX,
Expand Down
7 changes: 3 additions & 4 deletions src/components/TextInput/Label/LabelBackground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import type { LabelBackgroundProps } from '../types';
const LabelBackground = ({
labeled,
labelLayoutWidth,
labelLayoutHeight,
placeholderStyle,
baseLabelTranslateX,
topPosition,
label,
backgroundColor,
roundness,
labelStyle,
Expand Down Expand Up @@ -69,16 +69,15 @@ const LabelBackground = ({
{
top: topPosition + 1,
width: labelLayoutWidth - placeholderStyle.paddingHorizontal,
height: labelLayoutHeight,
backgroundColor,
opacity,
transform: labelTextTransform,
},
]}
numberOfLines={1}
maxFontSizeMultiplier={maxFontSizeMultiplier}
>
{typeof label === 'string' ? label : label?.props.children}
</AnimatedText>,
/>,
];
};

Expand Down
1 change: 1 addition & 0 deletions src/components/TextInput/TextInputFlat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ const TextInputFlat = ({
wiggle={Boolean(parentState.value && labelProps.labelError)}
labelLayoutMeasured={parentState.labelLayout.measured}
labelLayoutWidth={parentState.labelLayout.width}
labelLayoutHeight={parentState.labelLayout.height}
{...labelProps}
/>
) : null}
Expand Down
1 change: 1 addition & 0 deletions src/components/TextInput/TextInputOutlined.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ const TextInputOutlined = ({
wiggle={Boolean(parentState.value && labelProps.labelError)}
labelLayoutMeasured={parentState.labelLayout.measured}
labelLayoutWidth={parentState.labelLayout.width}
labelLayoutHeight={parentState.labelLayout.height}
{...labelProps}
labelBackground={LabelBackground}
maxFontSizeMultiplier={rest.maxFontSizeMultiplier}
Expand Down
2 changes: 2 additions & 0 deletions src/components/TextInput/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export type InputLabelProps = {
opacity: number;
labelLayoutMeasured: boolean;
labelLayoutWidth: number;
labelLayoutHeight: number;
inputContainerLayout: { width: number };
labelBackground?: any;
maxFontSizeMultiplier?: number | undefined | null;
Expand All @@ -148,6 +149,7 @@ export type LabelBackgroundProps = {
labelStyle: any;
labeled: Animated.Value;
labelLayoutWidth: number;
labelLayoutHeight: number;
maxFontSizeMultiplier?: number | undefined | null;
theme?: ThemeProp;
} & LabelProps;
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,7 @@ exports[`correctly applies height to multiline Outline TextInput 1`] = `
"fontFamily": "System",
"fontSize": 16,
"fontWeight": undefined,
"height": 0,
"left": 8,
"letterSpacing": 0.15,
"lineHeight": undefined,
Expand Down Expand Up @@ -1111,9 +1112,7 @@ exports[`correctly applies height to multiline Outline TextInput 1`] = `
}
}
testID="text-input-outlined-label-background"
>
Outline Input
</Text>
/>
<Text
collapsable={false}
maxFontSizeMultiplier={1.5}
Expand Down

0 comments on commit d9db02e

Please sign in to comment.