|
| 1 | +import React, { useState } from "react"; |
| 2 | + |
| 3 | +import { Avatar, SistentThemeProvider } from "@sistent/sistent"; |
| 4 | +import { SistentLayout } from "../../sistent-layout"; |
| 5 | +import TabButton from "../../../../../reusecore/Button"; |
| 6 | +import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; |
| 7 | +import { CodeBlock } from "../button/code-block"; |
| 8 | +import user from "../../../../../assets/images/sistent/placeholder/user.webp"; |
| 9 | +const AvatarComponent = () => { |
| 10 | + const { isDark } = useStyledDarkMode(); |
| 11 | + const [activeTab, setActiveTab] = useState("Overview"); |
| 12 | + |
| 13 | + const codes = [ |
| 14 | + "<Avatar src='/path/to/user-image.jpg' alt='User Name' />", |
| 15 | + `<Avatar> |
| 16 | + JD |
| 17 | +</Avatar>`, |
| 18 | + // }, |
| 19 | + // { |
| 20 | + // title: "Icon Avatar", |
| 21 | + // description: "Use icons for generic representation", |
| 22 | + // code: ( |
| 23 | + // <Avatar> |
| 24 | + // <FaUser /> |
| 25 | + // </Avatar> |
| 26 | + // ), |
| 27 | + // snippet: `<Avatar> |
| 28 | + // <UserIcon /> |
| 29 | + // </Avatar>`, |
| 30 | + // }, |
| 31 | + // { |
| 32 | + // title: "Sized Avatars", |
| 33 | + // description: "Adjust avatar sizes for different contexts", |
| 34 | + // code: `<Avatar size="small" /> |
| 35 | + // <Avatar size="medium" /> |
| 36 | + // <Avatar size="large" />`, |
| 37 | + // }, |
| 38 | + // { |
| 39 | + // title: "Custom Styling", |
| 40 | + // description: "Apply custom styles and themes", |
| 41 | + // code: `<Avatar |
| 42 | + // src="/image.jpg" |
| 43 | + // sx={{ |
| 44 | + // border: 'px solid primary.main', |
| 45 | + // boxShadow: 2 |
| 46 | + // }} |
| 47 | + // />`, |
| 48 | + // }, |
| 49 | + ]; |
| 50 | + return ( |
| 51 | + <SistentLayout title="Avatar"> |
| 52 | + <div className="content"> |
| 53 | + <a id="Identity"> |
| 54 | + <h2>Avatar Component</h2> |
| 55 | + </a> |
| 56 | + <div className="filterBtns"> |
| 57 | + {"Overview Guidance Code".split(" ").map((tab) => ( |
| 58 | + <TabButton |
| 59 | + key={tab} |
| 60 | + title={tab} |
| 61 | + className={activeTab === tab ? "active" : ""} |
| 62 | + onClick={() => setActiveTab(tab)} |
| 63 | + /> |
| 64 | + ))} |
| 65 | + </div> |
| 66 | + <p> |
| 67 | + The Avatar component provides a flexible visual representation of |
| 68 | + users or entities across digital interfaces, supporting images, |
| 69 | + initials, and icons. |
| 70 | + </p> |
| 71 | + |
| 72 | + {activeTab === "Code" && ( |
| 73 | + <div className="code-examples"> |
| 74 | + <h3>Avatar Implementation Variants</h3> |
| 75 | + <SistentThemeProvider initialMode={isDark ? "dark" : "light"}> |
| 76 | + <h4>Image Avatar</h4> |
| 77 | + <p>Display user profile images</p> |
| 78 | + <div className="showcase"> |
| 79 | + <div className="items"> |
| 80 | + <Avatar src={user} alt="User Name" /> |
| 81 | + </div> |
| 82 | + <CodeBlock name="image-avatar" code={codes[0]} /> |
| 83 | + </div> |
| 84 | + |
| 85 | + <h4>Initials Avatar</h4> |
| 86 | + <p>Use initials when image is unavailable</p> |
| 87 | + <div className="showcase"> |
| 88 | + <div className="items"> |
| 89 | + <Avatar>JD</Avatar> |
| 90 | + </div> |
| 91 | + <CodeBlock name="initials-avatar" code={codes[1]} /> |
| 92 | + </div> |
| 93 | + </SistentThemeProvider> |
| 94 | + </div> |
| 95 | + )} |
| 96 | + </div> |
| 97 | + </SistentLayout> |
| 98 | + ); |
| 99 | +}; |
| 100 | + |
| 101 | +export default AvatarComponent; |
0 commit comments