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

Molecule added for Profile Card #165

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

Rohan27s
Copy link

@Rohan27s Rohan27s commented Jul 25, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a visually enhanced ProfileCard component for displaying teacher and student profiles.
    • Added new CSS styles for various profile card designs, including gold, silver, and bronze categories.
    • Implemented Storybook stories for visualizing different configurations of the ProfileCard.
  • Bug Fixes

    • Improved fallback mechanisms for missing data in profile displays, ensuring UI functionality remains intact.

Copy link

vercel bot commented Jul 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
stencil-ui ❌ Failed (Inspect) Jul 25, 2024 8:27am

Copy link

coderabbitai bot commented Jul 25, 2024

Walkthrough

The recent changes introduce a new set of components and styles for profile cards, enhancing the UI for displaying teacher and student profiles. The updates include the addition of CSS styles for different profile types, a React component that leverages these styles, and Storybook stories to demonstrate various configurations. This creates a visually engaging and flexible framework for representing user profiles, ensuring a modern and consistent design.

Changes

Files Change Summary
packages/molecules/src/profile-card/index.module.css Introduced styles for profile cards, including base styles and specific designs for teachers and students. Added utilities for text and layout organization.
packages/molecules/src/profile-card/index.stories.ts Created Storybook configuration for ProfileCard, defining stories for teacher and student profiles with relevant props and layout specifications.
packages/molecules/src/profile-card/index.tsx Implemented the ProfileCard React component, supporting conditional rendering for different user profiles and ensuring responsive design with Material-UI.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant ProfileCard
    User->>App: Request Profile Card
    App->>ProfileCard: Pass User Details
    ProfileCard->>ProfileCard: Render Profile Based on Type
    ProfileCard-->>App: Display Profile Card
    App-->>User: Show Profile Card
Loading

🐰 Hop along with joy, let's cheer for the change,
Profile cards now shine, in style they'll arrange.
For teachers and students, each tale they will tell,
With colors and gradients, they surely will dwell!
So leap and rejoice, in this vibrant new land,
A world full of profiles, all magically planned! 🌈


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cdfcd7d and c1a8b9b.

Files ignored due to path filters (4)
  • packages/molecules/%SystemDrive%/ProgramData/Microsoft/Windows/Caches/cversions.2.db is excluded by !**/*.db
  • packages/molecules/%SystemDrive%/ProgramData/Microsoft/Windows/Caches/{4819D7AC-741E-4EB8-9922-4572D3973EAB}.2.ver0x0000000000000001.db is excluded by !**/*.db
  • packages/molecules/%SystemDrive%/ProgramData/Microsoft/Windows/Caches/{6AF0698E-D558-4F6E-9B3C-3716689AF493}.2.ver0x0000000000000001.db is excluded by !**/*.db
  • packages/molecules/%SystemDrive%/ProgramData/Microsoft/Windows/Caches/{DDF571F2-BE98-426D-8288-1A9A39C3FDA2}.2.ver0x0000000000000001.db is excluded by !**/*.db
Files selected for processing (3)
  • packages/molecules/src/profile-card/index.module.css (1 hunks)
  • packages/molecules/src/profile-card/index.stories.ts (1 hunks)
  • packages/molecules/src/profile-card/index.tsx (1 hunks)
Additional comments not posted (23)
packages/molecules/src/profile-card/index.stories.ts (5)

1-17: LGTM!

The meta object is correctly defined and satisfies the Meta type.


22-31: LGTM!

The TeacherGold story is correctly defined and uses appropriate arguments.


33-42: LGTM!

The TeacherSilver story is correctly defined and uses appropriate arguments.


44-53: LGTM!

The TeacherBronze story is correctly defined and uses appropriate arguments.


55-66: LGTM!

The Student story is correctly defined and uses appropriate arguments.

packages/molecules/src/profile-card/index.module.css (14)

3-7: LGTM!

The .profileCard style is correctly defined and uses appropriate properties.


9-16: LGTM!

The .teacherCard style is correctly defined and uses appropriate properties.


28-33: LGTM!

The .goldCard style is correctly defined and uses appropriate properties.


35-41: LGTM!

The .silverCard style is correctly defined and uses appropriate properties.


43-49: LGTM!

The .bronzeCard style is correctly defined and uses appropriate properties.


51-54: LGTM!

The .goldName style is correctly defined and uses appropriate properties.


56-60: LGTM!

The .silverName style is correctly defined and uses appropriate properties.


62-66: LGTM!

The .bronzeName style is correctly defined and uses appropriate properties.


68-75: LGTM!

