From 00c87518042b269101079ad63f6fbea2fadd84ab Mon Sep 17 00:00:00 2001 From: Philipp Hugenroth Date: Thu, 8 Jul 2021 13:17:40 +0200 Subject: [PATCH] Wrap catalog filters in accordion for smaller screens Signed-off-by: Philipp Hugenroth --- .../CatalogFilter/CatalogFilter.tsx | 76 +++++++++++++++++++ .../src/components/CatalogFilter/index.ts | 17 +++++ .../components/CatalogPage/CatalogPage.tsx | 64 ++++++---------- 3 files changed, 117 insertions(+), 40 deletions(-) create mode 100644 plugins/catalog/src/components/CatalogFilter/CatalogFilter.tsx create mode 100644 plugins/catalog/src/components/CatalogFilter/index.ts diff --git a/plugins/catalog/src/components/CatalogFilter/CatalogFilter.tsx b/plugins/catalog/src/components/CatalogFilter/CatalogFilter.tsx new file mode 100644 index 0000000000..a8673b395a --- /dev/null +++ b/plugins/catalog/src/components/CatalogFilter/CatalogFilter.tsx @@ -0,0 +1,76 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + EntityKindPicker, + EntityLifecyclePicker, + EntityOwnerPicker, + EntityTagPicker, + EntityTypePicker, + UserListFilterKind, + UserListPicker, +} from '@backstage/plugin-catalog-react'; +import { + Accordion, + AccordionDetails, + AccordionSummary, + Grid, + isWidthDown, + Typography, + withWidth, +} from '@material-ui/core'; +import { Breakpoint } from '@material-ui/core/styles/createBreakpoints'; +import ExpandMore from '@material-ui/icons/ExpandMore'; +import React, { PropsWithChildren } from 'react'; + +interface IProps { + initiallySelectedFilter?: UserListFilterKind; +} + +const CatalogFilterWrapper = withWidth()( + ({ width, children }: PropsWithChildren<{ width: Breakpoint }>) => + isWidthDown('md', width) ? ( + + }> + Filters + + {children} + + ) : ( + {children} + ), +); + +export const CatalogFilter = ({ + initiallySelectedFilter = 'owned', +}: IProps) => ( + + + + + + + + + + + + + + +); diff --git a/plugins/catalog/src/components/CatalogFilter/index.ts b/plugins/catalog/src/components/CatalogFilter/index.ts new file mode 100644 index 0000000000..dc57ef02e2 --- /dev/null +++ b/plugins/catalog/src/components/CatalogFilter/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { CatalogFilter } from './CatalogFilter'; diff --git a/plugins/catalog/src/components/CatalogPage/CatalogPage.tsx b/plugins/catalog/src/components/CatalogPage/CatalogPage.tsx index 089e61f0fb..6f8dd0dd2b 100644 --- a/plugins/catalog/src/components/CatalogPage/CatalogPage.tsx +++ b/plugins/catalog/src/components/CatalogPage/CatalogPage.tsx @@ -15,16 +15,10 @@ */ import React from 'react'; -import { Grid } from '@material-ui/core'; +import { Grid, withWidth } from '@material-ui/core'; import { - EntityKindPicker, - EntityLifecyclePicker, EntityListProvider, - EntityOwnerPicker, - EntityTagPicker, - EntityTypePicker, UserListFilterKind, - UserListPicker, } from '@backstage/plugin-catalog-react'; import { CatalogTable } from '../CatalogTable'; @@ -38,6 +32,7 @@ import { TableColumn, TableProps, } from '@backstage/core-components'; +import { CatalogFilter } from '../CatalogFilter'; export type CatalogPageProps = { initiallySelectedFilter?: UserListFilterKind; @@ -45,40 +40,29 @@ export type CatalogPageProps = { actions?: TableProps['actions']; }; -export const CatalogPage = ({ - initiallySelectedFilter = 'owned', - columns, - actions, -}: CatalogPageProps) => ( - - - - - All your software catalog entities - - - - - - - - - - + + + ); + }, );