Skip to content
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
4 changes: 2 additions & 2 deletions src/components/TextInput/BaseTextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ class BaseTextInput extends Component {
Animated.parallel([
Animated.spring(this.state.labelTranslateY, {
toValue: translateY,
duration: 80,
duration: styleConst.LABEL_ANIMATION_DURATION,
useNativeDriver: true,
}),
Animated.spring(this.state.labelScale, {
toValue: scale,
duration: 80,
duration: styleConst.LABEL_ANIMATION_DURATION,
useNativeDriver: true,
}),
]).start();
Expand Down
7 changes: 7 additions & 0 deletions src/components/TextInput/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import _ from 'underscore';
import styles from '../../styles/styles';
import * as styleConst from './styleConst';
import BaseTextInput from './BaseTextInput';
import * as baseTextInputPropTypes from './baseTextInputPropTypes';

Expand All @@ -17,6 +18,11 @@ class TextInput extends React.Component {

render() {
const isLabeledMultiline = Boolean(this.props.label.length) && this.props.multiline;
const labelAnimationStyle = {
'--active-label-translate-y': `${styleConst.ACTIVE_LABEL_TRANSLATE_Y}px`,
'--active-label-scale': `${styleConst.ACTIVE_LABEL_SCALE}`,
'--label-transition-duration': `${styleConst.LABEL_ANIMATION_DURATION}ms`,
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This style definition doesn't fit to React style but pure web css.
Is there any way to convert this to React style?
i.e. labelTransitionDuration: styleConst.LABEL_ANIMATION_DURATION

@therealsujitk therealsujitk May 25, 2023 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe so, they have to be written in that format so CSS detects them as variables - StackOverflow, CSS Variables. Also the value has to be a string, otherwise it gets set to px by default.


return (
<BaseTextInput
Expand All @@ -36,6 +42,7 @@ class TextInput extends React.Component {
this.props.innerRef.current = el;
}}
inputStyle={[styles.baseTextInput, styles.textInputDesktop, isLabeledMultiline ? styles.textInputMultiline : {}, ...this.props.inputStyle]}
textInputContainerStyles={[labelAnimationStyle, ...this.props.textInputContainerStyles]}
/>
);
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/TextInput/styleConst.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ const ACTIVE_LABEL_SCALE = 0.8668;
const INACTIVE_LABEL_TRANSLATE_Y = variables.INACTIVE_LABEL_TRANSLATE_Y;
const INACTIVE_LABEL_SCALE = 1;

export {ACTIVE_LABEL_TRANSLATE_Y, ACTIVE_LABEL_SCALE, INACTIVE_LABEL_TRANSLATE_Y, INACTIVE_LABEL_SCALE};
const LABEL_ANIMATION_DURATION = 80;

export {ACTIVE_LABEL_TRANSLATE_Y, ACTIVE_LABEL_SCALE, INACTIVE_LABEL_TRANSLATE_Y, INACTIVE_LABEL_SCALE, LABEL_ANIMATION_DURATION};
6 changes: 6 additions & 0 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@
caret-color: #ffffff;
}

/* Prevent autofill from overlapping with the input label in Chrome */
div:has(input:-webkit-autofill) > label {
transform: translateY(var(--active-label-translate-y)) scale(var(--active-label-scale)) !important;
transition: transform var(--label-transition-duration);
}

@media screen and (min-width: 480px) {
.splash-logo > svg {
width: 104px;
Expand Down