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

Add granular support for allowFontScaling to the IOText component #347

Merged
merged 2 commits into from
Nov 8, 2024

Conversation

dmnplb
Copy link
Collaborator

@dmnplb dmnplb commented Nov 4, 2024

Short description

This PR adds granular support for the allowFontScaling and maxFontSizeMultiplier props to the IOText component. This change alone allows the developer to override these values in the single instance instead of all instances.

List of changes proposed in this pull request

  • Relax the TS check about IOText for the mentioned props

How to test

Try forcing allowFontScaling on the typographic styles, even with the experimental DS turned off.

@dmnplb dmnplb merged commit 1b58e30 into main Nov 8, 2024
6 checks passed
@dmnplb dmnplb deleted the IOAPPX-416-add-granular-support-for-dynamic-text-size branch November 8, 2024 15:30
dmnplb added a commit that referenced this pull request Dec 16, 2024
…ts based on the value of `fontScale` (#348)

>[!caution]
> This PR depends on the following PR:
> * #347

## Short description
This PR adds a dynamic size to some components, based on the value of
`fontScale`. Dynamic size is currently supported on the following
components:
- `Tag`, `Badge`, `Alert` and `FeatureInfo`
- All the selection components (`ListItemCheckbox`, `ListItemRadio`,
etc…)
- All the `ListItem…` components

## List of changes proposed in this pull request
- Add the new `useIOFontDynamicScale` hook to get the current
`fontScale` value
- Add the new `allowFontScaling` to `Icon`, `AnimatedIcon` and
`Pictogram` components to enable dynamic size based on the `fontScale`
value
- Add the new `allowScaleSpacing` to `Stack` components to enable the
same behavior
- Add dynamic spacing to `Tag`, `Badge`, all the selection and
`ListItem…` components
- Increase value of the `maxFontSizeMultiplier` from `1.25` to `1.5`
- Hide decorative icons from `ListItem…` and `Module…` components if the
text size multiplier is quite big (>= 1.5)

### Preview

#### `ListItemCheckbox`
As you can see, the size of the margins, icons and checkboxes also
changes depending on the value of `fontScale`:
| Default size | Larger text size |
|--------|--------|
| ![Simulator Screenshot - iPhone 16 Pro - 2024-11-06 at 17 14
09](https://github.com/user-attachments/assets/42d1c209-c7c9-4ac2-a7e3-739ef7d28a74)
| ![Simulator Screenshot - iPhone 16 Pro - 2024-11-06 at 17 12
20](https://github.com/user-attachments/assets/fc9e689e-6219-4f15-9ffc-89c53a344899)
|

#### `Alert`
Same as above, but with boldEnabled set to _ON._
| Default size | Larger text size |
|--------|--------|
| ![Simulator Screenshot - iPhone 16 Pro - 2024-11-07 at 16 26
33](https://github.com/user-attachments/assets/9169214b-69d6-48d6-8d75-0fdfdf9be1e0)
| ![Simulator Screenshot - iPhone 16 Pro - 2024-11-07 at 16 23
46](https://github.com/user-attachments/assets/737d7113-8170-469d-91dc-2d3a05d577af)
|





## How to test
1. Launch the example app
2. Go to the **Accessibility → Display & Text Size → Larger text**
3. Change the values
4. Go back to the example app to see the applied changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants