social-logos 3.1.7 → 3.1.8

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,3 +1,7 @@
1
+ ## [3.1.8] - 2024-09-05
2
+ ### Fixed
3
+ - Address React usage issues found by eslint in example.tsx. [#39214]
4
+
1
5
  ## [3.1.7] - 2024-08-23
2
6
  ### Changed
3
7
  - Internal updates.
@@ -149,6 +153,7 @@
149
153
 
150
154
  - Build: Refactored (aligned build system with Gridicons).
151
155
 
156
+ [3.1.8]: https://github.com/Automattic/social-logos/compare/v3.1.7...v3.1.8
152
157
  [3.1.7]: https://github.com/Automattic/social-logos/compare/v3.1.6...v3.1.7
153
158
  [3.1.6]: https://github.com/Automattic/social-logos/compare/v3.1.5...v3.1.6
154
159
  [3.1.5]: https://github.com/Automattic/social-logos/compare/v3.1.4...v3.1.5
@@ -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 handleClick = name => {
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 })));
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "social-logos",
3
- "version": "3.1.7",
3
+ "version": "3.1.8",
4
4
  "description": "A repository of all the social logos used on WordPress.com.",
5
5
  "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/social-logos/",
6
6
  "bugs": {