-
Notifications
You must be signed in to change notification settings - Fork 27
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
base: dev
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe 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
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
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this 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
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 theMeta
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.
.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; | ||
} |
There was a problem hiding this comment.
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.
.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; | |
} |
> | ||
{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> | ||
); | ||
}; |
There was a problem hiding this comment.
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.
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")); | |
}, []); |
Summary by CodeRabbit
New Features
ProfileCard
component for displaying teacher and student profiles.ProfileCard
.Bug Fixes