-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f293e1c
commit 3034697
Showing
7 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
design-system/molecules/avatar-description/adapters/default/default.adapter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Avatar } from "@/design-system/atoms/avatar"; | ||
import { Typo } from "@/design-system/atoms/typo"; | ||
|
||
import { cn } from "@/shared/helpers/cn"; | ||
|
||
import { AvatarDescriptionPort } from "../../avatar-description.types"; | ||
import { AvatarDescriptionDefaultVariants } from "./default.variants"; | ||
|
||
export function AvatarDescriptionDefaultAdapter({ | ||
avatarProps, | ||
labelProps, | ||
descriptionProps, | ||
classNames, | ||
}: AvatarDescriptionPort) { | ||
const slots = AvatarDescriptionDefaultVariants(); | ||
|
||
return ( | ||
<div className={cn(slots.base(), classNames?.base)}> | ||
<Avatar {...avatarProps} size={"m"} /> | ||
<div className={"grid"}> | ||
<Typo {...labelProps} size={"xs"} weight={"medium"} color={"text-1"} /> | ||
{descriptionProps ? <Typo {...labelProps} size={"xxs"} weight={"regular"} color={"text-2"} /> : null} | ||
</div> | ||
</div> | ||
); | ||
} |
9 changes: 9 additions & 0 deletions
9
design-system/molecules/avatar-description/adapters/default/default.variants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { tv } from "tailwind-variants"; | ||
|
||
export const AvatarDescriptionDefaultVariants = tv({ | ||
slots: { | ||
base: "flex gap-1", | ||
}, | ||
variants: {}, | ||
defaultVariants: {}, | ||
}); |
28 changes: 28 additions & 0 deletions
28
design-system/molecules/avatar-description/avatar-description.loading.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { ComponentProps } from "react"; | ||
|
||
import { AvatarLoading } from "@/design-system/atoms/avatar/avatar.loading"; | ||
import { Skeleton } from "@/design-system/atoms/skeleton"; | ||
import { AvatarDescriptionDefaultVariants } from "@/design-system/molecules/avatar-description/adapters/default/default.variants"; | ||
import { AvatarDescriptionPort } from "@/design-system/molecules/avatar-description/avatar-description.types"; | ||
|
||
import { cn } from "@/shared/helpers/cn"; | ||
|
||
export function AvatarDescriptionLoading({ | ||
avatarShape, | ||
classNames, | ||
}: { | ||
avatarShape?: ComponentProps<typeof AvatarLoading>["shape"]; | ||
classNames?: AvatarDescriptionPort["classNames"]; | ||
}) { | ||
const slots = AvatarDescriptionDefaultVariants(); | ||
|
||
return ( | ||
<div className={cn(slots.base(), classNames?.base)}> | ||
<AvatarLoading size={"m"} shape={avatarShape} /> | ||
<div className={"flex flex-col justify-between"}> | ||
<Skeleton classNames={{ base: "h-3 w-20" }} /> | ||
<Skeleton classNames={{ base: "h-3 w-10" }} /> | ||
</div> | ||
</div> | ||
); | ||
} |
58 changes: 58 additions & 0 deletions
58
design-system/molecules/avatar-description/avatar-description.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { AvatarDescriptionLoading } from "@/design-system/molecules/avatar-description/avatar-description.loading"; | ||
|
||
import { AvatarDescription } from "./variants/avatar-description-default"; | ||
|
||
type Story = StoryObj<typeof AvatarDescription>; | ||
|
||
const meta: Meta<typeof AvatarDescription> = { | ||
component: AvatarDescription, | ||
title: "Molecules/AvatarDescription", | ||
tags: ["autodocs"], | ||
parameters: { | ||
backgrounds: { | ||
default: "black", | ||
values: [{ name: "black", value: "#05051E" }], | ||
}, | ||
}, | ||
}; | ||
|
||
export const Default: Story = { | ||
parameters: { | ||
docs: { | ||
source: { code: "<AvatarDescription />" }, | ||
}, | ||
}, | ||
render: args => { | ||
return ( | ||
<div className="flex w-full items-center gap-2"> | ||
<AvatarDescription | ||
{...args} | ||
avatarProps={{ shape: "square" }} | ||
labelProps={{ children: "Label" }} | ||
descriptionProps={{ children: "Description" }} | ||
/> | ||
|
||
<AvatarDescription {...args} avatarProps={{ shape: "square" }} labelProps={{ children: "Label" }} /> | ||
</div> | ||
); | ||
}, | ||
}; | ||
|
||
export const Loading: Story = { | ||
parameters: { | ||
docs: { | ||
source: { code: "<AvatarDescriptionLoading />" }, | ||
}, | ||
}, | ||
render: () => { | ||
return ( | ||
<div className="flex w-full items-center gap-2"> | ||
<AvatarDescriptionLoading avatarShape={"square"} /> | ||
</div> | ||
); | ||
}, | ||
}; | ||
|
||
export default meta; |
17 changes: 17 additions & 0 deletions
17
design-system/molecules/avatar-description/avatar-description.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ComponentProps } from "react"; | ||
|
||
import { AvatarPort } from "@/design-system/atoms/avatar"; | ||
import { Typo } from "@/design-system/atoms/typo"; | ||
|
||
interface Variants {} | ||
|
||
interface ClassNames { | ||
base: string; | ||
} | ||
|
||
export interface AvatarDescriptionPort extends Partial<Variants> { | ||
avatarProps: AvatarPort; | ||
labelProps: ComponentProps<typeof Typo>; | ||
descriptionProps?: ComponentProps<typeof Typo>; | ||
classNames?: Partial<ClassNames>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from "./variants/avatar-description-default"; | ||
export * from "./avatar-description.types"; | ||
export * from "./avatar-description.loading"; |
8 changes: 8 additions & 0 deletions
8
design-system/molecules/avatar-description/variants/avatar-description-default.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { withComponentAdapter } from "@/design-system/helpers/with-component-adapter"; | ||
|
||
import { AvatarDescriptionDefaultAdapter } from "../adapters/default/default.adapter"; | ||
import { AvatarDescriptionPort } from "../avatar-description.types"; | ||
|
||
export function AvatarDescription(props: AvatarDescriptionPort) { | ||
return withComponentAdapter<AvatarDescriptionPort>(AvatarDescriptionDefaultAdapter)(props); | ||
} |