diff --git a/.changeset/sour-hats-kick.md b/.changeset/sour-hats-kick.md new file mode 100644 index 0000000000..023cfff0f4 --- /dev/null +++ b/.changeset/sour-hats-kick.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-react': patch +--- + +Allow specifying screen size when catalog filters are hidden in drawer diff --git a/plugins/catalog-react/api-report.md b/plugins/catalog-react/api-report.md index 9bf87778dd..b5ab8b6c7f 100644 --- a/plugins/catalog-react/api-report.md +++ b/plugins/catalog-react/api-report.md @@ -63,7 +63,13 @@ export const catalogApiRef: ApiRef; // @public (undocumented) export const CatalogFilterLayout: { (props: { children: React_2.ReactNode }): JSX.Element; - Filters: (props: { children: React_2.ReactNode }) => JSX.Element; + Filters: (props: { + children: React_2.ReactNode; + options?: { + drawerBreakpoint?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number; + drawerAnchor?: 'left' | 'right' | 'top' | 'bottom'; + }; + }) => JSX.Element; Content: (props: { children: React_2.ReactNode }) => JSX.Element; }; diff --git a/plugins/catalog-react/src/components/CatalogFilterLayout/CatalogFilterLayout.tsx b/plugins/catalog-react/src/components/CatalogFilterLayout/CatalogFilterLayout.tsx index 751eb35f1d..1a1404edf2 100644 --- a/plugins/catalog-react/src/components/CatalogFilterLayout/CatalogFilterLayout.tsx +++ b/plugins/catalog-react/src/components/CatalogFilterLayout/CatalogFilterLayout.tsx @@ -28,14 +28,20 @@ import FilterListIcon from '@material-ui/icons/FilterList'; import { BackstageTheme } from '@backstage/theme'; /** @public */ -export const Filters = (props: { children: React.ReactNode }) => { - const isMidSizeScreen = useMediaQuery(theme => - theme.breakpoints.down('md'), +export const Filters = (props: { + children: React.ReactNode; + options?: { + drawerBreakpoint?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number; + drawerAnchor?: 'left' | 'right' | 'top' | 'bottom'; + }; +}) => { + const isScreenSmallerThanBreakpoint = useMediaQuery(theme => + theme.breakpoints.down(props.options?.drawerBreakpoint ?? 'md'), ); const theme = useTheme(); const [filterDrawerOpen, setFilterDrawerOpen] = useState(false); - return isMidSizeScreen ? ( + return isScreenSmallerThanBreakpoint ? ( <>