social-logos 3.1.6 → 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,11 @@
1
+ ## [3.1.8] - 2024-09-05
2
+ ### Fixed
3
+ - Address React usage issues found by eslint in example.tsx. [#39214]
4
+
5
+ ## [3.1.7] - 2024-08-23
6
+ ### Changed
7
+ - Internal updates.
8
+
1
9
  ## [3.1.6] - 2024-08-21
2
10
  ### Fixed
3
11
  - Revert recent SVG image optimizations. [#38981]
@@ -145,6 +153,8 @@
145
153
 
146
154
  - Build: Refactored (aligned build system with Gridicons).
147
155
 
156
+ [3.1.8]: https://github.com/Automattic/social-logos/compare/v3.1.7...v3.1.8
157
+ [3.1.7]: https://github.com/Automattic/social-logos/compare/v3.1.6...v3.1.7
148
158
  [3.1.6]: https://github.com/Automattic/social-logos/compare/v3.1.5...v3.1.6
149
159
  [3.1.5]: https://github.com/Automattic/social-logos/compare/v3.1.4...v3.1.5
150
160
  [3.1.4]: https://github.com/Automattic/social-logos/compare/v3.1.3...v3.1.4
@@ -1,10 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const jsx_runtime_1 = require("react/jsx-runtime");
4
+ /* eslint-disable no-alert -- ok for demo */
4
5
  const react_1 = require("react");
5
6
  const social_logo_1 = require("./social-logo");
6
7
  const social_logo_data_1 = require("./social-logo-data");
7
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
+ }
8
25
  /**
9
26
  * An example React component that displays all the social logos.
10
27
  *
@@ -14,19 +31,13 @@ function SocialLogosExample() {
14
31
  const [useSmallIcons, setUseSmallIcons] = (0, react_1.useState)(false);
15
32
  const [showIconNames, setShowIconNames] = (0, react_1.useState)(true);
16
33
  const iconSize = useSmallIcons ? 24 : 48;
17
- const handleClick = name => {
18
- const code = `<SocialLogo icon="${name}" size="${iconSize}" />`;
19
- window.prompt('Copy component code:', code);
20
- };
21
- const handleSmallIconsToggle = e => {
34
+ const handleSmallIconsToggle = (0, react_1.useCallback)(e => {
22
35
  setUseSmallIcons(e.target.checked);
23
- };
24
- const handleIconNamesToggle = e => {
36
+ }, [setUseSmallIcons]);
37
+ const handleIconNamesToggle = (0, react_1.useCallback)(e => {
25
38
  setShowIconNames(e.target.checked);
26
- };
27
- const allSocialLogos = social_logo_data_1.SocialLogoData.map(logo => {
28
- 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));
29
- });
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 })));
30
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" })) })] })));
31
42
  }
32
43
  exports.default = SocialLogosExample;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "social-logos",
3
- "version": "3.1.6",
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": {