index.tsx 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  1. import {Fragment, useCallback, useContext, useEffect} from 'react';
  2. import {css} from '@emotion/react';
  3. import styled from '@emotion/styled';
  4. import {hideSidebar, showSidebar} from 'sentry/actionCreators/preferences';
  5. import Feature from 'sentry/components/acl/feature';
  6. import GuideAnchor from 'sentry/components/assistant/guideAnchor';
  7. import {OnboardingContext} from 'sentry/components/onboarding/onboardingContext';
  8. import {getMergedTasks} from 'sentry/components/onboardingWizard/taskConfig';
  9. import PerformanceOnboardingSidebar from 'sentry/components/performanceOnboarding/sidebar';
  10. import ReplaysOnboardingSidebar from 'sentry/components/replaysOnboarding/sidebar';
  11. import {isDone} from 'sentry/components/sidebar/utils';
  12. import {
  13. IconChevron,
  14. IconDashboard,
  15. IconGraph,
  16. IconIssues,
  17. IconLightning,
  18. IconMegaphone,
  19. IconPlay,
  20. IconProfiling,
  21. IconProject,
  22. IconReleases,
  23. IconSettings,
  24. IconSiren,
  25. IconStar,
  26. IconStats,
  27. IconSupport,
  28. IconTelescope,
  29. IconTimer,
  30. } from 'sentry/icons';
  31. import {t} from 'sentry/locale';
  32. import ConfigStore from 'sentry/stores/configStore';
  33. import DemoWalkthroughStore from 'sentry/stores/demoWalkthroughStore';
  34. import HookStore from 'sentry/stores/hookStore';
  35. import PreferencesStore from 'sentry/stores/preferencesStore';
  36. import SidebarPanelStore from 'sentry/stores/sidebarPanelStore';
  37. import {useLegacyStore} from 'sentry/stores/useLegacyStore';
  38. import {space} from 'sentry/styles/space';
  39. import {Organization} from 'sentry/types';
  40. import {isDemoWalkthrough} from 'sentry/utils/demoMode';
  41. import {getDiscoverLandingUrl} from 'sentry/utils/discover/urls';
  42. import {isActiveSuperuser} from 'sentry/utils/isActiveSuperuser';
  43. import theme from 'sentry/utils/theme';
  44. import {useLocation} from 'sentry/utils/useLocation';
  45. import useMedia from 'sentry/utils/useMedia';
  46. import useProjects from 'sentry/utils/useProjects';
  47. import {RELEASE_LEVEL as WEBVITALS_RELEASE_LEVEL} from 'sentry/views/performance/browser/webVitals/settings';
  48. import {SCREENS_RELEASE_LEVEL} from 'sentry/views/performance/mobile/settings';
  49. import {ProfilingOnboardingSidebar} from '../profiling/ProfilingOnboarding/profilingOnboardingSidebar';
  50. import Broadcasts from './broadcasts';
  51. import SidebarHelp from './help';
  52. import OnboardingStatus from './onboardingStatus';
  53. import ServiceIncidents from './serviceIncidents';
  54. import {SidebarAccordion} from './sidebarAccordion';
  55. import SidebarDropdown from './sidebarDropdown';
  56. import SidebarItem from './sidebarItem';
  57. import {SidebarOrientation, SidebarPanelKey} from './types';
  58. type Props = {
  59. organization?: Organization;
  60. };
  61. function activatePanel(panel: SidebarPanelKey) {
  62. SidebarPanelStore.activatePanel(panel);
  63. }
  64. function togglePanel(panel: SidebarPanelKey) {
  65. SidebarPanelStore.togglePanel(panel);
  66. }
  67. function hidePanel() {
  68. SidebarPanelStore.hidePanel();
  69. }
  70. function useOpenOnboardingSidebar(organization?: Organization) {
  71. const onboardingContext = useContext(OnboardingContext);
  72. const {projects: project} = useProjects();
  73. const location = useLocation();
  74. const openOnboardingSidebar = (() => {
  75. if (location?.hash === '#welcome') {
  76. if (organization && !ConfigStore.get('demoMode')) {
  77. const tasks = getMergedTasks({
  78. organization,
  79. projects: project,
  80. onboardingContext,
  81. });
  82. const allDisplayedTasks = tasks
  83. .filter(task => task.display)
  84. .filter(task => !task.renderCard);
  85. const doneTasks = allDisplayedTasks.filter(isDone);
  86. return !(doneTasks.length >= allDisplayedTasks.length);
  87. }
  88. return true;
  89. }
  90. return false;
  91. })();
  92. useEffect(() => {
  93. if (openOnboardingSidebar) {
  94. activatePanel(SidebarPanelKey.ONBOARDING_WIZARD);
  95. }
  96. }, [openOnboardingSidebar]);
  97. }
  98. function Sidebar({organization}: Props) {
  99. const location = useLocation();
  100. const config = useLegacyStore(ConfigStore);
  101. const preferences = useLegacyStore(PreferencesStore);
  102. const activePanel = useLegacyStore(SidebarPanelStore);
  103. const collapsed = !!preferences.collapsed;
  104. const horizontal = useMedia(`(max-width: ${theme.breakpoints.medium})`);
  105. const hasSuperuserSession = isActiveSuperuser(organization);
  106. useOpenOnboardingSidebar();
  107. const toggleCollapse = useCallback(() => {
  108. if (collapsed) {
  109. showSidebar();
  110. } else {
  111. hideSidebar();
  112. }
  113. }, [collapsed]);
  114. // Close panel on any navigation
  115. useEffect(() => void hidePanel(), [location?.pathname]);
  116. // Add classname to body
  117. useEffect(() => {
  118. const bcl = document.body.classList;
  119. bcl.add('body-sidebar');
  120. return () => bcl.remove('body-sidebar');
  121. }, []);
  122. useEffect(() => {
  123. Object.values(SidebarPanelKey).forEach(key => {
  124. if (location?.hash === `#sidebar-${key}`) {
  125. togglePanel(key);
  126. }
  127. });
  128. }, [location?.hash]);
  129. // Add sidebar collapse classname to body
  130. useEffect(() => {
  131. const bcl = document.body.classList;
  132. if (collapsed) {
  133. bcl.add('collapsed');
  134. } else {
  135. bcl.remove('collapsed');
  136. }
  137. return () => bcl.remove('collapsed');
  138. }, [collapsed]);
  139. const hasPanel = !!activePanel;
  140. const hasOrganization = !!organization;
  141. const orientation: SidebarOrientation = horizontal ? 'top' : 'left';
  142. const sidebarItemProps = {
  143. orientation,
  144. collapsed,
  145. hasPanel,
  146. organization,
  147. };
  148. const sidebarAnchor = isDemoWalkthrough() ? (
  149. <GuideAnchor target="projects" disabled={!DemoWalkthroughStore.get('sidebar')}>
  150. {t('Projects')}
  151. </GuideAnchor>
  152. ) : (
  153. <GuideAnchor target="projects">{t('Projects')}</GuideAnchor>
  154. );
  155. const projects = hasOrganization && (
  156. <SidebarItem
  157. {...sidebarItemProps}
  158. index
  159. icon={<IconProject />}
  160. label={sidebarAnchor}
  161. to={`/organizations/${organization.slug}/projects/`}
  162. id="projects"
  163. />
  164. );
  165. const issues = hasOrganization && (
  166. <SidebarItem
  167. {...sidebarItemProps}
  168. icon={<IconIssues />}
  169. label={<GuideAnchor target="issues">{t('Issues')}</GuideAnchor>}
  170. to={`/organizations/${organization.slug}/issues/`}
  171. search="?referrer=sidebar"
  172. id="issues"
  173. />
  174. );
  175. const discover2 = hasOrganization && (
  176. <Feature
  177. hookName="feature-disabled:discover2-sidebar-item"
  178. features="discover-basic"
  179. organization={organization}
  180. >
  181. <SidebarItem
  182. {...sidebarItemProps}
  183. icon={<IconTelescope />}
  184. label={<GuideAnchor target="discover">{t('Discover')}</GuideAnchor>}
  185. to={getDiscoverLandingUrl(organization)}
  186. id="discover-v2"
  187. />
  188. </Feature>
  189. );
  190. const performance = hasOrganization && (
  191. <Feature
  192. hookName="feature-disabled:performance-sidebar-item"
  193. features="performance-view"
  194. organization={organization}
  195. >
  196. {(() => {
  197. // If Database View or Web Vitals View is enabled, show a Performance accordion with a Database and/or Web Vitals sub-item
  198. if (
  199. organization.features.includes('performance-database-view') ||
  200. organization.features.includes('starfish-browser-webvitals') ||
  201. organization.features.includes('performance-screens-view')
  202. ) {
  203. return (
  204. <SidebarAccordion
  205. {...sidebarItemProps}
  206. icon={<IconLightning />}
  207. label={<GuideAnchor target="performance">{t('Performance')}</GuideAnchor>}
  208. to={`/organizations/${organization.slug}/performance/`}
  209. id="performance"
  210. >
  211. <Feature features="performance-database-view" organization={organization}>
  212. <SidebarItem
  213. {...sidebarItemProps}
  214. label={
  215. <GuideAnchor target="performance-database">
  216. {t('Queries')}
  217. </GuideAnchor>
  218. }
  219. to={`/organizations/${organization.slug}/performance/database/`}
  220. id="performance-database"
  221. // collapsed controls whether the dot is visible or not.
  222. // We always want it visible for these sidebar items so force it to true.
  223. icon={<SubitemDot collapsed />}
  224. />
  225. </Feature>
  226. <Feature features="starfish-browser-webvitals" organization={organization}>
  227. <SidebarItem
  228. {...sidebarItemProps}
  229. isAlpha={WEBVITALS_RELEASE_LEVEL === 'alpha'}
  230. isBeta={WEBVITALS_RELEASE_LEVEL === 'beta'}
  231. isNew={WEBVITALS_RELEASE_LEVEL === 'new'}
  232. label={
  233. <GuideAnchor target="performance-webvitals">
  234. {t('Web Vitals')}
  235. </GuideAnchor>
  236. }
  237. to={`/organizations/${organization.slug}/performance/browser/pageloads/`}
  238. id="performance-webvitals"
  239. icon={<SubitemDot collapsed />}
  240. />
  241. </Feature>
  242. <Feature features="performance-screens-view" organization={organization}>
  243. <SidebarItem
  244. {...sidebarItemProps}
  245. isAlpha={SCREENS_RELEASE_LEVEL === 'alpha'}
  246. isBeta={SCREENS_RELEASE_LEVEL === 'beta'}
  247. isNew={SCREENS_RELEASE_LEVEL === 'new'}
  248. label={t('Mobile')}
  249. to={`/organizations/${organization.slug}/performance/mobile/screens/`}
  250. id="performance-mobile-screens"
  251. icon={<SubitemDot collapsed />}
  252. />
  253. </Feature>
  254. <Feature features="starfish-browser-resource-module-ui">
  255. <SidebarItem
  256. {...sidebarItemProps}
  257. isNew
  258. label={<GuideAnchor target="starfish">{t('Resources')}</GuideAnchor>}
  259. to={`/organizations/${organization.slug}/performance/browser/resources`}
  260. id="performance-browser-resources"
  261. icon={<SubitemDot collapsed />}
  262. />
  263. </Feature>
  264. </SidebarAccordion>
  265. );
  266. }
  267. // Otherwise, show a regular sidebar link to the Performance landing page
  268. return (
  269. <SidebarItem
  270. {...sidebarItemProps}
  271. icon={<IconLightning />}
  272. label={<GuideAnchor target="performance">{t('Performance')}</GuideAnchor>}
  273. to={`/organizations/${organization.slug}/performance/`}
  274. id="performance"
  275. />
  276. );
  277. })()}
  278. </Feature>
  279. );
  280. const starfish = hasOrganization && (
  281. <Feature
  282. hookName="feature-disabled:starfish-view"
  283. features="starfish-view"
  284. organization={organization}
  285. >
  286. <SidebarAccordion
  287. {...sidebarItemProps}
  288. icon={<IconStar />}
  289. aria-label={t('Starfish')}
  290. label={<GuideAnchor target="starfish">{t('Starfish')}</GuideAnchor>}
  291. to={`/organizations/${organization.slug}/starfish/`}
  292. id="starfish"
  293. exact
  294. >
  295. <SidebarItem
  296. {...sidebarItemProps}
  297. label={<GuideAnchor target="starfish">{t('Database')}</GuideAnchor>}
  298. to={`/organizations/${organization.slug}/performance/database/`}
  299. id="performance-database"
  300. icon={<SubitemDot collapsed={collapsed} />}
  301. />
  302. <SidebarItem
  303. {...sidebarItemProps}
  304. label={<GuideAnchor target="starfish">{t('Interactions')}</GuideAnchor>}
  305. to={`/organizations/${organization.slug}/performance/browser/interactions`}
  306. id="performance-browser-interactions"
  307. icon={<SubitemDot collapsed={collapsed} />}
  308. />
  309. <SidebarItem
  310. {...sidebarItemProps}
  311. label={<GuideAnchor target="starfish">{t('App Startup')}</GuideAnchor>}
  312. to={`/organizations/${organization.slug}/starfish/appStartup`}
  313. id="performance-mobile-app-startup"
  314. icon={<SubitemDot collapsed={collapsed} />}
  315. />
  316. </SidebarAccordion>
  317. </Feature>
  318. );
  319. const releases = hasOrganization && (
  320. <SidebarItem
  321. {...sidebarItemProps}
  322. icon={<IconReleases />}
  323. label={<GuideAnchor target="releases">{t('Releases')}</GuideAnchor>}
  324. to={`/organizations/${organization.slug}/releases/`}
  325. id="releases"
  326. />
  327. );
  328. const userFeedback = hasOrganization && (
  329. <Feature features="old-user-feedback" organization={organization}>
  330. <SidebarItem
  331. {...sidebarItemProps}
  332. icon={<IconSupport />}
  333. label={t('User Feedback')}
  334. to={`/organizations/${organization.slug}/user-feedback/`}
  335. id="user-feedback"
  336. />
  337. </Feature>
  338. );
  339. const feedback = hasOrganization && (
  340. <Feature features="user-feedback-ui" organization={organization}>
  341. <SidebarItem
  342. {...sidebarItemProps}
  343. icon={<IconMegaphone />}
  344. label={t('User Feedback')}
  345. isBeta
  346. variant="short"
  347. to={`/organizations/${organization.slug}/feedback/`}
  348. id="feedback"
  349. />
  350. </Feature>
  351. );
  352. const alerts = hasOrganization && (
  353. <SidebarItem
  354. {...sidebarItemProps}
  355. icon={<IconSiren />}
  356. label={t('Alerts')}
  357. to={`/organizations/${organization.slug}/alerts/rules/`}
  358. id="alerts"
  359. />
  360. );
  361. const monitors = hasOrganization && (
  362. <Feature features="monitors" organization={organization}>
  363. <SidebarItem
  364. {...sidebarItemProps}
  365. icon={<IconTimer />}
  366. label={t('Crons')}
  367. to={`/organizations/${organization.slug}/crons/`}
  368. id="crons"
  369. isBeta
  370. />
  371. </Feature>
  372. );
  373. const replays = hasOrganization && (
  374. <Feature
  375. hookName="feature-disabled:replay-sidebar-item"
  376. features="session-replay-ui"
  377. organization={organization}
  378. requireAll={false}
  379. >
  380. <SidebarItem
  381. {...sidebarItemProps}
  382. icon={<IconPlay />}
  383. label={t('Replays')}
  384. to={`/organizations/${organization.slug}/replays/`}
  385. id="replays"
  386. />
  387. </Feature>
  388. );
  389. const ddm = hasOrganization && (
  390. <Feature
  391. features={['ddm-ui', 'custom-metrics']}
  392. organization={organization}
  393. requireAll
  394. >
  395. <SidebarItem
  396. {...sidebarItemProps}
  397. icon={<IconGraph />}
  398. label={t('DDM')}
  399. to={`/organizations/${organization.slug}/ddm/`}
  400. id="ddm"
  401. isAlpha
  402. />
  403. </Feature>
  404. );
  405. const dashboards = hasOrganization && (
  406. <Feature
  407. hookName="feature-disabled:dashboards-sidebar-item"
  408. features={['discover', 'discover-query', 'dashboards-basic', 'dashboards-edit']}
  409. organization={organization}
  410. requireAll={false}
  411. >
  412. <SidebarItem
  413. {...sidebarItemProps}
  414. index
  415. icon={<IconDashboard />}
  416. label={t('Dashboards')}
  417. to={`/organizations/${organization.slug}/dashboards/`}
  418. id="customizable-dashboards"
  419. />
  420. </Feature>
  421. );
  422. const profiling = hasOrganization && (
  423. <Feature
  424. hookName="feature-disabled:profiling-sidebar-item"
  425. features="profiling"
  426. organization={organization}
  427. requireAll={false}
  428. >
  429. <SidebarItem
  430. {...sidebarItemProps}
  431. index
  432. icon={<IconProfiling />}
  433. label={t('Profiling')}
  434. to={`/organizations/${organization.slug}/profiling/`}
  435. id="profiling"
  436. />
  437. </Feature>
  438. );
  439. const stats = hasOrganization && (
  440. <SidebarItem
  441. {...sidebarItemProps}
  442. icon={<IconStats />}
  443. label={t('Stats')}
  444. to={`/organizations/${organization.slug}/stats/`}
  445. id="stats"
  446. />
  447. );
  448. const settings = hasOrganization && (
  449. <SidebarItem
  450. {...sidebarItemProps}
  451. icon={<IconSettings />}
  452. label={t('Settings')}
  453. to={`/settings/${organization.slug}/`}
  454. id="settings"
  455. />
  456. );
  457. return (
  458. <SidebarWrapper
  459. aria-label={t('Primary Navigation')}
  460. collapsed={collapsed}
  461. isSuperuser={hasSuperuserSession}
  462. >
  463. <SidebarSectionGroupPrimary>
  464. <SidebarSection>
  465. <SidebarDropdown
  466. orientation={orientation}
  467. collapsed={collapsed}
  468. org={organization}
  469. user={config.user}
  470. config={config}
  471. />
  472. </SidebarSection>
  473. <PrimaryItems>
  474. {hasOrganization && (
  475. <Fragment>
  476. <SidebarSection>
  477. {issues}
  478. {projects}
  479. </SidebarSection>
  480. <SidebarSection>
  481. {performance}
  482. {starfish}
  483. {profiling}
  484. {ddm}
  485. {replays}
  486. {feedback}
  487. {monitors}
  488. {alerts}
  489. </SidebarSection>
  490. <SidebarSection>
  491. {discover2}
  492. {dashboards}
  493. {releases}
  494. {userFeedback}
  495. </SidebarSection>
  496. <SidebarSection>
  497. {stats}
  498. {settings}
  499. </SidebarSection>
  500. </Fragment>
  501. )}
  502. </PrimaryItems>
  503. </SidebarSectionGroupPrimary>
  504. {hasOrganization && (
  505. <SidebarSectionGroup>
  506. <PerformanceOnboardingSidebar
  507. currentPanel={activePanel}
  508. onShowPanel={() => togglePanel(SidebarPanelKey.PERFORMANCE_ONBOARDING)}
  509. hidePanel={hidePanel}
  510. {...sidebarItemProps}
  511. />
  512. <ReplaysOnboardingSidebar
  513. currentPanel={activePanel}
  514. onShowPanel={() => togglePanel(SidebarPanelKey.REPLAYS_ONBOARDING)}
  515. hidePanel={hidePanel}
  516. {...sidebarItemProps}
  517. />
  518. <ProfilingOnboardingSidebar
  519. currentPanel={activePanel}
  520. onShowPanel={() => togglePanel(SidebarPanelKey.REPLAYS_ONBOARDING)}
  521. hidePanel={hidePanel}
  522. {...sidebarItemProps}
  523. />
  524. <SidebarSection noMargin noPadding>
  525. <OnboardingStatus
  526. org={organization}
  527. currentPanel={activePanel}
  528. onShowPanel={() => togglePanel(SidebarPanelKey.ONBOARDING_WIZARD)}
  529. hidePanel={hidePanel}
  530. {...sidebarItemProps}
  531. />
  532. </SidebarSection>
  533. <SidebarSection>
  534. {HookStore.get('sidebar:bottom-items').length > 0 &&
  535. HookStore.get('sidebar:bottom-items')[0]({
  536. orientation,
  537. collapsed,
  538. hasPanel,
  539. organization,
  540. })}
  541. <SidebarHelp
  542. orientation={orientation}
  543. collapsed={collapsed}
  544. hidePanel={hidePanel}
  545. organization={organization}
  546. />
  547. <Broadcasts
  548. orientation={orientation}
  549. collapsed={collapsed}
  550. currentPanel={activePanel}
  551. onShowPanel={() => togglePanel(SidebarPanelKey.BROADCASTS)}
  552. hidePanel={hidePanel}
  553. organization={organization}
  554. />
  555. <ServiceIncidents
  556. orientation={orientation}
  557. collapsed={collapsed}
  558. currentPanel={activePanel}
  559. onShowPanel={() => togglePanel(SidebarPanelKey.SERVICE_INCIDENTS)}
  560. hidePanel={hidePanel}
  561. />
  562. </SidebarSection>
  563. {!horizontal && (
  564. <SidebarSection>
  565. <SidebarCollapseItem
  566. id="collapse"
  567. data-test-id="sidebar-collapse"
  568. {...sidebarItemProps}
  569. icon={<IconChevron direction={collapsed ? 'right' : 'left'} size="sm" />}
  570. label={collapsed ? t('Expand') : t('Collapse')}
  571. onClick={toggleCollapse}
  572. />
  573. </SidebarSection>
  574. )}
  575. </SidebarSectionGroup>
  576. )}
  577. </SidebarWrapper>
  578. );
  579. }
  580. export default Sidebar;
  581. const responsiveFlex = css`
  582. display: flex;
  583. flex-direction: column;
  584. @media (max-width: ${theme.breakpoints.medium}) {
  585. flex-direction: row;
  586. }
  587. `;
  588. export const SidebarWrapper = styled('nav')<{collapsed: boolean; isSuperuser?: boolean}>`
  589. background: ${p =>
  590. p.isSuperuser ? p.theme.superuserSidebar : p.theme.sidebarGradient};
  591. color: ${p => (p.isSuperuser ? 'white' : p.theme.sidebar.color)};
  592. line-height: 1;
  593. padding: 12px 0 2px; /* Allows for 32px avatars */
  594. width: ${p => p.theme.sidebar[p.collapsed ? 'collapsedWidth' : 'expandedWidth']};
  595. position: fixed;
  596. top: ${p => (ConfigStore.get('demoMode') ? p.theme.demo.headerSize : 0)};
  597. left: 0;
  598. bottom: 0;
  599. justify-content: space-between;
  600. z-index: ${p => p.theme.zIndex.sidebar};
  601. border-right: solid 1px ${p => p.theme.sidebarBorder};
  602. ${responsiveFlex};
  603. @media (max-width: ${p => p.theme.breakpoints.medium}) {
  604. top: 0;
  605. left: 0;
  606. right: 0;
  607. height: ${p => p.theme.sidebar.mobileHeight};
  608. bottom: auto;
  609. width: auto;
  610. padding: 0 ${space(1)};
  611. align-items: center;
  612. border-right: none;
  613. border-bottom: solid 1px ${p => p.theme.sidebarBorder};
  614. }
  615. `;
  616. const SidebarSectionGroup = styled('div')`
  617. ${responsiveFlex};
  618. flex-shrink: 0; /* prevents shrinking on Safari */
  619. gap: 1px;
  620. `;
  621. const SidebarSectionGroupPrimary = styled('div')`
  622. ${responsiveFlex};
  623. /* necessary for child flexing on msedge and ff */
  624. min-height: 0;
  625. min-width: 0;
  626. flex: 1;
  627. /* expand to fill the entire height on mobile */
  628. @media (max-width: ${p => p.theme.breakpoints.medium}) {
  629. height: 100%;
  630. align-items: center;
  631. }
  632. `;
  633. const PrimaryItems = styled('div')`
  634. overflow: auto;
  635. flex: 1;
  636. display: flex;
  637. flex-direction: column;
  638. gap: 1px;
  639. -ms-overflow-style: -ms-autohiding-scrollbar;
  640. @media (max-height: 675px) and (min-width: ${p => p.theme.breakpoints.medium}) {
  641. border-bottom: 1px solid ${p => p.theme.gray400};
  642. padding-bottom: ${space(1)};
  643. box-shadow: rgba(0, 0, 0, 0.15) 0px -10px 10px inset;
  644. }
  645. @media (max-width: ${p => p.theme.breakpoints.medium}) {
  646. overflow-y: visible;
  647. flex-direction: row;
  648. height: 100%;
  649. align-items: center;
  650. border-right: 1px solid ${p => p.theme.gray400};
  651. padding-right: ${space(1)};
  652. margin-right: ${space(0.5)};
  653. box-shadow: rgba(0, 0, 0, 0.15) -10px 0px 10px inset;
  654. ::-webkit-scrollbar {
  655. display: none;
  656. }
  657. }
  658. `;
  659. const SubitemDot = styled('div')<{collapsed: boolean}>`
  660. width: 3px;
  661. height: 3px;
  662. background: currentcolor;
  663. border-radius: 50%;
  664. opacity: ${p => (p.collapsed ? 1 : 0)};
  665. @media (max-width: ${p => p.theme.breakpoints.medium}) {
  666. opacity: 1;
  667. }
  668. `;
  669. const SidebarSection = styled(SidebarSectionGroup)<{
  670. noMargin?: boolean;
  671. noPadding?: boolean;
  672. }>`
  673. ${p => !p.noMargin && `margin: ${space(1)} 0`};
  674. ${p => !p.noPadding && `padding: 0 ${space(2)}`};
  675. @media (max-width: ${p => p.theme.breakpoints.small}) {
  676. margin: 0;
  677. padding: 0;
  678. }
  679. &:empty {
  680. display: none;
  681. }
  682. `;
  683. const SidebarCollapseItem = styled(SidebarItem)`
  684. @media (max-width: ${p => p.theme.breakpoints.medium}) {
  685. display: none;
  686. }
  687. `;