@cypress-design/react-statusicon 0.0.9 → 0.1.0

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 CHANGED
@@ -1,5 +1,29 @@
1
1
  # @cypress-design/react-statusicon
2
2
 
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#105](https://github.com/cypress-io/cypress-design/pull/105) [`2f54f5b`](https://github.com/cypress-io/cypress-design/commit/2f54f5b867b60ba5ce2e40fd38870bd65187ba30) Thanks [@elevatebart](https://github.com/elevatebart)! - move animation of running status to SMIL
8
+
9
+ ### Patch Changes
10
+
11
+ - [#103](https://github.com/cypress-io/cypress-design/pull/103) [`e82d8cb`](https://github.com/cypress-io/cypress-design/commit/e82d8cb60882a379d89f86d1ff7b8f1d5b56ce66) Thanks [@mapsandapps](https://github.com/mapsandapps)! - Change the status icon for noTests; fix some icon colors
12
+
13
+ - Updated dependencies [[`2f54f5b`](https://github.com/cypress-io/cypress-design/commit/2f54f5b867b60ba5ce2e40fd38870bd65187ba30), [`e82d8cb`](https://github.com/cypress-io/cypress-design/commit/e82d8cb60882a379d89f86d1ff7b8f1d5b56ce66)]:
14
+ - @cypress-design/react-icon@0.11.0
15
+ - @cypress-design/icon-registry@0.13.0
16
+
17
+ ## 0.0.10
18
+
19
+ ### Patch Changes
20
+
21
+ - [#98](https://github.com/cypress-io/cypress-design/pull/98) [`f41d962`](https://github.com/cypress-io/cypress-design/commit/f41d962b3331767e89a74f0dc6ba207b11ff6226) Thanks [@elevatebart](https://github.com/elevatebart)! - refactor: status colors should be in status icons
22
+
23
+ - Updated dependencies [[`f41d962`](https://github.com/cypress-io/cypress-design/commit/f41d962b3331767e89a74f0dc6ba207b11ff6226)]:
24
+ - @cypress-design/react-icon@0.10.1
25
+ - @cypress-design/icon-registry@0.12.1
26
+
3
27
  ## 0.0.9
4
28
 
5
29
  ### Patch Changes
@@ -7,15 +7,15 @@ import { compileProps } from './compileProps'
7
7
  export const OutlineStatusIcon: React.FC<
8
8
  VariantStatusIconProps & SVGProps<SVGSVGElement>
9
9
  > = ({ size = '24', status = 'placeholder', ...rest }) => {
10
- return React.createElement(
11
- 'svg',
12
- compileProps({
10
+ return React.createElement('svg', {
11
+ ...rest,
12
+ ...compileProps({
13
13
  status,
14
14
  statuses,
15
15
  className: rest.className,
16
16
  size,
17
- })
18
- )
17
+ }),
18
+ })
19
19
  }
20
20
 
21
21
  export default OutlineStatusIcon
@@ -7,15 +7,15 @@ import { compileProps } from './compileProps'
7
7
  export const SimpleStatusIcon: React.FC<
8
8
  VariantStatusIconProps & SVGProps<SVGSVGElement>
9
9
  > = ({ size = '24', status = 'placeholder', ...rest }) => {
10
- return React.createElement(
11
- 'svg',
12
- compileProps({
10
+ return React.createElement('svg', {
11
+ ...rest,
12
+ ...compileProps({
13
13
  status,
14
14
  statuses,
15
15
  className: rest.className,
16
16
  size,
17
- })
18
- )
17
+ }),
18
+ })
19
19
  }
20
20
 
21
21
  export default SimpleStatusIcon
@@ -7,15 +7,15 @@ import { compileProps } from './compileProps'
7
7
  export const SolidStatusIcon: React.FC<
8
8
  VariantStatusIconProps & SVGProps<SVGSVGElement>
9
9
  > = ({ size = '24', status = 'placeholder', ...rest }) => {
10
- return React.createElement(
11
- 'svg',
12
- compileProps({
10
+ return React.createElement('svg', {
11
+ ...rest,
12
+ ...compileProps({
13
13
  status,
14
14
  statuses,
15
15
  className: rest.className,
16
16
  size,
17
- })
18
- )
17
+ }),
18
+ })
19
19
  }
20
20
 
21
21
  export default SolidStatusIcon
@@ -30,9 +30,7 @@ export default () => (
30
30
  </tr>
31
31
  </thead>
32
32
  <tbody>
33
- {Object.keys(statuses).map((status) => {
34
- const statusInfo = statuses[status]
35
-
33
+ {Object.entries(statuses).map(([status, statusInfo]) => {
36
34
  return (
37
35
  <>
38
36
  {statusInfo.variants.map((variant, i) => {
@@ -64,8 +62,8 @@ export default () => (
64
62
  return (
65
63
  <td key={`${status}-${size}-${variant}`} className="py-2">
66
64
  <StatusIcon
67
- status={status}
68
- size={size}
65
+ status={status as any}
66
+ size={size as any}
69
67
  variant={variant}
70
68
  />
71
69
  </td>
@@ -10,24 +10,6 @@ describe('StatusIcon', () => {
10
10
  mount(<StatusIconStory />)
11
11
  })
12
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
13
  it('defaults to a variant that exists if the one provided does not exist', () => {
32
14
  mount(
33
15
  <div>
package/compileProps.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import type { IconSet, VariantStatusIconProps } from '../constants'
2
+ import { statuses as StatusForColor } from '../constants'
2
3
  import { compileReactIconProperties } from '@cypress-design/react-icon'
4
+ import { getComponentAttributes } from '@cypress-design/icon-registry'
3
5
 
4
6
  export const compileProps = ({
5
7
  status,
@@ -12,15 +14,23 @@ export const compileProps = ({
12
14
  }) => {
13
15
  const statusInfo = status ? statuses[status] : statuses.placeholder
14
16
 
15
- const icon = statusInfo[`size${size}Icon`]
17
+ const iconInfo = status ? StatusForColor[status] : StatusForColor.placeholder
16
18
 
17
- const classes = `inline-block ${className || ''} ${
18
- statusInfo.shouldSpin && size !== '4' ? 'animate-spin' : ''
19
- }`
19
+ const { data: iconData, name } = statusInfo[`size${size}Icon`]
20
+
21
+ const classes = `inline-block ${className || ''}`
22
+
23
+ const { compiledClasses } = getComponentAttributes({
24
+ name,
25
+ strokeColor: iconInfo.color,
26
+ size,
27
+ availableSizes: [size],
28
+ fillColor: iconInfo.secondaryColor,
29
+ })
20
30
 
21
31
  return compileReactIconProperties({
22
- body: icon.data,
23
- compiledClasses: [classes],
32
+ body: iconData,
33
+ compiledClasses: [...compiledClasses, classes],
24
34
  size,
25
35
  })
26
36
  }
@@ -1,17 +1,18 @@
1
+ import type { WindiColor } from '@cypress-design/icon-registry';
1
2
  export declare type Variant = 'outline' | 'simple' | 'solid';
2
3
  export declare type Size = '4' | '8' | '12' | '16' | '24';
3
4
  declare type StatusInfo = {
4
- color: string;
5
+ color: WindiColor;
5
6
  link?: string;
6
7
  use: string;
7
8
  variants: readonly Variant[];
9
+ secondaryColor?: WindiColor;
8
10
  };
9
11
  export declare type IconContents = {
10
12
  name: string;
11
13
  data: string;
12
14
  };
13
15
  export declare type IconSet = {
14
- shouldSpin: boolean;
15
16
  size4Icon: IconContents;
16
17
  size8Icon: IconContents;
17
18
  size12Icon: IconContents;
@@ -26,6 +27,7 @@ declare const constStatuses: {
26
27
  readonly color: "indigo-400";
27
28
  readonly use: "Runs, specs, groups, test results";
28
29
  readonly variants: readonly ["outline"];
30
+ readonly secondaryColor: "gray-100";
29
31
  };
30
32
  readonly passed: {
31
33
  readonly color: "jade-400";
@@ -55,7 +57,7 @@ declare const constStatuses: {
55
57
  readonly variants: readonly ["outline", "solid"];
56
58
  };
57
59
  readonly noTests: {
58
- readonly color: "gray-400";
60
+ readonly color: "orange-400";
59
61
  readonly use: "Runs, specs, groups";
60
62
  readonly variants: readonly ["outline", "solid"];
61
63
  };
@@ -1 +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;IAC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