@cypress-design/vue-icon 0.23.1 → 0.24.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.
@@ -2,14 +2,14 @@ $ yarn build:codegen && yarn build:module && yarn build:types
2
2
  $ node ./generate-icons.js
3
3
  $ yarn vite build
4
4
  $ /home/runner/work/cypress-design/cypress-design/node_modules/.bin/vite build
5
- vite v4.3.9 building for production...
5
+ vite v4.4.4 building for production...
6
6
  transforming...
7
7
  ✓ 4 modules transformed.
8
8
  rendering chunks...
9
9
  computing gzip size...
10
- dist/index.es.mjs 275.30 kB │ gzip: 49.79 kB │ map: 450.39 kB
10
+ dist/index.es.mjs 263.56 kB │ gzip: 51.64 kB │ map: 444.62 kB
11
11
  Entry module "index.ts" is using named and default exports together. Consumers of your bundle will have to use `Icon.default` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.
12
- dist/index.umd.js 252.61 kB │ gzip: 49.78 kB │ map: 437.94 kB
13
- ✓ built in 5.81s
12
+ dist/index.umd.js 228.88 kB │ gzip: 51.08 kB │ map: 432.39 kB
13
+ ✓ built in 6.64s
14
14
  $ yarn tsc --project ./tsconfig.build.json
15
15
  $ /home/runner/work/cypress-design/cypress-design/node_modules/.bin/tsc --project ./tsconfig.build.json
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @cypress-design/vue-icon
2
2
 
3
+ ## 0.24.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#280](https://github.com/cypress-io/cypress-design/pull/280) [`e390827`](https://github.com/cypress-io/cypress-design/commit/e3908270ece513886c64cebcb78cebe0cd0d8c3d) Thanks [@dkasper-was-taken](https://github.com/dkasper-was-taken)! - adding icon for test replay initiative
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`e390827`](https://github.com/cypress-io/cypress-design/commit/e3908270ece513886c64cebcb78cebe0cd0d8c3d)]:
12
+ - @cypress-design/icon-registry@0.25.0
13
+
14
+ ## 0.23.2
15
+
16
+ ### Patch Changes
17
+
18
+ - [#234](https://github.com/cypress-io/cypress-design/pull/234) [`ff95963`](https://github.com/cypress-io/cypress-design/commit/ff95963feb7ae5d9eb01e6122e5e411517f105b9) Thanks [@elevatebart](https://github.com/elevatebart)! - allow to use a gradient icon more than once
19
+
20
+ - Updated dependencies [[`ff95963`](https://github.com/cypress-io/cypress-design/commit/ff95963feb7ae5d9eb01e6122e5e411517f105b9)]:
21
+ - @cypress-design/icon-registry@0.24.1
22
+
3
23
  ## 0.23.1
4
24
 
5
25
  ### Patch Changes
package/Icon.ts CHANGED
@@ -1,18 +1,69 @@
1
- import { compileIcon } from '@cypress-design/icon-registry'
1
+ import {
2
+ ICON_COLOR_PROP_NAMES,
3
+ compileIcon,
4
+ } from '@cypress-design/icon-registry'
2
5
  import type { OpenIconProps, IconProps } from '@cypress-design/icon-registry'
3
- import { h } from 'vue'
6
+ import { h, computed, defineComponent } from 'vue'
4
7
  import type { SVGAttributes } from 'vue'
5
- import { compileVueIconProperties } from './compileProperties'
8
+ import {
9
+ compileVueIconProperties,
10
+ useShouldRenderDefs,
11
+ } from './compileProperties'
6
12
 
7
- export default (
8
- // the OpenIconProps helps volar extract the documentation from the props
9
- // since the IconProps are more restrictive, it will not change the use behavior
10
- props: OpenIconProps & Pick<IconProps, 'name'> & Omit<SVGAttributes, 'name'>
11
- ) => {
12
- const { class: className, ...otherProps } = props
13
- const properties = compileVueIconProperties(compileIcon(otherProps))
14
- return h('svg', {
15
- ...properties,
16
- class: [className, properties.class],
17
- })
18
- }
13
+ export default defineComponent(
14
+ (
15
+ // the OpenIconProps helps volar extract the documentation from the props
16
+ // since the IconProps are more restrictive, it will not change the use behavior
17
+ props: OpenIconProps & Pick<IconProps, 'name'> & { class?: string },
18
+ { attrs }: { attrs: Omit<SVGAttributes, 'name' | 'class'> }
19
+ ) => {
20
+ const ret = computed(() => {
21
+ const { class: className, ...otherProps } = props
22
+ const iconProps = compileIcon(otherProps)
23
+ return { className, iconProps }
24
+ })
25
+
26
+ const { componentProps, defs } = compileVueIconProperties(
27
+ computed(() => ret.value.iconProps)
28
+ )
29
+
30
+ const { shouldRenderDefs } = useShouldRenderDefs(props.name, defs)
31
+
32
+ return () => {
33
+ return shouldRenderDefs.value
34
+ ? [
35
+ h('svg', {
36
+ innerHTML: defs.value,
37
+ 'data-cy-icon-unified-defs': props.name,
38
+ class: [
39
+ 'w-0',
40
+ 'h-0',
41
+ 'absolute',
42
+ 'pointer-events-none',
43
+ 'opacity-0',
44
+ ],
45
+ }),
46
+ h('svg', {
47
+ ...attrs,
48
+ ...componentProps.value,
49
+ class: [ret.value.className, componentProps.value.class],
50
+ }),
51
+ ]
52
+ : h('svg', {
53
+ ...attrs,
54
+ ...componentProps.value,
55
+ class: [ret.value.className, componentProps.value.class],
56
+ })
57
+ }
58
+ },
59
+ {
60
+ // @ts-expect-error - vue types need an update
61
+ props: [
62
+ ...ICON_COLOR_PROP_NAMES,
63
+ 'interactiveColorsOnGroup',
64
+ 'size',
65
+ 'name',
66
+ 'class',
67
+ ],
68
+ }
69
+ )
package/IconVue.cy.tsx CHANGED
@@ -1,5 +1,10 @@
1
+ import { ref } from 'vue'
1
2
  import assertions from '../assertions'
2
- import Icon, { IconDocumentBlank, IconObjectBookCode } from './index'
3
+ import Icon, {
4
+ IconDocumentBlank,
5
+ IconObjectBookCode,
6
+ IconBrowserWebkit,
7
+ } from './index'
3
8
  import { mount } from 'cypress/vue'
4
9
 
5
10
  describe('Icon', { viewportWidth: 80, viewportHeight: 80 }, () => {
@@ -20,4 +25,81 @@ describe('Icon', { viewportWidth: 80, viewportHeight: 80 }, () => {
20
25
  }
21
26
  mount(() => <IconDocumentBlank {...props} />)
22
27
  })
28
+
29
+ it('renders multiple times an icon with defs with the Icon comp', () => {
30
+ mount(() => (
31
+ <div class="p-2">
32
+ <Icon name="browser-webkit" class="w-16 h-16 hidden" />
33
+ <Icon name="browser-webkit" class="w-16 h-16" />
34
+ </div>
35
+ ))
36
+ })
37
+
38
+ it('renders multiple times an icon with defs', () => {
39
+ mount(() => (
40
+ <div class="p-2 flex">
41
+ <IconBrowserWebkit class="w-16 h-16 hidden" />
42
+ <IconBrowserWebkit class="w-16 h-16" />
43
+ </div>
44
+ ))
45
+ })
46
+
47
+ it('when an icon is unmounted later', () => {
48
+ cy.viewport(200, 100)
49
+ const iconVisible = ref(true)
50
+ mount(() => (
51
+ <div class="p-2 flex">
52
+ {iconVisible.value ? <IconBrowserWebkit class="w-16 h-16" /> : null}
53
+ <IconBrowserWebkit class="w-16 h-16" />
54
+ <button onClick={() => (iconVisible.value = !iconVisible.value)}>
55
+ toggle
56
+ </button>
57
+ </div>
58
+ ))
59
+
60
+ cy.get('button').click()
61
+ // the svg defs should have been transferred to the end of the body
62
+ cy.get('svg').should('have.length', 2)
63
+ })
64
+
65
+ it('when an icon is hidden later', () => {
66
+ cy.viewport(200, 100)
67
+ const iconVisible = ref(true)
68
+ mount(() => (
69
+ <div class="p-2 flex">
70
+ <IconBrowserWebkit
71
+ class={`w-16 h-16 ${iconVisible.value ? '' : 'hidden'}`}
72
+ />
73
+ <IconBrowserWebkit class="w-16 h-16" />
74
+ <button onClick={() => (iconVisible.value = !iconVisible.value)}>
75
+ toggle
76
+ </button>
77
+ </div>
78
+ ))
79
+
80
+ cy.get('button').click()
81
+ })
82
+
83
+ it('renders multiple times an icon with defs with the Icon comp', () => {
84
+ cy.viewport(200, 200)
85
+ const iconName = ref<'browser-webkit' | 'browser-safari'>('browser-safari')
86
+ mount(() => (
87
+ <div class="p-2 flex flex-col h-screen items-center justify-center">
88
+ <Icon name={iconName.value} class="w-16 h-16 hidden" />
89
+ <Icon name={iconName.value} class="w-16 h-16" />
90
+ <button
91
+ onClick={() =>
92
+ (iconName.value =
93
+ iconName.value === 'browser-webkit'
94
+ ? 'browser-safari'
95
+ : 'browser-webkit')
96
+ }
97
+ >
98
+ toggle
99
+ </button>
100
+ </div>
101
+ ))
102
+
103
+ cy.get('button').click()
104
+ })
23
105
  })