-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Toast] Add tone, actionOnComponent and leadingIcon props to Toast #11431
Conversation
9878a99
to
a977064
Compare
@lone-star how can we consolidate error with your proposal for What is the timeline for this change and what priority is it? I would like to think a bit more about the existing toast functionality and how we can consolidate it with the new proposals. |
Thanks for looking at the PR Alex! You are exactly right, I decomposed the I left the error as is in order to keep things backward compatible, but we could change it. The timelines for this are quite urgent. It would be good to have a resolution as soon as possible. More context: Together with @sainihas and @jameswfindlater, we have been discussing the need for a different sort of notification component for Polaris. The Toast component is only used for ephemeral messages, and we would like to have more permanent notifications for the user. It is also important for those more permanent notifications to integrate well with the current Toast UI. For the moment we are introducing these changes, but we anticipate further iterations on the Toast component. |
+1 this is a critical piece of the Taxonomy mission. I do think there'll be an evolved answer overtime as magic patterns are solidified more but this feels like a reasonable stepping stone (particularly given the decomposition). |
Thanks @lone-star and @elsom25. Would there be any interest to do a follow up PRs to:
It's a lot of work on our team to keep the library as small as it is meant to be. I am aligned with this change but don't want the follow up work to disappear. I understand you are moving fast but these consolidations are super important to stop our props bloating. Let me know. |
It seems sensible to me if this feels worth a breaking change from your vantage-point. Magic-toning seems to be something that's propagating to many elements in polaris at this point so also feels broadly in-line (but I'll defer to @lone-star here) |
@alex-page Happy to make those PRs, the direction seems clear and straightforward. I've raised an issue here that contains the changes you requested: #11451 (not sure about the right labels) Please let me know if there is anything else, then I'll fix the conflicts and update the current PR. |
|
@heyjoethomas you can check out the prototype here to get a bit more context on the pattern and why we're introducing it for the taxonomy mission (magic autofill is a core experience of this new product). It also illustrates why there's a need for a more permanent toast for magic specifically within the context of winter editions launch. We'll work with polaris team on the component for a persistent toast post-editions. |
20edc4f
to
077680e
Compare
Rebased to update with the icon changes. |
@lone-star I wanted to ask if this could be a wrapper with overrides in |
Thanks for your feedback Alex. Here are some of my investigation, as well as my understanding. Happy to be corrected if there are mistakes. Could we use a separate component to display the magic messages?I initially prototyped a separate component. Unfortunately the page that displays this component also uses the Polaris Toast. Since the Toast component uses a fixed positioning (similar to the component that I want to use), the two of them overlap. The only way is therefore to integrate with the current Polaris Toast manager so that we don't have overlapping fixed components. I believe this to be true both for the proposed Magic toast (in this PR), and for the permanent component that @alenaiouguina is referring to here. Some pages already have overlaps between Toast and floating pills (ie: Variant Card, cc @sainihas). So we don't want to introduce yet another ugly UI. More so since we expect user actions to trigger both a magic Toast and a standard Toast in a closely timed manner. It's essential then for us to be able to stack toasts. Could we integrate with the ToastManager with a wrapper?There are 2 options there:
Do we want to expose to 3P?We are already exposing magic tones to 3P, and I expect us to expose this feature in the future (as for all the other magic UI elements). Since the Toast component itself is already being deprecated in favour of the AppBridge toast API, this won't change what 3P use in the immediate term. I assume that once we have had the opportunity to rework the feature we'll be able to expose it to 3P in AppBridge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @lone-star, thanks for contributing! The magic tone looks great ✨ I've provided detailed suggestions to simplify and align the API additions with the rest of the system.
polaris-react/src/components/Frame/components/Toast/tests/Toast.test.tsx
Outdated
Show resolved
Hide resolved
polaris-react/src/components/Frame/components/Toast/tests/Toast.test.tsx
Outdated
Show resolved
Hide resolved
8615bb6
to
3a0109c
Compare
Thank you for the feedback, I've updated the PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code and 🎩 (while pairing) LGTM! Minor non-blocking comments
<Icon source={AlertCircleIcon} tone="inherit" /> | ||
</div> | ||
) : null; | ||
let leadingIconMarkup; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are quite similar, maybe stylistic but can we set it as a const but use the ternary in the source
prop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It actually makes readability more messy due to typescript:
With the following:
const leadingIconMarkup =
error || icon ? (
<div className={styles.LeadingIcon}>
<Icon source={error ? AlertCircleIcon : icon} tone="inherit" />
</div>
) : null;
Typescript will complain that the source
prop cannot be undefined. That's because it is unable to pickup the logic where source=icon
only if error
is nullish and that means that icon
is defined. The solution for this involves adding some additional conditionals, and that makes readability really bad because we get multiple levels of nested ternary. I'd rather have a let
with 2 conditional, a single level of nesting and a bit of repetition.
8b329a4
to
daa7ad1
Compare
/snapit |
🫰✨ Thanks @lone-star! Your snapshots have been published to npm. Test the snapshots by updating your yarn add @shopify/polaris-migrator@0.0.0-snapshot-release-20240124105023 yarn add @shopify/polaris@0.0.0-snapshot-release-20240124105023 yarn add @shopify/polaris-tokens@0.0.0-snapshot-release-20240124105023 yarn add @shopify/stylelint-polaris@0.0.0-snapshot-release-20240124105023 |
Add the following options to the Toast component: - tone - onClick - icon
daa7ad1
to
b507edd
Compare
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @shopify/polaris-icons@8.1.0 ### Minor Changes - [#11478](#11478) [`b786bb93c`](b786bb9) Thanks [@Rusty-UX](https://github.com/Rusty-UX)! - Added DatabaseConnectIcon ## @shopify/polaris@12.11.0 ### Minor Changes - [#11474](#11474) [`26b3afb3d`](26b3afb) Thanks [@mrcthms](https://github.com/mrcthms)! - [BulkActions and SelectAllActions] Ensure backwards compatibilility after prop reorganisation between components - [#11497](#11497) [`d50cc6d91`](d50cc6d) Thanks [@mrcthms](https://github.com/mrcthms)! - Improved test reliability for non-rolled up actions in `ActionMenu` - [#10981](#10981) [`2dcc73f1a`](2dcc73f) Thanks [@mrcthms](https://github.com/mrcthms)! - Updated the sticky behaviour of BulkActions, SelectAllActions, and Pagination for our tables and lists - [#11441](#11441) [`74174b6c1`](74174b6) Thanks [@mrcthms](https://github.com/mrcthms)! - Improved the logic of action rollup and calculation of available space in `ActionMenu` and `Tabs` - [#11491](#11491) [`ac004fc97`](ac004fc) Thanks [@lgriffee](https://github.com/lgriffee)! - [`Button`] Remove underline from `monochromePlain` default state - [#11486](#11486) [`02a6d9b18`](02a6d9b) Thanks [@translation-platform](https://github.com/apps/translation-platform)! - Updated translations for SearchField suffix within IndexFilters - [#11344](#11344) [`c9abd3c0c`](c9abd3c) Thanks [@aaronccasanova](https://github.com/aaronccasanova)! - Added Polaris Tokens for Mobile typography - [#11412](#11412) [`f1b44ab57`](f1b44ab) Thanks [@mrcthms](https://github.com/mrcthms)! - [TextField] Updated the TextField with new `autoSize` and `loading` props - [#11431](#11431) [`f9b9fa4e8`](f9b9fa4) Thanks [@lone-star](https://github.com/lone-star)! - Added `tone`, `icon`, and `onClick` props to `Toast` ### Patch Changes - [#11464](#11464) [`2ee7dbd30`](2ee7dbd) Thanks [@sam-b-rose](https://github.com/sam-b-rose)! - Updated `Button` shadow tokens and replaced hardcoded box-shadow values - [#11504](#11504) [`1910c6975`](1910c69) Thanks [@mrcthms](https://github.com/mrcthms)! - Updated Page Header to only ensure no wrapping of the title when the title is relatively short - [#11473](#11473) [`6579537e4`](6579537) Thanks [@sam-b-rose](https://github.com/sam-b-rose)! - Fixed focus ring size for plain and plain monochrome Button variants - [#11487](#11487) [`4aabf7c1a`](4aabf7c) Thanks [@yurm04](https://github.com/yurm04)! - [Modal] Fixed Footer position to bottom of container - [#11466](#11466) [`1953b6935`](1953b69) Thanks [@mrcthms](https://github.com/mrcthms)! - [TextField] Fixed positional issue of loading indicator when no clear button is present - [#11462](#11462) [`2febd60f1`](2febd60) Thanks [@sophschneider](https://github.com/sophschneider)! - Lowered the z-index of `Filter`s container to be below `Card` shadow bevel - [#11467](#11467) [`75cbcd70b`](75cbcd7) Thanks [@kyledurand](https://github.com/kyledurand)! - Increased contrast on Tooltip underline - [#11482](#11482) [`59371946c`](5937194) Thanks [@translation-platform](https://github.com/apps/translation-platform)! - [SearchField] Updated translation - Updated dependencies \[[`2ee7dbd30`](2ee7dbd), [`c9abd3c0c`](c9abd3c), [`b786bb93c`](b786bb9)]: - @shopify/polaris-tokens@8.6.0 - @shopify/polaris-icons@8.1.0 ## @shopify/polaris-tokens@8.6.0 ### Minor Changes - [#11344](#11344) [`c9abd3c0c`](c9abd3c) Thanks [@aaronccasanova](https://github.com/aaronccasanova)! - Added Polaris Tokens for Mobile typography ### Patch Changes - [#11464](#11464) [`2ee7dbd30`](2ee7dbd) Thanks [@sam-b-rose](https://github.com/sam-b-rose)! - Updated `Button` shadow tokens and replaced hardcoded box-shadow values ## @shopify/stylelint-polaris@15.1.0 ### Minor Changes - [#11344](#11344) [`c9abd3c0c`](c9abd3c) Thanks [@aaronccasanova](https://github.com/aaronccasanova)! - Updated `typography` `declaration-property-value-disallowed-list` to support Polaris Tokens `text` variants ### Patch Changes - Updated dependencies \[[`2ee7dbd30`](2ee7dbd), [`c9abd3c0c`](c9abd3c)]: - @shopify/polaris-tokens@8.6.0 ## @shopify/polaris-migrator@0.27.1 ### Patch Changes - Updated dependencies \[[`c9abd3c0c`](c9abd3c), [`2ee7dbd30`](2ee7dbd), [`c9abd3c0c`](c9abd3c)]: - @shopify/stylelint-polaris@15.1.0 - @shopify/polaris-tokens@8.6.0 ## polaris.shopify.com@0.62.0 ### Minor Changes - [#11506](#11506) [`c19b0f638`](c19b0f6) Thanks [@lgriffee](https://github.com/lgriffee)! - Added ability to mark prop values as deprecated ### Patch Changes - [#11457](#11457) [`966d1901e`](966d190) Thanks [@sam-b-rose](https://github.com/sam-b-rose)! - Added fallback to no active icon on Icons page when not a valid icon name is used in the search param - [#11466](#11466) [`1953b6935`](1953b69) Thanks [@mrcthms](https://github.com/mrcthms)! - [TextField] Fixed positional issue of loading indicator when no clear button is present - [#11461](#11461) [`d26df7eb0`](d26df7e) Thanks [@sam-b-rose](https://github.com/sam-b-rose)! - Added deprecation warning to old icon names informing users to use the new icon name - [#11467](#11467) [`75cbcd70b`](75cbcd7) Thanks [@kyledurand](https://github.com/kyledurand)! - Increased contrast on Tooltip underline - Updated dependencies \[[`26b3afb3d`](26b3afb), [`2ee7dbd30`](2ee7dbd), [`1910c6975`](1910c69), [`d50cc6d91`](d50cc6d), [`6579537e4`](6579537), [`2dcc73f1a`](2dcc73f), [`74174b6c1`](74174b6), [`4aabf7c1a`](4aabf7c), [`ac004fc97`](ac004fc), [`1953b6935`](1953b69), [`02a6d9b18`](02a6d9b), [`c9abd3c0c`](c9abd3c), [`2febd60f1`](2febd60), [`b786bb93c`](b786bb9), [`75cbcd70b`](75cbcd7), [`f1b44ab57`](f1b44ab), [`f9b9fa4e8`](f9b9fa4), [`59371946c`](5937194)]: - @shopify/polaris@12.11.0 - @shopify/polaris-tokens@8.6.0 - @shopify/polaris-icons@8.1.0 ## polaris-for-vscode@0.9.4 ### Patch Changes - Updated dependencies \[[`2ee7dbd30`](2ee7dbd), [`c9abd3c0c`](c9abd3c)]: - @shopify/polaris-tokens@8.6.0 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…hopify#11431) <!-- ☝️How to write a good PR title: - Prefix it with [ComponentName] (if applicable), for example: [Button] - Start with a verb, for example: Add, Delete, Improve, Fix… - Give as much context as necessary and as little as possible - Open it as a draft if it’s a work in progress --> ### WHY are these changes introduced? We would like to add more customisation to the current Toast component: - tone: this allows us to provide specific tones for styling. - actionOnComponent: this makes the whole component clickable instead of having a link inside - leadingIcon: we can use custom icons in the component. ### WHAT is this pull request doing? #### Magic tone We can change the tone of the toast to `magic` <img width="224" alt="Screenshot 2024-01-11 at 20 19 45" src="https://github.com/Shopify/polaris/assets/78884/43f7809d-5348-425a-a4cc-3aaa797fffb8"> #### Action on component The whole component is now clickable. https://github.com/Shopify/polaris/assets/78884/56e06a79-8e37-40d9-becf-828e8aa5c9f0 #### Leading icon In this example, we have both the magic tone, the leading icon, and the Action On Component https://github.com/Shopify/polaris/assets/78884/64ec9807-a340-472e-918d-d881c20d0172 ### How to 🎩 🖥 [Local development instructions](https://github.com/Shopify/polaris/blob/main/README.md#install-dependencies-and-build-workspaces) 🗒 [General tophatting guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md) 📄 [Changelog guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog) ### 🎩 checklist - [x] Tested a [snapshot](https://github.com/Shopify/polaris/blob/main/documentation/Releasing.md#-snapshot-releases) - [x] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [x] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [x] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [x] Updated the component's `README.md` with documentation changes - [x] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide
WHY are these changes introduced?
We would like to add more customisation to the current Toast component:
WHAT is this pull request doing?
Magic tone
We can change the tone of the toast to
magic
Action on component
The whole component is now clickable.
action-on-component.mp4
Leading icon
In this example, we have both the magic tone, the leading icon, and the Action On Component
magic-leading-icon.mp4
How to 🎩
🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines
🎩 checklist
README.md
with documentation changes