Skip to content

Commit d74d3be

Browse files
authored
ref(ui): remove usages of DO_NOT_USE_ChonkTheme (#104439)
There is now only one `Theme`, and we can use `darkTheme` and `lightTheme` directly (even though we need to eslint-disable the import, as they are discouraged, but there are a few places where we need direct theme access).
1 parent c5f64a1 commit d74d3be

File tree

30 files changed

+74
-109
lines changed

30 files changed

+74
-109
lines changed

static/app/components/assigneeBadge.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {t, tct} from 'sentry/locale';
1212
import {space} from 'sentry/styles/space';
1313
import type {Actor} from 'sentry/types/core';
1414
import type {SuggestedOwnerReason} from 'sentry/types/group';
15-
import type {DO_NOT_USE_ChonkTheme} from 'sentry/utils/theme';
15+
import type {Theme} from 'sentry/utils/theme';
1616
import {withChonk} from 'sentry/utils/theme/withChonk';
1717

1818
type AssigneeBadgeProps = {
@@ -161,7 +161,7 @@ const UnassignedTag = withChonk(
161161
styled(StyledTag)`
162162
border-style: dashed;
163163
`,
164-
styled(StyledTag)<{theme: DO_NOT_USE_ChonkTheme}>`
164+
styled(StyledTag)<{theme: Theme}>`
165165
border: 1px dashed ${p => p.theme.border};
166166
background-color: transparent;
167167
`

static/app/components/core/avatar/letterAvatar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {useTheme} from '@emotion/react';
33
import styled from '@emotion/styled';
44
import color from 'color';
55

6-
import type {DO_NOT_USE_ChonkTheme} from 'sentry/utils/theme';
6+
import type {Theme} from 'sentry/utils/theme';
77
import {isChonkTheme} from 'sentry/utils/theme/withChonk';
88

99
import {baseAvatarStyles, type BaseAvatarStyleProps} from './baseAvatarComponentStyles';
@@ -103,7 +103,7 @@ function getColor(identifier: string | undefined): Color {
103103

104104
function getChonkColor(
105105
identifier: string | undefined,
106-
theme: DO_NOT_USE_ChonkTheme
106+
theme: Theme
107107
): {
108108
background: string;
109109
content: string;
@@ -131,7 +131,7 @@ function getInitials(displayName: string | undefined) {
131131
return initials.toUpperCase();
132132
}
133133

134-
function makeChonkLetterAvatarColors(theme: DO_NOT_USE_ChonkTheme) {
134+
function makeChonkLetterAvatarColors(theme: Theme) {
135135
return theme.chart.getColorPalette(9).map(c => ({
136136
background: c,
137137
content: color(c).isDark() ? theme.colors.white : theme.colors.black,

static/app/components/core/badge/alertBadge.chonk.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import type {AlertBadgeProps} from 'sentry/components/core/badge/alertBadge';
2-
import type {DO_NOT_USE_ChonkTheme} from 'sentry/utils/theme';
2+
import type {Theme} from 'sentry/utils/theme';
33
import {chonkStyled} from 'sentry/utils/theme/theme';
44
import {IncidentStatus} from 'sentry/views/alerts/types';
55

66
function makeChonkAlertBadgeDiamondBackgroundTheme(
77
status: AlertBadgeProps['status'],
88
isIssue: AlertBadgeProps['isIssue'],
99
isDisabled: AlertBadgeProps['isDisabled'],
10-
theme: DO_NOT_USE_ChonkTheme
10+
theme: Theme
1111
): React.CSSProperties {
1212
if (isDisabled) {
1313
return {

static/app/components/core/badge/tag.chonk.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type {TagProps} from 'sentry/components/core/badge/tag';
22
import {space} from 'sentry/styles/space';
3-
import type {DO_NOT_USE_ChonkTheme} from 'sentry/utils/theme';
3+
import type {Theme} from 'sentry/utils/theme';
44
import {chonkStyled} from 'sentry/utils/theme/theme';
55
import {unreachable} from 'sentry/utils/unreachable';
66

@@ -43,10 +43,7 @@ export const TagPill = chonkStyled('div')<{
4343
}
4444
`;
4545

46-
function makeTagPillTheme(
47-
type: TagType | undefined,
48-
theme: DO_NOT_USE_ChonkTheme
49-
): React.CSSProperties {
46+
function makeTagPillTheme(type: TagType | undefined, theme: Theme): React.CSSProperties {
5047
switch (type) {
5148
case undefined:
5249
case 'default':

static/app/components/core/button/styles.chonk.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type {DO_NOT_USE_ButtonProps as ButtonProps} from 'sentry/components/core/button/types';
22
import {chonkFor} from 'sentry/components/core/chonk';
33
// eslint-disable-next-line boundaries/element-types
4-
import type {DO_NOT_USE_ChonkTheme, StrictCSSObject} from 'sentry/utils/theme';
4+
import type {StrictCSSObject, Theme} from 'sentry/utils/theme';
55

66
// @TODO: remove Link type in the future
77
type ChonkButtonType =
@@ -43,7 +43,7 @@ const chonkHoverElevation = '1px';
4343
export function DO_NOT_USE_getChonkButtonStyles(
4444
p: Pick<ButtonProps, 'priority' | 'busy' | 'disabled' | 'borderless'> & {
4545
size: NonNullable<ButtonProps['size']>;
46-
theme: DO_NOT_USE_ChonkTheme;
46+
theme: Theme;
4747
}
4848
): StrictCSSObject {
4949
const type = chonkPriorityToType(p.priority);
@@ -254,7 +254,7 @@ export function DO_NOT_USE_getChonkButtonStyles(
254254
};
255255
}
256256

257-
function getChonkButtonTheme(type: ChonkButtonType, theme: DO_NOT_USE_ChonkTheme) {
257+
function getChonkButtonTheme(type: ChonkButtonType, theme: Theme) {
258258
switch (type) {
259259
case 'default':
260260
return {
@@ -299,7 +299,7 @@ function getChonkButtonTheme(type: ChonkButtonType, theme: DO_NOT_USE_ChonkTheme
299299

300300
function getChonkButtonSizeTheme(
301301
size: ButtonProps['size'],
302-
theme: DO_NOT_USE_ChonkTheme
302+
theme: Theme
303303
): StrictCSSObject {
304304
switch (size) {
305305
case 'md':

static/app/components/core/chonk.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import color from 'color';
22

3-
import type {DO_NOT_USE_ChonkTheme} from 'sentry/utils/theme';
3+
import type {Theme} from 'sentry/utils/theme';
44

55
const chonkCache = new Map<{baseColor: string; type: 'light' | 'dark'}, string>();
66

7-
export function chonkFor(theme: DO_NOT_USE_ChonkTheme, baseColor: string) {
7+
export function chonkFor(theme: Theme, baseColor: string) {
88
const cacheKey = {baseColor, type: theme.type};
99
if (chonkCache.has(cacheKey)) {
1010
return chonkCache.get(cacheKey)!;
@@ -23,7 +23,7 @@ export function chonkFor(theme: DO_NOT_USE_ChonkTheme, baseColor: string) {
2323
return result;
2424
}
2525

26-
export function debossedBackground(theme: DO_NOT_USE_ChonkTheme) {
26+
export function debossedBackground(theme: Theme) {
2727
return {
2828
backgroundColor: theme.type === 'dark' ? 'rgba(8,0,24,0.28)' : 'rgba(0,0,112,0.03)',
2929
};

static/app/components/core/code/codeBlock.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import {IconCopy} from 'sentry/icons';
88
import {t} from 'sentry/locale';
99
import {space} from 'sentry/styles/space';
1010
import {loadPrismLanguage} from 'sentry/utils/prism';
11-
import {DO_NOT_USE_darkChonkTheme} from 'sentry/utils/theme/theme';
11+
// eslint-disable-next-line no-restricted-imports
12+
import {darkTheme} from 'sentry/utils/theme/theme';
1213

1314
interface CodeBlockProps {
1415
children: string;
@@ -209,11 +210,7 @@ export function CodeBlock({
209210

210211
// Override theme provider when in dark mode to provider dark theme to
211212
// components
212-
return (
213-
<ThemeProvider theme={dark ? (DO_NOT_USE_darkChonkTheme as any) : theme}>
214-
{snippet}
215-
</ThemeProvider>
216-
);
213+
return <ThemeProvider theme={dark ? darkTheme : theme}>{snippet}</ThemeProvider>;
217214
}
218215

219216
const FlexSpacer = styled('div')`

static/app/components/core/input/input.chonk.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {debossedBackground} from 'sentry/components/core/chonk';
2-
import type {DO_NOT_USE_ChonkTheme, StrictCSSObject} from 'sentry/utils/theme';
2+
import type {StrictCSSObject, Theme} from 'sentry/utils/theme';
33

44
import type {InputStylesProps} from './input';
55

@@ -8,7 +8,7 @@ export const chonkInputStyles = ({
88
monospace,
99
readOnly,
1010
size = 'md',
11-
}: InputStylesProps & {theme: DO_NOT_USE_ChonkTheme}): StrictCSSObject => {
11+
}: InputStylesProps & {theme: Theme}): StrictCSSObject => {
1212
const boxShadow = `0px 1px 0px 0px ${theme.tokens.border.primary} inset`;
1313

1414
return {

static/app/components/core/input/inputGroup.chonk.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import styled from '@emotion/styled';
44
import {Input} from 'sentry/components/core/input/index';
55
import {TextArea} from 'sentry/components/core/textarea';
66
import {space} from 'sentry/styles/space';
7-
import type {DO_NOT_USE_ChonkTheme, FormSize, StrictCSSObject} from 'sentry/utils/theme';
7+
import type {FormSize, StrictCSSObject, Theme} from 'sentry/utils/theme';
88
import {chonkStyled} from 'sentry/utils/theme/theme';
99

1010
export interface InputStyleProps {
@@ -35,7 +35,7 @@ const chonkInputStyles = ({
3535
trailingWidth,
3636
size = 'md',
3737
theme,
38-
}: InputStyleProps & {theme: DO_NOT_USE_ChonkTheme}): StrictCSSObject => css`
38+
}: InputStyleProps & {theme: Theme}): StrictCSSObject => css`
3939
${leadingWidth &&
4040
css`
4141
padding-left: calc(

static/app/components/core/layout/styles.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {useCallback, useMemo, useSyncExternalStore} from 'react';
22
import {css, useTheme, type SerializedStyles} from '@emotion/react';
33

4-
import type {DO_NOT_USE_ChonkTheme, Theme} from 'sentry/utils/theme';
4+
import type {Theme} from 'sentry/utils/theme';
55
import {isChonkTheme} from 'sentry/utils/theme/withChonk';
66

77
// It is unfortunate, but Emotion seems to use the fn callback name in the classname, so lets keep it short.
@@ -65,7 +65,7 @@ const BREAKPOINT_ORDER: readonly Breakpoint[] = [
6565
];
6666

6767
// We alias None -> 0 to make it slighly more terse and easier to read.
68-
export type RadiusSize = keyof DO_NOT_USE_ChonkTheme['radius'];
68+
export type RadiusSize = keyof Theme['radius'];
6969
export type SpacingSize = keyof Theme['space'];
7070
export type Border = keyof Theme['tokens']['border'];
7171
export type Breakpoint = keyof Theme['breakpoints'];

0 commit comments

Comments
 (0)