The .TeacherName style is correctly defined and uses appropriate properties.


77-84: LGTM!

The .studentName style is correctly defined and uses appropriate properties.


86-89: LGTM!

The .line style is correctly defined and uses appropriate properties.


91-95: LGTM!

The .goldLine style is correctly defined and uses appropriate properties.


97-101: LGTM!

The .silverLine style is correctly defined and uses appropriate properties.


103-107: LGTM!

The .bronzeLine style is correctly defined and uses appropriate properties.

packages/molecules/src/profile-card/index.tsx (4)

1-5: LGTM!

The imports are correctly defined and necessary for the component.


7-29: LGTM!

The type definitions are correctly defined and necessary for the component.


39-46: LGTM!

The getImageURL function is correctly defined and uses appropriate logic.


231-246: LGTM!

The DetailItem component is correctly defined and uses appropriate properties.

Comment on lines +18 to +26
.studentCardContainer {
box-shadow: 0px 0px 6px 0px rgba(47, 50, 147, 0.5);

box-shadow: 0 0 9px 0 rgba(0, 0, 0, 0.25)!important;

padding: 12px;
border-radius: 8px;
border: 3px solid #e0e0e0;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove redundant box-shadow property.

The .studentCardContainer style has a redundant box-shadow property on line 19.

-    box-shadow: 0px 0px 6px 0px rgba(47, 50, 147, 0.5);
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.studentCardContainer {
box-shadow: 0px 0px 6px 0px rgba(47, 50, 147, 0.5);
box-shadow: 0 0 9px 0 rgba(0, 0, 0, 0.25)!important;
padding: 12px;
border-radius: 8px;
border: 3px solid #e0e0e0;
}
.studentCardContainer {
box-shadow: 0 0 9px 0 rgba(0, 0, 0, 0.25)!important;
padding: 12px;
border-radius: 8px;
border: 3px solid #e0e0e0;
}

Comment on lines +31 to +229
>
{block}
</Typography>
</Box>
</>
)}
{profileType === "student" && studentDetails && (
<>
<Box display={"flex"} alignItems={"center"}>
जनपद :
<Typography
component="p"
sx={{
fontWeight: "600",
color: "#2F3293",
fontSize: "14px",
marginLeft: "8px",
}}
>
{district || "AGRA"}
</Typography>
</Box>
<Box display={"flex"} alignItems={"center"} margin={"10px 0"}>
UDISE:
<Typography
component="p"
sx={{
fontWeight: "600",
color: "#2F3293",
fontSize: "14px",
marginLeft: "8px",
}}
>
{studentDetails.id}
</Typography>
</Box>
<Box display={"flex"} alignItems={"center"}>
आखरी आकलन :
<Typography
component="p"
sx={{
fontWeight: "600",
color: "#2F3293",
fontSize: "14px",
marginLeft: "8px",
}}
>
{studentDetails.roll_no}
</Typography>
</Box>
</>
)}
</Box>
<Box
margin={"auto"}
width={"50%"}
display={"flex"}
flexDirection={"column"}
alignItems={"center"}
justifyContent={"center"}
>
<Box
display={"flex"}
alignItems={"center"}
justifyContent={"center"}
width={"100%"}
>
{typeof window === "undefined" ? (
<img
className={styles.image}
src={imageURL}
width={profileType === "teacher" ? 47 : 69}
height={profileType === "teacher" ? 74 : 101}
alt={profileType === "teacher" ? "सर्व शिक्षा अभियान" : "icon"}
/>
) : (
<Image
className={styles.image}
src={imageURL}
width={profileType === "teacher" ? 47 : 69}
height={profileType === "teacher" ? 74 : 101}
alt={profileType === "teacher" ? "सर्व शिक्षा अभियान" : "icon"}
/>
)}
</Box>
{profileType === "teacher" && (
<Typography
component="p"
className={styles.bottomText}
fontWeight={600}
fontSize={"12px"}
>
मई में आपके 50+ छात्र निपुण हैं 🎉
</Typography>
)}
</Box>
</Box>
</Card>
);
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle localStorage usage more gracefully.

The use of localStorage directly in the component can cause issues during server-side rendering. Consider using a useEffect hook to handle this.

