social-logos 3.1.7 → 3.1.9
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 +10 -0
- package/build/react/example.js +21 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [3.1.9] - 2024-10-14
|
|
2
|
+
### Fixed
|
|
3
|
+
- Add `key` in React example to make it more correct. [#39709]
|
|
4
|
+
|
|
5
|
+
## [3.1.8] - 2024-09-05
|
|
6
|
+
### Fixed
|
|
7
|
+
- Address React usage issues found by eslint in example.tsx. [#39214]
|
|
8
|
+
|
|
1
9
|
## [3.1.7] - 2024-08-23
|
|
2
10
|
### Changed
|
|
3
11
|
- Internal updates.
|
|
@@ -149,6 +157,8 @@
|
|
|
149
157
|
|
|
150
158
|
- Build: Refactored (aligned build system with Gridicons).
|
|
151
159
|
|
|
160
|
+
[3.1.9]: https://github.com/Automattic/social-logos/compare/v3.1.8...v3.1.9
|
|
161
|
+
[3.1.8]: https://github.com/Automattic/social-logos/compare/v3.1.7...v3.1.8
|
|
152
162
|
[3.1.7]: https://github.com/Automattic/social-logos/compare/v3.1.6...v3.1.7
|
|
153
163
|
[3.1.6]: https://github.com/Automattic/social-logos/compare/v3.1.5...v3.1.6
|
|
154
164
|
[3.1.5]: https://github.com/Automattic/social-logos/compare/v3.1.4...v3.1.5
|
package/build/react/example.js
CHANGED
|
@@ -6,6 +6,22 @@ const react_1 = require("react");
|
|
|
6
6
|
const social_logo_1 = require("./social-logo");
|
|
7
7
|
const social_logo_data_1 = require("./social-logo-data");
|
|
8
8
|
require("../css/example.css");
|
|
9
|
+
/**
|
|
10
|
+
* An example React component that displays a single social logo.
|
|
11
|
+
*
|
|
12
|
+
* @param {object} props - The properties.
|
|
13
|
+
* @param {string} props.name - Logo name.
|
|
14
|
+
* @param {number} props.iconSize - Icon size.
|
|
15
|
+
* @param {boolean} props.showIconNames - Whether to show icon names.
|
|
16
|
+
* @return {React.Component} The `SocialLogoItemExample` component.
|
|
17
|
+
*/
|
|
18
|
+
function SocialLogoItemExample({ name, iconSize, showIconNames }) {
|
|
19
|
+
const handleClick = (0, react_1.useCallback)(() => {
|
|
20
|
+
const code = `<SocialLogo icon="${name}" size="${iconSize}" />`;
|
|
21
|
+
window.prompt('Copy component code:', code);
|
|
22
|
+
}, [iconSize, name]);
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(social_logo_1.SocialLogo, { icon: name, size: iconSize, onClick: handleClick }), showIconNames && (0, jsx_runtime_1.jsx)("p", { children: name })] }, name));
|
|
24
|
+
}
|
|
9
25
|
/**
|
|
10
26
|
* An example React component that displays all the social logos.
|
|
11
27
|
*
|
|
@@ -15,19 +31,13 @@ function SocialLogosExample() {
|
|
|
15
31
|
const [useSmallIcons, setUseSmallIcons] = (0, react_1.useState)(false);
|
|
16
32
|
const [showIconNames, setShowIconNames] = (0, react_1.useState)(true);
|
|
17
33
|
const iconSize = useSmallIcons ? 24 : 48;
|
|
18
|
-
const
|
|
19
|
-
const code = `<SocialLogo icon="${name}" size="${iconSize}" />`;
|
|
20
|
-
window.prompt('Copy component code:', code);
|
|
21
|
-
};
|
|
22
|
-
const handleSmallIconsToggle = e => {
|
|
34
|
+
const handleSmallIconsToggle = (0, react_1.useCallback)(e => {
|
|
23
35
|
setUseSmallIcons(e.target.checked);
|
|
24
|
-
};
|
|
25
|
-
const handleIconNamesToggle = e => {
|
|
36
|
+
}, [setUseSmallIcons]);
|
|
37
|
+
const handleIconNamesToggle = (0, react_1.useCallback)(e => {
|
|
26
38
|
setShowIconNames(e.target.checked);
|
|
27
|
-
};
|
|
28
|
-
const allSocialLogos = social_logo_data_1.SocialLogoData.map(logo => {
|
|
29
|
-
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(social_logo_1.SocialLogo, { icon: logo.name, size: iconSize, onClick: handleClick.bind(this, logo.name) }), showIconNames && (0, jsx_runtime_1.jsx)("p", { children: logo.name })] }, logo.name));
|
|
30
|
-
});
|
|
39
|
+
}, [setShowIconNames]);
|
|
40
|
+
const allSocialLogos = social_logo_data_1.SocialLogoData.map(logo => ((0, jsx_runtime_1.jsx)(SocialLogoItemExample, { name: logo.name, iconSize: iconSize, showIconNames: showIconNames }, logo.name)));
|
|
31
41
|
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "social-logos-example" }, { children: [(0, jsx_runtime_1.jsx)("h1", { children: "Social Logos" }), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "display-control-group" }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "display-control" }, { children: [(0, jsx_runtime_1.jsx)("h4", { children: "Small icons" }), (0, jsx_runtime_1.jsxs)("label", Object.assign({ className: "switch" }, { children: [(0, jsx_runtime_1.jsx)("input", { type: "checkbox", onChange: handleSmallIconsToggle, checked: useSmallIcons }), (0, jsx_runtime_1.jsx)("span", { className: "handle" })] }))] })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "display-control" }, { children: [(0, jsx_runtime_1.jsx)("h4", { children: "Icon names" }), (0, jsx_runtime_1.jsxs)("label", Object.assign({ className: "switch" }, { children: [(0, jsx_runtime_1.jsx)("input", { type: "checkbox", onChange: handleIconNamesToggle, checked: showIconNames }), (0, jsx_runtime_1.jsx)("span", { className: "handle" }), (0, jsx_runtime_1.jsx)("span", { className: "switch-label", "data-on": "On", "data-off": "Off" })] }))] }))] })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "icons" }, { children: allSocialLogos })), (0, jsx_runtime_1.jsx)("p", { children: (0, jsx_runtime_1.jsx)("a", Object.assign({ href: "https://github.com/Automattic/social-logos" }, { children: "GitHub" })) })] })));
|
|
32
42
|
}
|
|
33
43
|
exports.default = SocialLogosExample;
|
package/package.json
CHANGED