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

[Feature] Update components to use typography tokens or Text component #612

Merged

Conversation

narin
Copy link
Contributor

@narin narin commented Dec 13, 2024

Description of Change

  • Updates components to use either typography tokens or the Text component
  • Typography tokens were used when text required colors that didn't align with tones, text decoration, or special style or props such as flexShrink or allowFontScaling
  • Note that most components will seem slightly larger due to fractional increase in font size or increased lineHeights
  • Aliased { Text as RNText } when import from react-native to differentiate between RN component and DS component

Testing Packages

  • components@0.28.1-alpha.2

Screenshots/Video

Alert Before/after  
Button Before/after  
Checkbox Before/after  
CheckboxGroup Before/after  
CheckboxGroup (Tiled) Before/after  
Link Before/after  
LoadingIndicator Before/after  
RadioButton Before/after  
SegmentedControl Before/after  
Snackbar Before/after  

Testing

  • Tested on iOS
  • Tested on Android
  • Tested on Web

PR Checklist

Code reviewer validation:

  • General
    • PR is linked to ticket(s)
    • PR has changelog label applied if it's to be included in the changelog
    • Acceptance criteria:
      • All satisfied or
      • Documented reason for not being performed or
      • Split to separate ticket and ticket is linked by relevant AC(s)
    • Above PR sections adequately filled out
    • If any breaking changes, in accordance with the pre-1.0.0 versioning guidelines: a CU ticket has been created for the VA Mobile App detailing necessary adjustments with the package version that will be published by this ticket
  • Code
    • Tests are included if appropriate (or split to separate ticket)
    • New functions have proper TSDoc annotations

Publish

If changes warrant a new version per the versioning guidelines and the PR is approved and ready to merge:

narin added 11 commits December 11, 2024 13:31
…ext styling

- Replaced hardcoded font properties with typography tokens from mobile-tokens.
- Simplified textStyle definition and ensured consistent link color handling based on variant.
- Removed redundant code related to font settings and link color assignment.
…ext styling

- Integrated typography tokens from mobile-tokens to enhance text styling consistency.
- Updated textStyle to use typography.vadsFontBodyLarge for better maintainability.
- Retained conditional fontFamily assignment for selected state while removing redundant font definitions.
… styling consistency

- Replaced hardcoded font properties with typography tokens from mobile-tokens.
- Updated text styles for Header, Hint, Error, Label, and Description components to use typography.vadsFontBodyLarge and typography.vadsFontBodySmall.
- Renamed Text import to RNText for clarity and consistency across the component.
- Removed redundant font definitions to streamline the codebase.
- Removed TODO comments in Button and SegmentedControl components to clean up the codebase.
- Updated Link component to set marginBottom to 0
@narin narin changed the title Feature/542 narin update components to use text tokens or component [Feature] Update components to use typography tokens or Text component Dec 13, 2024
…al cleanup and refactoring:

- Simplified getTextStyle function in Button component for cleaner code.
- Removed unnecessary Spacer components in CheckboxGroup, RadioButton, and CheckboxRadio components to streamline layout.
- Updated LoadingIndicator to remove unused imports and improve clarity.
- Refactored FormText component to utilize typography tokens for consistent text styling across Header, Hint, Error, Label, and Description components.
- Replaced hardcoded font properties with typography tokens and integrated the Text component for improved maintainability.
…or-component' of github.com:department-of-veterans-affairs/va-mobile-library into feature/542-narin-update-components-to-use-text-tokens-or-component
@narin narin marked this pull request as ready for review December 13, 2024 20:48
@narin narin requested a review from a team as a code owner December 13, 2024 20:48
@TimRoe
Copy link
Contributor

TimRoe commented Dec 16, 2024

Should this also be linked to another ticket? Just linked to one for adding colors, not updating components to use Text.

@@ -143,8 +128,9 @@ export const Alert: FC<AlertProps> = ({
const iconViewStyle: ViewStyle = {
flexDirection: 'row',
// Below keeps icon aligned with first row of text, centered, and scalable
// If Text variant for header changes, token referenced in minHeight must change accordingly
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if there's any good way to rework, but seems unlikely this comment would be noticed in that eventuality.

const getTextStyle = (pressed: boolean): TextStyle => ({
...typography.vadsFontBodyLarge,
fontFamily: family.vadsFontFamilySansSerifBold,
marginBottom: 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should maybe use the none spacing token.

...font,
...typography.vadsFontBodyLarge,
fontFamily: isSelected ? 'SourceSansPro-Bold' : 'SourceSansPro-Regular',
marginBottom: 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar token suggestion.

...font,
...typography.vadsFontBodyLarge,
fontFamily: isSelected ? 'SourceSansPro-Bold' : 'SourceSansPro-Regular',
marginBottom: 0,
color: theme.vadsColorForegroundDefault,
Copy link
Contributor

Choose a reason for hiding this comment

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

Did none of the tones work here? Seems like with the Text updates to include bold and center that maybe this could still use the Text component?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Couldn't use Text component here due to the allowFontScaling prop used on line 121, unless we add that prop.

Comment on lines 35 to 37
...typography.vadsFontBodyLarge,
marginBottom: 0,
color: theme.vadsColorForegroundDefault,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't this be handled by our Text component with default tone and none bottomSpacing?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, or can it not because the role of heading while being body text?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup. This was done due to the role

Copy link
Contributor

@TimRoe TimRoe left a comment

Choose a reason for hiding this comment

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

Approving since the whole seems alright, but some comments that likely should be addressed prior to merging.

@narin narin merged commit 5a50058 into main Dec 16, 2024
4 of 5 checks passed
@narin narin deleted the feature/542-narin-update-components-to-use-text-tokens-or-component branch December 16, 2024 19:34
@@ -79,6 +79,9 @@ export const Text: FC<TextProps> = ({
variant = 'body',
}) => {
const theme = useTheme()

if (!children) return null
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this needed for TS to not get upset about the bold check or just a random piece of "defensive" code?

import { useTranslation } from 'react-i18next'
import React, { FC } from 'react'

import { SpacerSize } from '../Spacer/Spacer'
Copy link
Contributor

Choose a reason for hiding this comment

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

Calling attention to this since I assume it's going to cause linting failures in main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants