diff --git a/lib/experimental/Information/Tags/DotTag/index.tsx b/lib/experimental/Information/Tags/DotTag/index.tsx index 6c87de2e1..7b04e6e74 100644 --- a/lib/experimental/Information/Tags/DotTag/index.tsx +++ b/lib/experimental/Information/Tags/DotTag/index.tsx @@ -18,12 +18,12 @@ type NewColor = Extract< | "camel" > -interface Props { +export interface DotTagProps { text: string color: NewColor } -export const DotTag = forwardRef( +export const DotTag = forwardRef( ({ text, color }, ref) => { useTextFormatEnforcer(text, { disallowEmpty: true }) diff --git a/lib/experimental/Information/Tags/RawTag/index.tsx b/lib/experimental/Information/Tags/RawTag/index.tsx index 01c67ffbe..a8a97aa00 100644 --- a/lib/experimental/Information/Tags/RawTag/index.tsx +++ b/lib/experimental/Information/Tags/RawTag/index.tsx @@ -5,20 +5,23 @@ import { cn } from "@/lib/utils" import { forwardRef } from "react" import { BaseTag } from "../BaseTag" -type Props = { +export type RawTagProps = { text?: string additionalAccesibleText?: string icon?: IconType + noBorder?: boolean } -export const RawTag = forwardRef( - ({ text, additionalAccesibleText, icon }, ref) => { +export const RawTag = forwardRef( + ({ text, additionalAccesibleText, icon, noBorder }, ref) => { useTextFormatEnforcer(text, { disallowEmpty: true }) return ( diff --git a/lib/experimental/Information/Tags/StatusTag/index.tsx b/lib/experimental/Information/Tags/StatusTag/index.tsx index dbf0227b6..91eaddb90 100644 --- a/lib/experimental/Information/Tags/StatusTag/index.tsx +++ b/lib/experimental/Information/Tags/StatusTag/index.tsx @@ -7,7 +7,7 @@ type Variant = "neutral" | "info" | "positive" | "warning" | "critical" export type StatusVariant = Variant -interface Props { +export interface StatusTagProps { text: string variant: Variant /** @@ -17,7 +17,7 @@ interface Props { additionalAccesibleText?: string } -export const StatusTag = forwardRef( +export const StatusTag = forwardRef( ({ text, additionalAccesibleText, variant }, ref) => { useTextFormatEnforcer(text, { disallowEmpty: true }) diff --git a/lib/experimental/Lists/PersonListItem/index.stories.tsx b/lib/experimental/Lists/PersonListItem/index.stories.tsx new file mode 100644 index 000000000..5353c9202 --- /dev/null +++ b/lib/experimental/Lists/PersonListItem/index.stories.tsx @@ -0,0 +1,80 @@ +import { Check, Placeholder } from "@/icons/app" +import type { Meta, StoryObj } from "@storybook/react" +import { PersonListItem } from "./index" + +const meta = { + title: "Experimental/Lists/PersonListItem", + component: PersonListItem, + tags: ["autodocs"], +} satisfies Meta + +export default meta +type Story = StoryObj + +export const Default: Story = { + args: { + person: { + firstName: "John", + lastName: "Smith", + avatarUrl: "https://i.pravatar.cc/300", + avatarBadge: { + icon: Check, + type: "positive", + }, + }, + description: "Software Engineer", + rightTag: { + text: "Parental leave", + color: "army", + }, + }, +} + +export const WithActions: Story = { + args: { + person: { + firstName: "Sarah", + lastName: "Johnson", + avatarUrl: "https://i.pravatar.cc/300", + }, + description: "Product Designer", + actions: { + primary: { + icon: Placeholder, + label: "Message", + onClick: () => console.log("Primary action clicked"), + }, + secondary: { + icon: Placeholder, + onClick: () => console.log("Secondary action clicked"), + }, + }, + }, +} + +export const WithTags: Story = { + args: { + person: { + firstName: "Emma", + lastName: "Wilson", + avatarUrl: "https://i.pravatar.cc/300", + }, + bottomTags: [ + { text: "Label", icon: Placeholder }, + { text: "Label", icon: Placeholder }, + { text: "Label", icon: Placeholder }, + { text: "Label", icon: Placeholder }, + ], + }, +} + +export const Minimal: Story = { + args: { + person: { + firstName: "Emma", + lastName: "Wilson", + avatarUrl: "https://i.pravatar.cc/300", + }, + description: "Software Engineer", + }, +} diff --git a/lib/experimental/Lists/PersonListItem/index.tsx b/lib/experimental/Lists/PersonListItem/index.tsx new file mode 100644 index 000000000..845ebc3c5 --- /dev/null +++ b/lib/experimental/Lists/PersonListItem/index.tsx @@ -0,0 +1,112 @@ +import { Button } from "@/components/Actions/Button" +import { Icon, IconType } from "@/components/Utilities/Icon" +import { BadgeProps } from "@/experimental/exports" +import { PersonAvatar } from "@/experimental/Information/Avatars/PersonAvatar" +import { DotTag, DotTagProps } from "@/experimental/Information/Tags/DotTag" +import { RawTag, RawTagProps } from "@/experimental/Information/Tags/RawTag" +import { InfoCircle } from "@/icons/app" +import React from "react" + +export type PersonListItemProps = { + person: { + firstName: string + lastName: string + avatarUrl?: string + avatarBadge?: Omit + } + description?: string + bottomTags: Omit[] + rightTag?: DotTagProps + actions?: { + primary?: { + icon?: IconType + label: string + onClick: () => void + } + secondary?: { + icon: IconType + onClick: () => void + } + } + onClick: () => void +} + +export const PersonListItem = React.forwardRef< + HTMLDivElement, + PersonListItemProps +>(({ person, onClick, ...props }, ref) => { + const handleClick = () => { + onClick() + } + + return ( +
+ + +
+
+ {`${person.firstName} ${person.lastName}`} + +
+ {"bottomTags" in props && ( +
+ {props.bottomTags.map((tag, i) => ( + <> + + {i < props.bottomTags.length - 1 && ยท} + + ))} +
+ )} + {"description" in props && props.description && ( +

+ {props.description} +

+ )} +
+ +
+ {"rightTag" in props && props.rightTag && ( + + )} + {"actions" in props && ( +
+ {props.actions?.primary && ( +
+ )} +
+
+ ) +}) + +PersonListItem.displayName = "PersonListItem"