Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: MDS-860 Avatar component docs #24

Merged
merged 47 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
7b4ff5f
First draft Avatar component
salvatorecriscioneweb Dec 18, 2023
317cc72
refactor: Move constants in the specific file
salvatorecriscioneweb Dec 18, 2023
080b611
changed import order
salvatorecriscioneweb Dec 18, 2023
06cc367
fmt + merge from main
salvatorecriscioneweb Dec 18, 2023
b898584
first draft MDS-860 Avatar
salvatorecriscioneweb Dec 18, 2023
7e50c70
MDS-860 Props
salvatorecriscioneweb Dec 18, 2023
b50eda3
Prettified Code!
salvatorecriscioneweb Dec 18, 2023
59dac9b
fix with main Avatar
salvatorecriscioneweb Dec 18, 2023
45ed184
First draft Avatar component
salvatorecriscioneweb Dec 18, 2023
eb02555
refactor: Move constants in the specific file
salvatorecriscioneweb Dec 18, 2023
ba91eee
changed import order
salvatorecriscioneweb Dec 18, 2023
989ee4b
fmt + merge from main
salvatorecriscioneweb Dec 18, 2023
c9e7388
first draft MDS-860 Avatar
salvatorecriscioneweb Dec 18, 2023
2689ce7
Prettified Code!
salvatorecriscioneweb Dec 18, 2023
b6bcf5a
First draft Avatar component
salvatorecriscioneweb Dec 18, 2023
e04be7c
refactor: Move constants in the specific file
salvatorecriscioneweb Dec 18, 2023
c917098
changed import order
salvatorecriscioneweb Dec 18, 2023
11b02b6
fmt + merge from main
salvatorecriscioneweb Dec 18, 2023
d5d93e5
first draft MDS-860 Avatar
salvatorecriscioneweb Dec 18, 2023
1c00b4b
Prettified Code!
salvatorecriscioneweb Dec 18, 2023
c83a108
First draft Avatar component
salvatorecriscioneweb Dec 18, 2023
ee1325c
refactor: Move constants in the specific file
salvatorecriscioneweb Dec 18, 2023
064c8ef
changed import order
salvatorecriscioneweb Dec 18, 2023
5b70bc9
fmt + merge from main
salvatorecriscioneweb Dec 18, 2023
0c3d6de
first draft MDS-860 Avatar
salvatorecriscioneweb Dec 18, 2023
1344b14
Prettified Code!
salvatorecriscioneweb Dec 18, 2023
ce7c369
fix with main Avatar
salvatorecriscioneweb Dec 18, 2023
6c70e97
First draft Avatar component
salvatorecriscioneweb Dec 18, 2023
869d971
refactor: Move constants in the specific file
salvatorecriscioneweb Dec 18, 2023
113138d
changed import order
salvatorecriscioneweb Dec 18, 2023
44e7688
fmt + merge from main
salvatorecriscioneweb Dec 18, 2023
35cb47c
first draft MDS-860 Avatar
salvatorecriscioneweb Dec 18, 2023
c0e665e
Prettified Code!
salvatorecriscioneweb Dec 18, 2023
1b25e51
First draft Avatar component
salvatorecriscioneweb Dec 18, 2023
34e343c
refactor: Move constants in the specific file
salvatorecriscioneweb Dec 18, 2023
94c4007
changed import order
salvatorecriscioneweb Dec 18, 2023
46ca5fa
fmt + merge from main
salvatorecriscioneweb Dec 18, 2023
5236c15
first draft MDS-860 Avatar
salvatorecriscioneweb Dec 18, 2023
172694d
Prettified Code!
salvatorecriscioneweb Dec 18, 2023
15420fe
Update words.txt
salvatorecriscioneweb Dec 19, 2023
c791e19
fix: apply function issue fixed
salvatorecriscioneweb Dec 19, 2023
9ba8ce6
docs Avatar component
salvatorecriscioneweb Dec 19, 2023
fb474c2
MDS-860 Tests e2e
salvatorecriscioneweb Dec 19, 2023
6d9e660
Merge branch 'main' into MDS-860-Avatar-component-doc
salvatorecriscioneweb Dec 19, 2023
781f9db
RTL Test
salvatorecriscioneweb Dec 20, 2023
ac23f76
Merge branch 'main' into MDS-860-Avatar-component-doc
salvatorecriscioneweb Dec 20, 2023
daf5def
Update types.ts
salvatorecriscioneweb Dec 20, 2023
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
6 changes: 4 additions & 2 deletions docs/app/client/authcode/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from "react";
import dynamic from "next/dynamic";
import { Loader } from "@heathmont/moon-base-tw";
import { getExamples } from "@/utils/getExamples";
import { ExampleSectionData } from "@/components/exampleSection/ExampleSection";
import { MainLayout } from "@/components/MainLayout";

