allaw-ui 0.0.330 → 0.0.332

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.
@@ -45,6 +45,8 @@
45
45
  .oauth-provider-button.linkedin {
46
46
  background: #0a66c2;
47
47
  width: 100%;
48
+ padding-left: 10px;
49
+ padding-right: 10px;
48
50
  }
49
51
 
50
52
  .oauth-provider-button.apple .label {
@@ -110,6 +112,6 @@
110
112
  justify-content: center;
111
113
  width: 24px;
112
114
  height: 24px;
113
- border-radius: 8px;
115
+ border-radius: 4px;
114
116
  background: #ffffff;
115
117
  }
@@ -1,10 +1,11 @@
1
- import React from "react";
1
+ import React, { useState, useEffect, useRef } from "react";
2
2
  import "./OAuthProviderButton.css";
3
3
  import "../../../styles/global.css";
4
4
  var OAuthProviderButton = function (_a) {
5
5
  var provider = _a.provider, type = _a.type, url = _a.url, size = _a.size, onClick = _a.onClick;
6
- var getLabel = function () {
7
- var _a;
6
+ var _b = useState(""), label = _b[0], setLabel = _b[1];
7
+ var buttonRef = useRef(null);
8
+ var getLabels = function () {
8
9
  var labels = {
9
10
  google: {
10
11
  login: "Continuer avec Google",
@@ -19,8 +20,48 @@ var OAuthProviderButton = function (_a) {
19
20
  signup: "S'inscrire avec LinkedIn",
20
21
  },
21
22
  };
22
- return ((_a = labels[provider]) === null || _a === void 0 ? void 0 : _a[type]) || "";
23
+ var shortLabels = {
24
+ google: "Google",
25
+ apple: "Apple",
26
+ linkedin: "LinkedIn",
27
+ };
28
+ return { labels: labels, shortLabels: shortLabels };
23
29
  };
30
+ var getThresholdWidth = function (size) {
31
+ switch (size) {
32
+ case 14:
33
+ return 210;
34
+ case 16:
35
+ return 220;
36
+ case 18:
37
+ return 230;
38
+ case 20:
39
+ return 240;
40
+ case 22:
41
+ return 260;
42
+ case 24:
43
+ return 290;
44
+ default:
45
+ return 250;
46
+ }
47
+ };
48
+ var updateLabel = function () {
49
+ var _a;
50
+ var _b = getLabels(), labels = _b.labels, shortLabels = _b.shortLabels;
51
+ var maxWidth = ((_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0;
52
+ var thresholdWidth = getThresholdWidth(size);
53
+ var newLabel = maxWidth < thresholdWidth
54
+ ? shortLabels[provider]
55
+ : labels[provider][type];
56
+ setLabel(newLabel);
57
+ };
58
+ useEffect(function () {
59
+ updateLabel();
60
+ window.addEventListener("resize", updateLabel);
61
+ return function () {
62
+ window.removeEventListener("resize", updateLabel);
63
+ };
64
+ }, [provider, type, size]);
24
65
  var renderIcon = function () {
25
66
  var iconSizes = {
26
67
  google: size * 0.8,
@@ -42,13 +83,15 @@ var OAuthProviderButton = function (_a) {
42
83
  React.createElement("span", { className: "path4" })));
43
84
  }
44
85
  else if (provider === "linkedin") {
45
- var containerSize = size * 1.4; // Adjust this multiplier as needed
86
+ var containerSize = size * 1.4;
46
87
  return (React.createElement("div", { className: "linkedin-icon-container", style: {
47
88
  fontSize: "".concat(iconSize, "px"),
48
89
  width: "".concat(containerSize, "px"),
49
90
  height: "".concat(containerSize, "px"),
91
+ minWidth: "".concat(containerSize, "px"),
92
+ minHeight: "".concat(containerSize, "px"),
50
93
  } },
51
- React.createElement("i", { className: iconClass })));
94
+ React.createElement("i", { className: iconClass, style: { fontSize: "".concat(iconSize, "px") } })));
52
95
  }
53
96
  else {
54
97
  return (React.createElement("i", { className: iconClass, style: { fontSize: "".concat(iconSize, "px") } }));
@@ -80,8 +123,9 @@ var OAuthProviderButton = function (_a) {
80
123
  return "400px";
81
124
  }
82
125
  };
83
- return (React.createElement("button", { className: "oauth-provider-button ".concat(provider), onClick: handleClick, style: { height: "".concat(size * 2.55, "px"), maxWidth: getMaxWidth() } },
126
+ var maxWidth = getMaxWidth();
127
+ return (React.createElement("button", { ref: buttonRef, className: "oauth-provider-button ".concat(provider), onClick: handleClick, style: { height: "".concat(size * 2.55, "px"), maxWidth: maxWidth } },
84
128
  renderIcon(),
85
- React.createElement("span", { className: "label", style: { fontSize: "".concat(size, "px") } }, getLabel())));
129
+ React.createElement("span", { className: "label", style: { fontSize: "".concat(size, "px") } }, label)));
86
130
  };
87
131
  export default OAuthProviderButton;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allaw-ui",
3
- "version": "0.0.330",
3
+ "version": "0.0.332",
4
4
  "description": "Composants UI pour l'application Allaw",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",