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

ref: remove default margin from Alert in sentry #85128

Merged
merged 12 commits into from
Feb 14, 2025

Conversation

michellewzhang
Copy link
Member

@michellewzhang michellewzhang commented Feb 13, 2025

Context

Because Alert used to have a default bottom margin, we had a lot of instances of styled Alerts across the codebase that looked like this:

const StyledAlert = styled(Alert)`
   margin: 0;
`;

The goal was to remove these instances entirely. In this PR, the default margin is removed from Alert and placed inside a Alert.Container export instead.

This PR also updates all Alert instances to either

  • wrap with Alert.Container if it was using the default margins of the Alert component, or
  • remove the margin: 0 style

In summary:

BEFORE AFTER
SCR-20250212-pdos SCR-20250212-pdnt
SCR-20250212-pdyh SCR-20250212-peah
SCR-20250212-peqt SCR-20250212-petn
SCR-20250212-petn SCR-20250212-pfbk
SCR-20250212-phuy SCR-20250212-phuy (no change)

tldr, using Alert going forward

Alert will no longer have a default bottom margin. If you'd still like to utilize that old built-in margin, you can wrap your component with <Alert.Container>:

<Alert.Container>
   <Alert/>
</Alert.Container>

note that components that utilize Alert as a child, such as PanelAlert and ProjectPermissionAlert, already have the <Alert.Container> wrapped around it inside the component definition.

relates to #85109
see also https://github.com/getsentry/getsentry/pull/16482 (getsentry counterpart)

@michellewzhang michellewzhang force-pushed the mz/mz/update-alert-margin-sentry branch from 22b032a to d245601 Compare February 13, 2025 22:50
@michellewzhang michellewzhang marked this pull request as ready for review February 13, 2025 22:55
@michellewzhang michellewzhang requested review from a team as code owners February 13, 2025 22:55
}
>
This alert can be dismissed!
<Alert.Container>
Copy link
Member

Choose a reason for hiding this comment

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

It's a story i know... but this could go inside the isDismissed check so there's no "extra" space when it's dismissed

Copy link
Member Author

@michellewzhang michellewzhang Feb 13, 2025

Choose a reason for hiding this comment

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

it looks pretty much the same either way...but i updated it😆

@@ -1,5 +1,4 @@
import {Fragment} from 'react';
import styled from '@emotion/styled';
Copy link
Member

Choose a reason for hiding this comment

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

so many places that removed this import! that's a win too

Comment on lines -201 to -203
const AlertWithMarginBottom = styled(Alert)`
const StyledAlert = styled(Alert)`
margin-top: ${space(2)};
margin-bottom: 0;
Copy link
Member

Choose a reason for hiding this comment

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

WAT

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

we need a #shame channel :)

@@ -217,10 +216,6 @@ export const DismissButton = styled(Button)`
}
`;

export const StyledAlert = styled(Alert)`
Copy link
Member Author

Choose a reason for hiding this comment

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

this wasn't used or imported anywhere

@JonasBa
Copy link
Member

JonasBa commented Feb 14, 2025

Love to see all those style imports deleted ❤️ Great idea to also target the child via > as it means the container wont take space once

@michellewzhang michellewzhang force-pushed the mz/mz/update-alert-margin-sentry branch from d0117d0 to d1936e1 Compare February 14, 2025 19:58
@michellewzhang michellewzhang merged commit 72c6969 into master Feb 14, 2025
42 checks passed
@michellewzhang michellewzhang deleted the mz/mz/update-alert-margin-sentry branch February 14, 2025 20:14
@github-actions github-actions bot locked and limited conversation to collaborators Mar 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants