@eclass/ui-kit 1.59.6 → 1.59.7

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.
@@ -6759,18 +6759,18 @@ function skipAttributesToProps(node2) {
6759
6759
  var HTMLReactParser = /* @__PURE__ */ getDefaultExportFromCjs(lib$3);
6760
6760
  var ReactParser = HTMLReactParser.default || HTMLReactParser;
6761
6761
  const AVATAR_COLORS = ["#0076ba", "#229f9c", "#2cb26b", "#30baed", "#95569e", "#9bc03a", "#d84315", "#f5a623", "#f6712f", "#ff6363"];
6762
- const getColorByUserId = (userId) => {
6763
- if (userId >= 0) {
6764
- const digits = userId.toString().split("");
6765
- const position = parseInt(digits[digits.length - 1], 10);
6766
- return AVATAR_COLORS[position];
6767
- }
6768
- return AVATAR_COLORS[Math.floor(Math.random() * AVATAR_COLORS.length)];
6762
+ const getColorIndex = (fullName) => {
6763
+ var _a;
6764
+ const trimmedNameLength = (_a = fullName == null ? void 0 : fullName.trim().length) != null ? _a : 0;
6765
+ return trimmedNameLength % 10;
6766
+ };
6767
+ const getAvatarColor = (fullName) => {
6768
+ const position = getColorIndex(fullName);
6769
+ return AVATAR_COLORS[position];
6769
6770
  };
6770
6771
  const getInitials = (fullName) => fullName.split(" ").map((word) => word[0]).slice(0, 2).join("").toUpperCase();
6771
6772
  const Avatar = ({
6772
6773
  fullName,
6773
- userId,
6774
6774
  picture,
6775
6775
  size = 50,
6776
6776
  fontSize = 14,
@@ -6781,8 +6781,8 @@ const Avatar = ({
6781
6781
  const [bgColor, setBgColor] = useState("");
6782
6782
  const [imageValid, setImageValid] = useState(false);
6783
6783
  useEffect(() => {
6784
- setBgColor(getColorByUserId(userId));
6785
- }, [userId]);
6784
+ setBgColor(getAvatarColor(fullName));
6785
+ }, [fullName]);
6786
6786
  const wrapperStyle = {
6787
6787
  alignItems: "center",
6788
6788
  backgroundColor: (fullName == null ? void 0 : fullName.length) === 0 ? "#fff" : bgColor,