diff --git a/packages/app/src/components/search/SearchPage.tsx b/packages/app/src/components/search/SearchPage.tsx index 2a21ad0e86..a734b72142 100644 --- a/packages/app/src/components/search/SearchPage.tsx +++ b/packages/app/src/components/search/SearchPage.tsx @@ -14,7 +14,13 @@ * limitations under the License. */ -import { Content, Header, Lifecycle, Page } from '@backstage/core-components'; +import { + Content, + Header, + Lifecycle, + Page, + SidebarStateContext, +} from '@backstage/core-components'; import { CatalogResultListItem } from '@backstage/plugin-catalog'; import { DefaultResultListItem, @@ -25,16 +31,8 @@ import { SearchType, } from '@backstage/plugin-search'; import { DocsResultListItem } from '@backstage/plugin-techdocs'; -import { - Grid, - List, - makeStyles, - Paper, - Theme, - useMediaQuery, -} from '@material-ui/core'; -import React from 'react'; -import { BackstageTheme } from '@backstage/theme'; +import { Grid, List, makeStyles, Paper, Theme } from '@material-ui/core'; +import React, { useContext } from 'react'; const useStyles = makeStyles((theme: Theme) => ({ bar: { @@ -52,15 +50,11 @@ const useStyles = makeStyles((theme: Theme) => ({ const SearchPage = () => { const classes = useStyles(); - const isMobileScreen = useMediaQuery(theme => - theme.breakpoints.down('xs'), - ); + const { isMobile } = useContext(SidebarStateContext); return ( - {!isMobileScreen && ( -
} /> - )} + {!isMobile &&
} />} @@ -68,7 +62,7 @@ const SearchPage = () => { - {!isMobileScreen && ( + {!isMobile && ( ) => JSX.Element | null; +export const MobileSidebar: ( + props: React_2.PropsWithChildren<{}>, +) => JSX.Element | null; // Warning: (ae-missing-release-tag) "OAuthRequestDialog" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -843,16 +841,10 @@ export type SelectClassKey = // @public (undocumented) export type SelectInputBaseClassKey = 'root' | 'input'; -// Warning: (ae-forgotten-export) The symbol "Props" needs to be exported by the entry point index.d.ts -// Warning: (ae-missing-release-tag) "Sidebar" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) -export const Sidebar: ({ - children, - openDelayMs, - closeDelayMs, - disableExpandOnHover, -}: React_2.PropsWithChildren) => JSX.Element; +export const Sidebar: ( + props: React_2.PropsWithChildren, +) => JSX.Element; // Warning: (ae-missing-release-tag) "SIDEBAR_INTRO_LOCAL_STORAGE" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -860,8 +852,6 @@ export const Sidebar: ({ export const SIDEBAR_INTRO_LOCAL_STORAGE = '@backstage/core/sidebar-intro-dismissed'; -// Warning: (ae-missing-release-tag) "SidebarClassKey" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export type SidebarClassKey = 'drawer' | 'drawerOpen'; @@ -1174,19 +1164,11 @@ export type SidebarDividerClassKey = 'root'; // @public export const SidebarExpandButton: () => JSX.Element | null; -// Warning: (ae-missing-release-tag) "SidebarGroup" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) -export const SidebarGroup: ({ - children, - to, - label, - icon, - value, -}: React_2.PropsWithChildren) => JSX.Element; +export const SidebarGroup: ( + props: React_2.PropsWithChildren, +) => JSX.Element; -// Warning: (ae-missing-release-tag) "SidebarGroupProps" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export interface SidebarGroupProps extends BottomNavigationActionProps { // (undocumented) @@ -1243,17 +1225,11 @@ export function SidebarPage(props: PropsWithChildren<{}>): JSX.Element; // @public (undocumented) export type SidebarPageClassKey = 'root'; -// Warning: (ae-missing-release-tag) "SidebarPinStateContext" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) -export const SidebarPinStateContext: React_2.Context; - -// Warning: (ae-missing-release-tag) "SidebarPinStateContextType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type SidebarPinStateContextType = { - isPinned: boolean; - toggleSidebarPinState: () => any; +export type SidebarProps = { + openDelayMs?: number; + closeDelayMs?: number; + disableExpandOnHover?: boolean; }; // Warning: (ae-missing-release-tag) "SidebarScrollWrapper" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -2079,6 +2055,16 @@ export const SidebarSpacer: React_2.ComponentType< // @public (undocumented) export type SidebarSpacerClassKey = 'root'; +// @public (undocumented) +export const SidebarStateContext: React_2.Context; + +// @public (undocumented) +export type SidebarStateContextType = { + isPinned: boolean; + toggleSidebarPinState: () => any; + isMobile: boolean; +}; + // @public export const SidebarSubmenu: (props: SidebarSubmenuProps) => JSX.Element; @@ -2111,7 +2097,7 @@ export type SidebarSubmenuProps = { // Warning: (ae-missing-release-tag) "SignInPage" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export function SignInPage(props: Props_18): JSX.Element; +export function SignInPage(props: Props_17): JSX.Element; // Warning: (ae-missing-release-tag) "SignInPageClassKey" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -2282,7 +2268,7 @@ export type TabBarClassKey = 'indicator' | 'flexContainer' | 'root'; // Warning: (ae-missing-release-tag) "TabbedCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export function TabbedCard(props: PropsWithChildren): JSX.Element; +export function TabbedCard(props: PropsWithChildren): JSX.Element; // Warning: (ae-missing-release-tag) "TabbedCardClassKey" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // diff --git a/packages/core-components/src/layout/Sidebar/Bar.test.tsx b/packages/core-components/src/layout/Sidebar/Bar.test.tsx index 11b4088dc0..acfd949ac5 100644 --- a/packages/core-components/src/layout/Sidebar/Bar.test.tsx +++ b/packages/core-components/src/layout/Sidebar/Bar.test.tsx @@ -26,12 +26,16 @@ import { Sidebar } from './Bar'; import { SidebarItem, SidebarSearchField, SidebarExpandButton } from './Items'; import { SidebarSubmenuItem } from './SidebarSubmenuItem'; import { SidebarSubmenu } from './SidebarSubmenu'; -import { SidebarPinStateContext } from '.'; +import { SidebarStateContext } from '.'; async function renderScalableSidebar() { await renderInTestApp( - {} }} + {}, + }} > {}} to="/search" /> @@ -58,7 +62,7 @@ async function renderScalableSidebar() { - , + , ); } diff --git a/packages/core-components/src/layout/Sidebar/Bar.tsx b/packages/core-components/src/layout/Sidebar/Bar.tsx index 96f7335acd..51d4268d05 100644 --- a/packages/core-components/src/layout/Sidebar/Bar.tsx +++ b/packages/core-components/src/layout/Sidebar/Bar.tsx @@ -20,9 +20,10 @@ import classnames from 'classnames'; import React, { useState, useContext, PropsWithChildren, useRef } from 'react'; import { sidebarConfig, SidebarContext } from './config'; import { BackstageTheme } from '@backstage/theme'; -import { SidebarPinStateContext } from './Page'; +import { SidebarStateContext } from './Page'; import { MobileSidebar } from './MobileSidebar'; +/** @public */ export type SidebarClassKey = 'drawer' | 'drawerOpen'; const useStyles = makeStyles( @@ -69,7 +70,8 @@ enum State { Open, } -type Props = { +/** @public */ +export type SidebarProps = { openDelayMs?: number; closeDelayMs?: number; disableExpandOnHover?: boolean; @@ -80,7 +82,7 @@ const DesktopSidebar = ({ closeDelayMs = sidebarConfig.defaultCloseDelayMs, disableExpandOnHover, children, -}: PropsWithChildren) => { +}: PropsWithChildren) => { const classes = useStyles(); const isSmallScreen = useMediaQuery( theme => theme.breakpoints.down('md'), @@ -88,9 +90,7 @@ const DesktopSidebar = ({ ); const [state, setState] = useState(State.Closed); const hoverTimerRef = useRef(); - const { isPinned, toggleSidebarPinState } = useContext( - SidebarPinStateContext, - ); + const { isPinned, toggleSidebarPinState } = useContext(SidebarStateContext); const handleOpen = () => { if (isPinned || disableExpandOnHover) { @@ -163,18 +163,12 @@ const DesktopSidebar = ({ ); }; -export const Sidebar = ({ - children, - openDelayMs, - closeDelayMs, - disableExpandOnHover, -}: React.PropsWithChildren) => { - const isMobileScreen = useMediaQuery( - theme => theme.breakpoints.down('xs'), - { noSsr: true }, - ); +/** @public */ +export const Sidebar = (props: React.PropsWithChildren) => { + const { children, openDelayMs, closeDelayMs, disableExpandOnHover } = props; + const { isMobile } = useContext(SidebarStateContext); - return isMobileScreen ? ( + return isMobile ? ( {children} ) : ( ( fontSize: theme.typography.fontSize, }, searchFieldHTMLInput: { - padding: `${theme.spacing(2)} 0 ${theme.spacing(2)}`, + padding: theme.spacing(2, 0, 2), }, searchContainer: { width: drawerWidthOpen - iconContainerWidth, @@ -219,7 +222,7 @@ const useStyles = makeStyles( fontSize: theme.typography.fontSize, }, searchFieldHTMLInput: { - padding: `${theme.spacing(2)} 0 ${theme.spacing(2)}`, + padding: theme.spacing(2, 0, 2), }, searchContainer: { width: drawerWidthOpen - iconContainerWidth, @@ -237,7 +240,7 @@ const useStyles = makeStyles( const useLocationMatch = ( submenu: React.ReactElement, - locationPathname: string, + location: Location, ): boolean => // Evaluates the routes of the SubmenuItems & nested DropdownItems. // The reeveluation is only triggered, if the `locationPathname` changes, as `useElementFilter` uses memorization @@ -257,93 +260,21 @@ const useLocationMatch = ( if (dropdownItems?.length) { dropdownItems.forEach( ({ to: _to }) => - (active = active || locationPathname.includes(_to)), + (active = + active || isLocationMatch(location, resolvePath(_to))), ); return; } if (to) { - active = locationPathname.includes(to); + active = isLocationMatch(location, resolvePath(to)); } } }, ); return active; }, - [locationPathname], + [location.pathname], ); -/* -function isSidebarItemWithSubmenuActive( - submenu: ReactNode, - currentLocation: Location, -) { - // Item is active if any of submenu items have active paths - const toPathnames: string[] = []; - let isActive = false; - let submenuItems: ReactNode; - Children.forEach(submenu, element => { - if (!React.isValidElement(element)) return; - submenuItems = element.props.children; - }); - Children.forEach(submenuItems, element => { - if (!React.isValidElement(element)) return; - if (element.props.dropdownItems) { - element.props.dropdownItems.map((item: { to: string }) => - toPathnames.push(item.to), - ); - } else if (element.props.to) { - toPathnames.push(element.props.to); - } - }); - isActive = toPathnames.some(to => { - const toLocation = resolvePath(to); - return isLocationMatch(currentLocation, toLocation); - }); - return isActive; -} - -const SidebarItemWithSubmenu = ({ - text, - hasNotifications = false, - icon: Icon, - children, -}: PropsWithChildren) => { - const classes = useStyles(); - const [isHoveredOn, setIsHoveredOn] = useState(false); - const currentLocation = useLocation(); - const isActive = isSidebarItemWithSubmenuActive(children, currentLocation); - - const handleMouseEnter = () => { - setIsHoveredOn(true); - }; - const handleMouseLeave = () => { - setIsHoveredOn(false); - }; - - const { isOpen } = useContext(SidebarContext); - const itemIcon = ( - - - - ); - const openContent = ( - <> -
- {itemIcon} -
- {text && ( - - {text} - - )} -
{}
- - );*/ type SidebarItemBaseProps = { icon: IconComponent; @@ -522,8 +453,8 @@ const SidebarItemWithSubmenu = ({ }) => { const classes = useStyles(); const [isHoveredOn, setIsHoveredOn] = useState(false); - const { pathname: locationPathname } = useLocation(); - const isActive = useLocationMatch(children, locationPathname); + const location = useLocation(); + const isActive = useLocationMatch(children, location); const isSmallScreen = useMediaQuery((theme: BackstageTheme) => theme.breakpoints.down('sm'), ); diff --git a/packages/core-components/src/layout/Sidebar/MobileSidebar.tsx b/packages/core-components/src/layout/Sidebar/MobileSidebar.tsx index 6ee2451755..158b20e6be 100644 --- a/packages/core-components/src/layout/Sidebar/MobileSidebar.tsx +++ b/packages/core-components/src/layout/Sidebar/MobileSidebar.tsx @@ -20,6 +20,7 @@ import BottomNavigation from '@material-ui/core/BottomNavigation'; import Box from '@material-ui/core/Box'; import IconButton from '@material-ui/core/IconButton'; import { makeStyles } from '@material-ui/core/styles'; +import Drawer from '@material-ui/core/Drawer'; import Typography from '@material-ui/core/Typography'; import CloseIcon from '@material-ui/icons/Close'; import MenuIcon from '@material-ui/icons/Menu'; @@ -43,7 +44,7 @@ const useStyles = makeStyles(theme => ({ bottom: 0, left: 0, right: 0, - zIndex: 1000, + zIndex: theme.zIndex.snackbar, // SidebarDivider color borderTop: '1px solid #383838', }, @@ -51,11 +52,10 @@ const useStyles = makeStyles(theme => ({ overlay: { background: theme.palette.navigation.background, width: '100%', - flex: '0 1 auto', + bottom: `${sidebarConfig.mobileSidebarHeight}px`, height: `calc(100% - ${sidebarConfig.mobileSidebarHeight}px)`, + flex: '0 1 auto', overflow: 'auto', - position: 'fixed', - zIndex: 500, }, overlayHeader: { @@ -63,7 +63,7 @@ const useStyles = makeStyles(theme => ({ color: theme.palette.bursts.fontColor, alignItems: 'center', justifyContent: 'space-between', - padding: `${theme.spacing(2)}px ${theme.spacing(3)}px`, + padding: theme.spacing(2, 3), }, overlayHeaderClose: { @@ -81,12 +81,22 @@ const sortSidebarGroupsForPriority = (children: React.ReactElement[]) => const OverlayMenu = ({ children, label = 'Menu', + open, onClose, -}: React.PropsWithChildren<{ label?: string; onClose: () => void }>) => { +}: React.PropsWithChildren<{ + label?: string; + onClose: () => void; + open: boolean; +}>) => { const classes = useStyles(); return ( - + {label} {children} - + ); }; @@ -106,7 +116,9 @@ export const MobileSidebarContext = createContext({ setSelectedMenuItemIndex: () => {}, }); -export const MobileSidebar = ({ children }: React.PropsWithChildren<{}>) => { +/** @public */ +export const MobileSidebar = (props: React.PropsWithChildren<{}>) => { + const { children } = props; const classes = useStyles(); const location = useLocation(); const [selectedMenuItemIndex, setSelectedMenuItemIndex] = @@ -146,12 +158,19 @@ export const MobileSidebar = ({ children }: React.PropsWithChildren<{}>) => { - {shouldShowGroupChildren && ( - setSelectedMenuItemIndex(-1)} - /> - )} + setSelectedMenuItemIndex(-1)} + > + {sidebarGroups[selectedMenuItemIndex] && + (sidebarGroups[selectedMenuItemIndex].props + .children as React.ReactChildren)} + ( { name: 'BackstageSidebarPage' }, ); -export type SidebarPinStateContextType = { +/** @public */ +export type SidebarStateContextType = { isPinned: boolean; toggleSidebarPinState: () => any; + isMobile: boolean; }; -export const SidebarPinStateContext = createContext( - { - isPinned: true, - toggleSidebarPinState: () => {}, - }, -); +/** @public */ +export const SidebarStateContext = createContext({ + isPinned: true, + toggleSidebarPinState: () => {}, + isMobile: false, +}); export function SidebarPage(props: PropsWithChildren<{}>) { const [isPinned, setIsPinned] = useState(() => @@ -67,17 +70,23 @@ export function SidebarPage(props: PropsWithChildren<{}>) { LocalStorage.setSidebarPinState(isPinned); }, [isPinned]); + const isMobile = useMediaQuery( + theme => theme.breakpoints.down('xs'), + { noSsr: true }, + ); + const toggleSidebarPinState = () => setIsPinned(!isPinned); const classes = useStyles({ isPinned }); return ( -
{props.children}
-
+ ); } diff --git a/packages/core-components/src/layout/Sidebar/Sidebar.stories.tsx b/packages/core-components/src/layout/Sidebar/Sidebar.stories.tsx index 0636cac134..9b5d76a32c 100644 --- a/packages/core-components/src/layout/Sidebar/Sidebar.stories.tsx +++ b/packages/core-components/src/layout/Sidebar/Sidebar.stories.tsx @@ -108,6 +108,5 @@ export const SampleScalableSidebar = () => ( - Test ); diff --git a/packages/core-components/src/layout/Sidebar/SidebarGroup.tsx b/packages/core-components/src/layout/Sidebar/SidebarGroup.tsx index 51ae35c2db..1a43f703bf 100644 --- a/packages/core-components/src/layout/Sidebar/SidebarGroup.tsx +++ b/packages/core-components/src/layout/Sidebar/SidebarGroup.tsx @@ -20,13 +20,14 @@ import BottomNavigationAction, { BottomNavigationActionProps, } from '@material-ui/core/BottomNavigationAction'; import { makeStyles } from '@material-ui/core/styles'; -import useMediaQuery from '@material-ui/core/useMediaQuery'; import React, { useContext } from 'react'; import { useLocation } from 'react-router-dom'; +import { SidebarStateContext } from '.'; import { Link } from '../../components'; import { sidebarConfig } from './config'; import { MobileSidebarContext } from './MobileSidebar'; +/** @public */ export interface SidebarGroupProps extends BottomNavigationActionProps { to?: string; priority?: number; @@ -35,7 +36,7 @@ export interface SidebarGroupProps extends BottomNavigationActionProps { const useStyles = makeStyles(theme => ({ root: { flexGrow: 0, - margin: `0 ${theme.spacing(2)}px`, + margin: theme.spacing(0, 2), color: theme.palette.navigation.color, }, @@ -50,7 +51,8 @@ const useStyles = makeStyles(theme => ({ }, })); -const MobileSidebarGroup = ({ to, label, icon, value }: SidebarGroupProps) => { +const MobileSidebarGroup = (props: SidebarGroupProps) => { + const { to, label, icon, value } = props; const classes = useStyles(); const location = useLocation(); const { selectedMenuItemIndex, setSelectedMenuItemIndex } = @@ -86,18 +88,14 @@ const MobileSidebarGroup = ({ to, label, icon, value }: SidebarGroupProps) => { ); }; -export const SidebarGroup = ({ - children, - to, - label, - icon, - value, -}: React.PropsWithChildren) => { - const isMobileScreen = useMediaQuery(theme => - theme.breakpoints.down('xs'), - ); +/** @public */ +export const SidebarGroup = ( + props: React.PropsWithChildren, +) => { + const { children, to, label, icon, value } = props; + const { isMobile } = useContext(SidebarStateContext); - return isMobileScreen ? ( + return isMobile ? ( ) : ( <>{children} diff --git a/packages/core-components/src/layout/Sidebar/index.ts b/packages/core-components/src/layout/Sidebar/index.ts index 2b5ff77538..4a1e1c0474 100644 --- a/packages/core-components/src/layout/Sidebar/index.ts +++ b/packages/core-components/src/layout/Sidebar/index.ts @@ -25,9 +25,15 @@ export type { SidebarSubmenuItemProps, SidebarSubmenuItemDropdownItem, } from './SidebarSubmenuItem'; -export type { SidebarClassKey } from './Bar'; -export { SidebarPage, SidebarPinStateContext } from './Page'; -export type { SidebarPinStateContextType, SidebarPageClassKey } from './Page'; +export type { SidebarClassKey, SidebarProps } from './Bar'; +export { + SidebarPage, + SidebarStateContext as SidebarStateContext, +} from './Page'; +export type { + SidebarStateContextType as SidebarStateContextType, + SidebarPageClassKey, +} from './Page'; export { SidebarDivider, SidebarItem, diff --git a/plugins/user-settings/src/components/General/UserSettingsAppearanceCard.tsx b/plugins/user-settings/src/components/General/UserSettingsAppearanceCard.tsx index 83937f9300..915edc94cb 100644 --- a/plugins/user-settings/src/components/General/UserSettingsAppearanceCard.tsx +++ b/plugins/user-settings/src/components/General/UserSettingsAppearanceCard.tsx @@ -13,23 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { InfoCard } from '@backstage/core-components'; -import { BackstageTheme } from '@backstage/theme'; -import { List, useMediaQuery } from '@material-ui/core'; -import React from 'react'; +import { InfoCard, SidebarStateContext } from '@backstage/core-components'; +import { List } from '@material-ui/core'; +import React, { useContext } from 'react'; import { UserSettingsPinToggle } from './UserSettingsPinToggle'; import { UserSettingsThemeToggle } from './UserSettingsThemeToggle'; export const UserSettingsAppearanceCard = () => { - const isMobileScreen = useMediaQuery(theme => - theme.breakpoints.down('xs'), - ); + const isMobile = useContext(SidebarStateContext); return ( - {!isMobileScreen && } + {!isMobile && } ); diff --git a/plugins/user-settings/src/components/General/UserSettingsPinToggle.test.tsx b/plugins/user-settings/src/components/General/UserSettingsPinToggle.test.tsx index 39387df907..e2c9f23b91 100644 --- a/plugins/user-settings/src/components/General/UserSettingsPinToggle.test.tsx +++ b/plugins/user-settings/src/components/General/UserSettingsPinToggle.test.tsx @@ -18,18 +18,22 @@ import { renderWithEffects, wrapInTestApp } from '@backstage/test-utils'; import { fireEvent } from '@testing-library/react'; import React from 'react'; import { UserSettingsPinToggle } from './UserSettingsPinToggle'; -import { SidebarPinStateContext } from '@backstage/core-components'; +import { SidebarStateContext } from '@backstage/core-components'; describe('', () => { it('toggles the pin sidebar button', async () => { const mockToggleFn = jest.fn(); const rendered = await renderWithEffects( wrapInTestApp( - - , + , ), ); expect(rendered.getByText('Pin Sidebar')).toBeInTheDocument(); diff --git a/plugins/user-settings/src/components/General/UserSettingsPinToggle.tsx b/plugins/user-settings/src/components/General/UserSettingsPinToggle.tsx index 4d71df8113..1cfd8b06dd 100644 --- a/plugins/user-settings/src/components/General/UserSettingsPinToggle.tsx +++ b/plugins/user-settings/src/components/General/UserSettingsPinToggle.tsx @@ -22,12 +22,10 @@ import { Switch, Tooltip, } from '@material-ui/core'; -import { SidebarPinStateContext } from '@backstage/core-components'; +import { SidebarStateContext } from '@backstage/core-components'; export const UserSettingsPinToggle = () => { - const { isPinned, toggleSidebarPinState } = useContext( - SidebarPinStateContext, - ); + const { isPinned, toggleSidebarPinState } = useContext(SidebarStateContext); return ( diff --git a/plugins/user-settings/src/components/SettingsPage.tsx b/plugins/user-settings/src/components/SettingsPage.tsx index d5c7171148..b1bfdb5fc9 100644 --- a/plugins/user-settings/src/components/SettingsPage.tsx +++ b/plugins/user-settings/src/components/SettingsPage.tsx @@ -14,10 +14,13 @@ * limitations under the License. */ -import { Header, Page, TabbedLayout } from '@backstage/core-components'; -import { BackstageTheme } from '@backstage/theme'; -import { useMediaQuery } from '@material-ui/core'; -import React from 'react'; +import { + Header, + Page, + SidebarStateContext, + TabbedLayout, +} from '@backstage/core-components'; +import React, { useContext } from 'react'; import { UserSettingsAuthProviders } from './AuthProviders'; import { UserSettingsFeatureFlags } from './FeatureFlags'; import { UserSettingsGeneral } from './General'; @@ -27,13 +30,11 @@ type Props = { }; export const SettingsPage = ({ providerSettings }: Props) => { - const isMobileScreen = useMediaQuery(theme => - theme.breakpoints.down('xs'), - ); + const { isMobile } = useContext(SidebarStateContext); return ( - {!isMobileScreen &&
} + {!isMobile &&
}