Skip to content

Commit 44274ea

Browse files
TkDodoandrewshie-sentry
authored andcommitted
fix(ui2): contrast for upgrade banners (#97169)
The `BannerAlert` component explicitly sets a high contrast backgroundColor / color to be distinguishable from the rest of the page: light mode has a dark banner: <img width="1211" height="145" alt="Screenshot 2025-08-05 at 15 45 04" src="https://github.com/user-attachments/assets/c7e6ae93-0417-463b-98ae-fdb6ea3f5a35" /> dark mode has a light banner: <img width="1211" height="145" alt="Screenshot 2025-08-05 at 15 45 10" src="https://github.com/user-attachments/assets/349d1bb6-22c2-4586-a6bb-86e493dbf4f2" /> but this approach with custom style overrides doesn’t work in UI2 - they are ignored, thus leaving us with banners that look the same as the background, which makes them not stick out at all: <img width="1211" height="145" alt="Screenshot 2025-08-05 at 15 44 56" src="https://github.com/user-attachments/assets/d3c1813b-b78c-4b23-bdbd-ba59dbdb8eb1" /> <img width="1211" height="145" alt="Screenshot 2025-08-05 at 15 44 59" src="https://github.com/user-attachments/assets/4e79e273-0caf-4bb2-b672-a056a3fe7d50" /> --- To fix this in UI2, I’ve simply inverted the theme to show a regular light banner in dark mode and a dark banner in light mode, without any custom styles: | how it’s now, light mode | how it’s now, dark mode | |--------|--------| | <img width="1211" height="145" alt="Screenshot 2025-08-05 at 15 37 29" src="https://github.com/user-attachments/assets/f63f8e76-d3e0-4502-b1d9-179f8fa0d5f2" /> | <img width="1211" height="145" alt="Screenshot 2025-08-05 at 15 37 24" src="https://github.com/user-attachments/assets/3b84bcb2-0723-49fc-877e-161fdb511be9" /> | | <img width="1211" height="145" alt="Screenshot 2025-08-05 at 15 37 34" src="https://github.com/user-attachments/assets/f1fc24d5-4aac-4d50-9bb9-0b9e8659f2d5" /> | <img width="1211" height="145" alt="Screenshot 2025-08-05 at 15 37 18" src="https://github.com/user-attachments/assets/d2b6a91f-a925-4e42-9a29-84133fba0421" /> | | <img width="1211" height="145" alt="Screenshot 2025-08-05 at 15 39 25" src="https://github.com/user-attachments/assets/68322cfe-256d-4362-b574-39d2c407bcb9" /> | <img width="1211" height="145" alt="Screenshot 2025-08-05 at 15 39 29" src="https://github.com/user-attachments/assets/0dd1d525-9576-4241-a8bb-fb09bea629fd" /> | | <img width="1211" height="145" alt="Screenshot 2025-08-05 at 15 39 20" src="https://github.com/user-attachments/assets/a2e68329-66b7-4ee6-a2d7-f594350ea87b" /> | <img width="1211" height="145" alt="Screenshot 2025-08-05 at 15 39 32" src="https://github.com/user-attachments/assets/0981df92-374a-43b5-bb37-02f1bd5e338b" /> |
1 parent 141ff14 commit 44274ea

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

static/app/utils/theme/theme.chonk.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -943,11 +943,6 @@ const generateAliases = (
943943
warning: colors.yellow200,
944944
warningActive: color(colors.yellow200).opaquer(1).string(),
945945
},
946-
947-
/**
948-
* Background of alert banners at the top
949-
*/
950-
bannerBackground: colors.gray500,
951946
});
952947

953948
const fontSize = {

static/app/utils/theme/theme.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -437,11 +437,6 @@ const generateThemeAliases = (colors: Colors) => ({
437437
warning: colors.yellow200,
438438
warningActive: color(colors.yellow200).opaquer(1).string(),
439439
},
440-
441-
/**
442-
* Background of alert banners at the top
443-
*/
444-
bannerBackground: colors.gray500,
445440
});
446441

447442
type Alert = 'muted' | 'info' | 'warning' | 'success' | 'error';

static/gsApp/components/gsBanner.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, {Component, Fragment} from 'react';
2+
import {ThemeProvider} from '@emotion/react';
23
import styled from '@emotion/styled';
34
import * as Sentry from '@sentry/react';
45
import Cookies from 'js-cookie';
@@ -16,7 +17,7 @@ import {
1617
promptsUpdate,
1718
} from 'sentry/actionCreators/prompts';
1819
import type {Client} from 'sentry/api';
19-
import {Alert} from 'sentry/components/core/alert';
20+
import {Alert, type AlertProps} from 'sentry/components/core/alert';
2021
import {Badge} from 'sentry/components/core/badge';
2122
import {Button} from 'sentry/components/core/button';
2223
import {ButtonBar} from 'sentry/components/core/button/buttonBar';
@@ -33,6 +34,7 @@ import type {Organization} from 'sentry/types/organization';
3334
import {isActiveSuperuser} from 'sentry/utils/isActiveSuperuser';
3435
import {Oxfordize} from 'sentry/utils/oxfordizeArray';
3536
import {promptIsDismissed} from 'sentry/utils/promptIsDismissed';
37+
import {useInvertedTheme} from 'sentry/utils/theme/useInvertedTheme';
3638
import normalizeUrl from 'sentry/utils/url/normalizeUrl';
3739
import {useNavigate} from 'sentry/utils/useNavigate';
3840
import withApi from 'sentry/utils/withApi';
@@ -1151,7 +1153,7 @@ class GSBanner extends Component<Props, State> {
11511153
updateUrl: (
11521154
<LinkButton
11531155
to={billingUrl}
1154-
size="xs"
1156+
size="zero"
11551157
priority="default"
11561158
aria-label={t('Update payment information')}
11571159
onClick={addButtonAnalytics}
@@ -1165,7 +1167,7 @@ class GSBanner extends Component<Props, State> {
11651167
updateUrl: (
11661168
<LinkButton
11671169
to={membersPageUrl}
1168-
size="xs"
1170+
size="zero"
11691171
priority="default"
11701172
aria-label={t('Org Owner or Billing Member')}
11711173
onClick={addButtonAnalytics}
@@ -1262,8 +1264,21 @@ export default withPromotions(withApi(withSubscription(GSBanner, {noLoader: true
12621264

12631265
// XXX: We have no alert types with this styling, but for now we would like for
12641266
// it to be differentiated.
1265-
const BannerAlert = styled(Alert)`
1267+
const StyledBannerAlert = styled(Alert)`
12661268
color: ${p => p.theme.headerBackground};
1267-
background-color: ${p => p.theme.bannerBackground};
1269+
background-color: ${p => p.theme.gray500};
12681270
border: none;
12691271
`;
1272+
1273+
function BannerAlert(props: AlertProps) {
1274+
const invertedTheme = useInvertedTheme();
1275+
1276+
if (invertedTheme.isChonk) {
1277+
return (
1278+
<ThemeProvider theme={invertedTheme}>
1279+
<Alert {...props} />
1280+
</ThemeProvider>
1281+
);
1282+
}
1283+
return <StyledBannerAlert {...props} />;
1284+
}

0 commit comments

Comments
 (0)