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

UI: Refactor Text component and typography handling #585

Conversation

ksharma-xyz
Copy link
Owner

@ksharma-xyz ksharma-xyz commented Feb 6, 2025

TL;DR

Improved text style handling and simplified Text component parameters.

What changed?

  • Removed redundant fontFamily parameter from Text component overload
  • Added explicit handling of LocalTextColor with fallback to theme's onSurface color
  • Introduced separate textStyle and textColor variables for clearer style composition
  • Modified style merging to use copy() for more explicit property updates

Why make this change?

When the Text API is used inside a Button, it will provide a composition local style for text and color, which should be respected by the Text component. However, Text can also be used independently, requiring a style parameter. If we provide a style parameter, users might misuse it within a Button. To address this, we are merging and giving higher priority to the composition local text and color styles, then falling back to the provided parameters. This ensures consistency and prevents misuse.

Copy link
Owner Author

ksharma-xyz commented Feb 6, 2025

@ksharma-xyz ksharma-xyz changed the title Text should repect style of LocalTextStyle composition local provider UI: Remove fontFamily param and optimize text styling Feb 6, 2025
use composition local, if it is not specified, then use the color provided otherwise fallback on the onSurface
@ksharma-xyz ksharma-xyz changed the title UI: Remove fontFamily param and optimize text styling UI: Refactor Text component and typography handling Feb 6, 2025
@ksharma-xyz ksharma-xyz marked this pull request as ready for review February 6, 2025 05:23
@ksharma-xyz ksharma-xyz merged commit 9ec4897 into main Feb 6, 2025
4 checks passed
Copy link
Owner Author

Merge activity

  • Feb 6, 12:35 AM EST: A user merged this pull request with Graphite.

@ksharma-xyz ksharma-xyz deleted the 02-06-text_should_repect_style_of_localtextstyle_composition_local_provider branch February 6, 2025 05:35
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.

1 participant