Skip to content

Commit

Permalink
Add storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro Fernández Gómez committed Nov 22, 2022
1 parent 79177dd commit 8d393b6
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 3 deletions.
3 changes: 0 additions & 3 deletions packages/shared-ux/prompt/errors/README.md

This file was deleted.

12 changes: 12 additions & 0 deletions packages/shared-ux/prompt/errors/README.mdx
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 packages/shared-ux/prompt/errors/src/not_found.stories.tsx
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>
);
};

0 comments on commit 8d393b6

Please sign in to comment.