allaw-ui 2.7.9 → 2.8.0
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/dist/components/atoms/radios/SelectCard.d.ts +4 -0
- package/dist/components/atoms/radios/SelectCard.js +36 -6
- package/dist/components/atoms/radios/SelectCard.module.css +2 -3
- package/dist/components/atoms/radios/SelectCard.stories.d.ts +16 -1
- package/dist/components/atoms/radios/SelectCard.stories.js +39 -0
- package/package.json +1 -1
|
@@ -4,6 +4,8 @@ export type ResponsiveConfig = {
|
|
|
4
4
|
label?: string;
|
|
5
5
|
height?: number;
|
|
6
6
|
width?: number;
|
|
7
|
+
maxWidth?: number;
|
|
8
|
+
imageVerticalOffset?: number;
|
|
7
9
|
};
|
|
8
10
|
export type ResponsiveBreakpoints = Record<number, ResponsiveConfig>;
|
|
9
11
|
export interface SelectCardProps {
|
|
@@ -15,6 +17,8 @@ export interface SelectCardProps {
|
|
|
15
17
|
size?: "small" | "medium" | "large";
|
|
16
18
|
onClick: () => void;
|
|
17
19
|
responsiveConfig?: ResponsiveBreakpoints;
|
|
20
|
+
maxWidth?: number;
|
|
21
|
+
imageVerticalOffset?: number;
|
|
18
22
|
}
|
|
19
23
|
declare const SelectCard: React.FC<SelectCardProps>;
|
|
20
24
|
export default SelectCard;
|
|
@@ -1,10 +1,22 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
import React, { useEffect, useState } from "react";
|
|
2
13
|
import styles from "./SelectCard.module.css";
|
|
3
14
|
import "../../../styles/icons.css";
|
|
4
15
|
var SelectCard = function (_a) {
|
|
5
|
-
var iconName = _a.iconName, iconUrl = _a.iconUrl, label = _a.label, _b = _a.isActive, isActive = _b === void 0 ? false : _b, _c = _a.isDisabled, isDisabled = _c === void 0 ? false : _c, _d = _a.size, size = _d === void 0 ? "medium" : _d, onClick = _a.onClick, responsiveConfig = _a.responsiveConfig;
|
|
6
|
-
var
|
|
7
|
-
var
|
|
16
|
+
var iconName = _a.iconName, iconUrl = _a.iconUrl, label = _a.label, _b = _a.isActive, isActive = _b === void 0 ? false : _b, _c = _a.isDisabled, isDisabled = _c === void 0 ? false : _c, _d = _a.size, size = _d === void 0 ? "medium" : _d, onClick = _a.onClick, responsiveConfig = _a.responsiveConfig, maxWidth = _a.maxWidth, _e = _a.imageVerticalOffset, imageVerticalOffset = _e === void 0 ? 0 : _e;
|
|
17
|
+
var _f = useState(label), currentLabel = _f[0], setCurrentLabel = _f[1];
|
|
18
|
+
var _g = useState({}), currentStyle = _g[0], setCurrentStyle = _g[1];
|
|
19
|
+
var _h = useState(imageVerticalOffset), currentImageOffset = _h[0], setCurrentImageOffset = _h[1];
|
|
8
20
|
useEffect(function () {
|
|
9
21
|
if (!responsiveConfig)
|
|
10
22
|
return;
|
|
@@ -17,6 +29,8 @@ var SelectCard = function (_a) {
|
|
|
17
29
|
var selectedLabel = label;
|
|
18
30
|
var selectedWidth = undefined;
|
|
19
31
|
var selectedHeight = undefined;
|
|
32
|
+
var selectedMaxWidth = maxWidth;
|
|
33
|
+
var selectedImageOffset = imageVerticalOffset;
|
|
20
34
|
// Trouver la configuration appropriée pour la largeur actuelle
|
|
21
35
|
for (var _i = 0, breakpoints_1 = breakpoints; _i < breakpoints_1.length; _i++) {
|
|
22
36
|
var breakpoint = breakpoints_1[_i];
|
|
@@ -28,6 +42,10 @@ var SelectCard = function (_a) {
|
|
|
28
42
|
selectedWidth = config.width;
|
|
29
43
|
if (config.height)
|
|
30
44
|
selectedHeight = config.height;
|
|
45
|
+
if (config.maxWidth !== undefined)
|
|
46
|
+
selectedMaxWidth = config.maxWidth;
|
|
47
|
+
if (config.imageVerticalOffset !== undefined)
|
|
48
|
+
selectedImageOffset = config.imageVerticalOffset;
|
|
31
49
|
}
|
|
32
50
|
else {
|
|
33
51
|
break;
|
|
@@ -37,7 +55,9 @@ var SelectCard = function (_a) {
|
|
|
37
55
|
setCurrentStyle({
|
|
38
56
|
width: selectedWidth ? "".concat(selectedWidth, "px") : undefined,
|
|
39
57
|
height: selectedHeight ? "".concat(selectedHeight, "px") : undefined,
|
|
58
|
+
maxWidth: selectedMaxWidth ? "".concat(selectedMaxWidth, "px") : undefined,
|
|
40
59
|
});
|
|
60
|
+
setCurrentImageOffset(selectedImageOffset);
|
|
41
61
|
};
|
|
42
62
|
// Vérification initiale
|
|
43
63
|
handleResize();
|
|
@@ -47,7 +67,7 @@ var SelectCard = function (_a) {
|
|
|
47
67
|
return function () {
|
|
48
68
|
window.removeEventListener("resize", handleResize);
|
|
49
69
|
};
|
|
50
|
-
}, [responsiveConfig, label]);
|
|
70
|
+
}, [responsiveConfig, label, maxWidth, imageVerticalOffset]);
|
|
51
71
|
var handleClick = function () {
|
|
52
72
|
if (!isDisabled) {
|
|
53
73
|
onClick();
|
|
@@ -62,9 +82,19 @@ var SelectCard = function (_a) {
|
|
|
62
82
|
}
|
|
63
83
|
return null;
|
|
64
84
|
};
|
|
65
|
-
|
|
85
|
+
// Calculer le style pour l'icône avec l'offset vertical
|
|
86
|
+
var iconWrapperStyle = {
|
|
87
|
+
transform: currentImageOffset !== 0
|
|
88
|
+
? "translateY(".concat(currentImageOffset, "px)")
|
|
89
|
+
: undefined,
|
|
90
|
+
};
|
|
91
|
+
// Calculer le style pour le bouton avec maxWidth
|
|
92
|
+
var buttonStyle = __assign(__assign({}, currentStyle), { maxWidth: maxWidth && !currentStyle.maxWidth
|
|
93
|
+
? "".concat(maxWidth, "px")
|
|
94
|
+
: currentStyle.maxWidth });
|
|
95
|
+
return (React.createElement("button", { className: "".concat(styles.selectCard, " \n ").concat(isActive ? styles.active : "", " \n ").concat(isDisabled ? styles.disabled : "", " \n ").concat(styles[size]), onClick: handleClick, disabled: isDisabled, type: "button", style: buttonStyle, title: currentLabel },
|
|
66
96
|
React.createElement("div", { className: styles.contentWrapper },
|
|
67
|
-
(iconName || iconUrl) && (React.createElement("div", { className: styles.iconWrapper }, renderIcon())),
|
|
97
|
+
(iconName || iconUrl) && (React.createElement("div", { className: styles.iconWrapper, style: iconWrapperStyle }, renderIcon())),
|
|
68
98
|
React.createElement("span", { className: styles.label }, currentLabel))));
|
|
69
99
|
};
|
|
70
100
|
export default SelectCard;
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
width: 100%;
|
|
27
27
|
height: 100%;
|
|
28
28
|
box-sizing: border-box;
|
|
29
|
+
position: relative;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
.iconWrapper {
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
justify-content: center;
|
|
35
36
|
height: 48px; /* Hauteur fixe pour l'icône */
|
|
36
37
|
margin-bottom: 4px; /* Espace supplémentaire en bas de l'icône */
|
|
38
|
+
transition: transform 0.2s ease;
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
/* Taille d'icône par défaut */
|
|
@@ -66,7 +68,6 @@
|
|
|
66
68
|
.small {
|
|
67
69
|
min-width: 80px;
|
|
68
70
|
min-height: 80px;
|
|
69
|
-
max-width: 80px;
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
.small .iconFont {
|
|
@@ -85,7 +86,6 @@
|
|
|
85
86
|
.medium {
|
|
86
87
|
min-width: 120px;
|
|
87
88
|
min-height: 120px;
|
|
88
|
-
max-width: 120px;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
.medium .iconFont {
|
|
@@ -104,7 +104,6 @@
|
|
|
104
104
|
.large {
|
|
105
105
|
min-width: 160px;
|
|
106
106
|
min-height: 160px;
|
|
107
|
-
max-width: 160px;
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
.large .iconFont {
|
|
@@ -47,12 +47,24 @@ declare namespace _default {
|
|
|
47
47
|
let description_5: string;
|
|
48
48
|
export { description_5 as description };
|
|
49
49
|
}
|
|
50
|
-
namespace
|
|
50
|
+
namespace maxWidth {
|
|
51
51
|
let control_6: string;
|
|
52
52
|
export { control_6 as control };
|
|
53
53
|
let description_6: string;
|
|
54
54
|
export { description_6 as description };
|
|
55
55
|
}
|
|
56
|
+
namespace imageVerticalOffset {
|
|
57
|
+
let control_7: string;
|
|
58
|
+
export { control_7 as control };
|
|
59
|
+
let description_7: string;
|
|
60
|
+
export { description_7 as description };
|
|
61
|
+
}
|
|
62
|
+
namespace responsiveConfig {
|
|
63
|
+
let control_8: string;
|
|
64
|
+
export { control_8 as control };
|
|
65
|
+
let description_8: string;
|
|
66
|
+
export { description_8 as description };
|
|
67
|
+
}
|
|
56
68
|
}
|
|
57
69
|
export namespace parameters {
|
|
58
70
|
namespace backgrounds {
|
|
@@ -73,5 +85,8 @@ export const Small: any;
|
|
|
73
85
|
export const Large: any;
|
|
74
86
|
export const WithImageUrl: any;
|
|
75
87
|
export const WithLongText: any;
|
|
88
|
+
export const WithCustomMaxWidth: any;
|
|
89
|
+
export const WithImageOffset: any;
|
|
90
|
+
export const WithNegativeImageOffset: any;
|
|
76
91
|
export const WithResponsiveConfig: any;
|
|
77
92
|
import SelectCard from "./SelectCard";
|
|
@@ -48,6 +48,14 @@ export default {
|
|
|
48
48
|
},
|
|
49
49
|
description: "Taille du bouton",
|
|
50
50
|
},
|
|
51
|
+
maxWidth: {
|
|
52
|
+
control: "number",
|
|
53
|
+
description: "Largeur maximale du bouton en pixels",
|
|
54
|
+
},
|
|
55
|
+
imageVerticalOffset: {
|
|
56
|
+
control: "number",
|
|
57
|
+
description: "Décalage vertical de l'icône en pixels (positif = vers le bas, négatif = vers le haut)",
|
|
58
|
+
},
|
|
51
59
|
responsiveConfig: {
|
|
52
60
|
control: "object",
|
|
53
61
|
description: "Configuration responsive du bouton",
|
|
@@ -131,6 +139,33 @@ WithLongText.args = {
|
|
|
131
139
|
isDisabled: false,
|
|
132
140
|
size: "medium",
|
|
133
141
|
};
|
|
142
|
+
export var WithCustomMaxWidth = Template.bind({});
|
|
143
|
+
WithCustomMaxWidth.args = {
|
|
144
|
+
label: "Bouton avec largeur maximale personnalisée",
|
|
145
|
+
iconName: "allaw-icon-upload-file",
|
|
146
|
+
isActive: false,
|
|
147
|
+
isDisabled: false,
|
|
148
|
+
size: "medium",
|
|
149
|
+
maxWidth: 200,
|
|
150
|
+
};
|
|
151
|
+
export var WithImageOffset = Template.bind({});
|
|
152
|
+
WithImageOffset.args = {
|
|
153
|
+
label: "Icône décalée vers le bas",
|
|
154
|
+
iconName: "allaw-icon-upload-file",
|
|
155
|
+
isActive: false,
|
|
156
|
+
isDisabled: false,
|
|
157
|
+
size: "medium",
|
|
158
|
+
imageVerticalOffset: 10,
|
|
159
|
+
};
|
|
160
|
+
export var WithNegativeImageOffset = Template.bind({});
|
|
161
|
+
WithNegativeImageOffset.args = {
|
|
162
|
+
label: "Icône décalée vers le haut",
|
|
163
|
+
iconName: "allaw-icon-upload-file",
|
|
164
|
+
isActive: false,
|
|
165
|
+
isDisabled: false,
|
|
166
|
+
size: "medium",
|
|
167
|
+
imageVerticalOffset: -10,
|
|
168
|
+
};
|
|
134
169
|
export var WithResponsiveConfig = Template.bind({});
|
|
135
170
|
WithResponsiveConfig.args = {
|
|
136
171
|
label: "Version Desktop",
|
|
@@ -143,11 +178,15 @@ WithResponsiveConfig.args = {
|
|
|
143
178
|
label: "Version Tablette",
|
|
144
179
|
width: 100,
|
|
145
180
|
height: 100,
|
|
181
|
+
maxWidth: 150,
|
|
182
|
+
imageVerticalOffset: 5,
|
|
146
183
|
},
|
|
147
184
|
480: {
|
|
148
185
|
label: "Mobile",
|
|
149
186
|
width: 80,
|
|
150
187
|
height: 80,
|
|
188
|
+
maxWidth: 100,
|
|
189
|
+
imageVerticalOffset: -5,
|
|
151
190
|
},
|
|
152
191
|
},
|
|
153
192
|
};
|