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

feat(toast): toast vertical align prop #6391

Merged
merged 2 commits into from
Nov 8, 2023

Conversation

nuria1110
Copy link
Contributor

fix #6301

Proposed behaviour

  • Added alignY prop which allows to vertically align the component at the top, center and bottom of the screen.
  • The notice variant will still render at the bottom of the screen by default but you can set alignY set to "top" to render it at the top of the screen.
  • Fixed visual bug on when align was set to left.

Current behaviour

  • Toast currently does not support vertical alignment.
  • There is a visual bug when align is set to "left" and the screen size is small:

Screenshot 2023-10-26 at 17 03 27

Checklist

  • Commits follow our style guide
  • Related issues linked in commit messages if required
  • Screenshots are included in the PR if useful
  • All themes are supported if required
  • Unit tests added or updated if required
  • Cypress automation tests added or updated if required
  • Playwright automation tests added or updated if required
  • Storybook added or updated if required
  • Translations added or updated (including creating or amending translation keys table in storybook) if required
  • Typescript d.ts file added or updated if required
  • Related docs have been updated if required

QA

  • Tested in CodeSandbox/storybook
  • Add new Cypress test coverage if required
  • Carbon implementation matches Design System/designs
  • UI Tests GitHub check reviewed if required

Additional context

Testing instructions

Added a test story for cases where there is more than one toast on the screen at the same time and have different vertical alignments.

The following CodeSandbox is an example of the broken behaviour.
You can see the new behaviour by looking at the version in the comment by codesandbox[bot].

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 26, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit ab8c768:

Sandbox Source
carbon-quickstart Configuration
carbon-quickstart-typescript Configuration
carbon-quickstart PR

@nuria1110 nuria1110 force-pushed the FE-6209-toast-screen-position branch from bcf0d7a to fb57583 Compare October 27, 2023 11:34
Copy link
Contributor

@edleeks87 edleeks87 left a comment

Choose a reason for hiding this comment

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

Some minor comments from me but overall great work @nuria1110 👏 .

I think we could also slightly tweak the commit message here as it will form the release note when this is merged. Something like below might work but happy for you to go with what you want here 😄

feat(toast): add alignY prop to allow vertical alignment to be configurable 

adds `alignY` prop to `Toast` which allows consumers to vertically align the component on the screen

fix #6301

src/components/toast/toast.style.ts Outdated Show resolved Hide resolved
src/components/toast/toast.style.ts Show resolved Hide resolved
src/components/toast/toast.style.ts Outdated Show resolved Hide resolved
src/components/toast/toast.stories.tsx Show resolved Hide resolved
src/components/toast/toast.spec.tsx Show resolved Hide resolved
@Parsium Parsium self-requested a review October 30, 2023 14:34
@@ -234,6 +234,164 @@ Visual.parameters = {
themeProvider: { chromatic: { theme: "sage" } },
};

export const AllAlign = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

praise: nice idea to use chromatic to check all the align permutations 👍🏼

});

it.each(["top", "center", "bottom"] as const)(
"should then pass the prop to Styled Portal",
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion(non-blocking): it might help rewording this slightly so its a bit clearer what the preconditions are:

Suggested change
"should then pass the prop to Styled Portal",
"when align prop is %s, Portal is correctly positioned",

Comment on lines +215 to +219
toastComponent()
.parent()
.parent()
.parent()
.parent()
Copy link
Contributor

Choose a reason for hiding this comment

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

thought: it might be worth when we migrate these tests to Playwright to amend how we are locating the portal element here.

It's not essential now, but if we can directly locate the portal element instead of traversing the DOM, this should make the test less fragile if we ever change the component's markup.

@nuria1110 nuria1110 force-pushed the FE-6209-toast-screen-position branch from befad0f to 8396b43 Compare November 1, 2023 12:43
Parsium
Parsium previously approved these changes Nov 1, 2023
edleeks87
edleeks87 previously approved these changes Nov 1, 2023
@edleeks87 edleeks87 marked this pull request as ready for review November 1, 2023 14:16
@edleeks87 edleeks87 requested review from a team as code owners November 1, 2023 14:16
@harpalsingh
Copy link
Member

Approved PR but wasnt sure we wanted centre aligned, however we are considering some updates around that placement, so good to allow that to be included and we can test.

ZhuoyuJin
ZhuoyuJin previously approved these changes Nov 7, 2023
@nuria1110 nuria1110 dismissed stale reviews from ZhuoyuJin, edleeks87, and Parsium via 47bfe28 November 8, 2023 11:11
@nuria1110 nuria1110 force-pushed the FE-6209-toast-screen-position branch from ecaf08a to 47bfe28 Compare November 8, 2023 11:11
…urable

adds `alignY` prop to Toast which allows consumers to vertically
align the component on the screen

fix #6301
@nuria1110 nuria1110 force-pushed the FE-6209-toast-screen-position branch from 47bfe28 to 64203e1 Compare November 8, 2023 11:15
@nuria1110 nuria1110 merged commit ba96d14 into master Nov 8, 2023
15 checks passed
@nuria1110 nuria1110 deleted the FE-6209-toast-screen-position branch November 8, 2023 12:36
@carbonci
Copy link
Collaborator

carbonci commented Nov 8, 2023

🎉 This PR is included in version 123.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

Allow Toast components to be show at the bottom of the screen.
6 participants