import dynamic from "next/dynamic";

import { Loader } from "@heathmont/moon-base-tw";
import { PageHeadComponent } from "@/components/PageHeadComponent";
import { PropsTable } from "@/components/propsTable";

Expand Down
Binary file added docs/app/client/avatar/avatar.webp
Binary file not shown.
Binary file added docs/app/client/avatar/avatar_example.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/app/client/avatar/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The Avatar component is typically used to display images, icons, or initials representing people or other entities.
5 changes: 5 additions & 0 deletions docs/app/client/avatar/descriptions/ActiveStatus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Active Status for your Avatar
---

You can use the component `<Avatar.Status />` as a child of the component `<Avatar />` to display the status of your user, or the availability of a specific resource.
5 changes: 5 additions & 0 deletions docs/app/client/avatar/descriptions/Customization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Customization
---

The `<Avatar />` component supports any CSS classes, enabling it to be fully customizable in all of its aspects.
5 changes: 5 additions & 0 deletions docs/app/client/avatar/descriptions/Default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Default
---

The component can be used by default to display icons out-of-the-box. Just pass them as direct children of the `<Avatar />` component.
5 changes: 5 additions & 0 deletions docs/app/client/avatar/descriptions/Sizes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Different sizes
---

The component `<Avatar />` supports various sizes using the `size` prop, allowing seamless integration with your custom layout.
5 changes: 5 additions & 0 deletions docs/app/client/avatar/descriptions/StatusOrigin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Reposition the Status within the Avatar
---

`<Avatar.Status />` supports flexible positioning. Specify the desired visibility location by using `position` prop.
5 changes: 5 additions & 0 deletions docs/app/client/avatar/descriptions/Variants.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Different content type support
---

The `<Avatar />` component is versatile and can be used in various different scenarios. It supports an icon, text(e.g., the user fullname's initials), or an image by providing the URL through the `imageUrl` prop.
26 changes: 26 additions & 0 deletions docs/app/client/avatar/examples/ActiveStatus.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Avatar } from "@heathmont/moon-core-tw";
import { GenericUser } from "@heathmont/moon-icons-tw";

import image from "../avatar_example.jpeg";

const sharedProps = {
className: "border-beerus border",
};

const ActiveStatus = () => (
<>
<Avatar {...sharedProps}>
<GenericUser className="text-moon-24" />
<Avatar.Status />
</Avatar>
<Avatar {...sharedProps}>
md
<Avatar.Status className="bg-trunks" />
</Avatar>
<Avatar imageUrl={image.src}>
<Avatar.Status />
</Avatar>
</>
);

export default ActiveStatus;
26 changes: 26 additions & 0 deletions docs/app/client/avatar/examples/Customization.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Avatar } from "@heathmont/moon-core-tw";
import { GenericUser } from "@heathmont/moon-icons-tw";

const Customization = () => (
<>
<Avatar className="text-chichi border border-beerus">
<GenericUser className="text-moon-24" />
</Avatar>
<Avatar className="bg-piccolo text-goten">
<GenericUser className="text-moon-24" />
</Avatar>
<Avatar className="rounded-full border border-beerus">
<GenericUser className="text-moon-24" />
</Avatar>
<Avatar className="border border-beerus">
<GenericUser className="text-moon-24" />
<Avatar.Status className="bg-chichi" />
</Avatar>
<Avatar className="border border-beerus">
<GenericUser className="text-moon-24" />
<Avatar.Status className="border-chichi" />
</Avatar>
</>
);

