@cypress-design/vue-icon 0.1.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 +58 -0
- package/Icon.stories.mdx +49 -18
- package/Icon.ts +26 -23
- package/IconVue.cy.tsx +15 -0
- package/ReadMe.md +41 -1
- package/dist/Icon.d.ts +3 -6
- package/dist/Icon.d.ts.map +1 -1
- package/dist/TreeShakableIcons.d.ts +154 -120
- package/dist/TreeShakableIcons.d.ts.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +727 -467
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/generate-icons.js +18 -18
- package/index.ts +6 -2
- package/package.json +3 -3
- package/tsconfig.build.json +1 -1
- package/vite.config.ts +3 -3
- package/Icon.cy.tsx +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,63 @@
|
|
|
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
|
+
|
|
39
|
+
## 0.3.0
|
|
40
|
+
|
|
41
|
+
### Minor Changes
|
|
42
|
+
|
|
43
|
+
- [#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
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- Updated dependencies [[`5f9cf10`](https://github.com/cypress-io/cypress-design/commit/5f9cf10ff4709fcd7d322c2dc5dbc676473b433e), [`69b3327`](https://github.com/cypress-io/cypress-design/commit/69b332757ba3b73d0ae881c5959daa7a2e644fe0)]:
|
|
48
|
+
- @cypress-design/icon-registry@0.3.0
|
|
49
|
+
|
|
50
|
+
## 0.2.0
|
|
51
|
+
|
|
52
|
+
### Minor Changes
|
|
53
|
+
|
|
54
|
+
- [`efb31b3`](https://github.com/cypress-io/cypress-design/commit/efb31b35d9c84b922a20ae46afa583f0b5849b41) Thanks [@elevatebart](https://github.com/elevatebart)! - Export the WindiColor and iconId types
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- Updated dependencies [[`efb31b3`](https://github.com/cypress-io/cypress-design/commit/efb31b35d9c84b922a20ae46afa583f0b5849b41)]:
|
|
59
|
+
- @cypress-design/icon-registry@0.2.0
|
|
60
|
+
|
|
3
61
|
## 0.1.0
|
|
4
62
|
|
|
5
63
|
### 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
|
-
```
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
```
|
|
90
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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 {
|
|
2
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
secondaryStrokeColor,
|
|
15
|
-
secondaryFillColor,
|
|
16
|
+
class: className,
|
|
17
|
+
interactiveColorsOnGroup,
|
|
16
18
|
...attributes
|
|
17
|
-
}:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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.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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
package/dist/Icon.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../Icon.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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"}
|