Fix avatars not overlapping (#6405)

* Fix avatars being weird

* Fix useravatar import

* Fix type error

* Fixing spacing
This commit is contained in:
sean-brydon authored and GitHub committed 2023-01-11 15:00:46 +00:00
1 parent 7b2bfc2a64
commit a669403604
9 files changed
+21 -24

No files matched your search

@@ -11,19 +11,21 @@ export type AvatarGroupProps = {
}[];
className?: string;
accepted?: boolean;
truncateAfter?: number;
};
export const AvatarGroup = function AvatarGroup(props: AvatarGroupProps) {
const avatars = props.items.slice(0, 4);
const LENGTH = props.items.length;
const truncateAfter = props.truncateAfter || 4;
return (
<ul className={classNames(props.className, "flex items-center")}>
{avatars.map((item, enumerator) => {
if (item.image != null) {
if (LENGTH > 4 && enumerator === 3) {
if (LENGTH > truncateAfter && enumerator === truncateAfter - 1) {
return (
<li key={enumerator} className="relative -mr-4 inline-block ">
<li key={enumerator} className="relative -mr-[4px] inline-block ">
<div className="relative">
<div className="h-90 relative min-w-full scale-105 transform border-gray-200 ">
<Avatar className="" imageSrc={item.image} alt={item.alt || ""} size={props.size} />
@@ -34,14 +36,14 @@ export const AvatarGroup = function AvatarGroup(props: AvatarGroupProps) {
"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 text-white",
props.size === "sm" ? "text-base" : "text-2xl"
)}>
<span>+{LENGTH - 3}</span>
<span>+{LENGTH - truncateAfter - 1}</span>
</div>
</li>
);
}
// Always display the first Four items items
return (
<li key={enumerator} className="-mr-4 inline-block">
<li key={enumerator} className="-mr-[4px] inline-block">
<Avatar
className="border-gray-200"
imageSrc={item.image}
+1
View File
@@ -1,3 +1,4 @@
export { Avatar } from "./Avatar";
export type { AvatarProps } from "./Avatar";
export { AvatarGroup } from "./AvatarGroup";
export type { AvatarGroupProps } from "./AvatarGroup";
+1 -1
View File
@@ -1,5 +1,5 @@
export { Avatar, AvatarGroup } from "./avatar";
export type { AvatarProps } from "./avatar";
export type { AvatarProps, AvatarGroupProps } from "./avatar";
export { Badge } from "./badge";
export type { BadgeProps } from "./badge";
export { Breadcrumb, BreadcrumbContainer, BreadcrumbItem } from "./breadcrumb";
+1
View File
@@ -130,6 +130,7 @@ export type {
NavTabProps,
HorizontalTabItemProps,
VerticalTabItemProps,
AvatarGroupProps,
} from "./components";
export { default as CheckboxField } from "./components/form/checkbox/Checkbox";
/** ⬇️ TODO - Move these to components */