@cypress-design/react-statusicon 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/OutlineStatusIcon.ts +21 -0
- package/ReadMe.md +35 -0
- package/SimpleStatusIcon.ts +21 -0
- package/SolidStatusIcon.ts +21 -0
- package/StatusIcon.rootstory.tsx +85 -0
- package/StatusIcon.stories.mdx +134 -0
- package/StatusIcon.tsx +38 -0
- package/StatusIconReact.cy.tsx +75 -0
- package/compileProps.ts +26 -0
- package/dist/constants.d.ts +104 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/index.es.js +455 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +482 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/outline-imports.d.ts +3 -0
- package/dist/outline-imports.d.ts.map +1 -0
- package/dist/react/OutlineStatusIcon.d.ts +6 -0
- package/dist/react/OutlineStatusIcon.d.ts.map +1 -0
- package/dist/react/SimpleStatusIcon.d.ts +6 -0
- package/dist/react/SimpleStatusIcon.d.ts.map +1 -0
- package/dist/react/SolidStatusIcon.d.ts +6 -0
- package/dist/react/SolidStatusIcon.d.ts.map +1 -0
- package/dist/react/StatusIcon.d.ts +21 -0
- package/dist/react/StatusIcon.d.ts.map +1 -0
- package/dist/react/compileProps.d.ts +6 -0
- package/dist/react/compileProps.d.ts.map +1 -0
- package/dist/react/index.d.ts +5 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/simple-imports.d.ts +3 -0
- package/dist/simple-imports.d.ts.map +1 -0
- package/dist/solid-imports.d.ts +3 -0
- package/dist/solid-imports.d.ts.map +1 -0
- package/index.ts +4 -0
- package/package.json +27 -0
- package/rollup.config.js +3 -0
- package/tsconfig.build.json +8 -0
- package/tsconfig.json +9 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @cypress-design/react-statusicon
|
|
2
|
+
|
|
3
|
+
## 0.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#52](https://github.com/cypress-io/cypress-design/pull/52) [`43b53eb`](https://github.com/cypress-io/cypress-design/commit/43b53eb6bd10111629239a87374cfcc894eda0e3) Thanks [@mapsandapps](https://github.com/mapsandapps)! - New icons for statuses
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`31aaa18`](https://github.com/cypress-io/cypress-design/commit/31aaa182c8cd415f2884289144f504183e5ab418), [`ccd8f9a`](https://github.com/cypress-io/cypress-design/commit/ccd8f9a8feb624c0a52deaa9754c76969f43fc1e), [`0866c65`](https://github.com/cypress-io/cypress-design/commit/0866c654f24c36951c98468d789462748606b428), [`43b53eb`](https://github.com/cypress-io/cypress-design/commit/43b53eb6bd10111629239a87374cfcc894eda0e3)]:
|
|
10
|
+
- @cypress-design/icon-registry@0.5.0
|
|
11
|
+
- @cypress-design/react-icon@0.4.0
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { SVGProps } from 'react'
|
|
3
|
+
import { statuses } from '../outline-imports'
|
|
4
|
+
import type { VariantStatusIconProps } from '../constants'
|
|
5
|
+
import { compileProps } from './compileProps'
|
|
6
|
+
|
|
7
|
+
export const OutlineStatusIcon: React.FC<
|
|
8
|
+
VariantStatusIconProps & SVGProps<SVGSVGElement>
|
|
9
|
+
> = ({ size = '24', status = 'placeholder', ...rest }) => {
|
|
10
|
+
return React.createElement(
|
|
11
|
+
'svg',
|
|
12
|
+
compileProps({
|
|
13
|
+
status,
|
|
14
|
+
statuses,
|
|
15
|
+
className: rest.className,
|
|
16
|
+
size,
|
|
17
|
+
})
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default OutlineStatusIcon
|
package/ReadMe.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# StatusIcon
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
The icons that get displayed to represent run, spec, group, and test result statuses.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @cypress-design/react-statusicon
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
or with yarn
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
yarn add @cypress-design/react-statusicon
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
The simple way of using the StatusIcon component
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import StatusIcon from '@cypress-design/react-statusicon'
|
|
25
|
+
|
|
26
|
+
export default () => <StatusIcon size="16" status="failed" variant="solid" />
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The tree-shakable way (more optimized)
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { SolidStatusIcon } from '@cypress-design/react-statusicon'
|
|
33
|
+
|
|
34
|
+
export default () => <SolidStatusIcon size="16" status="failed" />
|
|
35
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { SVGProps } from 'react'
|
|
3
|
+
import { statuses } from '../simple-imports'
|
|
4
|
+
import type { VariantStatusIconProps } from '../constants'
|
|
5
|
+
import { compileProps } from './compileProps'
|
|
6
|
+
|
|
7
|
+
export const SimpleStatusIcon: React.FC<
|
|
8
|
+
VariantStatusIconProps & SVGProps<SVGSVGElement>
|
|
9
|
+
> = ({ size = '24', status = 'placeholder', ...rest }) => {
|
|
10
|
+
return React.createElement(
|
|
11
|
+
'svg',
|
|
12
|
+
compileProps({
|
|
13
|
+
status,
|
|
14
|
+
statuses,
|
|
15
|
+
className: rest.className,
|
|
16
|
+
size,
|
|
17
|
+
})
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default SimpleStatusIcon
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { SVGProps } from 'react'
|
|
3
|
+
import { statuses } from '../solid-imports'
|
|
4
|
+
import type { VariantStatusIconProps } from '../constants'
|
|
5
|
+
import { compileProps } from './compileProps'
|
|
6
|
+
|
|
7
|
+
export const SolidStatusIcon: React.FC<
|
|
8
|
+
VariantStatusIconProps & SVGProps<SVGSVGElement>
|
|
9
|
+
> = ({ size = '24', status = 'placeholder', ...rest }) => {
|
|
10
|
+
return React.createElement(
|
|
11
|
+
'svg',
|
|
12
|
+
compileProps({
|
|
13
|
+
status,
|
|
14
|
+
statuses,
|
|
15
|
+
className: rest.className,
|
|
16
|
+
size,
|
|
17
|
+
})
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default SolidStatusIcon
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import clsx from 'clsx'
|
|
3
|
+
import StatusIcon from './StatusIcon'
|
|
4
|
+
import { statuses } from '../constants'
|
|
5
|
+
|
|
6
|
+
const sizes = ['4', '8', '12', '16', '24']
|
|
7
|
+
|
|
8
|
+
export default () => (
|
|
9
|
+
<table className="w-full">
|
|
10
|
+
<thead>
|
|
11
|
+
<tr key="h0">
|
|
12
|
+
<th className="text-left">Status</th>
|
|
13
|
+
<th className="text-left">Variant</th>
|
|
14
|
+
<th className="text-left" colSpan={sizes.length}>
|
|
15
|
+
Size
|
|
16
|
+
</th>
|
|
17
|
+
<th className="text-left">Used for</th>
|
|
18
|
+
</tr>
|
|
19
|
+
<tr key="h1">
|
|
20
|
+
<th />
|
|
21
|
+
<th />
|
|
22
|
+
{sizes.map((size) => {
|
|
23
|
+
return (
|
|
24
|
+
<th key={`heading-${size}`} className="text-left">
|
|
25
|
+
{size}
|
|
26
|
+
</th>
|
|
27
|
+
)
|
|
28
|
+
})}
|
|
29
|
+
<th />
|
|
30
|
+
</tr>
|
|
31
|
+
</thead>
|
|
32
|
+
<tbody>
|
|
33
|
+
{Object.keys(statuses).map((status) => {
|
|
34
|
+
const statusInfo = statuses[status]
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<>
|
|
38
|
+
{statusInfo.variants.map((variant, i) => {
|
|
39
|
+
return (
|
|
40
|
+
<tr
|
|
41
|
+
className={clsx(i === 0 && 'border-t')}
|
|
42
|
+
key={`${status}-${variant}`}
|
|
43
|
+
>
|
|
44
|
+
{i === 0 ? (
|
|
45
|
+
<td>
|
|
46
|
+
{statusInfo.link ? (
|
|
47
|
+
<a
|
|
48
|
+
href={statusInfo.link}
|
|
49
|
+
className="text-indigo-500 underline"
|
|
50
|
+
target="_blank"
|
|
51
|
+
>
|
|
52
|
+
{status}
|
|
53
|
+
</a>
|
|
54
|
+
) : (
|
|
55
|
+
status
|
|
56
|
+
)}
|
|
57
|
+
</td>
|
|
58
|
+
) : (
|
|
59
|
+
<td />
|
|
60
|
+
)}
|
|
61
|
+
|
|
62
|
+
<td>{variant}</td>
|
|
63
|
+
{sizes.map((size) => {
|
|
64
|
+
return (
|
|
65
|
+
<td key={`${status}-${size}-${variant}`} className="py-2">
|
|
66
|
+
<StatusIcon
|
|
67
|
+
status={status}
|
|
68
|
+
size={size}
|
|
69
|
+
variant={variant}
|
|
70
|
+
/>
|
|
71
|
+
</td>
|
|
72
|
+
)
|
|
73
|
+
})}
|
|
74
|
+
<td className="align-top py-2">
|
|
75
|
+
{i === 0 ? statusInfo.use : ''}
|
|
76
|
+
</td>
|
|
77
|
+
</tr>
|
|
78
|
+
)
|
|
79
|
+
})}
|
|
80
|
+
</>
|
|
81
|
+
)
|
|
82
|
+
})}
|
|
83
|
+
</tbody>
|
|
84
|
+
</table>
|
|
85
|
+
)
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { ArgsTable, Canvas, Meta, Story, Description } from '@storybook/addon-docs'
|
|
2
|
+
import { version } from "./package.json"
|
|
3
|
+
import changelog from "./CHANGELOG.md"
|
|
4
|
+
import StatusIconStory from './StatusIcon.rootstory'
|
|
5
|
+
import { statuses } from '../constants'
|
|
6
|
+
|
|
7
|
+
import StatusIcon from './StatusIcon'
|
|
8
|
+
import { OutlineStatusIcon, SimpleStatusIcon, SolidStatusIcon } from '@cypress-design/react-statusicon'
|
|
9
|
+
|
|
10
|
+
<h1>StatusIcon<span className="text-lg font-normal"> - v{version}</span></h1>
|
|
11
|
+
|
|
12
|
+
There is <a href="https://on.cypress.io/writing-and-organizing-tests" target="_blank">info in the docs</a> about what these statuses mean. The terminology can be a bit confusing, particularly around <a href="https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests#Pending" target="_blank">pending</a> and <a href="https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests#Skipped" target="_blank">skipped</a> test results.
|
|
13
|
+
|
|
14
|
+
Runs, specs, and groups have one and only one of the following status: RUNNING, ERRORED, FAILED, TIMEDOUT, NOTESTS, PASSED, OVERLIMIT, or CANCELLED
|
|
15
|
+
|
|
16
|
+
Specs can also have status UNCLAIMED
|
|
17
|
+
|
|
18
|
+
Test results have one and only one of the following statuses: RUNNING, PENDING, SKIPPED, FAILED, PASSED, TIMEDOUT, ERRORED, or CANCELLED
|
|
19
|
+
|
|
20
|
+
<Meta
|
|
21
|
+
title="StatusIcon"
|
|
22
|
+
component={StatusIcon}
|
|
23
|
+
parameters={{
|
|
24
|
+
design: {
|
|
25
|
+
type: "figma",
|
|
26
|
+
url: "https://www.figma.com/file/1WJ3GVQyMV5e7xVxPg3yID/Design-System?node-id=6814%3A10841",
|
|
27
|
+
}
|
|
28
|
+
}}
|
|
29
|
+
argTypes={{
|
|
30
|
+
size: {
|
|
31
|
+
control: { type: 'select' },
|
|
32
|
+
defaultValue: '16'
|
|
33
|
+
},
|
|
34
|
+
status: {
|
|
35
|
+
control: { type: 'select' },
|
|
36
|
+
options: Object.keys(statuses),
|
|
37
|
+
defaultValue: 'failed'
|
|
38
|
+
},
|
|
39
|
+
variant: {
|
|
40
|
+
control: { type: 'select' },
|
|
41
|
+
defaultValue: 'simple'
|
|
42
|
+
},
|
|
43
|
+
}} />
|
|
44
|
+
|
|
45
|
+
<Canvas withSource="none">
|
|
46
|
+
<Story name="StatusIcon">
|
|
47
|
+
<StatusIconStory />
|
|
48
|
+
</Story>
|
|
49
|
+
</Canvas>
|
|
50
|
+
|
|
51
|
+
## Basic use
|
|
52
|
+
|
|
53
|
+
```jsx
|
|
54
|
+
import StatusIcon from '@cypress-design/react-statusicon'
|
|
55
|
+
|
|
56
|
+
<StatusIcon status="failed" size="16" variant="simple" />
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
<Canvas>
|
|
60
|
+
<Story name="Basic use">
|
|
61
|
+
{(args) => {
|
|
62
|
+
return (
|
|
63
|
+
<StatusIcon
|
|
64
|
+
status={args.status}
|
|
65
|
+
size={args.size}
|
|
66
|
+
variant={args.variant}
|
|
67
|
+
/>
|
|
68
|
+
)
|
|
69
|
+
}}
|
|
70
|
+
</Story>
|
|
71
|
+
</Canvas>
|
|
72
|
+
|
|
73
|
+
Not all statuses have unique icons for each variant. But if you pass any variant of the icon, it will default to one that is available for that status.
|
|
74
|
+
|
|
75
|
+
As an example, if you pass `variant="simple"` with `status="errored"`, it will default to the solid variant, since the errored status has no simple variant available.
|
|
76
|
+
|
|
77
|
+
<Canvas>
|
|
78
|
+
<StatusIcon
|
|
79
|
+
status="errored"
|
|
80
|
+
size="16"
|
|
81
|
+
variant="simple"
|
|
82
|
+
/>
|
|
83
|
+
</Canvas>
|
|
84
|
+
|
|
85
|
+
## Tree-shakable
|
|
86
|
+
|
|
87
|
+
If you want to avoid loading all the icon variants, you may use each variant separately.
|
|
88
|
+
|
|
89
|
+
```jsx
|
|
90
|
+
import { OutlineStatusIcon } from '@cypress-design/react-statusicon'
|
|
91
|
+
|
|
92
|
+
<OutlineStatusIcon status="failed" size="16" />
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
<Canvas>
|
|
96
|
+
<Story name="Tree-shakable">
|
|
97
|
+
<OutlineStatusIcon
|
|
98
|
+
status="failed"
|
|
99
|
+
size="16"
|
|
100
|
+
/>
|
|
101
|
+
<SimpleStatusIcon
|
|
102
|
+
status="failed"
|
|
103
|
+
size="16"
|
|
104
|
+
/>
|
|
105
|
+
<SolidStatusIcon
|
|
106
|
+
status="failed"
|
|
107
|
+
size="16"
|
|
108
|
+
/>
|
|
109
|
+
</Story>
|
|
110
|
+
</Canvas>
|
|
111
|
+
|
|
112
|
+
## Placeholder
|
|
113
|
+
|
|
114
|
+
The placeholder icon appears if you pass a falsy status or no status at all.
|
|
115
|
+
|
|
116
|
+
<Canvas>
|
|
117
|
+
<Story name="Placeholder">
|
|
118
|
+
<StatusIcon
|
|
119
|
+
status={null}
|
|
120
|
+
size="16"
|
|
121
|
+
variant="simple"
|
|
122
|
+
/>
|
|
123
|
+
<StatusIcon
|
|
124
|
+
size="16"
|
|
125
|
+
variant="simple"
|
|
126
|
+
/>
|
|
127
|
+
</Story>
|
|
128
|
+
</Canvas>
|
|
129
|
+
|
|
130
|
+
<ArgsTable />
|
|
131
|
+
|
|
132
|
+
<Description>
|
|
133
|
+
{changelog.replace(/^# .+/, '## Changelog')}
|
|
134
|
+
</Description>
|
package/StatusIcon.tsx
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { SVGProps } from 'react'
|
|
3
|
+
import type { Variant, Size } from '../constants'
|
|
4
|
+
import { statuses } from '../constants'
|
|
5
|
+
import OutlineStatusIcon from './OutlineStatusIcon'
|
|
6
|
+
import SimpleStatusIcon from './SimpleStatusIcon'
|
|
7
|
+
import SolidStatusIcon from './SolidStatusIcon'
|
|
8
|
+
|
|
9
|
+
export type StatusIconProps = {
|
|
10
|
+
/**
|
|
11
|
+
* The size of the icon's canvas, in pixels.
|
|
12
|
+
*/
|
|
13
|
+
size?: Size
|
|
14
|
+
/**
|
|
15
|
+
If there is no status provided, a placeholder icon will be shown
|
|
16
|
+
*/
|
|
17
|
+
status?: keyof typeof statuses | null | undefined
|
|
18
|
+
/**
|
|
19
|
+
* If a status doesn't have an icon for that variant, it will default to one it does have
|
|
20
|
+
*/
|
|
21
|
+
variant?: Variant
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const StatusIcon: React.FC<
|
|
25
|
+
StatusIconProps & SVGProps<SVGSVGElement>
|
|
26
|
+
> = ({ size = '24', status, variant = 'simple', ...rest }) => {
|
|
27
|
+
if (variant === 'outline') {
|
|
28
|
+
return <OutlineStatusIcon size={size} status={status} {...rest} />
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (variant === 'simple') {
|
|
32
|
+
return <SimpleStatusIcon size={size} status={status} {...rest} />
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return <SolidStatusIcon size={size} status={status} {...rest} />
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default StatusIcon
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { mount } from 'cypress/react'
|
|
5
|
+
import StatusIcon from './StatusIcon'
|
|
6
|
+
import StatusIconStory from './StatusIcon.rootstory'
|
|
7
|
+
|
|
8
|
+
describe('StatusIcon', () => {
|
|
9
|
+
it('renders', () => {
|
|
10
|
+
mount(<StatusIconStory />)
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
it('running icon spins', () => {
|
|
14
|
+
mount(<StatusIcon variant="simple" size="16" status="running" />)
|
|
15
|
+
|
|
16
|
+
cy.get('svg').should('have.class', 'animate-spin')
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('small running icon does not spin', () => {
|
|
20
|
+
mount(<StatusIcon variant="simple" size="4" status="running" />)
|
|
21
|
+
|
|
22
|
+
cy.get('svg').should('not.have.class', 'animate-spin')
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('other icons do not spin', () => {
|
|
26
|
+
mount(<StatusIcon variant="simple" size="16" status="passed" />)
|
|
27
|
+
|
|
28
|
+
cy.get('svg').should('not.have.class', 'animate-spin')
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('defaults to a variant that exists if the one provided does not exist', () => {
|
|
32
|
+
mount(
|
|
33
|
+
<div>
|
|
34
|
+
<StatusIcon variant="simple" size="16" status="placeholder" />
|
|
35
|
+
<StatusIcon variant="solid" size="16" status="placeholder" />
|
|
36
|
+
</div>
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
cy.get('svg').first().invoke('html').as('firstIcon')
|
|
40
|
+
cy.get('svg').last().invoke('html').as('secondIcon')
|
|
41
|
+
cy.then(function () {
|
|
42
|
+
expect(this.firstIcon).to.eq(this.secondIcon)
|
|
43
|
+
})
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('displays a placeholder icon if no status is passed', () => {
|
|
47
|
+
mount(
|
|
48
|
+
<div>
|
|
49
|
+
<StatusIcon variant="simple" size="16" />
|
|
50
|
+
<StatusIcon variant="solid" size="16" status="placeholder" />
|
|
51
|
+
</div>
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
cy.get('svg').first().invoke('html').as('firstIcon')
|
|
55
|
+
cy.get('svg').last().invoke('html').as('secondIcon')
|
|
56
|
+
cy.then(function () {
|
|
57
|
+
expect(this.firstIcon).to.eq(this.secondIcon)
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('displays a placeholder icon if null status is passed', () => {
|
|
62
|
+
mount(
|
|
63
|
+
<div>
|
|
64
|
+
<StatusIcon variant="simple" size="16" status={null} />
|
|
65
|
+
<StatusIcon variant="simple" size="16" status="placeholder" />
|
|
66
|
+
</div>
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
cy.get('svg').first().invoke('html').as('firstIcon')
|
|
70
|
+
cy.get('svg').last().invoke('html').as('secondIcon')
|
|
71
|
+
cy.then(function () {
|
|
72
|
+
expect(this.firstIcon).to.eq(this.secondIcon)
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
})
|
package/compileProps.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IconSet, VariantStatusIconProps } from '../constants'
|
|
2
|
+
import { compileReactIconProperties } from '@cypress-design/react-icon'
|
|
3
|
+
|
|
4
|
+
export const compileProps = ({
|
|
5
|
+
status,
|
|
6
|
+
statuses,
|
|
7
|
+
className,
|
|
8
|
+
size,
|
|
9
|
+
}: VariantStatusIconProps & {
|
|
10
|
+
statuses: Record<string, IconSet>
|
|
11
|
+
className: string | undefined
|
|
12
|
+
}) => {
|
|
13
|
+
const statusInfo = status ? statuses[status] : statuses.placeholder
|
|
14
|
+
|
|
15
|
+
const icon = statusInfo[`size${size}Icon`]
|
|
16
|
+
|
|
17
|
+
const classes = `inline-block ${className || ''} ${
|
|
18
|
+
statusInfo.shouldSpin && size !== '4' ? 'animate-spin' : ''
|
|
19
|
+
}`
|
|
20
|
+
|
|
21
|
+
return compileReactIconProperties({
|
|
22
|
+
body: icon.data,
|
|
23
|
+
compiledClasses: [classes],
|
|
24
|
+
size,
|
|
25
|
+
})
|
|
26
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export declare type Variant = 'outline' | 'simple' | 'solid';
|
|
2
|
+
export declare type Size = '4' | '8' | '12' | '16' | '24';
|
|
3
|
+
declare type StatusInfo = {
|
|
4
|
+
color: string;
|
|
5
|
+
link?: string;
|
|
6
|
+
use: string;
|
|
7
|
+
variants: readonly Variant[];
|
|
8
|
+
};
|
|
9
|
+
export declare type IconContents = {
|
|
10
|
+
name: string;
|
|
11
|
+
data: string;
|
|
12
|
+
};
|
|
13
|
+
export declare type IconSet = {
|
|
14
|
+
shouldSpin: boolean;
|
|
15
|
+
size4Icon: IconContents;
|
|
16
|
+
size8Icon: IconContents;
|
|
17
|
+
size12Icon: IconContents;
|
|
18
|
+
size16Icon: IconContents;
|
|
19
|
+
size24Icon: IconContents;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* This "const" is used to create the list of statuses
|
|
23
|
+
*/
|
|
24
|
+
declare const constStatuses: {
|
|
25
|
+
readonly running: {
|
|
26
|
+
readonly color: "indigo-400";
|
|
27
|
+
readonly use: "Runs, specs, groups, test results";
|
|
28
|
+
readonly variants: readonly ["outline"];
|
|
29
|
+
};
|
|
30
|
+
readonly passed: {
|
|
31
|
+
readonly color: "jade-400";
|
|
32
|
+
readonly use: "Runs, specs, groups, test results";
|
|
33
|
+
readonly link: "https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests#Passed";
|
|
34
|
+
readonly variants: readonly ["outline", "simple", "solid"];
|
|
35
|
+
};
|
|
36
|
+
readonly failed: {
|
|
37
|
+
readonly color: "red-400";
|
|
38
|
+
readonly use: "Runs, specs, groups, test results";
|
|
39
|
+
readonly link: "https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests#Failed";
|
|
40
|
+
readonly variants: readonly ["outline", "simple", "solid"];
|
|
41
|
+
};
|
|
42
|
+
readonly unclaimed: {
|
|
43
|
+
readonly color: "gray-100";
|
|
44
|
+
readonly use: "Specs";
|
|
45
|
+
readonly variants: readonly ["outline"];
|
|
46
|
+
};
|
|
47
|
+
readonly placeholder: {
|
|
48
|
+
readonly color: "gray-300";
|
|
49
|
+
readonly use: "Placeholder";
|
|
50
|
+
readonly variants: readonly ["solid"];
|
|
51
|
+
};
|
|
52
|
+
readonly cancelled: {
|
|
53
|
+
readonly color: "gray-300";
|
|
54
|
+
readonly use: "Runs, specs, groups, test results";
|
|
55
|
+
readonly variants: readonly ["outline", "solid"];
|
|
56
|
+
};
|
|
57
|
+
readonly noTests: {
|
|
58
|
+
readonly color: "gray-400";
|
|
59
|
+
readonly use: "Runs, specs, groups";
|
|
60
|
+
readonly variants: readonly ["outline", "solid"];
|
|
61
|
+
};
|
|
62
|
+
readonly errored: {
|
|
63
|
+
readonly color: "orange-400";
|
|
64
|
+
readonly use: "Runs, specs, groups, test results";
|
|
65
|
+
readonly variants: readonly ["outline", "solid"];
|
|
66
|
+
};
|
|
67
|
+
readonly timedOut: {
|
|
68
|
+
readonly color: "orange-400";
|
|
69
|
+
readonly use: "Runs, specs, groups, test results";
|
|
70
|
+
readonly variants: readonly ["outline", "solid"];
|
|
71
|
+
};
|
|
72
|
+
readonly overLimit: {
|
|
73
|
+
readonly color: "orange-400";
|
|
74
|
+
readonly use: "Runs, specs, groups";
|
|
75
|
+
readonly link: "https://docs.cypress.io/faq/questions/dashboard-faq#What-happens-once-I-reach-the-test-results-limit";
|
|
76
|
+
readonly variants: readonly ["outline", "solid"];
|
|
77
|
+
};
|
|
78
|
+
readonly skipped: {
|
|
79
|
+
readonly color: "gray-400";
|
|
80
|
+
readonly use: "Test results";
|
|
81
|
+
readonly link: "https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests#Skipped";
|
|
82
|
+
readonly variants: readonly ["outline"];
|
|
83
|
+
};
|
|
84
|
+
readonly pending: {
|
|
85
|
+
readonly color: "gray-300";
|
|
86
|
+
readonly use: "Test results";
|
|
87
|
+
readonly link: "https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests#Pending";
|
|
88
|
+
readonly variants: readonly ["outline"];
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
export declare type statusTypes = keyof typeof constStatuses;
|
|
92
|
+
/**
|
|
93
|
+
* The status we have here, allow us to check the validity of the constant
|
|
94
|
+
*/
|
|
95
|
+
export declare const statuses: Record<statusTypes, StatusInfo>;
|
|
96
|
+
export declare type VariantStatusIconProps = {
|
|
97
|
+
size: Size;
|
|
98
|
+
/**
|
|
99
|
+
If there is no status provided, a placeholder icon will be shown
|
|
100
|
+
*/
|
|
101
|
+
status?: keyof typeof statuses | null | undefined;
|
|
102
|
+
};
|
|
103
|
+
export {};
|
|
104
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../constants.ts"],"names":[],"mappings":"AAAA,oBAAY,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;AACpD,oBAAY,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAEjD,aAAK,UAAU,GAAG;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAA;CAC7B,CAAA;AAED,oBAAY,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,oBAAY,OAAO,GAAG;IACpB,UAAU,EAAE,OAAO,CAAA;IACnB,SAAS,EAAE,YAAY,CAAA;IACvB,SAAS,EAAE,YAAY,CAAA;IACvB,UAAU,EAAE,YAAY,CAAA;IACxB,UAAU,EAAE,YAAY,CAAA;IACxB,UAAU,EAAE,YAAY,CAAA;CACzB,CAAA;AAED;;GAEG;AACH,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkET,CAAA;AAEV,oBAAY,WAAW,GAAG,MAAM,OAAO,aAAa,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,UAAU,CAAiB,CAAA;AAEtE,oBAAY,sBAAsB,GAAG;IACnC,IAAI,EAAE,IAAI,CAAA;IACV;;MAEE;IACF,MAAM,CAAC,EAAE,MAAM,OAAO,QAAQ,GAAG,IAAI,GAAG,SAAS,CAAA;CAClD,CAAA"}
|