@cypress-design/vue-icon 0.2.0 → 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 CHANGED
@@ -1,5 +1,61 @@
1
1
  # @cypress-design/vue-icon
2
2
 
3
+ ## 0.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`c339ddd`](https://github.com/cypress-io/cypress-design/commit/c339dddb8347ceccdb497a0c2a4dfa3b52947114) Thanks [@elevatebart](https://github.com/elevatebart)! - take into account kebab-cased attributes in the icons plugin
8
+
9
+ - Updated dependencies [[`c339ddd`](https://github.com/cypress-io/cypress-design/commit/c339dddb8347ceccdb497a0c2a4dfa3b52947114)]:
10
+ - @cypress-design/icon-registry@0.4.1
11
+
12
+ ## 0.4.0
13
+
14
+ ### Minor Changes
15
+
16
+ - [#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
17
+
18
+ ### With a prefix focus/hover
19
+
20
+ ```html
21
+ <IconBook
22
+ size="16"
23
+ strokeColor="blue-600"
24
+ hoverStrokeColor="jade-600"
25
+ focusStrokeColor="jade-900"
26
+ />
27
+ ```
28
+
29
+ ### With the same prefix acting on a group
30
+
31
+ ```html
32
+ <button class="group">
33
+ <IconBook
34
+ size="16"
35
+ strokeColor="blue-600"
36
+ hoverStrokeColor="jade-600"
37
+ focusStrokeColor="jade-900"
38
+ interactiveColorsOnGroup
39
+ />Read
40
+ </button>
41
+ ```
42
+
43
+ ### Patch Changes
44
+
45
+ - Updated dependencies [[`4259026`](https://github.com/cypress-io/cypress-design/commit/4259026314464260e89bcd88690c8a60ad2f0459)]:
46
+ - @cypress-design/icon-registry@0.4.0
47
+
48
+ ## 0.3.0
49
+
50
+ ### Minor Changes
51
+
52
+ - [#33](https://github.com/cypress-io/cypress-design/pull/33) [`5f9cf10`](https://github.com/cypress-io/cypress-design/commit/5f9cf10ff4709fcd7d322c2dc5dbc676473b433e) Thanks [@elevatebart](https://github.com/elevatebart)! - Allow vue icon to have a class
53
+
54
+ ### Patch Changes
55
+
56
+ - Updated dependencies [[`5f9cf10`](https://github.com/cypress-io/cypress-design/commit/5f9cf10ff4709fcd7d322c2dc5dbc676473b433e), [`69b3327`](https://github.com/cypress-io/cypress-design/commit/69b332757ba3b73d0ae881c5959daa7a2e644fe0)]:
57
+ - @cypress-design/icon-registry@0.3.0
58
+
3
59
  ## 0.2.0
4
60
 
5
61
  ### Minor Changes
package/Icon.stories.mdx CHANGED
@@ -44,7 +44,7 @@ import Icon from './Icon'
44
44
  }}
45
45
  />
46
46
 
47
- <Canvas>
47
+ <Canvas withSource="none">
48
48
  <Story name="Icon">
49
49
  {(args) => (
50
50
  {
@@ -68,32 +68,63 @@ import Icon from './Icon'
68
68
  </Story>
69
69
  </Canvas>
70
70
 
71
- <ArgsTable/>
72
-
73
71
  ## Usage
74
72
 
75
73
  The simple way using the Icon component
76
74
 
77
- ```tsx
78
- import { Icon } from '@cypress-design/react-icon'
79
-
80
- export const MyButtonWithIcon = () => {
81
- return (<button>
82
- <Icon name="book" size="16" strokeColor="blue-600" fillColor="red-200" className="bg-red-100" />Read
83
- </button>)
84
- }
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>
85
84
  ```
86
85
 
87
86
  The tree-shakable way (more optimized)
88
87
 
89
- ```tsx
90
- 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:`.
91
118
 
92
- export const MyButtonWithIcon = () => {
93
- return (<button>
94
- <IconBook size="16" strokeColor="blue-600" fillColor="red-200" />
95
- </button>)
96
- }
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>
97
128
  ```
98
129
 
99
130
  <Description>
package/Icon.ts CHANGED
@@ -1,40 +1,43 @@
1
- import { type IconProps, compileIcon } from '@cypress-design/icon-registry';
2
- import { h, type SVGAttributes } from 'vue';
1
+ import {
2
+ type IconProps,
3
+ type OpenIconProps,
4
+ compileIcon,
5
+ } from '@cypress-design/icon-registry'
6
+ import { h, type SVGAttributes } from 'vue'
3
7
 
4
8
  export default (props: IconProps & Omit<SVGAttributes, 'name'>) => {
5
- return h('svg', compileVueIconProperties(compileIcon(props)));
6
- };
9
+ return h('svg', compileVueIconProperties(compileIcon(props)))
10
+ }
7
11
 
8
12
  export const compileVueIconProperties = ({
9
13
  body,
10
14
  compiledClasses,
11
15
  size,
12
- strokeColor,
13
- fillColor,
14
- secondaryStrokeColor,
15
- secondaryFillColor,
16
+ class: className,
17
+ interactiveColorsOnGroup,
16
18
  ...attributes
17
- }: SVGAttributes & {
18
- body: string;
19
- compiledClasses: string[];
20
- size: string;
21
- strokeColor?: string;
22
- fillColor?: string;
23
- secondaryStrokeColor?: string;
24
- secondaryFillColor?: string;
25
- }) => {
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.toLowerCase().endsWith('color')) {
28
+ // @ts-ignore
29
+ delete attributes[key]
30
+ }
31
+ })
26
32
  const componentProps: any = {
27
33
  width: size,
28
34
  height: size,
29
35
  fill: 'none',
30
36
  innerHTML: body,
31
37
  ...attributes, // add all standard attributes back to the svg tag
32
- };
33
- if (attributes.class) {
34
- compiledClasses.push(attributes.class);
35
38
  }
36
39
  if (compiledClasses.length) {
37
- componentProps.class = compiledClasses.join(' ');
40
+ componentProps.class = compiledClasses.join(' ')
38
41
  }
39
- return componentProps;
40
- };
42
+ return componentProps
43
+ }
package/IconVue.cy.tsx ADDED
@@ -0,0 +1,15 @@
1
+ import { IconObjectBookCode } from './index'
2
+ import { mount } from 'cypress/vue'
3
+
4
+ describe('Icon', () => {
5
+ it('renders correctly', () => {
6
+ mount(() => (
7
+ <IconObjectBookCode
8
+ fillColor="red-100"
9
+ strokeColor="red-500"
10
+ secondaryFillColor="indigo-100"
11
+ secondaryStrokeColor="indigo-600"
12
+ />
13
+ ))
14
+ })
15
+ })
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, ...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,CAAC;AAC5E,OAAO,EAAK,KAAK,aAAa,EAAE,MAAM,KAAK,CAAC;gCAErB,SAAS,GAAG,KAAK,aAAa,EAAE,MAAM,CAAC;;;AAA9D,wBAEE;AAEF,eAAO,MAAM,wBAAwB;UAU7B,MAAM;qBACK,MAAM,EAAE;UACnB,MAAM;;;;;SAoBb,CAAC"}
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"}