@cypress-design/react-icon 0.2.1 → 0.3.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,43 @@
1
1
  # @cypress-design/react-icon
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#41](https://github.com/cypress-io/cypress-design/pull/41) [`4259026`](https://github.com/cypress-io/cypress-design/commit/4259026314464260e89bcd88690c8a60ad2f0459) Thanks [@elevatebart](https://github.com/elevatebart)! - ## New syntaxes to add dynamic icon colors
8
+
9
+ ### With a prefix focus/hover
10
+
11
+ ```html
12
+ <IconBook
13
+ size="16"
14
+ strokeColor="blue-600"
15
+ hoverStrokeColor="jade-600"
16
+ focusStrokeColor="jade-900"
17
+ />
18
+ ```
19
+
20
+ ### With the same prefix acting on a group
21
+
22
+ ```html
23
+ <button class="group">
24
+ <IconBook
25
+ size="16"
26
+ strokeColor="blue-600"
27
+ hoverStrokeColor="jade-600"
28
+ focusStrokeColor="jade-900"
29
+ interactiveColorsOnGroup
30
+ />Read
31
+ </button>
32
+ ```
33
+
34
+ ### Patch Changes
35
+
36
+ - [#39](https://github.com/cypress-io/cypress-design/pull/39) [`1b383f3`](https://github.com/cypress-io/cypress-design/commit/1b383f3d149948bf2cc062d3baa17d5ce032f07e) Thanks [@elevatebart](https://github.com/elevatebart)! - fix file path of sourcemaps
37
+
38
+ - Updated dependencies [[`4259026`](https://github.com/cypress-io/cypress-design/commit/4259026314464260e89bcd88690c8a60ad2f0459)]:
39
+ - @cypress-design/icon-registry@0.4.0
40
+
3
41
  ## 0.2.1
4
42
 
5
43
  ### Patch Changes
package/Icon.stories.mdx CHANGED
@@ -50,7 +50,7 @@ import { Icon } from './Icon'
50
50
  </Story>
51
51
  </Canvas>
52
52
 
53
- <ArgsTable/>
53
+ <ArgsTable exclude={/^(hover|focus|hocus)/g} />
54
54
 
55
55
  ## Usage
56
56
 
@@ -73,7 +73,37 @@ import { IconBook } from '@cypress-design/react-icon'
73
73
 
74
74
  export const MyButtonWithIcon = () => {
75
75
  return (<button>
76
- <IconBook size="16" strokeColor="blue-600" fillColor="red-200" />
76
+ <IconBook size="16" strokeColor="indigo-600" fillColor="red-200" />
77
+ </button>)
78
+ }
79
+ ```
80
+
81
+ Should you need to change the color of the icon on `hover` or `focus` prefix the props with these words.
82
+
83
+ Here, the `strokeColor` will change on hover from indigo to jade
84
+
85
+ ```tsx
86
+ import { IconBook } from '@cypress-design/react-icon'
87
+
88
+ export const MyButtonWithIcon = () => {
89
+ return (<button>
90
+ <IconBook size="16" strokeColor="indigo-600" hoverStrokeColor="jade-600" />
91
+ </button>)
92
+ }
93
+ ```
94
+
95
+ If you need the `hover` or `focus` effect to be triggered on the parent group, use `interactiveColorsOnGroup`.
96
+ This prop will change all the pseudo prefixes to be group focused instead of triggered by the icon itself.
97
+
98
+ To achieve the same goal, in WindiCSS, we would use `group-hover:` instead of `hover:`.
99
+
100
+ ```tsx
101
+ import { IconBook } from '@cypress-design/react-icon'
102
+
103
+ export const MyButtonWithIcon = () => {
104
+ return (<button className="group hover:text-jade-800">
105
+ <IconBook size="16" strokeColor="indigo-600" hoverStrokeColor="jade-600" interactiveColorsOnGroup />
106
+ Book
77
107
  </button>)
78
108
  }
79
109
  ```
package/Icon.tsx CHANGED
@@ -21,20 +21,20 @@ export const compileReactIconProperties = ({
21
21
  body,
22
22
  compiledClasses,
23
23
  size,
24
- strokeColor,
25
- fillColor,
26
- secondaryStrokeColor,
27
- secondaryFillColor,
24
+ interactiveColorsOnGroup,
28
25
  ...attributes
29
26
  }: {
30
27
  body: string
31
28
  compiledClasses: string[]
32
29
  size: string
33
- strokeColor?
34
- fillColor?
35
- secondaryStrokeColor?
36
- secondaryFillColor?
30
+ interactiveColorsOnGroup?: boolean
37
31
  } & SVGPropsWithoutColorsOrSize) => {
32
+ Object.keys(attributes).forEach((key) => {
33
+ if (key.endsWith('Color')) {
34
+ // @ts-ignore
35
+ delete attributes[key]
36
+ }
37
+ })
38
38
  const componentProps = {
39
39
  width: size,
40
40
  height: size,
package/ReadMe.md CHANGED
@@ -31,7 +31,50 @@ import { IconBook } from '@cypress-design/react-icon'
31
31
  export const MyButtonWithIcon = () => {
32
32
  return (
33
33
  <button>
34
- <IconBook size="16" strokeColor="blue-600" fillColor="red-200" />
34
+ <IconBook size="16" strokeColor="indigo-600" fillColor="red-200" />
35
+ </button>
36
+ )
37
+ }
38
+ ```
39
+
40
+ Should you need to change the color of the icon on `hover` or `focus` prefix the props with these words.
41
+
42
+ Here, the `strokeColor` will change on hover from indigo to jade
43
+
44
+ ```tsx
45
+ import { IconBook } from '@cypress-design/react-icon'
46
+
47
+ export const MyButtonWithIcon = () => {
48
+ return (
49
+ <button>
50
+ <IconBook
51
+ size="16"
52
+ strokeColor="indigo-600"
53
+ hoverStrokeColor="jade-600"
54
+ />
55
+ </button>
56
+ )
57
+ }
58
+ ```
59
+
60
+ If you need the `hover` or `focus` effect to be triggered on the parent group, use `interactiveColorsOnGroup`.
61
+ This prop will change all the pseudo prefixes to be group focused instead of triggered by the icon itself.
62
+
63
+ To achieve the same goal, in WindiCSS, we would use `group-hover:` instead of `hover:`.
64
+
65
+ ```tsx
66
+ import { IconBook } from '@cypress-design/react-icon'
67
+
68
+ export const MyButtonWithIcon = () => {
69
+ return (
70
+ <button className="group hover:text-jade-800">
71
+ <IconBook
72
+ size="16"
73
+ strokeColor="indigo-600"
74
+ hoverStrokeColor="jade-600"
75
+ interactiveColorsOnGroup
76
+ />
77
+ Book
35
78
  </button>
36
79
  )
37
80
  }
package/dist/Icon.d.ts CHANGED
@@ -3,14 +3,11 @@ import type { FunctionComponent } from 'react';
3
3
  import type { IconProps } from '@cypress-design/icon-registry';
4
4
  declare type SVGPropsWithoutColorsOrSize = Omit<React.SVGProps<SVGSVGElement>, 'fill' | 'stroke' | 'fillColor' | 'strokeColor' | 'size'>;
5
5
  export declare const Icon: FunctionComponent<IconProps & SVGPropsWithoutColorsOrSize>;
6
- export declare const compileReactIconProperties: ({ body, compiledClasses, size, strokeColor, fillColor, secondaryStrokeColor, secondaryFillColor, ...attributes }: {
6
+ export declare const compileReactIconProperties: ({ body, compiledClasses, size, interactiveColorsOnGroup, ...attributes }: {
7
7
  body: string;
8
8
  compiledClasses: string[];
9
9
  size: string;
10
- strokeColor?: any;
11
- fillColor?: any;
12
- secondaryStrokeColor?: any;
13
- secondaryFillColor?: any;
10
+ interactiveColorsOnGroup?: boolean | undefined;
14
11
  } & SVGPropsWithoutColorsOrSize) => {
15
12
  string?: string | number | undefined;
16
13
  className?: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../Icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,iBAAiB,EAAY,MAAM,OAAO,CAAA;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAE9D,aAAK,2BAA2B,GAAG,IAAI,CACrC,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,EAC7B,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,aAAa,GAAG,MAAM,CACzD,CAAA;AAED,eAAO,MAAM,IAAI,EAAE,iBAAiB,CAClC,SAAS,GAAG,2BAA2B,CAMxC,CAAA;AAED,eAAO,MAAM,0BAA0B;UAU/B,MAAM;qBACK,MAAM,EAAE;UACnB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyBb,CAAA;AAED,eAAe,IAAI,CAAA"}
package/dist/index.es.js CHANGED
@@ -44,7 +44,13 @@ var Icon = function (props) {
44
44
  return React.createElement('svg', compileReactIconProperties$1(compileIcon(props)));
45
45
  };
46
46
  var compileReactIconProperties$1 = function (_a) {
47
- var body = _a.body, compiledClasses = _a.compiledClasses, size = _a.size; _a.strokeColor; _a.fillColor; _a.secondaryStrokeColor; _a.secondaryFillColor; var attributes = __rest(_a, ["body", "compiledClasses", "size", "strokeColor", "fillColor", "secondaryStrokeColor", "secondaryFillColor"]);
47
+ var body = _a.body, compiledClasses = _a.compiledClasses, size = _a.size; _a.interactiveColorsOnGroup; var attributes = __rest(_a, ["body", "compiledClasses", "size", "interactiveColorsOnGroup"]);
48
+ Object.keys(attributes).forEach(function (key) {
49
+ if (key.endsWith('Color')) {
50
+ // @ts-ignore
51
+ delete attributes[key];
52
+ }
53
+ });
48
54
  var componentProps = __assign({ width: size, height: size, fill: 'none', dangerouslySetInnerHTML: {
49
55
  __html: body
50
56
  } }, attributes);