-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alejandro Fernández Gómez
committed
Nov 22, 2022
1 parent
79177dd
commit 8d393b6
Showing
3 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
id: sharedUX/Prompt/NotFound | ||
slug: /shared-ux/prompt/not-found | ||
title: Not Found Prompt | ||
description: A prompt to be displayed when a page or a resource does not exist. | ||
tags: ['shared-ux', 'component', 'prompt', 'not-found'] | ||
date: 2022-02-09 | ||
--- | ||
|
||
Sometimes the user tries to go to a page that doesn't exist, because the URL is broken or because they try to load a resource that does not exist. For those cases we want to show a standard 404 error. | ||
|
||
The default call to action is a "Go back" button that simulates the browser's "Back" behaviour. Consumers can specify their own CTA's with the `actions` prop. |
60 changes: 60 additions & 0 deletions
60
packages/shared-ux/prompt/errors/src/not_found.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { EuiButton, EuiButtonEmpty, EuiPageTemplate } from '@elastic/eui'; | ||
import React from 'react'; | ||
import mdx from '../README.mdx'; | ||
|
||
import { NotFound } from './not_found'; | ||
|
||
export default { | ||
title: 'Not found/Not found', | ||
description: | ||
'A component to display when the user reaches a page or tries to load a resource that does not exist', | ||
parameters: { | ||
docs: { | ||
page: mdx, | ||
}, | ||
}, | ||
}; | ||
|
||
export const EmptyPage = () => { | ||
return ( | ||
<EuiPageTemplate> | ||
<EuiPageTemplate.Section alignment="center"> | ||
<NotFound /> | ||
</EuiPageTemplate.Section> | ||
</EuiPageTemplate> | ||
); | ||
}; | ||
|
||
export const PageWithSidebar = () => { | ||
return ( | ||
<EuiPageTemplate panelled> | ||
<EuiPageTemplate.Sidebar>sidebar</EuiPageTemplate.Sidebar> | ||
<NotFound /> | ||
</EuiPageTemplate> | ||
); | ||
}; | ||
|
||
export const CustomActions = () => { | ||
return ( | ||
<EuiPageTemplate> | ||
<EuiPageTemplate.Section alignment="center"> | ||
<NotFound | ||
actions={[ | ||
<EuiButton fill color="primary" onClick={() => {}}> | ||
Go home | ||
</EuiButton>, | ||
<EuiButtonEmpty iconType="search">Go to discover</EuiButtonEmpty>, | ||
]} | ||
/> | ||
</EuiPageTemplate.Section> | ||
</EuiPageTemplate> | ||
); | ||
}; |