allaw-ui 2.6.9 → 2.7.1

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.
@@ -4,7 +4,7 @@
4
4
  justify-content: center;
5
5
  align-items: center;
6
6
  gap: 10px;
7
- border-radius: 8px;
7
+ border-radius: 12px;
8
8
  font-family: "Open Sans", sans-serif;
9
9
  font-size: 14px;
10
10
  font-style: normal;
@@ -24,17 +24,17 @@
24
24
  }
25
25
 
26
26
  .actionButtonEnabled {
27
- background: #127aa0;
27
+ background: #1985e8;
28
28
  color: var(--pure-white, #fff);
29
29
  }
30
30
 
31
31
  .actionButtonEnabled:hover {
32
- background: #1590bb;
32
+ background: #1a92ff;
33
33
  }
34
34
 
35
35
  .actionButtonEnabled:active {
36
- background: #107194;
37
- /* opacity: 0.7; */
36
+ background: #1578d0;
37
+ /* opacity: 0.8; */
38
38
  }
39
39
 
40
40
  .actionButtonDisabled {
@@ -1,6 +1,7 @@
1
1
  import React, { ButtonHTMLAttributes } from "react";
2
2
  import "./SecondaryButton.css";
3
3
  import "../../../styles/global.css";
4
+ export type ResponsiveLabels = Record<number, string>;
4
5
  export interface SecondaryButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
5
6
  startIcon?: React.ReactNode;
6
7
  endIcon?: React.ReactNode;
@@ -15,6 +16,7 @@ export interface SecondaryButtonProps extends ButtonHTMLAttributes<HTMLButtonEle
15
16
  type?: "button" | "submit" | "reset";
16
17
  isLoading?: boolean;
17
18
  size?: "medium" | "large";
19
+ responsiveLabels?: ResponsiveLabels;
18
20
  }
19
21
  declare const SecondaryButton: React.ForwardRefExoticComponent<SecondaryButtonProps & React.RefAttributes<HTMLButtonElement>>;
20
22
  export default SecondaryButton;
@@ -61,10 +61,11 @@ import React, { forwardRef, useImperativeHandle, useState, useEffect, } from "re
61
61
  import "./SecondaryButton.css";
62
62
  import "../../../styles/global.css";
63
63
  var SecondaryButton = forwardRef(function (_a, ref) {
64
- var startIcon = _a.startIcon, endIcon = _a.endIcon, startIconName = _a.startIconName, endIconName = _a.endIconName, label = _a.label, _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.mode, mode = _c === void 0 ? "dark" : _c, _d = _a.color, color = _d === void 0 ? "noir" : _d, onClick = _a.onClick, _e = _a.fullWidth, fullWidth = _e === void 0 ? false : _e, _f = _a.type, type = _f === void 0 ? "button" : _f, _g = _a.isLoading, isLoading = _g === void 0 ? false : _g, _h = _a.size, size = _h === void 0 ? "medium" : _h, props = __rest(_a, ["startIcon", "endIcon", "startIconName", "endIconName", "label", "disabled", "mode", "color", "onClick", "fullWidth", "type", "isLoading", "size"]);
64
+ var startIcon = _a.startIcon, endIcon = _a.endIcon, startIconName = _a.startIconName, endIconName = _a.endIconName, label = _a.label, _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.mode, mode = _c === void 0 ? "dark" : _c, _d = _a.color, color = _d === void 0 ? "noir" : _d, onClick = _a.onClick, _e = _a.fullWidth, fullWidth = _e === void 0 ? false : _e, _f = _a.type, type = _f === void 0 ? "button" : _f, _g = _a.isLoading, isLoading = _g === void 0 ? false : _g, _h = _a.size, size = _h === void 0 ? "medium" : _h, responsiveLabels = _a.responsiveLabels, props = __rest(_a, ["startIcon", "endIcon", "startIconName", "endIconName", "label", "disabled", "mode", "color", "onClick", "fullWidth", "type", "isLoading", "size", "responsiveLabels"]);
65
65
  var buttonRef = React.useRef(null);
66
66
  var _j = useState(false), internalIsLoading = _j[0], setInternalIsLoading = _j[1];
67
67
  var _k = useState(""), loadingDots = _k[0], setLoadingDots = _k[1];
68
+ var _l = useState(label), currentLabel = _l[0], setCurrentLabel = _l[1];
68
69
  useImperativeHandle(ref, function () { return buttonRef.current; });
69
70
  var isButtonLoading = isLoading || internalIsLoading;
70
71
  useEffect(function () {
@@ -84,6 +85,39 @@ var SecondaryButton = forwardRef(function (_a, ref) {
84
85
  }
85
86
  };
86
87
  }, [isButtonLoading]);
88
+ // Effect for responsive labels
89
+ useEffect(function () {
90
+ if (!responsiveLabels) {
91
+ setCurrentLabel(label);
92
+ return;
93
+ }
94
+ var handleResize = function () {
95
+ var width = window.innerWidth;
96
+ var breakpoints = Object.keys(responsiveLabels)
97
+ .map(Number)
98
+ .sort(function (a, b) { return a - b; });
99
+ // Find the appropriate label for the current width
100
+ var selectedLabel = label; // Default to the prop label
101
+ for (var _i = 0, breakpoints_1 = breakpoints; _i < breakpoints_1.length; _i++) {
102
+ var breakpoint = breakpoints_1[_i];
103
+ if (width >= breakpoint) {
104
+ selectedLabel = responsiveLabels[breakpoint];
105
+ }
106
+ else {
107
+ break;
108
+ }
109
+ }
110
+ setCurrentLabel(selectedLabel);
111
+ };
112
+ // Initial check
113
+ handleResize();
114
+ // Add event listener
115
+ window.addEventListener("resize", handleResize);
116
+ // Cleanup
117
+ return function () {
118
+ window.removeEventListener("resize", handleResize);
119
+ };
120
+ }, [responsiveLabels, label]);
87
121
  var handleClick = function (event) { return __awaiter(void 0, void 0, void 0, function () {
88
122
  return __generator(this, function (_a) {
89
123
  switch (_a.label) {
@@ -110,7 +144,7 @@ var SecondaryButton = forwardRef(function (_a, ref) {
110
144
  }); };
111
145
  return (React.createElement("button", __assign({ ref: buttonRef, className: "secondary-button ".concat(disabled ? "secondary-button-disabled" : "secondary-button-enabled", " secondary-button-").concat(mode, " ").concat(fullWidth ? "secondary-button-full-width" : "", " ").concat(isButtonLoading ? "secondary-button-loading" : "", " ").concat(color ? "secondary-button-color-".concat(color) : "", " ").concat(size === "large" ? "secondary-button-large" : ""), disabled: disabled, onClick: handleClick, type: type }, props),
112
146
  startIcon && (React.createElement("span", { className: "secondary-button-icon ".concat(startIconName) })),
113
- React.createElement("span", { className: "secondary-button-label" }, label),
147
+ React.createElement("span", { className: "secondary-button-label" }, currentLabel),
114
148
  isButtonLoading ? (React.createElement("span", { className: "secondary-button-loading-dots" }, loadingDots)) : (endIcon && React.createElement("span", { className: "secondary-button-icon ".concat(endIconName) }))));
115
149
  });
116
150
  SecondaryButton.displayName = "SecondaryButton";
@@ -4,9 +4,16 @@ declare namespace _default {
4
4
  export { SecondaryButton as component };
5
5
  export let tags: string[];
6
6
  export let excludeStories: RegExp;
7
- export let args: {};
7
+ export namespace args {
8
+ let responsiveLabels: {
9
+ 480: string;
10
+ 768: string;
11
+ 1024: string;
12
+ 1440: string;
13
+ };
14
+ }
8
15
  export namespace argTypes {
9
- namespace startIcon {
16
+ export namespace startIcon {
10
17
  namespace control {
11
18
  let type: string;
12
19
  }
@@ -17,7 +24,7 @@ declare namespace _default {
17
24
  export { _false as false };
18
25
  }
19
26
  }
20
- namespace endIcon {
27
+ export namespace endIcon {
21
28
  export namespace control_1 {
22
29
  let type_1: string;
23
30
  export { type_1 as type };
@@ -31,10 +38,10 @@ declare namespace _default {
31
38
  }
32
39
  export { mapping_1 as mapping };
33
40
  }
34
- namespace onClick {
41
+ export namespace onClick {
35
42
  let action: string;
36
43
  }
37
- namespace color {
44
+ export namespace color {
38
45
  export namespace control_2 {
39
46
  let type_2: string;
40
47
  export { type_2 as type };
@@ -43,7 +50,7 @@ declare namespace _default {
43
50
  export let options: string[];
44
51
  export let defaultValue: string;
45
52
  }
46
- namespace size {
53
+ export namespace size {
47
54
  export namespace control_3 {
48
55
  let type_3: string;
49
56
  export { type_3 as type };
@@ -52,6 +59,11 @@ declare namespace _default {
52
59
  }
53
60
  export { control_3 as control };
54
61
  }
62
+ export namespace responsiveLabels_1 {
63
+ let control_4: string;
64
+ export { control_4 as control };
65
+ }
66
+ export { responsiveLabels_1 as responsiveLabels };
55
67
  }
56
68
  export namespace parameters {
57
69
  namespace backgrounds {
@@ -81,4 +93,5 @@ export const WithValidColor: any;
81
93
  export const LargeButton: any;
82
94
  export const LargeButtonWithIcons: any;
83
95
  export const LargeColoredButton: any;
96
+ export const ResponsiveButton: any;
84
97
  import SecondaryButton from "./SecondaryButton";
@@ -54,7 +54,12 @@ export default {
54
54
  component: SecondaryButton,
55
55
  tags: ["autodocs"],
56
56
  excludeStories: /.*Data$/,
57
- args: __assign({}, ActionsData),
57
+ args: __assign(__assign({}, ActionsData), { responsiveLabels: {
58
+ 480: "Court",
59
+ 768: "Moyen",
60
+ 1024: "Label complet",
61
+ 1440: "Label complet avec détails",
62
+ } }),
58
63
  argTypes: {
59
64
  startIcon: {
60
65
  control: {
@@ -96,6 +101,9 @@ export default {
96
101
  options: ["medium", "large"],
97
102
  },
98
103
  },
104
+ responsiveLabels: {
105
+ control: "object",
106
+ },
99
107
  },
100
108
  parameters: {
101
109
  backgrounds: {
@@ -160,3 +168,10 @@ export var LargeButtonWithIcons = Template.bind({});
160
168
  LargeButtonWithIcons.args = __assign(__assign({}, Default.args), { label: "Grand Bouton avec Icônes", startIcon: true, endIcon: true, size: "large" });
161
169
  export var LargeColoredButton = Template.bind({});
162
170
  LargeColoredButton.args = __assign(__assign({}, Default.args), { label: "Grand Bouton Coloré", color: "bleu-allaw", size: "large" });
171
+ export var ResponsiveButton = Template.bind({});
172
+ ResponsiveButton.args = __assign(__assign({}, Default.args), { label: "Label par défaut", responsiveLabels: {
173
+ 480: "Partager",
174
+ 768: "Partager sur",
175
+ 1024: "Partager sur LinkedIn",
176
+ 1440: "Partager votre avis sur LinkedIn",
177
+ }, color: "bleu-allaw" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allaw-ui",
3
- "version": "2.6.9",
3
+ "version": "2.7.1",
4
4
  "description": "Composants UI pour l'application Allaw",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",