Sean Perkins dcd23e188b feat(toast): support dynamic type (#28051)
Issue number: Internal

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->

Toast does not support the dynamic type feature in iOS. 

_A brief history on Ionic's toast..._

The toast component is influenced based on Material Design's
[Snackbar](https://m2.material.io/components/snackbars) component. iOS
does not include a toast component in their Human Interface Guidelines.
Ionic's implementation is a hybrid of a "close enough" design for iOS
that somewhat resembles iOS notifications.

Taking this into account, the new behavior specified below is very much
a best guess of reasonable defaults to provide an appropriate user
experience for a user that is displayed a toast while using the dynamic
type feature in iOS.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- The toast content (header and message) content will scale to a maximum
of 310% of its base size of 14px.
- Note: Header is not a valid aspect of MD Snackbar. This is an area
where the iOS notification style has bled into public API. We scale both
the header and message text to be consistent, but developers should be
cautious with how much content they are rendering. MD recommends a
maximum of 2 lines of text for mobile, this would include both the
header and message text[^1].
- The toast button will scale based on the same sizing rules as the back
button does for dynamic type. The action is important to scale for
visibility, but the content of the toast is the primary content that
should be scaled to the maximum size allocated.
- On iOS, the toast container has a maximum height of 478px. This value
is taken from scaling the notification UI in iOS to 310% and capturing
the height of the largest allowed notification[^2]. Developers that
display too much text will have the contents overflow (visibly hidden).
This is intentional to prevent the toast from covering the entire
application UI and to enforce developers limit their text. Developers
can continue to override this value through the `--max-height` CSS
variable.
- The fixed height requirement for toast has been removed. On iOS, the
toast container can expand up to the max height (defaults to `478px`).
On MD, the container will expand and overflow the viewport. Once again,
developers _should_ follow best practices of limiting their message to
1-2 lines of text.


https://github.com/ionic-team/ionic-framework/assets/13732623/d19e93c9-55c3-4b35-85af-3be9d98e008d


## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!-- If this introduces a breaking change, please describe the impact
and migration path for existing applications below. -->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->

I attempted to enforce the line requirements to have the header and
message text overflow, but line-clamp is not consistently implemented
across browsers and Safari does not render an ellipsis when the content
overflows. For this reason, I do not believe clamping the text to a
fixed number of lines is viable at this time.

[^1]: Reference to Material Design 2 Snackbar spec:
https://m2.material.io/components/snackbars#specs
[^2]: Reference image for iOS notifications scaled to 310%:
https://github.com/ionic-team/ionic-framework/assets/13732623/e2420340-8046-4a56-81c8-9e2ee1c1399b

---------

Co-authored-by: ionitron <hi@ionicframework.com>
2023-09-01 13:08:21 -04:00
2023-08-16 14:23:33 +00:00
2015-11-13 21:11:21 -06:00
2023-08-16 14:23:33 +00:00
2023-08-16 14:23:33 +00:00
2023-03-22 13:36:35 +00:00

Ionic

Ionic

Ionic is an open source app development toolkit for building modern, fast, top-quality cross-platform native and Progressive Web Apps from a single codebase with JavaScript and the Web.

Ionic is based on Web Components, which enables significant performance, usability, and feature improvements alongside support for popular web frameworks like Angular, React, and Vue.

Ionic Framework is released under the MIT license. PRs welcome! Follow @IonicFramework Official Ionic Discord

Quickstart · Documentation · Contribute · Blog
Community: Discord · Forums · Twitter

Packages

Project Package Version Downloads Links
Core @ionic/core version NPM Downloads README.md
Angular @ionic/angular version NPM Downloads README.md
Vue @ionic/vue version NPM Downloads README.md
React @ionic/react version NPM Downloads README.md

Looking for the ionic-angular package? Ionic 3 has been moved to the ionic-v3 repo. See Earlier Versions.

Getting Started

Start a new project by following our quick Getting Started guide. We would love to hear from you! If you have any feedback or run into issues using our framework, please file an issue on this repository.

Migration Guides

Already have an Ionic app? These guides will help you migrate to the latest versions.

Examples

The Ionic Conference App is a full featured Ionic app. It is the perfect starting point for learning and building your own app.

Contributing

Thanks for your interest in contributing! Read up on our guidelines for contributing and then look through our issues with a help wanted label.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Future Goals

As Ionic Framework components migrate to the web component standard, a goal of ours is to have Ionic Framework easily work within all of the popular frameworks.

Earlier Versions

The source code for earlier versions of the Ionic Framework may exist in other repositories. Please open issues and pull requests in their respective repositories.

Description
A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
Readme MIT 2.5 GiB
Languages
TypeScript 61.2%
HTML 25%
SCSS 10.4%
JavaScript 1.9%
Vue 1%
Other 0.5%