export default Customization;
10 changes: 10 additions & 0 deletions docs/app/client/avatar/examples/Default.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Avatar } from "@heathmont/moon-core-tw";
import { GenericUser } from "@heathmont/moon-icons-tw";

const AvatarDefault = () => (
<Avatar className="border border-beerus">
<GenericUser className="text-moon-24" />
</Avatar>
);

export default AvatarDefault;
60 changes: 60 additions & 0 deletions docs/app/client/avatar/examples/Sizes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { Avatar } from "@heathmont/moon-core-tw";
import { GenericUser } from "@heathmont/moon-icons-tw";
import image from "../avatar_example.jpeg";

const sharedProps = {
className: "border border-beerus",
};

const Example = () => (
<>
<div className="flex flex-wrap items-center justify-around gap-2 w-full">
<Avatar {...sharedProps} size="xs">
<GenericUser className="text-moon-16" />
</Avatar>
<Avatar {...sharedProps} size="sm">
<GenericUser className="text-moon-24" />
</Avatar>
<Avatar {...sharedProps}>
<GenericUser className="text-moon-24" />
</Avatar>
<Avatar {...sharedProps} size="lg">
<GenericUser className="text-moon-24" />
</Avatar>
<Avatar {...sharedProps} size="xl">
<GenericUser className="text-moon-24" />
</Avatar>
<Avatar {...sharedProps} size="2xl">
<GenericUser className="text-moon-32" />
</Avatar>
</div>
<div className="flex flex-wrap items-center justify-around gap-2 w-full">
<Avatar {...sharedProps} size="xs">
xs
</Avatar>
<Avatar {...sharedProps} size="sm">
sm
</Avatar>
<Avatar {...sharedProps}>md</Avatar>
<Avatar {...sharedProps} size="lg">
lg
</Avatar>
<Avatar {...sharedProps} size="xl">
xl
</Avatar>
<Avatar {...sharedProps} size="2xl">
2xl
</Avatar>
</div>
<div className="flex flex-wrap items-center justify-around gap-2 w-full">
<Avatar imageUrl={image.src} size="xs" />
<Avatar imageUrl={image.src} size="sm" />
<Avatar imageUrl={image.src} />
<Avatar imageUrl={image.src} size="lg" />
<Avatar imageUrl={image.src} size="xl" />
<Avatar imageUrl={image.src} size="2xl" />
</div>
</>
);

export default Example;
25 changes: 25 additions & 0 deletions docs/app/client/avatar/examples/StatusOrigin.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Avatar } from "@heathmont/moon-core-tw";
import { GenericUser } from "@heathmont/moon-icons-tw";

const StatusOrigin = () => (
<>
<Avatar className="border border-beerus">
<GenericUser className="text-moon-24" />
<Avatar.Status position={{ vertical: "top", horizontal: "right" }} />
</Avatar>
<Avatar className="border border-beerus">
<GenericUser className="text-moon-24" />
<Avatar.Status position={{ vertical: "top", horizontal: "left" }} />
</Avatar>
<Avatar className="border border-beerus">
<GenericUser className="text-moon-24" />
<Avatar.Status />
</Avatar>
<Avatar className="border border-beerus">
<GenericUser className="text-moon-24" />
<Avatar.Status position={{ vertical: "bottom", horizontal: "left" }} />
</Avatar>
</>
);

export default StatusOrigin;
15 changes: 15 additions & 0 deletions docs/app/client/avatar/examples/Variants.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Avatar } from "@heathmont/moon-core-tw";
import { GenericUser } from "@heathmont/moon-icons-tw";
import image from "../avatar_example.jpeg";

const Variants = () => (
<>
<Avatar className="border-beerus border">
<GenericUser className="text-moon-24" />
</Avatar>
<Avatar className="border-beerus border">md</Avatar>
<Avatar imageUrl={image.src} />
</>
);

export default Variants;
97 changes: 97 additions & 0 deletions docs/app/client/avatar/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import React from "react";
import { getExamples } from "@/utils/getExamples";
import { ExampleSectionData } from "@/components/exampleSection/ExampleSection";
import { MainLayout } from "@/components/MainLayout";

import dynamic from "next/dynamic";

import { Loader } from "@heathmont/moon-base-tw";
import { PageHeadComponent } from "@/components/PageHeadComponent";
import { avatarProps, avatarStatusProps } from "./props";
import image from "./avatar.webp";
import { PropsTable } from "@/components/propsTable";

const TITLE = "Avatar";
const ordered: string[] = [
"Default",
"Variants",
"Sizes",
"ActiveStatus",
"StatusOrigin",
"Customization",
];

export default async function AuthCodePage(request: {
searchParams: { raw: string };
}) {
const {
client: {
avatar: { description, descriptions: exampleDescriptions, examples },
},
} = await getExamples();

const searchParam = request?.searchParams?.raw;
const isMockup = !!searchParam && Object.keys(examples).includes(searchParam);

if (isMockup) {
const Component = dynamic(
() => import(`@/app/client/avatar/examples/${searchParam}`),
{
loading: () => <Loader />,
ssr: false,
},
);
return (
<div className="p-4" id="playwright-test">
<Component />
</div>
);
}

return (
<MainLayout
isMockup={isMockup}
componentName="avatar"
contentSidebar={ordered}
>
<div className="flex flex-col gap-4 text-moon-14 pb-20">
<PageHeadComponent
title={TITLE}
description={description}
tags={["ARIA", "RTL"]}
image={image}
/>

<ExampleSectionData
componentName="avatar"
client={{
description,
descriptions: exampleDescriptions,
examples,
}}
data={ordered}
/>
<PropsTable
title="Avatar props"
description={
<p>
These are props specific to the{" "}
<span className="text-frieza">Avatar</span> component:
</p>
}
data={avatarProps}
/>
<PropsTable
title="Avatar.Status props"
description={
<p>
These are props specific to the{" "}
<span className="text-frieza">Avatar.Status</span> component:
</p>
}
data={avatarStatusProps}
/>
</div>
</MainLayout>
);
}
32 changes: 32 additions & 0 deletions docs/app/client/avatar/props.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { PropsTableProp } from "@/types";

export const avatarProps: PropsTableProp[] = [
{
name: "className",
description: "Tailwind classes for customization",
type: ["string"],
},
{
name: "imageUrl",
description: "Path to the image",
type: ["string"],
},
{
name: "size",
description: "Size of avatar",
type: ["xs", "sm", "md", "lg", "xl", "2xl"],
defaultState: "md",
},
];
export const avatarStatusProps: PropsTableProp[] = [
{
name: "className",
description: "Tailwind classes for customization",
type: ["string"],
},
{
name: "position",
description: "Position for status indicator",
type: ["{ vertical: 'top' | 'bottom', horizontal: 'left' | 'right' }"],
},
];
19 changes: 19 additions & 0 deletions docs/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,25 @@ export type Examples = {
"WithManualSubmit": "string"
}
},
"avatar": {
"description": "string",
"descriptions": {
"ActiveStatus": "string",
"Customization": "string",
"Default": "string",
"Sizes": "string",
"StatusOrigin": "string",
"Variants": "string"
},
"examples": {
"ActiveStatus": "string",
"Customization": "string",
"Default": "string",
"Sizes": "string",
"StatusOrigin": "string",
"Variants": "string"
}
},
"breadcrumb": {
"description": "string",
"descriptions": {
Expand Down
5 changes: 5 additions & 0 deletions docs/components/MDX.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ const defaultComponents: ComponentProps<any> = {
{props.children}
</ul>
),
code: (props: HTMLProps<HTMLSpanElement>) => (
<code {...props} className="text-chichi bg-gohan">
{props.children}
</code>
),
};

export function MDX({
Expand Down
Loading