diff --git a/packages/core/src/components/EmptyState/EmptyState.stories.tsx b/packages/core/src/components/EmptyState/EmptyState.stories.tsx new file mode 100644 index 0000000000..f3e40bd31c --- /dev/null +++ b/packages/core/src/components/EmptyState/EmptyState.stories.tsx @@ -0,0 +1,81 @@ +/* + * Copyright 2020 Spotify AB + * + * 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 React from 'react'; +import { EmptyState } from './EmptyState'; +import { Button } from '@material-ui/core'; + +export default { + title: 'EmptyState', + component: EmptyState, +}; + +const containerStyle = { width: '100%', height: '100vh' }; + +export const MissingAnnotation = () => ( +
+ +
+); + +export const NoInformation = () => ( +
+ +
+); + +export const CreateComponent = () => ( +
+ +
+); + +export const NoBuild = () => ( +
+ +
+); + +export const WithAction = () => ( +
+ {}} variant="contained"> + DOCS + + } + /> +
+); diff --git a/packages/core/src/components/EmptyState/EmptyState.test.tsx b/packages/core/src/components/EmptyState/EmptyState.test.tsx new file mode 100644 index 0000000000..c5bc7a9876 --- /dev/null +++ b/packages/core/src/components/EmptyState/EmptyState.test.tsx @@ -0,0 +1,39 @@ +/* + * Copyright 2020 Spotify AB + * + * 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 React from 'react'; +import { EmptyState } from './EmptyState'; +import { renderWithEffects, wrapInTestApp } from '@backstage/test-utils'; +import { Button } from '@material-ui/core'; + +describe('', () => { + it('render EmptyState component with type annotaion is missing', async () => { + const rendered = await renderWithEffects( + wrapInTestApp( + DOCS} + />, + ), + ); + expect( + rendered.getByText('Your plugin is missing an annotation'), + ).toBeInTheDocument(); + expect(rendered.getByLabelText('button')).toBeInTheDocument(); + expect(rendered.getByTestId('missingAnnotation')).toBeInTheDocument(); + }); +}); diff --git a/packages/core/src/components/EmptyState/EmptyState.tsx b/packages/core/src/components/EmptyState/EmptyState.tsx new file mode 100644 index 0000000000..88becc7c90 --- /dev/null +++ b/packages/core/src/components/EmptyState/EmptyState.tsx @@ -0,0 +1,78 @@ +/* + * Copyright 2020 Spotify AB + * + * 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 React from 'react'; +import { makeStyles, Typography, Grid } from '@material-ui/core'; +import { EmptyStateImage } from './EmptyStateImage'; +import Background from './assets/Background.svg'; + +const useStyles = makeStyles(theme => ({ + root: { + backgroundColor: theme.palette.background.default, + padding: theme.spacing(10, 0, 0, 0), + }, + action: { + marginTop: theme.spacing(2), + }, + imageContainer: { + position: 'relative', + }, + backgroundImage: { + position: 'absolute', + width: '100%', + }, +})); + +type Props = { + title: string; + description?: string; + missing: 'field' | 'info' | 'content' | 'data'; + action?: JSX.Element; +}; + +export const EmptyState = ({ title, description, missing, action }: Props) => { + const classes = useStyles(); + return ( + + + + {title} + + + {description} + + + {action} + + + + background + + + + ); +}; diff --git a/packages/core/src/components/EmptyState/EmptyStateImage.tsx b/packages/core/src/components/EmptyState/EmptyStateImage.tsx new file mode 100644 index 0000000000..49598ae6db --- /dev/null +++ b/packages/core/src/components/EmptyState/EmptyStateImage.tsx @@ -0,0 +1,74 @@ +/* + * Copyright 2020 Spotify AB + * + * 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 React from 'react'; +import missingAnnotation from './assets/missingAnnotation.svg'; +import noInformation from './assets/noInformation.svg'; +import createComponent from './assets/createComponent.svg'; +import noBuild from './assets/noBuild.svg'; +import { makeStyles } from '@material-ui/core'; + +type Props = { + missing: 'field' | 'info' | 'content' | 'data'; +}; + +const useStyles = makeStyles({ + generalImg: { + width: '75%', + zIndex: 2, + position: 'absolute', + left: '50%', + top: '50%', + transform: 'translate(-50%, 15%)', + }, +}); + +export const EmptyStateImage = ({ missing }: Props) => { + const classes = useStyles(); + switch (missing) { + case 'field': + return ( + annotation is missing + ); + case 'info': + return ( + no Information + ); + case 'content': + return ( + create Component + ); + case 'data': + return ( + no Build + ); + default: + return null; + } +}; diff --git a/packages/core/src/components/EmptyState/assets/Background.svg b/packages/core/src/components/EmptyState/assets/Background.svg new file mode 100644 index 0000000000..e2fa538f7f --- /dev/null +++ b/packages/core/src/components/EmptyState/assets/Background.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/packages/core/src/components/EmptyState/assets/createComponent.svg b/packages/core/src/components/EmptyState/assets/createComponent.svg new file mode 100644 index 0000000000..af2ddd5678 --- /dev/null +++ b/packages/core/src/components/EmptyState/assets/createComponent.svg @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/core/src/components/EmptyState/assets/missingAnnotation.svg b/packages/core/src/components/EmptyState/assets/missingAnnotation.svg new file mode 100644 index 0000000000..475cda9699 --- /dev/null +++ b/packages/core/src/components/EmptyState/assets/missingAnnotation.svg @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/core/src/components/EmptyState/assets/noBuild.svg b/packages/core/src/components/EmptyState/assets/noBuild.svg new file mode 100644 index 0000000000..76a41749b9 --- /dev/null +++ b/packages/core/src/components/EmptyState/assets/noBuild.svg @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/core/src/components/EmptyState/assets/noInformation.svg b/packages/core/src/components/EmptyState/assets/noInformation.svg new file mode 100644 index 0000000000..e41cf94645 --- /dev/null +++ b/packages/core/src/components/EmptyState/assets/noInformation.svg @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/core/src/components/EmptyState/index.ts b/packages/core/src/components/EmptyState/index.ts new file mode 100644 index 0000000000..3774010467 --- /dev/null +++ b/packages/core/src/components/EmptyState/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2020 Spotify AB + * + * 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 { EmptyState } from './EmptyState'; diff --git a/packages/core/src/components/index.ts b/packages/core/src/components/index.ts index 6c070366c7..4f085ffd6a 100644 --- a/packages/core/src/components/index.ts +++ b/packages/core/src/components/index.ts @@ -34,3 +34,4 @@ export * from './Table'; export * from './Tabs'; export * from './TrendLine'; export * from './WarningPanel'; +export * from './EmptyState';