Skip to content

Support rendering leading Icon to TextField #815

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

Merged
merged 5 commits into from
Jun 24, 2020

Conversation

ethanshar
Copy link
Collaborator

@ethanshar ethanshar commented Jun 15, 2020

  • Support rendering leadingIcon prop
  • Prevent rendering of prefix or leadingIcon with floatingPlaceholder
    (WOAUILIB-499)

@ethanshar ethanshar added the WIP label Jun 15, 2020
@ethanshar ethanshar requested a review from ArnonZ June 15, 2020 15:35
@ethanshar ethanshar removed the WIP label Jun 15, 2020
@@ -57,6 +64,8 @@ export default class BasicTextFieldScreen extends Component {
error
} = this.state;



Copy link
Contributor

@ArnonZ ArnonZ Jun 24, 2020

Choose a reason for hiding this comment

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

typo?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's a github issue..
anyway I remove those lines, maybe it'll fix it..

@@ -642,6 +649,7 @@ export default class TextField extends BaseInput {
{paddingTop: this.getTopPaddings()}
]}
>
{leadingIcon && <Image {...leadingIcon} onLayout={this.onLeadingIconLayout}/>}
Copy link
Contributor

@ArnonZ ArnonZ Jun 24, 2020

Choose a reason for hiding this comment

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

onLayout is never used / this. onLeadingIconLayout is never defined.
Maybe you meant to implement onLayout to allow floating placeholder? to avoid this?:
leadIcon with floatingPlaceholder

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

const LEADING_ICON = {
source: Assets.icons.demo.search,
style: {marginRight: Spacings.s1}
};
Copy link
Contributor

@ArnonZ ArnonZ Jun 24, 2020

Choose a reason for hiding this comment

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

We don't want to supply a default margin and let it be overridden?
This forces to always supply a margin since it doesn't look good without it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I preferred to keep it clean as long as it doesn't look bad without custom styling.
This spacing is just for the sake of this example.
I assume we will pass something else in the private config

return Boolean(floatingPlaceholder && !centered && !this.shouldShowTopError());
const {floatingPlaceholder, centered, leadingIcon, prefix} = this.getThemeProps();

return !leadingIcon && !prefix && Boolean(floatingPlaceholder && !centered && !this.shouldShowTopError());
Copy link
Contributor

@ArnonZ ArnonZ Jun 24, 2020

Choose a reason for hiding this comment

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

Why not to allow leading icon and floatingPlaceholder?. Missing onLayout implementation for this of course (See relevant comment above).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was about to add it, but it caused a weird UI issue where the floating placeholder transition looked bad.
Anyway, I discussed with Yulia and she agreed there's no reason for both of these features to come together.

@@ -216,7 +220,7 @@ export default class TextField extends BaseInput {
const translate = width / 2 - (width * FLOATING_PLACEHOLDER_SCALE) / 2;
this.setState({floatingPlaceholderTranslate: translate / FLOATING_PLACEHOLDER_SCALE});
};

Copy link
Contributor

Choose a reason for hiding this comment

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

tab

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

@ethanshar ethanshar requested a review from ArnonZ June 24, 2020 06:08
@ArnonZ ArnonZ merged commit d8ad586 into master Jun 24, 2020
@ethanshar ethanshar deleted the feat/TextField_leadingIcon branch July 26, 2020 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants