Skip to content

Commit cad9227

Browse files
authored
nav: chonk compat for legacy nav (#89929)
Backwards compat for the legacy nav, so that we can decouple chonk launch from the nav launch. Chonk uses a light navbar here, so the colors need to be inverted (we were using a lot of white and black colors)
1 parent df97eb1 commit cad9227

File tree

6 files changed

+52
-33
lines changed

6 files changed

+52
-33
lines changed

static/app/components/sidebar/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,18 +665,20 @@ const PrimaryItems = styled('div')`
665665
@media (max-height: 675px) and (min-width: ${p => p.theme.breakpoints.medium}) {
666666
border-bottom: 1px solid ${p => p.theme.sidebar.border};
667667
padding-bottom: ${space(1)};
668-
box-shadow: rgba(0, 0, 0, 0.15) 0px -10px 10px inset;
668+
box-shadow: ${p =>
669+
p.theme.isChonk ? 'none' : 'rgba(0, 0, 0, 0.15) 0px -10px 10px inset'};
669670
}
670671
@media (max-width: ${p => p.theme.breakpoints.medium}) {
671672
overflow-y: hidden;
672673
overflow-x: auto;
673674
flex-direction: row;
674675
height: 100%;
675676
align-items: center;
676-
border-right: 1px solid ${p => p.theme.sidebar.border};
677677
padding-right: ${space(1)};
678678
margin-right: ${space(0.5)};
679-
box-shadow: rgba(0, 0, 0, 0.15) -10px 0px 10px inset;
679+
border-right: none;
680+
box-shadow: ${p =>
681+
p.theme.isChonk ? 'none' : 'rgba(0, 0, 0, 0.15) -10px 0px 10px inset'};
680682
::-webkit-scrollbar {
681683
display: none;
682684
}

static/app/components/sidebar/sidebarAccordion.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {ExpandedContext} from 'sentry/components/sidebar/expandedContextProvider
1919
import {IconChevron} from 'sentry/icons';
2020
import {t} from 'sentry/locale';
2121
import {space} from 'sentry/styles/space';
22+
import {isChonkTheme} from 'sentry/utils/theme/withChonk';
2223
import {useLocalStorageState} from 'sentry/utils/useLocalStorageState';
2324
import useMedia from 'sentry/utils/useMedia';
2425
import {useNavigate} from 'sentry/utils/useNavigate';
@@ -275,7 +276,7 @@ const SidebarAccordionExpandButton = styled(Button)<{sidebarCollapsed?: boolean}
275276
&:hover,
276277
a:hover &,
277278
a[active] & {
278-
color: ${p => p.theme.white};
279+
color: ${p => (isChonkTheme(p.theme) ? p.theme.colors.blue400 : p.theme.white)};
279280
}
280281
281282
${p => p.sidebarCollapsed && `display: none;`}

static/app/components/sidebar/sidebarDropdown/index.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {t} from 'sentry/locale';
2323
import ConfigStore from 'sentry/stores/configStore';
2424
import {useLegacyStore} from 'sentry/stores/useLegacyStore';
2525
import {space} from 'sentry/styles/space';
26+
import {isChonkTheme} from 'sentry/utils/theme/withChonk';
2627
import useApi from 'sentry/utils/useApi';
2728
import useOrganization from 'sentry/utils/useOrganization';
2829
import useProjects from 'sentry/utils/useProjects';
@@ -213,8 +214,9 @@ const OrgOrUserName = styled(TextOverflow)`
213214
font-size: ${p => p.theme.fontSizeLarge};
214215
line-height: 1.2;
215216
font-weight: ${p => p.theme.fontWeightBold};
216-
color: ${p => p.theme.white};
217-
text-shadow: 0 0 6px rgba(255, 255, 255, 0);
217+
color: ${p => (isChonkTheme(p.theme) ? p.theme.textColor : p.theme.white)};
218+
text-shadow: ${p =>
219+
isChonkTheme(p.theme) ? 'none' : '0 0 6px rgba(255, 255, 255, 0)'};
218220
transition: 0.15s text-shadow linear;
219221
`;
220222

@@ -235,18 +237,19 @@ const SidebarDropdownActor = styled('button')`
235237
236238
&:hover {
237239
${OrgOrUserName} {
238-
text-shadow: 0 0 6px rgba(255, 255, 255, 0.1);
240+
text-shadow: ${p =>
241+
isChonkTheme(p.theme) ? 'none' : '0 0 6px rgba(255, 255, 255, 0.1)'};
239242
}
240243
${UserNameOrEmail} {
241-
color: ${p => p.theme.white};
244+
color: ${p => (isChonkTheme(p.theme) ? p.theme.textColor : p.theme.white)};
242245
}
243246
}
244247
`;
245248

246249
const AvatarStyles = (p: {collapsed: boolean; theme: Theme}) => css`
247250
margin: ${space(0.25)} 0;
248251
margin-right: ${p.collapsed ? '0' : space(1.5)};
249-
box-shadow: 0 2px 0 rgba(0, 0, 0, 0.08);
252+
box-shadow: ${isChonkTheme(p.theme) ? 'none' : '0 2px 0 rgba(0, 0, 0, 0.08)'};
250253
border-radius: 6px; /* Fixes background bleeding on corners */
251254
252255
@media (max-width: ${p.theme.breakpoints.medium}) {

static/app/components/sidebar/sidebarDropdownMenu.styled.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ const SidebarDropdownMenu = (p: {theme: Theme}) => css`
66
background: ${p.theme.background};
77
color: ${p.theme.textColor};
88
border-radius: 4px;
9-
box-shadow:
10-
0 0 0 1px rgba(0, 0, 0, 0.08),
11-
0 4px 20px 0 rgba(0, 0, 0, 0.3);
9+
border: ${p.theme.isChonk ? `1px solid ${p.theme.border}` : 'none'};
10+
border-bottom: ${p.theme.isChonk ? `2px solid ${p.theme.border}` : 'none'};
11+
box-shadow: ${p.theme.isChonk
12+
? 'none'
13+
: '0 0 0 1px rgba(0, 0, 0, 0.08), 0 4px 20px 0 rgba(0, 0, 0, 0.3)'};
1214
padding: 5px 0;
1315
width: 250px;
1416
z-index: 1000;

static/app/components/sidebar/sidebarItem.tsx

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Fragment, isValidElement, useCallback, useContext, useMemo} from 'react';
2-
import type {Theme} from '@emotion/react';
2+
import {type Theme, useTheme} from '@emotion/react';
33
import {css} from '@emotion/react';
44
import styled from '@emotion/styled';
55
import type {LocationDescriptor} from 'history';
@@ -16,6 +16,7 @@ import {space} from 'sentry/styles/space';
1616
import {defined} from 'sentry/utils';
1717
import {trackAnalytics} from 'sentry/utils/analytics';
1818
import localStorage from 'sentry/utils/localStorage';
19+
import {isChonkTheme} from 'sentry/utils/theme/withChonk';
1920
import normalizeUrl from 'sentry/utils/url/normalizeUrl';
2021
import useOrganization from 'sentry/utils/useOrganization';
2122
import useRouter from 'sentry/utils/useRouter';
@@ -151,6 +152,7 @@ function SidebarItem({
151152
badgeTitle,
152153
...props
153154
}: SidebarItemProps) {
155+
const theme = useTheme();
154156
const {setExpandedItemId, shouldAccordionFloat} = useContext(ExpandedContext);
155157
const router = useRouter();
156158
// label might be wrapped in a guideAnchor
@@ -242,6 +244,7 @@ function SidebarItem({
242244
<SidebarNavigationItemHook id={id}>
243245
{({additionalContent}) => (
244246
<StyledSidebarItem
247+
theme={theme}
245248
{...props}
246249
id={`sidebar-item-${id}`}
247250
isInFloatingAccordion={isInFloatingAccordion}
@@ -371,10 +374,10 @@ const getActiveStyle = ({
371374
theme,
372375
isInFloatingAccordion,
373376
}: {
377+
theme: Theme;
374378
active?: string;
375379
hasNewNav?: boolean;
376380
isInFloatingAccordion?: boolean;
377-
theme?: Theme;
378381
}) => {
379382
if (!active) {
380383
return '';
@@ -384,21 +387,23 @@ const getActiveStyle = ({
384387
&:active,
385388
&:focus,
386389
&:hover {
387-
color: ${theme?.gray400};
390+
color: ${isChonkTheme(theme) ? theme.subText : theme.gray400};
388391
}
389392
`;
390393
}
391394
return css`
392-
color: ${theme?.white};
395+
color: ${isChonkTheme(theme) ? theme.colors.blue400 : theme.white};
393396
394397
&:active,
395398
&:focus,
396399
&:hover {
397-
color: ${theme?.white};
400+
color: ${isChonkTheme(theme) ? theme.colors.blue400 : theme.white};
398401
}
399402
400403
&:before {
401-
background-color: ${theme?.active};
404+
background-color: ${!!theme && isChonkTheme(theme)
405+
? theme.colors.chonk.blue400
406+
: theme.active};
402407
}
403408
`;
404409
};
@@ -407,12 +412,17 @@ const StyledSidebarItem = styled(Link, {
407412
shouldForwardProp: p =>
408413
!['isInFloatingAccordion', 'hasNewNav', 'index', 'organization'].includes(p),
409414
})`
415+
color: ${p =>
416+
isChonkTheme(p.theme)
417+
? p.theme.subText
418+
: p.isInFloatingAccordion
419+
? p.theme.gray400
420+
: 'inherit'};
421+
height: ${p => (p.isInFloatingAccordion ? '35px' : p.hasNewNav ? '40px' : '30px')};
410422
display: flex;
411-
color: ${p => (p.isInFloatingAccordion ? p.theme.gray400 : 'inherit')};
412423
position: relative;
413424
cursor: pointer;
414425
font-size: 15px;
415-
height: ${p => (p.isInFloatingAccordion ? '35px' : p.hasNewNav ? '40px' : '30px')};
416426
flex-shrink: 0;
417427
border-radius: ${p => p.theme.borderRadius};
418428
transition: none;
@@ -458,11 +468,11 @@ const StyledSidebarItem = styled(Link, {
458468
if (p.isInFloatingAccordion) {
459469
return css`
460470
background-color: ${p.theme.hover};
461-
color: ${p.theme.gray400};
471+
color: ${isChonkTheme(p.theme) ? p.theme.subText : p.theme.gray400};
462472
`;
463473
}
464474
return css`
465-
color: ${p.theme.white};
475+
color: ${isChonkTheme(p.theme) ? p.theme.colors.chonk.blue400 : p.theme.white};
466476
`;
467477
}}
468478
}
@@ -483,10 +493,10 @@ const SidebarItemWrapper = styled('div')<{collapsed?: boolean; hasNewNav?: boole
483493
display: flex;
484494
align-items: center;
485495
justify-content: center;
486-
${p => p.hasNewNav && 'flex-direction: column;'}
487496
width: 100%;
488-
497+
${p => p.hasNewNav && 'flex-direction: column;'}
489498
${p => !p.collapsed && `padding-right: ${space(1)};`}
499+
490500
@media (max-width: ${p => p.theme.breakpoints.medium}) {
491501
padding-right: 0;
492502
}
@@ -541,26 +551,27 @@ const getCollapsedBadgeStyle = ({collapsed, theme}: any) => {
541551
}
542552

543553
return css`
554+
background: ${theme.red300};
544555
text-indent: -99999em;
545556
position: absolute;
546557
right: 0;
547558
top: 1px;
548-
background: ${theme.red300};
549559
width: 11px;
550560
height: 11px;
551561
border-radius: 11px;
552562
line-height: 11px;
553-
box-shadow: 0 3px 3px #2f2936;
563+
box-shadow: ${theme.isChonk ? 'none' : '0 3px 3px #2f2936'};
554564
`;
555565
};
556566

557567
// @ts-expect-error TS(7031): Binding element '_' implicitly has an 'any' type.
558568
const SidebarItemBadge = styled(({collapsed: _, ...props}) => <span {...props} />)`
569+
color: ${p => p.theme.white};
570+
background: ${p =>
571+
isChonkTheme(p.theme) ? p.theme.colors.chonk.red400 : p.theme.red300};
559572
display: block;
560573
text-align: center;
561-
color: ${p => p.theme.white};
562574
font-size: 12px;
563-
background: ${p => p.theme.red300};
564575
width: 22px;
565576
height: 22px;
566577
border-radius: 22px;
@@ -576,6 +587,6 @@ const CollapsedFeatureBadge = styled(FeatureBadge)`
576587
`;
577588

578589
const StyledInteractionStateLayer = styled(InteractionStateLayer)`
579-
height: ${16 * 2 + 40}px;
590+
height: 72px;
580591
width: 70px;
581592
`;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ export const DO_NOT_USE_lightChonkTheme: ChonkTheme = {
10721072
scrollbarThumbColor: '#A0A0A0',
10731073
scrollbarColorTrack: 'rgba(45,26,50,92.42)', // end of the gradient which is used for background
10741074
gradient: lightAliases.background,
1075-
border: 'transparent',
1075+
border: lightAliases.border,
10761076
superuser: '#880808',
10771077
},
10781078
};
@@ -1142,11 +1142,11 @@ export const DO_NOT_USE_darkChonkTheme: ChonkTheme = {
11421142
},
11431143

11441144
sidebar: {
1145-
background: lightAliases.background,
1145+
background: darkAliases.background,
11461146
scrollbarThumbColor: '#A0A0A0',
11471147
scrollbarColorTrack: 'rgba(45,26,50,92.42)', // end of the gradient which is used for background
1148-
gradient: `none`,
1149-
border: 'transparent',
1148+
gradient: darkAliases.background,
1149+
border: darkAliases.border,
11501150
superuser: '#880808',
11511151
},
11521152
};

0 commit comments

Comments
 (0)