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

CORE-670 Split ToastContainer into BodyPortalToastContainer and non-body portal version #67

Merged
merged 3 commits into from
Jan 28, 2025

Conversation

Dantemss
Copy link
Member

To be used by Rex, which uses ToastContainer but doesn't want portals.

@Dantemss Dantemss requested a review from jivey January 24, 2025 16:50
@Dantemss Dantemss changed the title Added a "portal" boolean that can turn off BodyPortal, used in ToastContainer Split ToastContainer into BodyPortalToastContainer and non-body portal version Jan 24, 2025
@Dantemss Dantemss changed the title Split ToastContainer into BodyPortalToastContainer and non-body portal version CORE-670 Split ToastContainer into BodyPortalToastContainer and non-body portal version Jan 24, 2025
@Dantemss
Copy link
Member Author

Once this is released I'll go through all the Assignable repos and make PRs to update and change ToastContainer to BodyPortalToastContainer.

@Dantemss Dantemss marked this pull request as ready for review January 24, 2025 17:47
Copy link
Member

@jivey jivey left a comment

Choose a reason for hiding this comment

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

I'm thinking about how we ensure these stay in sync over time.... The inner components are the same so maybe both of these should be thin wrappers around some BaseToastContainer component that handles the map render?

};

export const BodyPortalToastContainer = ({ toasts, onDismissToast, inline = false, className }: {
toasts: ToastData[], onDismissToast?: ToastData['onDismiss'], inline?: boolean, className?: string
Copy link
Member

Choose a reason for hiding this comment

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

Can we make both of these a type/interface just so we don't forget these should take the same props

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, good idea

display: grid;
justify-items: center;
justify-content: center;
gap: 1vh;
Copy link
Member

Choose a reason for hiding this comment

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

This looks like the same css, can we put it into a variable for both?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about extracting the template string/array and reusing it, but I ran into issues with the types, because I think styled-components uses a generic type that gets some of its values from the template string/array.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I can probably make a factory function

@@ -4,7 +4,19 @@ import { Toast } from './Toast';
import { zIndex } from '../../src/theme';
import { ToastData } from '../../src/types';

const StyledToastContainer = styled(BodyPortal)`
const StyledToastContainer = styled.div`
Copy link
Member

Choose a reason for hiding this comment

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

With this being a regular div again i think you can remove slot='toast' in the ToastContainer

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point

@Dantemss
Copy link
Member Author

DRYed up the ToastContainer code and added types for the interface

@Dantemss Dantemss merged commit b13e71e into main Jan 28, 2025
3 checks passed
@Dantemss Dantemss deleted the optional-portals branch January 28, 2025 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants