-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: Adding avatar component for sistent project #6221
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
Closed
Closed
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
076c93c
feat: Adding avatar component for sistent project
Jaishree2310 05b9349
fix: eslint issues and unused component
Jaishree2310 2c4c64a
chore: updated the content.js
Jaishree2310 6d90004
fix: codeblock removed
Jaishree2310 0eb9ce6
feat: few changes made
Jaishree2310 56b622c
Code-block file added
Jaishree2310 00f803c
avatar-group removed empty
Jaishree2310 611cdcd
feat: Review changes made
Jaishree2310 da9e13f
details added
Jaishree2310 a4aa836
feat: tabs ui added in guidance
Jaishree2310 101422d
fix lint issue
Jaishree2310 6ceca58
tabs for overview in guidance
Jaishree2310 113638d
comments removed
Jaishree2310 f6cbdae
package.json resolved
Jaishree2310 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
20 changes: 20 additions & 0 deletions
20
src/sections/Projects/Sistent/components/avatar/code-block.js
This file contains hidden or 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,20 @@ | ||
| import React, { useState } from "react"; | ||
| import Code from "../../../../../components/CodeBlock"; | ||
|
|
||
| export const CodeBlock = ({ name, code }) => { | ||
Jaishree2310 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const [showCode, setShowCode] = useState(false); | ||
| const onChange = () => { | ||
| setShowCode((prev) => !prev); | ||
| }; | ||
| return ( | ||
| <div className="show-code"> | ||
| <input type="checkbox" name={name} id={name} onChange={onChange} /> | ||
| <label htmlFor={name} className="label"> | ||
| Show Code | ||
| </label> | ||
| {showCode && ( | ||
| <Code codeString={code} language="javascript" /> | ||
| )} | ||
| </div> | ||
| ); | ||
| }; | ||
Jaishree2310 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,71 @@ | ||
| import React from "react"; | ||
| import { Avatar, SistentThemeProvider } from "@layer5/sistent"; | ||
| import { SistentLayout } from "../../sistent-layout"; | ||
| import { CodeBlock } from "./code-block"; | ||
| import TabButton from "../../../../../reusecore/Button"; | ||
| import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; | ||
|
|
||
| const codes = [ | ||
| ` <SistentThemeProvider> | ||
| <Avatar src="https://via.placeholder.com/150" alt="User Avatar" size="small" /> | ||
| </SistentThemeProvider>`, | ||
| ` <SistentThemeProvider> | ||
| <Avatar src="https://via.placeholder.com/150" alt="User Avatar" size="medium" /> | ||
| </SistentThemeProvider>`, | ||
| ` <SistentThemeProvider> | ||
| <Avatar src="https://via.placeholder.com/150" alt="User Avatar" size="large" /> | ||
| </SistentThemeProvider>` | ||
| ]; | ||
|
|
||
| const AvatarComponent = () => { | ||
| const { isDark } = useStyledDarkMode(); | ||
|
|
||
| return ( | ||
| <SistentLayout title="Avatar"> | ||
| <div className="content"> | ||
| <a id="Identity"> | ||
| <h2>Avatar</h2> | ||
| </a> | ||
| <p> | ||
| The Avatar component is used to represent a user profile with an image or initials. | ||
| </p> | ||
| <div className="filterBtns"> | ||
| <TabButton title="Overview" /> | ||
| <TabButton title="Guidance" /> | ||
| <TabButton title="Code" /> | ||
| </div> | ||
| <div className="main-content"> | ||
| <h3>Small Avatar</h3> | ||
| <div className="showcase"> | ||
| <div className="items"> | ||
| <SistentThemeProvider initialMode={isDark ? "dark" : "light"}> | ||
| <Avatar src="https://via.placeholder.com/150" alt="User Avatar" size="small" /> | ||
| </SistentThemeProvider> | ||
| </div> | ||
| <CodeBlock name="small-avatar" code={codes[0]} /> | ||
| </div> | ||
| <h3>Medium Avatar</h3> | ||
| <div className="showcase"> | ||
| <div className="items"> | ||
| <SistentThemeProvider initialMode={isDark ? "dark" : "light"}> | ||
| <Avatar src="https://via.placeholder.com/150" alt="User Avatar" size="medium" /> | ||
| </SistentThemeProvider> | ||
| </div> | ||
| <CodeBlock name="medium-avatar" code={codes[1]} /> | ||
| </div> | ||
| <h3>Large Avatar</h3> | ||
| <div className="showcase"> | ||
| <div className="items"> | ||
| <SistentThemeProvider initialMode={isDark ? "dark" : "light"}> | ||
| <Avatar src="https://via.placeholder.com/150" alt="User Avatar" size="large" /> | ||
| </SistentThemeProvider> | ||
| </div> | ||
| <CodeBlock name="large-avatar" code={codes[2]} /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </SistentLayout> | ||
| ); | ||
| }; | ||
|
|
||
| export default AvatarComponent; |
41 changes: 41 additions & 0 deletions
41
src/sections/Projects/Sistent/components/avatar/guidance.js
This file contains hidden or 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,41 @@ | ||
| import React from "react"; | ||
| import { SistentLayout } from "../../sistent-layout"; | ||
|
|
||
| const AvatarGuidance = () => { | ||
| return ( | ||
| <SistentLayout title="Avatar Guidance"> | ||
| <div className="content"> | ||
| <a id="Identity"> | ||
| <h2>Avatar Usage Guidelines</h2> | ||
| </a> | ||
| <p> | ||
| The Avatar component is used to represent a user with an image, initials, or an icon. It is commonly used in user profiles, chat applications, and dashboards. | ||
| </p> | ||
| <h3>Best Practices</h3> | ||
| <ul> | ||
| <li>Ensure the avatar is visually distinguishable and represents the user clearly.</li> | ||
| <li>Use high-quality images for a professional appearance.</li> | ||
| <li>Fallback to initials or a placeholder image when the user image is unavailable.</li> | ||
| <li>Keep the size appropriate to the UI layout (e.g., small for chat bubbles, large for profile pages).</li> | ||
| </ul> | ||
| <h3>Accessibility Considerations</h3> | ||
| <ul> | ||
| <li>Provide an <code>alt</code> attribute describing the avatar for screen readers.</li> | ||
| <li>Ensure sufficient contrast between the avatar and background.</li> | ||
| <li>Use tooltips or labels to provide additional context when necessary.</li> | ||
| </ul> | ||
| <h3>Examples of Usage</h3> | ||
| <p> | ||
| Avatars can be used in multiple scenarios, including: | ||
| </p> | ||
| <ul> | ||
| <li>Displaying user profiles in a navigation bar.</li> | ||
| <li>Representing senders in a messaging interface.</li> | ||
| <li>Showing participants in a collaborative workspace.</li> | ||
| </ul> | ||
| </div> | ||
| </SistentLayout> | ||
| ); | ||
| }; | ||
|
|
||
| export default AvatarGuidance; |
105 changes: 105 additions & 0 deletions
105
src/sections/Projects/Sistent/components/avatar/index.js
Jaishree2310 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,105 @@ | ||
| import React from "react"; | ||
| import { navigate } from "gatsby"; | ||
| import { useLocation } from "@reach/router"; | ||
|
|
||
| import { SistentThemeProvider, Avatar } from "@layer5/sistent"; | ||
| import TabButton from "../../../../../reusecore/Button"; | ||
| import { SistentLayout } from "../../sistent-layout"; | ||
| import { Row } from "../../../../../reusecore/Layout"; | ||
| import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; | ||
|
|
||
| const SistentAvatar = () => { | ||
| const location = useLocation(); | ||
| const { isDark } = useStyledDarkMode(); | ||
|
|
||
| return ( | ||
| <SistentLayout title="Avatar"> | ||
| <div className="content"> | ||
| <a id="Identity"> | ||
| <h2>Avatar</h2> | ||
| </a> | ||
| <p> | ||
| Avatars are used to represent users and entities. They can display | ||
| images, icons, or initials based on the context. | ||
| </p> | ||
| <div className="filterBtns"> | ||
| <TabButton | ||
| className={ | ||
| location.pathname === "/projects/sistent/components/avatar" | ||
| ? "active" | ||
| : "" | ||
| } | ||
| onClick={() => navigate("/projects/sistent/components/avatar")} | ||
| title="Overview" | ||
| /> | ||
| <TabButton | ||
| className={ | ||
| location.pathname === | ||
| "/projects/sistent/components/avatar/guidance" | ||
| ? "active" | ||
| : "" | ||
| } | ||
| onClick={() => | ||
| navigate("/projects/sistent/components/avatar/guidance") | ||
| } | ||
| title="Guidance" | ||
| /> | ||
| <TabButton | ||
| className={ | ||
| location.pathname === "/projects/sistent/components/avatar/code" | ||
| ? "active" | ||
| : "" | ||
| } | ||
| onClick={() => navigate("/projects/sistent/components/avatar/code")} | ||
| title="Code" | ||
| /> | ||
| </div> | ||
| <div className="main-content"> | ||
| <h3>Image Avatar</h3> | ||
| <p> | ||
| Image avatars display profile pictures, logos, or other user | ||
| images. | ||
| </p> | ||
| <Row $Hcenter className="image-container"> | ||
| <SistentThemeProvider initialMode={isDark ? "dark" : "light"}> | ||
| <Avatar src="https://via.placeholder.com/150" alt="User Avatar" /> | ||
| </SistentThemeProvider> | ||
| </Row> | ||
| <h3>Initials Avatar</h3> | ||
| <p> | ||
| When an image is unavailable, avatars can display user initials. | ||
| </p> | ||
| <Row $Hcenter className="image-container"> | ||
| <SistentThemeProvider initialMode={isDark ? "dark" : "light"}> | ||
| <Avatar>JS</Avatar> | ||
| </SistentThemeProvider> | ||
| </Row> | ||
| <h3>Icon Avatar</h3> | ||
| <p> | ||
| Avatars can also use icons when representing users or objects. | ||
| </p> | ||
| <Row $Hcenter className="image-container"> | ||
| <SistentThemeProvider initialMode={isDark ? "dark" : "light"}> | ||
| <Avatar> | ||
| <span role="img" aria-label="user-icon"> | ||
| 👤 | ||
| </span> | ||
| </Avatar> | ||
| </SistentThemeProvider> | ||
| </Row> | ||
| <h3>Sizes</h3> | ||
| <p>Avatars come in different sizes to suit various use cases.</p> | ||
| <Row $Hcenter className="image-container"> | ||
| <SistentThemeProvider initialMode={isDark ? "dark" : "light"}> | ||
| <Avatar src="https://via.placeholder.com/150" alt="Small" sx={{ width: 32, height: 32 }} /> | ||
| <Avatar src="https://via.placeholder.com/150" alt="Medium" sx={{ width: 48, height: 48 }} /> | ||
| <Avatar src="https://via.placeholder.com/150" alt="Large" sx={{ width: 64, height: 64 }} /> | ||
| </SistentThemeProvider> | ||
| </Row> | ||
| </div> | ||
| </div> | ||
| </SistentLayout> | ||
| ); | ||
| }; | ||
|
|
||
| export default SistentAvatar; |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.