@cypress-design/vue-icon 0.3.0 → 0.4.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,41 @@
1
1
  # @cypress-design/vue-icon
2
2
 
3
+ ## 0.4.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
+ - Updated dependencies [[`4259026`](https://github.com/cypress-io/cypress-design/commit/4259026314464260e89bcd88690c8a60ad2f0459)]:
37
+ - @cypress-design/icon-registry@0.4.0
38
+
3
39
  ## 0.3.0
4
40
 
5
41
  ### Minor Changes
package/Icon.stories.mdx CHANGED
@@ -72,26 +72,59 @@ import Icon from './Icon'
72
72
 
73
73
  The simple way using the Icon component
74
74
 
75
- ```tsx
76
- import { Icon } from '@cypress-design/react-icon'
77
-
78
- export const MyButtonWithIcon = () => {
79
- return (<button>
80
- <Icon name="book" size="16" strokeColor="blue-600" fillColor="red-200" className="bg-red-100" />Read
81
- </button>)
82
- }
75
+ ```vue
76
+ <script setup>
77
+ import Icon from '@cypress-design/vue-icon'
78
+ </script>
79
+ <template>
80
+ <button>
81
+ <Icon name="book" size="16" strokeColor="blue-600" fillColor="red-200" class="bg-red-100" />Read
82
+ </button>
83
+ </template>
83
84
  ```
84
85
 
85
86
  The tree-shakable way (more optimized)
86
87
 
87
- ```tsx
88
- import { IconBook } from '@cypress-design/react-icon'
88
+ ```vue
89
+ <script setup>
90
+ import { IconBook } from '@cypress-design/vue-icon'
91
+ </script>
92
+ <template>
93
+ <button>
94
+ <IconBook size="16" strokeColor="blue-600" fillColor="red-200" class="bg-red-100" />Read
95
+ </button>
96
+ </template>
97
+ ```
98
+
99
+ Should you need to change the color of the icon on `hover` or `focus` prefix the props with these words.
100
+
101
+ Here, the `strokeColor` will change on hover from indigo to jade
102
+
103
+ ```vue
104
+ <script setup>
105
+ import { IconBook } from '@cypress-design/vue-icon'
106
+ </script>
107
+ <template>
108
+ <button>
109
+ <IconBook size="16" strokeColor="blue-600" hoverStrokeColor="jade-600" />Read
110
+ </button>
111
+ </template>
112
+ ```
113
+
114
+ If you need the `hover` or `focus` effect to be triggered on the parent group, use `interactiveColorsOnGroup`.
115
+ This prop will change all the pseudo prefixes to be group focused instead of triggered by the icon itself.
116
+
117
+ To achieve the same goal, in WindiCSS, we would use `group-hover:` instead of `hover:`.
89
118
 
90
- export const MyButtonWithIcon = () => {
91
- return (<button>
92
- <IconBook size="16" strokeColor="blue-600" fillColor="red-200" />
93
- </button>)
94
- }
119
+ ```vue
120
+ <script setup>
121
+ import { IconBook } from '@cypress-design/vue-icon'
122
+ </script>
123
+ <template>
124
+ <button class="group hover:text-jade-800">
125
+ <IconBook size="16" strokeColor="blue-600" hoverStrokeColor="jade-600" interactiveColorsOnGroup />Read
126
+ </button>
127
+ </template>
95
128
  ```
96
129
 
97
130
  <Description>
package/Icon.ts CHANGED
@@ -1,4 +1,8 @@
1
- import { type IconProps, compileIcon } from '@cypress-design/icon-registry'
1
+ import {
2
+ type IconProps,
3
+ type OpenIconProps,
4
+ compileIcon,
5
+ } from '@cypress-design/icon-registry'
2
6
  import { h, type SVGAttributes } from 'vue'
3
7
 
4
8
  export default (props: IconProps & Omit<SVGAttributes, 'name'>) => {
@@ -9,21 +13,22 @@ export const compileVueIconProperties = ({
9
13
  body,
10
14
  compiledClasses,
11
15
  size,
12
- strokeColor,
13
- fillColor,
14
- secondaryStrokeColor,
15
- secondaryFillColor,
16
16
  class: className,
17
+ interactiveColorsOnGroup,
17
18
  ...attributes
18
- }: SVGAttributes & {
19
- body: string
20
- compiledClasses: string[]
21
- size: string
22
- strokeColor?: string
23
- fillColor?: string
24
- secondaryStrokeColor?: string
25
- secondaryFillColor?: string
26
- }) => {
19
+ }: Omit<OpenIconProps, 'name'> &
20
+ SVGAttributes & {
21
+ body: string
22
+ compiledClasses: string[]
23
+ size: string
24
+ interactiveColorsOnGroup?: boolean
25
+ }) => {
26
+ Object.keys(attributes).forEach((key) => {
27
+ if (key.endsWith('Color')) {
28
+ // @ts-ignore
29
+ delete attributes[key]
30
+ }
31
+ })
27
32
  const componentProps: any = {
28
33
  width: size,
29
34
  height: size,
package/ReadMe.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Use the `<icon>` component to display an icon from the cypress figma library.
6
6
 
7
- ### Usage
7
+ ## Usage
8
8
 
9
9
  2 methods exist to load this component:
10
10
 
@@ -40,6 +40,46 @@ import Icon from @cypress-design/vue-icon
40
40
  </template>
41
41
  ```
42
42
 
43
+ Should you need to change the color of the icon on `hover` or `focus` prefix the props with these words.
44
+
45
+ Here, the `strokeColor` will change on hover from indigo to jade
46
+
47
+ ```vue
48
+ <script setup>
49
+ import { IconBook } from '@cypress-design/vue-icon'
50
+ </script>
51
+ <template>
52
+ <button>
53
+ <IconBook
54
+ size="16"
55
+ strokeColor="blue-600"
56
+ hoverStrokeColor="jade-600"
57
+ />Read
58
+ </button>
59
+ </template>
60
+ ```
61
+
62
+ If you need the `hover` or `focus` effect to be triggered on the parent group, use `interactiveColorsOnGroup`.
63
+ This prop will change all the pseudo prefixes to be group focused instead of triggered by the icon itself.
64
+
65
+ To achieve the same goal, in WindiCSS, we would use `group-hover:` instead of `hover:`.
66
+
67
+ ```vue
68
+ <script setup>
69
+ import { IconBook } from '@cypress-design/vue-icon'
70
+ </script>
71
+ <template>
72
+ <button class="group hover:text-jade-800">
73
+ <IconBook
74
+ size="16"
75
+ strokeColor="blue-600"
76
+ hoverStrokeColor="jade-600"
77
+ interactiveColorsOnGroup
78
+ />Read
79
+ </button>
80
+ </template>
81
+ ```
82
+
43
83
  ## install
44
84
 
45
85
  ```bash
package/dist/Icon.d.ts CHANGED
@@ -1,16 +1,13 @@
1
- import { type IconProps } from '@cypress-design/icon-registry';
1
+ import { type IconProps, type OpenIconProps } from '@cypress-design/icon-registry';
2
2
  import { type SVGAttributes } from 'vue';
3
3
  declare const _default: (props: IconProps & Omit<SVGAttributes, 'name'>) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
4
4
  [key: string]: any;
5
5
  }>;
6
6
  export default _default;
7
- export declare const compileVueIconProperties: ({ body, compiledClasses, size, strokeColor, fillColor, secondaryStrokeColor, secondaryFillColor, class: className, ...attributes }: SVGAttributes & {
7
+ export declare const compileVueIconProperties: ({ body, compiledClasses, size, class: className, interactiveColorsOnGroup, ...attributes }: Omit<OpenIconProps, "name"> & SVGAttributes & {
8
8
  body: string;
9
9
  compiledClasses: string[];
10
10
  size: string;
11
- strokeColor?: string | undefined;
12
- fillColor?: string | undefined;
13
- secondaryStrokeColor?: string | undefined;
14
- secondaryFillColor?: string | undefined;
11
+ interactiveColorsOnGroup?: boolean | undefined;
15
12
  }) => any;
16
13
  //# sourceMappingURL=Icon.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../Icon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAe,MAAM,+BAA+B,CAAA;AAC3E,OAAO,EAAK,KAAK,aAAa,EAAE,MAAM,KAAK,CAAA;gCAEpB,SAAS,GAAG,KAAK,aAAa,EAAE,MAAM,CAAC;;;AAA9D,wBAEC;AAED,eAAO,MAAM,wBAAwB;UAW7B,MAAM;qBACK,MAAM,EAAE;UACnB,MAAM;;;;;SAiBb,CAAA"}
1
+ {"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../Icon.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,aAAa,EAEnB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAK,KAAK,aAAa,EAAE,MAAM,KAAK,CAAA;gCAEpB,SAAS,GAAG,KAAK,aAAa,EAAE,MAAM,CAAC;;;AAA9D,wBAEC;AAED,eAAO,MAAM,wBAAwB;UAS3B,MAAM;qBACK,MAAM,EAAE;UACnB,MAAM;;SAoBf,CAAA"}