-  const UDISE = localStorage.getItem("udise");
+  const [UDISE, setUDISE] = React.useState<string | null>(null);
+  React.useEffect(() => {
+    setUDISE(localStorage.getItem("udise"));
+  }, []);
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const ProfileCard = ({
name,
profileType,
district,
block,
studentDetails,
teacherDetails,
}: Props) => {
const getImageURL = () => {
if (profileType === "teacher") {
return teacherDetails?.imageUrl || "";
} else if (profileType === "student") {
return studentDetails?.imageUrl || "";
}
return "";
};
const imageURL = getImageURL();
const UDISE = localStorage.getItem("udise");
return (
<Card
className={clsx(styles.profileCard, {
[styles.teacherCard]: profileType === "teacher",
[styles.studentCardContainer]: profileType === "student",
[styles.goldCard]: teacherDetails?.type === "gold",
[styles.silverCard]: teacherDetails?.type === "silver",
[styles.bronzeCard]: teacherDetails?.type === "bronze",
})}
>
<Typography
component="p"
className={clsx(styles.profileName, {
[styles.TeacherName]: profileType === "teacher",
[styles.studentName]: profileType === "student",
[styles.goldName]: teacherDetails?.type === "gold",
[styles.silverName]: teacherDetails?.type === "silver",
[styles.bronzeName]: teacherDetails?.type === "bronze",
})}
fontWeight={800}
>
{name}
</Typography>
<hr
className={clsx(styles.line, {
[styles.goldLine]: teacherDetails?.type === "gold",
[styles.silverLine]: teacherDetails?.type === "silver",
[styles.bronzeLine]: teacherDetails?.type === "bronze",
[styles.defaultLine]: profileType === "student",
})}
></hr>
<Box
display={"flex"}
alignItems={"center"}
gap={1}
margin={"0px 17px"}
justifyContent={"space-between"}
>
<Box width={"50%"}>
{profileType === "teacher" && (
<>
<Box display={"flex"} alignItems={"center"}>
जनपद :
<Typography
component="p"
sx={{
fontWeight: "600",
color: "#2F3293",
fontSize: "14px",
marginLeft: "8px",
}}
>
{district || "Agra"}
</Typography>
</Box>
<Box display={"flex"} alignItems={"center"} margin={"10px 0"}>
UDISE:
<Typography
component="p"
sx={{
fontWeight: "600",
color: "#2F3293",
fontSize: "14px",
marginLeft: "8px",
}}
>
{UDISE}
</Typography>
</Box>
<Box display={"flex"} alignItems={"center"}>
ब्लॉक :
<Typography
component="p"
sx={{
fontWeight: "600",
color: "#2F3293",
fontSize: "14px",
marginLeft: "8px",
}}
>
{block}
</Typography>
</Box>
</>
)}
{profileType === "student" && studentDetails && (
<>
<Box display={"flex"} alignItems={"center"}>
जनपद :
<Typography
component="p"
sx={{
fontWeight: "600",
color: "#2F3293",
fontSize: "14px",
marginLeft: "8px",
}}
>
{district || "AGRA"}
</Typography>
</Box>
<Box display={"flex"} alignItems={"center"} margin={"10px 0"}>
UDISE:
<Typography
component="p"
sx={{
fontWeight: "600",
color: "#2F3293",
fontSize: "14px",
marginLeft: "8px",
}}
>
{studentDetails.id}
</Typography>
</Box>
<Box display={"flex"} alignItems={"center"}>
आखरी आकलन :
<Typography
component="p"
sx={{
fontWeight: "600",
color: "#2F3293",
fontSize: "14px",
marginLeft: "8px",
}}
>
{studentDetails.roll_no}
</Typography>
</Box>
</>
)}
</Box>
<Box
margin={"auto"}
width={"50%"}
display={"flex"}
flexDirection={"column"}
alignItems={"center"}
justifyContent={"center"}
>
<Box
display={"flex"}
alignItems={"center"}
justifyContent={"center"}
width={"100%"}
>
{typeof window === "undefined" ? (
<img
className={styles.image}
src={imageURL}
width={profileType === "teacher" ? 47 : 69}
height={profileType === "teacher" ? 74 : 101}
alt={profileType === "teacher" ? "सर्व शिक्षा अभियान" : "icon"}
/>
) : (
<Image
className={styles.image}
src={imageURL}
width={profileType === "teacher" ? 47 : 69}
height={profileType === "teacher" ? 74 : 101}
alt={profileType === "teacher" ? "सर्व शिक्षा अभियान" : "icon"}
/>
)}
</Box>
{profileType === "teacher" && (
<Typography
component="p"
className={styles.bottomText}
fontWeight={600}
fontSize={"12px"}
>
मई में आपके 50+ छात्र निपुण हैं 🎉
</Typography>
)}
</Box>
</Box>
</Card>
);
};
const [UDISE, setUDISE] = React.useState<string | null>(null);
React.useEffect(() => {
setUDISE(localStorage.getItem("udise"));
}, []);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant