From bd118a87425efc7a38024939ae184e1daf0432a9 Mon Sep 17 00:00:00 2001 From: Mikyo King Date: Tue, 13 Jun 2023 10:59:17 -0600 Subject: [PATCH] feat: add empty for error and not found (#134) * feat: add empty for error and not found * add to limit for now * fix import --- package.json | 4 +- src/empty/EmptyGraphic.tsx | 10 +- ...ptyDocuments.tsx => EmptyDocumentsSVG.tsx} | 2 +- src/empty/graphics/ErrorSVG.tsx | 222 ++++++++++++++++++ src/empty/graphics/NotFoundSVG.tsx | 173 ++++++++++++++ src/empty/graphics/index.tsx | 5 +- stories/EmptyGraphic.stories.tsx | 6 +- 7 files changed, 413 insertions(+), 9 deletions(-) rename src/empty/graphics/{EmptyDocuments.tsx => EmptyDocumentsSVG.tsx} (99%) create mode 100644 src/empty/graphics/ErrorSVG.tsx create mode 100644 src/empty/graphics/NotFoundSVG.tsx diff --git a/package.json b/package.json index 9031b85f..29adc1c2 100644 --- a/package.json +++ b/package.json @@ -58,11 +58,11 @@ "size-limit": [ { "path": "dist/components.cjs.production.min.js", - "limit": "300 KB" + "limit": "500 KB" }, { "path": "dist/components.esm.js", - "limit": "300 KB" + "limit": "500 KB" } ], "devDependencies": { diff --git a/src/empty/EmptyGraphic.tsx b/src/empty/EmptyGraphic.tsx index e300bb18..3532aa1f 100644 --- a/src/empty/EmptyGraphic.tsx +++ b/src/empty/EmptyGraphic.tsx @@ -1,13 +1,13 @@ import React, { useMemo } from 'react'; import { assertUnreachable } from '../utils/typeUtils'; -import { EmptyDocuments } from './graphics'; +import { EmptyDocumentsSVG, NotFoundSVG, ErrorSVG } from './graphics'; export type EmptyGraphicProps = { /** * The icon to display * @default 'documents' **/ - graphicKey: 'documents'; + graphicKey: 'documents' | 'not found' | 'error'; /** * The size of the icon * @default 'S' @@ -41,7 +41,11 @@ export function EmptyGraphic(props: EmptyGraphicProps) { const graphic = useMemo(() => { switch (graphicKey) { case 'documents': - return ; + return ; + case 'not found': + return ; + case 'error': + return ; default: assertUnreachable(graphicKey); } diff --git a/src/empty/graphics/EmptyDocuments.tsx b/src/empty/graphics/EmptyDocumentsSVG.tsx similarity index 99% rename from src/empty/graphics/EmptyDocuments.tsx rename to src/empty/graphics/EmptyDocumentsSVG.tsx index 0d22d950..da7fbd76 100644 --- a/src/empty/graphics/EmptyDocuments.tsx +++ b/src/empty/graphics/EmptyDocumentsSVG.tsx @@ -3,7 +3,7 @@ import { css } from '@emotion/react'; import { StyleProps } from '../../types'; import { useStyleProps } from '../../utils'; -export const EmptyDocuments = (props: StyleProps) => { +export const EmptyDocumentsSVG = (props: StyleProps) => { // Create a unique ID so that more than one gradient def can exist // TODO - try to hoist the gradient defs to be global const id = useId(); diff --git a/src/empty/graphics/ErrorSVG.tsx b/src/empty/graphics/ErrorSVG.tsx new file mode 100644 index 00000000..86d6b821 --- /dev/null +++ b/src/empty/graphics/ErrorSVG.tsx @@ -0,0 +1,222 @@ +import React, { useId } from 'react'; +import { css } from '@emotion/react'; +import { StyleProps } from '../../types'; +import { useStyleProps } from '../../utils'; +export function ErrorSVG(props: StyleProps) { + // Create a unique ID so that more than one gradient def can exist + // TODO - try to hoist the gradient defs to be global + const id = useId(); + const { styleProps } = useStyleProps(props); + const linearGradientID = `${id}-linear-gradient`; + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +} diff --git a/src/empty/graphics/NotFoundSVG.tsx b/src/empty/graphics/NotFoundSVG.tsx new file mode 100644 index 00000000..9383c7ff --- /dev/null +++ b/src/empty/graphics/NotFoundSVG.tsx @@ -0,0 +1,173 @@ +import React, { useId } from 'react'; +import { css } from '@emotion/react'; +import { StyleProps } from '../../types'; +import { useStyleProps } from '../../utils'; +export const NotFoundSVG = (props: StyleProps) => { + // Create a unique ID so that more than one gradient def can exist + // TODO - try to hoist the gradient defs to be global + const id = useId(); + const { styleProps } = useStyleProps(props); + const linearGradientID1 = `${id}-linear-gradient-1`; + const linearGradientId2 = `${id}-linear-gradient-2`; + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +}; diff --git a/src/empty/graphics/index.tsx b/src/empty/graphics/index.tsx index 6341f3c8..152427aa 100644 --- a/src/empty/graphics/index.tsx +++ b/src/empty/graphics/index.tsx @@ -1,2 +1,3 @@ -export * from './EmptyDocuments'; -export * from './EmptyDocuments'; +export * from './EmptyDocumentsSVG'; +export * from './NotFoundSVG'; +export * from './ErrorSVG'; diff --git a/stories/EmptyGraphic.stories.tsx b/stories/EmptyGraphic.stories.tsx index 80828c8f..808ec447 100644 --- a/stories/EmptyGraphic.stories.tsx +++ b/stories/EmptyGraphic.stories.tsx @@ -25,7 +25,11 @@ const meta: Meta = { export default meta; -const graphics: EmptyGraphicProps['graphicKey'][] = ['documents']; +const graphics: EmptyGraphicProps['graphicKey'][] = [ + 'documents', + 'not found', + 'error', +]; export const Gallery = () => { return (