@cypress-design/react-icon 0.2.1 → 0.4.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 +60 -0
- package/Icon.stories.mdx +32 -2
- package/Icon.tsx +2 -37
- package/ReadMe.md +44 -1
- package/compileProperties.ts +16 -10
- package/dist/Icon.d.ts +2 -485
- package/dist/Icon.d.ts.map +1 -1
- package/dist/TreeShakableIcons.d.ts +22 -0
- package/dist/TreeShakableIcons.d.ts.map +1 -1
- package/dist/compileProperties.d.ts +3 -6
- package/dist/compileProperties.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +549 -276
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +570 -274
- package/dist/index.umd.js.map +1 -1
- package/generate-icons.js +5 -3
- package/index.ts +1 -0
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,65 @@
|
|
|
1
1
|
# @cypress-design/react-icon
|
|
2
2
|
|
|
3
|
+
## 0.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`25c6260`](https://github.com/cypress-io/cypress-design/commit/25c62605be573dafafff090b47fb80091b35aea4)]:
|
|
8
|
+
- @cypress-design/icon-registry@0.6.0
|
|
9
|
+
|
|
10
|
+
## 0.4.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- [#51](https://github.com/cypress-io/cypress-design/pull/51) [`ccd8f9a`](https://github.com/cypress-io/cypress-design/commit/ccd8f9a8feb624c0a52deaa9754c76969f43fc1e) Thanks [@elevatebart](https://github.com/elevatebart)! - in the build asset, add a comment containing all used windicss classes in the component
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#56](https://github.com/cypress-io/cypress-design/pull/56) [`0866c65`](https://github.com/cypress-io/cypress-design/commit/0866c654f24c36951c98468d789462748606b428) Thanks [@elevatebart](https://github.com/elevatebart)! - fix: avoid using `delete` to avoid memory leaks
|
|
19
|
+
|
|
20
|
+
* [#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
|
|
21
|
+
|
|
22
|
+
* Updated dependencies [[`31aaa18`](https://github.com/cypress-io/cypress-design/commit/31aaa182c8cd415f2884289144f504183e5ab418), [`0866c65`](https://github.com/cypress-io/cypress-design/commit/0866c654f24c36951c98468d789462748606b428), [`43b53eb`](https://github.com/cypress-io/cypress-design/commit/43b53eb6bd10111629239a87374cfcc894eda0e3)]:
|
|
23
|
+
- @cypress-design/icon-registry@0.5.0
|
|
24
|
+
|
|
25
|
+
## 0.3.0
|
|
26
|
+
|
|
27
|
+
### Minor Changes
|
|
28
|
+
|
|
29
|
+
- [#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
|
|
30
|
+
|
|
31
|
+
### With a prefix focus/hover
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<IconBook
|
|
35
|
+
size="16"
|
|
36
|
+
strokeColor="blue-600"
|
|
37
|
+
hoverStrokeColor="jade-600"
|
|
38
|
+
focusStrokeColor="jade-900"
|
|
39
|
+
/>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### With the same prefix acting on a group
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<button class="group">
|
|
46
|
+
<IconBook
|
|
47
|
+
size="16"
|
|
48
|
+
strokeColor="blue-600"
|
|
49
|
+
hoverStrokeColor="jade-600"
|
|
50
|
+
focusStrokeColor="jade-900"
|
|
51
|
+
interactiveColorsOnGroup
|
|
52
|
+
/>Read
|
|
53
|
+
</button>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- [#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
|
|
59
|
+
|
|
60
|
+
- Updated dependencies [[`4259026`](https://github.com/cypress-io/cypress-design/commit/4259026314464260e89bcd88690c8a60ad2f0459)]:
|
|
61
|
+
- @cypress-design/icon-registry@0.4.0
|
|
62
|
+
|
|
3
63
|
## 0.2.1
|
|
4
64
|
|
|
5
65
|
### 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="
|
|
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
|
@@ -2,9 +2,10 @@ import * as React from 'react'
|
|
|
2
2
|
import type { FunctionComponent, SVGProps } from 'react'
|
|
3
3
|
import { compileIcon } from '@cypress-design/icon-registry'
|
|
4
4
|
import type { IconProps } from '@cypress-design/icon-registry'
|
|
5
|
+
import { compileReactIconProperties } from './compileProperties'
|
|
5
6
|
|
|
6
7
|
type SVGPropsWithoutColorsOrSize = Omit<
|
|
7
|
-
|
|
8
|
+
SVGProps<SVGSVGElement>,
|
|
8
9
|
'fill' | 'stroke' | 'fillColor' | 'strokeColor' | 'size'
|
|
9
10
|
>
|
|
10
11
|
|
|
@@ -17,40 +18,4 @@ export const Icon: FunctionComponent<
|
|
|
17
18
|
)
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
export const compileReactIconProperties = ({
|
|
21
|
-
body,
|
|
22
|
-
compiledClasses,
|
|
23
|
-
size,
|
|
24
|
-
strokeColor,
|
|
25
|
-
fillColor,
|
|
26
|
-
secondaryStrokeColor,
|
|
27
|
-
secondaryFillColor,
|
|
28
|
-
...attributes
|
|
29
|
-
}: {
|
|
30
|
-
body: string
|
|
31
|
-
compiledClasses: string[]
|
|
32
|
-
size: string
|
|
33
|
-
strokeColor?
|
|
34
|
-
fillColor?
|
|
35
|
-
secondaryStrokeColor?
|
|
36
|
-
secondaryFillColor?
|
|
37
|
-
} & SVGPropsWithoutColorsOrSize) => {
|
|
38
|
-
const componentProps = {
|
|
39
|
-
width: size,
|
|
40
|
-
height: size,
|
|
41
|
-
fill: 'none',
|
|
42
|
-
dangerouslySetInnerHTML: {
|
|
43
|
-
__html: body,
|
|
44
|
-
},
|
|
45
|
-
...attributes, // add all standard attributes back to the svg tag
|
|
46
|
-
}
|
|
47
|
-
if (attributes.className) {
|
|
48
|
-
compiledClasses.push(attributes.className)
|
|
49
|
-
}
|
|
50
|
-
if (compiledClasses.length) {
|
|
51
|
-
componentProps.className = compiledClasses.join(' ')
|
|
52
|
-
}
|
|
53
|
-
return componentProps
|
|
54
|
-
}
|
|
55
|
-
|
|
56
21
|
export default Icon
|
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="
|
|
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/compileProperties.ts
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
|
+
import type { ColorIconProps } from '@cypress-design/icon-registry'
|
|
2
|
+
import { ICON_COLOR_PROP_NAMES } from '@cypress-design/icon-registry'
|
|
3
|
+
|
|
1
4
|
export const compileReactIconProperties = ({
|
|
2
5
|
body,
|
|
3
6
|
compiledClasses,
|
|
4
7
|
size,
|
|
5
|
-
strokeColor,
|
|
6
|
-
fillColor,
|
|
7
|
-
secondaryStrokeColor,
|
|
8
|
-
secondaryFillColor,
|
|
9
8
|
...attributes
|
|
10
9
|
}: {
|
|
11
10
|
body: string
|
|
12
11
|
compiledClasses: string[]
|
|
13
12
|
size: string
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
} & ColorIconProps &
|
|
14
|
+
React.SVGProps<SVGSVGElement>) => {
|
|
15
|
+
const filteredAttributes = Object.keys(attributes).reduce(
|
|
16
|
+
(newAttributes, attrName) => {
|
|
17
|
+
if (!ICON_COLOR_PROP_NAMES.includes(attrName)) {
|
|
18
|
+
newAttributes[attrName] =
|
|
19
|
+
attributes[attrName as keyof typeof attributes]
|
|
20
|
+
}
|
|
21
|
+
return newAttributes
|
|
22
|
+
},
|
|
23
|
+
{} as Record<string, any>
|
|
24
|
+
)
|
|
19
25
|
const componentProps: any = {
|
|
20
26
|
width: size,
|
|
21
27
|
height: size,
|
|
@@ -23,7 +29,7 @@ export const compileReactIconProperties = ({
|
|
|
23
29
|
dangerouslySetInnerHTML: {
|
|
24
30
|
__html: body,
|
|
25
31
|
},
|
|
26
|
-
...
|
|
32
|
+
...filteredAttributes, // add all standard attributes back to the svg tag
|
|
27
33
|
}
|
|
28
34
|
if (attributes.className) {
|
|
29
35
|
compiledClasses.push(attributes.className)
|