Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add empty for error and not found #134

Merged
merged 3 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
10 changes: 7 additions & 3 deletions src/empty/EmptyGraphic.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -41,7 +41,11 @@ export function EmptyGraphic(props: EmptyGraphicProps) {
const graphic = useMemo(() => {
switch (graphicKey) {
case 'documents':
return <EmptyDocuments {...dimensions} />;
return <EmptyDocumentsSVG {...dimensions} />;
case 'not found':
return <NotFoundSVG {...dimensions} />;
case 'error':
return <ErrorSVG {...dimensions} />;
default:
assertUnreachable(graphicKey);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
222 changes: 222 additions & 0 deletions src/empty/graphics/ErrorSVG.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 150 150"
{...(styleProps as any)}
css={css`
.cls-1 {
isolation: isolate;
}
.cls-2 {
fill: transparent;
}
.cls-3 {
fill: #2c353f;
}
.cls-4 {
mix-blend-mode: multiply;
opacity: 0.18;
}
.cls-5 {
fill: url(#${linearGradientID});
}
.cls-6,
.cls-7 {
fill: none;
stroke-linecap: round;
stroke-miterlimit: 10;
}
.cls-6 {
stroke: #02bf92;
stroke-dasharray: 0 6.31;
}
.cls-7 {
stroke: #5bdbff;
stroke-width: 2px;
}
`}
>
<defs>
<linearGradient
id={linearGradientID}
x1="40.04"
y1="75.24"
x2="109.77"
y2="75.24"
gradientTransform="translate(150.24 0.29) rotate(90)"
gradientUnits="userSpaceOnUse"
>
<stop offset="0" stopColor="#636a71" />
<stop offset="1" stopColor="#38424e" />
</linearGradient>
</defs>
<g className="cls-1">
<g id="Layer_2" data-name="Layer 2">
<g id="BG">
<rect className="cls-2" width="150" height="150" />
<circle className="cls-3" cx="75" cy="75.2" r="64.93" />
</g>
<g id="Art">
<image
className="cls-4"
width="122"
height="121"
transform="translate(14.23 14.82)"
xlinkHref="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHoAAAB5CAYAAAD2zTVKAAAACXBIWXMAAAsSAAALEgHS3X78AAAJWklEQVR4Xu3daXfaPBCG4dtZ2rRpuvz/H9nlTUOz+v1gPfF4LC+AAUtizpljQyihvpiR7ASlqu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>
<line
className="cls-6"
x1="75.01"
y1="17.89"
x2="75.01"
y2="3.44"
/>
<line
className="cls-6"
x1="55.41"
y1="21.34"
x2="50.47"
y2="7.76"
/>
<line
className="cls-6"
x1="38.17"
y1="31.29"
x2="28.88"
y2="20.22"
/>
<line
className="cls-6"
x1="25.38"
y1="46.53"
x2="12.86"
y2="39.31"
/>
<line
className="cls-6"
x1="18.57"
y1="65.24"
x2="4.33"
y2="62.73"
/>
<line
className="cls-6"
x1="18.56"
y1="85.14"
x2="4.33"
y2="87.65"
/>
<line
className="cls-6"
x1="25.36"
y1="103.84"
x2="12.85"
y2="111.07"
/>
<line
className="cls-6"
x1="38.15"
y1="119.09"
x2="28.86"
y2="130.16"
/>
<line
className="cls-6"
x1="55.39"
y1="129.05"
x2="50.44"
y2="142.63"
/>
<line
className="cls-6"
x1="74.99"
y1="132.51"
x2="74.99"
y2="146.96"
/>
<line
className="cls-6"
x1="94.59"
y1="129.06"
x2="99.53"
y2="142.64"
/>
<line
className="cls-6"
x1="111.83"
y1="119.11"
x2="121.12"
y2="130.18"
/>
<line
className="cls-6"
x1="124.62"
y1="103.87"
x2="137.14"
y2="111.09"
/>
<line
className="cls-6"
x1="131.43"
y1="85.17"
x2="145.67"
y2="87.67"
/>
<line
className="cls-6"
x1="131.44"
y1="65.26"
x2="145.67"
y2="62.75"
/>
<line
className="cls-6"
x1="124.64"
y1="46.56"
x2="137.15"
y2="39.33"
/>
<line
className="cls-6"
x1="111.85"
y1="31.31"
x2="121.14"
y2="20.24"
/>
<line
className="cls-6"
x1="94.61"
y1="21.35"
x2="99.56"
y2="7.77"
/>
<circle className="cls-7" cx="75" cy="100.67" r="5.34" />
<path
className="cls-7"
d="M76.88,86.93H73.12a2.51,2.51,0,0,1-2.5-2.32L68,47.07a2.49,2.49,0,0,1,2.49-2.67h9.06A2.49,2.49,0,0,1,82,47.07L79.38,84.61A2.51,2.51,0,0,1,76.88,86.93Z"
/>
</g>
</g>
</g>
</svg>
);
}
Loading