Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions packages/lib/src/action-icon/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,32 +92,33 @@ const modeColorMap = {
error: "var(--color-fg-error-medium)",
};

export const getColor = (color: ActionIconPropTypes["color"]) => (color ? contextualColorMap[color].text : undefined);
export const getColor = (color: ActionIconPropTypes["color"]) =>
color && contextualColorMap[color] ? contextualColorMap[color].text : contextualColorMap.transparent.text;

export const getBackgroundColor = (color: ActionIconPropTypes["color"]) =>
color ? contextualColorMap[color].background : undefined;
color && contextualColorMap[color] ? contextualColorMap[color].background : contextualColorMap.transparent.background;

export const getBorderRadius = (shape: ActionIconPropTypes["shape"], size: ActionIconPropTypes["size"]) => {
if (shape === "circle") {
return "100%";
}
if (shape === "square") {
return size ? borderRadiusMap[size] : "var(--border-radius-m)";
return size && borderRadiusMap[size] ? borderRadiusMap[size] : "var(--border-radius-m)";
}
return "100%";
};

export const getSize = (size: ActionIconPropTypes["size"]) => {
if (!size) return "var(--height-xl)";
return sizeMap[size] ?? "var(--height-xl)";
};
export const getSize = (size: ActionIconPropTypes["size"]) =>
size && sizeMap[size] ? sizeMap[size] : "var(--height-xl)";

export const getIconSize = (size: ActionIconPropTypes["size"]) => (size ? iconSizeMap[size] : "var(--height-s)");
export const getIconSize = (size: ActionIconPropTypes["size"]) =>
size && iconSizeMap[size] ? iconSizeMap[size] : "var(--height-s)";

export const getBorderWidth = (size: ActionIconPropTypes["size"]) =>
size ? borderWidthMap[size] : "var(--border-width-s)";
size && borderWidthMap[size] ? borderWidthMap[size] : "var(--border-width-s)";

export const getOutlineWidth = (size: ActionIconPropTypes["size"]) =>
size ? outlineWidthMap[size] : "var(--border-width-m)";
size && outlineWidthMap[size] ? outlineWidthMap[size] : "var(--border-width-m)";

export const getModeColor = (mode: Required<ActionIconPropTypes>["status"]["mode"]) =>
mode ? modeColorMap[mode] : "var(--color-fg-neutral-strong)";
mode && modeColorMap[mode] ? modeColorMap[mode] : "var(--color-fg-neutral-strong)";
8 changes: 6 additions & 2 deletions packages/lib/src/avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,19 @@ const DxcAvatar = memo(
<DxcActionIcon
ariaLabel={label}
content={(imageSrc && !error) || initials ? content : undefined}
color={color}
color={
["primary", "secondary", "tertiary", "success", "info", "neutral", "warning", "error"].includes(color)
? color
: "neutral"
}
disabled={disabled}
icon={icon}
linkHref={linkHref}
onClick={onClick}
shape={shape}
size={size}
status={status}
tabIndex={onClick || linkHref ? tabIndex : undefined}
tabIndex={tabIndex}
title={title}
/>
</LabelWrapper>
Expand Down