@zohodesk/icons 1.3.1 → 1.3.3
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/README.md +8 -1
- package/assets/fonts/zd-rIM.svg +11 -0
- package/assets/fonts/zd-rIM.woff +0 -0
- package/assets/fonts/zd-rIM.woff2 +0 -0
- package/assets/react/zd-font-rIM.module.css +20 -0
- package/es/Context/IconContext.js +7 -0
- package/es/Context/IconProvider.js +22 -0
- package/es/Context/__tests__/IconContext.spec.js +115 -0
- package/es/Context/__tests__/__snapshots__/IconContext.spec.js.snap +166 -0
- package/es/Context/props/defaultProps.js +5 -0
- package/es/Context/props/propTypes.js +7 -0
- package/es/Icon/FontFactory.js +3 -0
- package/es/Icon/FontIcon.js +1 -8
- package/es/Icon/Icon.module.css +6 -0
- package/es/Icon/SvgIcon.js +45 -0
- package/es/Icon/__tests__/SvgIcon.spec.js +94 -0
- package/es/Icon/__tests__/__snapshots__/SvgIcon.spec.js.snap +200 -0
- package/es/Icon/index.js +45 -2
- package/es/Icon/props/defaultProps.js +7 -1
- package/es/Icon/props/propTypes.js +17 -0
- package/es/index.js +3 -1
- package/lib/Context/IconContext.js +19 -0
- package/lib/Context/IconProvider.js +38 -0
- package/lib/Context/__tests__/IconContext.spec.js +123 -0
- package/lib/Context/__tests__/__snapshots__/IconContext.spec.js.snap +166 -0
- package/lib/Context/props/defaultProps.js +12 -0
- package/lib/Context/props/propTypes.js +18 -0
- package/lib/Icon/FontFactory.js +3 -0
- package/lib/Icon/FontIcon.js +1 -8
- package/lib/Icon/Icon.module.css +6 -0
- package/lib/Icon/SvgIcon.js +57 -0
- package/lib/Icon/__tests__/SvgIcon.spec.js +101 -0
- package/lib/Icon/__tests__/__snapshots__/SvgIcon.spec.js.snap +200 -0
- package/lib/Icon/index.js +52 -2
- package/lib/Icon/props/defaultProps.js +12 -3
- package/lib/Icon/props/propTypes.js +20 -2
- package/lib/index.js +16 -0
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -2,11 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
In this GiftBox we Provide FontIcons
|
|
4
4
|
|
|
5
|
+
# 1.3.3
|
|
6
|
+
|
|
7
|
+
- ReactIMReact --> New icon set created.
|
|
8
|
+
|
|
9
|
+
# 1.3.2
|
|
10
|
+
|
|
11
|
+
- Introduced SvgIcon, IconContext, and IconProvider to enable centralized control of SvgIcon behavior through IconProvider.
|
|
5
12
|
|
|
6
13
|
# 1.3.1
|
|
7
14
|
|
|
8
15
|
- ReactTicketsFontIcon --> ZD-TK-sideChat icon included.
|
|
9
|
-
- ReactAutomationIcon --> ZD-
|
|
16
|
+
- ReactAutomationIcon --> ZD-AU-skip, ZD-AU-scheduleDelay, ZD-AU-reschedule, ZD-AU-nodeRemove and ZD-AU-failure icons included.
|
|
10
17
|
|
|
11
18
|
# 1.3.0
|
|
12
19
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<?xml version="1.0" standalone="no"?>
|
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
|
3
|
+
<svg xmlns="http://www.w3.org/2000/svg">
|
|
4
|
+
<metadata>Generated by IcoMoon</metadata>
|
|
5
|
+
<defs>
|
|
6
|
+
<font id="icomoon" horiz-adv-x="1024">
|
|
7
|
+
<font-face units-per-em="1024" ascent="1024" descent="0" />
|
|
8
|
+
<missing-glyph horiz-adv-x="1024" />
|
|
9
|
+
<glyph unicode=" " horiz-adv-x="0" d="" />
|
|
10
|
+
<glyph unicode="󇔀" glyph-name="endChat" d="M753.408 832.256h-482.816c-42.24 0-76.8-34.56-76.8-76.8v-342.272c0-42.24 34.56-76.8 76.8-76.8h56.32v-95.744c0-19.968 12.032-37.632 30.464-45.312 5.888-2.304 12.288-3.584 18.432-3.584 13.056 0 25.6 5.12 35.072 14.848l125.696 129.792h216.832c42.24 0 76.8 34.56 76.8 76.8v342.272c0 42.24-34.56 76.8-76.8 76.8zM779.008 413.184c0-14.080-11.52-25.6-25.6-25.6h-227.584c-6.912 0-13.568-2.816-18.432-7.68l-129.024-133.376v115.456c0 14.080-11.52 25.6-25.6 25.6h-81.92c-14.080 0-25.6 11.52-25.6 25.6v342.272c0 14.080 11.52 25.6 25.6 25.6h482.56c14.080 0 25.6-11.52 25.6-25.6v-342.272zM612.096 652.032l-59.904-59.904 59.904-59.904c9.984-9.984 9.984-26.112 0-36.096-5.12-5.12-11.52-7.424-18.176-7.424s-13.056 2.56-18.176 7.424l-59.904 59.904-59.904-59.904c-5.12-5.12-11.52-7.424-18.176-7.424s-13.056 2.56-18.176 7.424c-9.984 9.984-9.984 26.112 0 36.096l59.904 59.904-59.904 59.904c-9.984 9.984-9.984 26.112 0 36.096s26.112 9.984 36.096 0l59.904-59.904 59.904 59.904c9.984 9.984 26.112 9.984 36.096 0s9.984-26.112 0-36.096z" />
|
|
11
|
+
</font></defs></svg>
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
@font-face{
|
|
2
|
+
font-family:"zdfonts-rIM";
|
|
3
|
+
src:url('../fonts/zd-rIM.woff2') format('woff2'), url('../fonts/zd-rIM.woff') format('woff'), url('../fonts/zd-rIM.svg#zdfonts') format('svg');
|
|
4
|
+
font-weight:normal;
|
|
5
|
+
font-style:normal;
|
|
6
|
+
font-display:block;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@layer dot-icons.core {
|
|
10
|
+
/*$Id$*/
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
.icon-endChat{
|
|
14
|
+
font-family:"zdfonts-rIM" !important;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.icon-endChat:before{
|
|
18
|
+
content:"\c7500";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import IconContext from "./IconContext";
|
|
3
|
+
import { IconProviderProps } from "./props/propTypes";
|
|
4
|
+
import { IconProviderDefaultProps } from "./props/defaultProps";
|
|
5
|
+
export default function IconProvider(props) {
|
|
6
|
+
let {
|
|
7
|
+
type,
|
|
8
|
+
svgIconPrefix,
|
|
9
|
+
svgIconClass,
|
|
10
|
+
children
|
|
11
|
+
} = props;
|
|
12
|
+
const value = React.useMemo(() => ({
|
|
13
|
+
type,
|
|
14
|
+
svgIconPrefix,
|
|
15
|
+
svgIconClass
|
|
16
|
+
}), [type, svgIconPrefix, svgIconClass]);
|
|
17
|
+
return /*#__PURE__*/React.createElement(IconContext.Provider, {
|
|
18
|
+
value: value
|
|
19
|
+
}, children);
|
|
20
|
+
}
|
|
21
|
+
IconProvider.propTypes = IconProviderProps;
|
|
22
|
+
IconProvider.defaultProps = IconProviderDefaultProps;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import Icon from "../../Icon";
|
|
4
|
+
import IconProvider from "../IconProvider";
|
|
5
|
+
describe('IconProvider / IconContext - ', () => {
|
|
6
|
+
test('default context - renders font icon (no provider)', () => {
|
|
7
|
+
const {
|
|
8
|
+
asFragment
|
|
9
|
+
} = render( /*#__PURE__*/React.createElement(Icon, {
|
|
10
|
+
name: "ZD-close2"
|
|
11
|
+
}));
|
|
12
|
+
expect(asFragment()).toMatchSnapshot();
|
|
13
|
+
});
|
|
14
|
+
test('type "fontIcon" - renders font icon', () => {
|
|
15
|
+
const {
|
|
16
|
+
asFragment
|
|
17
|
+
} = render( /*#__PURE__*/React.createElement(IconProvider, {
|
|
18
|
+
type: "fontIcon"
|
|
19
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
20
|
+
name: "ZD-close2"
|
|
21
|
+
})));
|
|
22
|
+
expect(asFragment()).toMatchSnapshot();
|
|
23
|
+
});
|
|
24
|
+
test('type "svgIcon" - renders svg symbol', () => {
|
|
25
|
+
const {
|
|
26
|
+
asFragment
|
|
27
|
+
} = render( /*#__PURE__*/React.createElement(IconProvider, {
|
|
28
|
+
type: "svgIcon"
|
|
29
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
30
|
+
name: "ZD-close2"
|
|
31
|
+
})));
|
|
32
|
+
expect(asFragment()).toMatchSnapshot();
|
|
33
|
+
});
|
|
34
|
+
test('type "svgIcon" with custom "svgIconPrefix"', () => {
|
|
35
|
+
const {
|
|
36
|
+
asFragment
|
|
37
|
+
} = render( /*#__PURE__*/React.createElement(IconProvider, {
|
|
38
|
+
type: "svgIcon",
|
|
39
|
+
svgIconPrefix: "/sprites.svg#"
|
|
40
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
41
|
+
name: "ZD-close2"
|
|
42
|
+
})));
|
|
43
|
+
expect(asFragment()).toMatchSnapshot();
|
|
44
|
+
});
|
|
45
|
+
test('type "svgIcon" with "svgIconClass"', () => {
|
|
46
|
+
const {
|
|
47
|
+
asFragment
|
|
48
|
+
} = render( /*#__PURE__*/React.createElement(IconProvider, {
|
|
49
|
+
type: "svgIcon",
|
|
50
|
+
svgIconClass: "app-svg-icon"
|
|
51
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
52
|
+
name: "ZD-close2"
|
|
53
|
+
})));
|
|
54
|
+
expect(asFragment()).toMatchSnapshot();
|
|
55
|
+
});
|
|
56
|
+
test('type "svgIcon" - passes "size" prop to svg', () => {
|
|
57
|
+
const {
|
|
58
|
+
asFragment
|
|
59
|
+
} = render( /*#__PURE__*/React.createElement(IconProvider, {
|
|
60
|
+
type: "svgIcon"
|
|
61
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
62
|
+
name: "ZD-close2",
|
|
63
|
+
size: "20"
|
|
64
|
+
})));
|
|
65
|
+
expect(asFragment()).toMatchSnapshot();
|
|
66
|
+
});
|
|
67
|
+
test('type "svgIcon" - passes "title" prop to svg', () => {
|
|
68
|
+
const {
|
|
69
|
+
asFragment
|
|
70
|
+
} = render( /*#__PURE__*/React.createElement(IconProvider, {
|
|
71
|
+
type: "svgIcon"
|
|
72
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
73
|
+
name: "ZD-close2",
|
|
74
|
+
title: "Close"
|
|
75
|
+
})));
|
|
76
|
+
expect(asFragment()).toMatchSnapshot();
|
|
77
|
+
});
|
|
78
|
+
test('type "svgIcon" - passes "iconClass" prop to svg', () => {
|
|
79
|
+
const {
|
|
80
|
+
asFragment
|
|
81
|
+
} = render( /*#__PURE__*/React.createElement(IconProvider, {
|
|
82
|
+
type: "svgIcon"
|
|
83
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
84
|
+
name: "ZD-close2",
|
|
85
|
+
iconClass: "custom-class"
|
|
86
|
+
})));
|
|
87
|
+
expect(asFragment()).toMatchSnapshot();
|
|
88
|
+
});
|
|
89
|
+
test('type "svgIcon" - passes "a11y" ariaHidden false', () => {
|
|
90
|
+
const {
|
|
91
|
+
asFragment
|
|
92
|
+
} = render( /*#__PURE__*/React.createElement(IconProvider, {
|
|
93
|
+
type: "svgIcon"
|
|
94
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
95
|
+
name: "ZD-close2",
|
|
96
|
+
a11y: {
|
|
97
|
+
ariaHidden: false
|
|
98
|
+
}
|
|
99
|
+
})));
|
|
100
|
+
expect(asFragment()).toMatchSnapshot();
|
|
101
|
+
});
|
|
102
|
+
test('multiple icons share the same provider context', () => {
|
|
103
|
+
const {
|
|
104
|
+
asFragment
|
|
105
|
+
} = render( /*#__PURE__*/React.createElement(IconProvider, {
|
|
106
|
+
type: "svgIcon",
|
|
107
|
+
svgIconPrefix: "#"
|
|
108
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
109
|
+
name: "ZD-close2"
|
|
110
|
+
}), /*#__PURE__*/React.createElement(Icon, {
|
|
111
|
+
name: "ZD-addAccount"
|
|
112
|
+
})));
|
|
113
|
+
expect(asFragment()).toMatchSnapshot();
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`IconProvider / IconContext - default context - renders font icon (no provider) 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<i
|
|
6
|
+
aria-hidden="true"
|
|
7
|
+
class="zd_font_icons basic icon-close2 "
|
|
8
|
+
data-id="fontIcon"
|
|
9
|
+
data-selector-id="fontIcon"
|
|
10
|
+
data-test-id="fontIcon"
|
|
11
|
+
/>
|
|
12
|
+
</DocumentFragment>
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
exports[`IconProvider / IconContext - multiple icons share the same provider context 1`] = `
|
|
16
|
+
<DocumentFragment>
|
|
17
|
+
<svg
|
|
18
|
+
aria-hidden="true"
|
|
19
|
+
class="svgIcon "
|
|
20
|
+
data-id="fontIcon"
|
|
21
|
+
data-selector-id="fontIcon"
|
|
22
|
+
data-test-id="fontIcon"
|
|
23
|
+
>
|
|
24
|
+
<use
|
|
25
|
+
href="#ZD-close2"
|
|
26
|
+
/>
|
|
27
|
+
</svg>
|
|
28
|
+
<svg
|
|
29
|
+
aria-hidden="true"
|
|
30
|
+
class="svgIcon "
|
|
31
|
+
data-id="fontIcon"
|
|
32
|
+
data-selector-id="fontIcon"
|
|
33
|
+
data-test-id="fontIcon"
|
|
34
|
+
>
|
|
35
|
+
<use
|
|
36
|
+
href="#ZD-addAccount"
|
|
37
|
+
/>
|
|
38
|
+
</svg>
|
|
39
|
+
</DocumentFragment>
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
exports[`IconProvider / IconContext - type "fontIcon" - renders font icon 1`] = `
|
|
43
|
+
<DocumentFragment>
|
|
44
|
+
<i
|
|
45
|
+
aria-hidden="true"
|
|
46
|
+
class="zd_font_icons basic icon-close2 "
|
|
47
|
+
data-id="fontIcon"
|
|
48
|
+
data-selector-id="fontIcon"
|
|
49
|
+
data-test-id="fontIcon"
|
|
50
|
+
/>
|
|
51
|
+
</DocumentFragment>
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
exports[`IconProvider / IconContext - type "svgIcon" - passes "a11y" ariaHidden false 1`] = `
|
|
55
|
+
<DocumentFragment>
|
|
56
|
+
<svg
|
|
57
|
+
aria-hidden="false"
|
|
58
|
+
class="svgIcon "
|
|
59
|
+
data-id="fontIcon"
|
|
60
|
+
data-selector-id="fontIcon"
|
|
61
|
+
data-test-id="fontIcon"
|
|
62
|
+
>
|
|
63
|
+
<use
|
|
64
|
+
href="#ZD-close2"
|
|
65
|
+
/>
|
|
66
|
+
</svg>
|
|
67
|
+
</DocumentFragment>
|
|
68
|
+
`;
|
|
69
|
+
|
|
70
|
+
exports[`IconProvider / IconContext - type "svgIcon" - passes "iconClass" prop to svg 1`] = `
|
|
71
|
+
<DocumentFragment>
|
|
72
|
+
<svg
|
|
73
|
+
aria-hidden="true"
|
|
74
|
+
class="svgIcon custom-class "
|
|
75
|
+
data-id="fontIcon"
|
|
76
|
+
data-selector-id="fontIcon"
|
|
77
|
+
data-test-id="fontIcon"
|
|
78
|
+
>
|
|
79
|
+
<use
|
|
80
|
+
href="#ZD-close2"
|
|
81
|
+
/>
|
|
82
|
+
</svg>
|
|
83
|
+
</DocumentFragment>
|
|
84
|
+
`;
|
|
85
|
+
|
|
86
|
+
exports[`IconProvider / IconContext - type "svgIcon" - passes "size" prop to svg 1`] = `
|
|
87
|
+
<DocumentFragment>
|
|
88
|
+
<svg
|
|
89
|
+
aria-hidden="true"
|
|
90
|
+
class="svgIcon "
|
|
91
|
+
data-id="fontIcon"
|
|
92
|
+
data-selector-id="fontIcon"
|
|
93
|
+
data-test-id="fontIcon"
|
|
94
|
+
style="--zd-iconfont-size: var(--zd_font_size20);"
|
|
95
|
+
>
|
|
96
|
+
<use
|
|
97
|
+
href="#ZD-close2"
|
|
98
|
+
/>
|
|
99
|
+
</svg>
|
|
100
|
+
</DocumentFragment>
|
|
101
|
+
`;
|
|
102
|
+
|
|
103
|
+
exports[`IconProvider / IconContext - type "svgIcon" - passes "title" prop to svg 1`] = `
|
|
104
|
+
<DocumentFragment>
|
|
105
|
+
<svg
|
|
106
|
+
aria-hidden="true"
|
|
107
|
+
class="svgIcon "
|
|
108
|
+
data-id="fontIcon"
|
|
109
|
+
data-selector-id="fontIcon"
|
|
110
|
+
data-test-id="fontIcon"
|
|
111
|
+
data-title="Close"
|
|
112
|
+
>
|
|
113
|
+
<use
|
|
114
|
+
href="#ZD-close2"
|
|
115
|
+
/>
|
|
116
|
+
</svg>
|
|
117
|
+
</DocumentFragment>
|
|
118
|
+
`;
|
|
119
|
+
|
|
120
|
+
exports[`IconProvider / IconContext - type "svgIcon" - renders svg symbol 1`] = `
|
|
121
|
+
<DocumentFragment>
|
|
122
|
+
<svg
|
|
123
|
+
aria-hidden="true"
|
|
124
|
+
class="svgIcon "
|
|
125
|
+
data-id="fontIcon"
|
|
126
|
+
data-selector-id="fontIcon"
|
|
127
|
+
data-test-id="fontIcon"
|
|
128
|
+
>
|
|
129
|
+
<use
|
|
130
|
+
href="#ZD-close2"
|
|
131
|
+
/>
|
|
132
|
+
</svg>
|
|
133
|
+
</DocumentFragment>
|
|
134
|
+
`;
|
|
135
|
+
|
|
136
|
+
exports[`IconProvider / IconContext - type "svgIcon" with "svgIconClass" 1`] = `
|
|
137
|
+
<DocumentFragment>
|
|
138
|
+
<svg
|
|
139
|
+
aria-hidden="true"
|
|
140
|
+
class="svgIcon app-svg-icon "
|
|
141
|
+
data-id="fontIcon"
|
|
142
|
+
data-selector-id="fontIcon"
|
|
143
|
+
data-test-id="fontIcon"
|
|
144
|
+
>
|
|
145
|
+
<use
|
|
146
|
+
href="#ZD-close2"
|
|
147
|
+
/>
|
|
148
|
+
</svg>
|
|
149
|
+
</DocumentFragment>
|
|
150
|
+
`;
|
|
151
|
+
|
|
152
|
+
exports[`IconProvider / IconContext - type "svgIcon" with custom "svgIconPrefix" 1`] = `
|
|
153
|
+
<DocumentFragment>
|
|
154
|
+
<svg
|
|
155
|
+
aria-hidden="true"
|
|
156
|
+
class="svgIcon "
|
|
157
|
+
data-id="fontIcon"
|
|
158
|
+
data-selector-id="fontIcon"
|
|
159
|
+
data-test-id="fontIcon"
|
|
160
|
+
>
|
|
161
|
+
<use
|
|
162
|
+
href="/sprites.svg#ZD-close2"
|
|
163
|
+
/>
|
|
164
|
+
</svg>
|
|
165
|
+
</DocumentFragment>
|
|
166
|
+
`;
|
package/es/Icon/FontFactory.js
CHANGED
package/es/Icon/FontIcon.js
CHANGED
|
@@ -65,11 +65,4 @@ export default class FontIcon extends React.Component {
|
|
|
65
65
|
|
|
66
66
|
}
|
|
67
67
|
FontIcon.propTypes = IconProps;
|
|
68
|
-
FontIcon.defaultProps = IconDefaultProps;
|
|
69
|
-
|
|
70
|
-
if (__DOCS__) {
|
|
71
|
-
FontIcon.docs = {
|
|
72
|
-
componentGroup: 'Icon',
|
|
73
|
-
folderName: 'Style Guide'
|
|
74
|
-
};
|
|
75
|
-
}
|
|
68
|
+
FontIcon.defaultProps = IconDefaultProps;
|
package/es/Icon/Icon.module.css
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { SvgIconDefaultProps } from "./props/defaultProps";
|
|
5
|
+
import { SvgIconProps } from "./props/propTypes";
|
|
6
|
+
import { DUMMY_OBJECT } from '@zohodesk/dotkit/es/utils/constants';
|
|
7
|
+
import style from "./Icon.module.css";
|
|
8
|
+
export default function SvgIcon(_ref) {
|
|
9
|
+
let {
|
|
10
|
+
name,
|
|
11
|
+
onClick,
|
|
12
|
+
title,
|
|
13
|
+
dataId,
|
|
14
|
+
dataSelectorId,
|
|
15
|
+
size,
|
|
16
|
+
iconClass,
|
|
17
|
+
titlePosition,
|
|
18
|
+
tagAttributes,
|
|
19
|
+
a11y,
|
|
20
|
+
svgPrefix
|
|
21
|
+
} = _ref;
|
|
22
|
+
let {
|
|
23
|
+
ariaHidden = true
|
|
24
|
+
} = a11y;
|
|
25
|
+
let href = `${svgPrefix}${name}`;
|
|
26
|
+
let fontStyle = size ? {
|
|
27
|
+
'--zd-iconfont-size': 'var(--zd_font_size' + size + ')'
|
|
28
|
+
} : DUMMY_OBJECT;
|
|
29
|
+
let className = `${style.svgIcon} ${iconClass ? iconClass : ''} ${onClick ? style.cursor : ''}`;
|
|
30
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
31
|
+
className: className,
|
|
32
|
+
onClick: onClick,
|
|
33
|
+
"data-title": title,
|
|
34
|
+
"data-id": dataId,
|
|
35
|
+
"data-test-id": dataId,
|
|
36
|
+
"data-selector-id": dataSelectorId,
|
|
37
|
+
"data-title-position": titlePosition,
|
|
38
|
+
style: fontStyle,
|
|
39
|
+
"aria-hidden": ariaHidden
|
|
40
|
+
}, tagAttributes), /*#__PURE__*/React.createElement("use", {
|
|
41
|
+
href: href
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
SvgIcon.propTypes = SvgIconProps;
|
|
45
|
+
SvgIcon.defaultProps = SvgIconDefaultProps;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import SvgIcon from "../SvgIcon";
|
|
3
|
+
import { render } from '@testing-library/react';
|
|
4
|
+
describe('SvgIcon - ', () => {
|
|
5
|
+
test('rendering the "default" props', () => {
|
|
6
|
+
const {
|
|
7
|
+
asFragment
|
|
8
|
+
} = render( /*#__PURE__*/React.createElement(SvgIcon, null));
|
|
9
|
+
expect(asFragment()).toMatchSnapshot();
|
|
10
|
+
});
|
|
11
|
+
test('rendering with "name" and "svgPrefix"', () => {
|
|
12
|
+
const {
|
|
13
|
+
asFragment
|
|
14
|
+
} = render( /*#__PURE__*/React.createElement(SvgIcon, {
|
|
15
|
+
name: "ZD-close2",
|
|
16
|
+
svgPrefix: "#"
|
|
17
|
+
}));
|
|
18
|
+
expect(asFragment()).toMatchSnapshot();
|
|
19
|
+
});
|
|
20
|
+
test('rendering with external sprite "svgPrefix"', () => {
|
|
21
|
+
const {
|
|
22
|
+
asFragment
|
|
23
|
+
} = render( /*#__PURE__*/React.createElement(SvgIcon, {
|
|
24
|
+
name: "ZD-close2",
|
|
25
|
+
svgPrefix: "/sprites.svg#"
|
|
26
|
+
}));
|
|
27
|
+
expect(asFragment()).toMatchSnapshot();
|
|
28
|
+
});
|
|
29
|
+
test('rendering with "title"', () => {
|
|
30
|
+
const {
|
|
31
|
+
asFragment
|
|
32
|
+
} = render( /*#__PURE__*/React.createElement(SvgIcon, {
|
|
33
|
+
name: "ZD-close2",
|
|
34
|
+
svgPrefix: "#",
|
|
35
|
+
title: "Close"
|
|
36
|
+
}));
|
|
37
|
+
expect(asFragment()).toMatchSnapshot();
|
|
38
|
+
});
|
|
39
|
+
test('rendering with "size"', () => {
|
|
40
|
+
const {
|
|
41
|
+
asFragment
|
|
42
|
+
} = render( /*#__PURE__*/React.createElement(SvgIcon, {
|
|
43
|
+
name: "ZD-close2",
|
|
44
|
+
svgPrefix: "#",
|
|
45
|
+
size: "15"
|
|
46
|
+
}));
|
|
47
|
+
expect(asFragment()).toMatchSnapshot();
|
|
48
|
+
});
|
|
49
|
+
test('rendering with "iconClass"', () => {
|
|
50
|
+
const {
|
|
51
|
+
asFragment
|
|
52
|
+
} = render( /*#__PURE__*/React.createElement(SvgIcon, {
|
|
53
|
+
name: "ZD-close2",
|
|
54
|
+
svgPrefix: "#",
|
|
55
|
+
iconClass: "myIconClass"
|
|
56
|
+
}));
|
|
57
|
+
expect(asFragment()).toMatchSnapshot();
|
|
58
|
+
});
|
|
59
|
+
test('rendering with "ariaHidden" false', () => {
|
|
60
|
+
const {
|
|
61
|
+
asFragment
|
|
62
|
+
} = render( /*#__PURE__*/React.createElement(SvgIcon, {
|
|
63
|
+
name: "ZD-close2",
|
|
64
|
+
svgPrefix: "#",
|
|
65
|
+
a11y: {
|
|
66
|
+
ariaHidden: false
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
expect(asFragment()).toMatchSnapshot();
|
|
70
|
+
});
|
|
71
|
+
const titlePositions = ['top', 'bottom', 'left', 'right'];
|
|
72
|
+
test.each(titlePositions)('rendering with "titlePosition" - %s', titlePosition => {
|
|
73
|
+
const {
|
|
74
|
+
asFragment
|
|
75
|
+
} = render( /*#__PURE__*/React.createElement(SvgIcon, {
|
|
76
|
+
name: "ZD-close2",
|
|
77
|
+
svgPrefix: "#",
|
|
78
|
+
titlePosition: titlePosition
|
|
79
|
+
}));
|
|
80
|
+
expect(asFragment()).toMatchSnapshot();
|
|
81
|
+
});
|
|
82
|
+
test('rendering with "tagAttributes"', () => {
|
|
83
|
+
const {
|
|
84
|
+
asFragment
|
|
85
|
+
} = render( /*#__PURE__*/React.createElement(SvgIcon, {
|
|
86
|
+
name: "ZD-close2",
|
|
87
|
+
svgPrefix: "#",
|
|
88
|
+
tagAttributes: {
|
|
89
|
+
'data-custom-attr': 'true'
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
expect(asFragment()).toMatchSnapshot();
|
|
93
|
+
});
|
|
94
|
+
});
|