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

Refactoring CSS files: merged PageNotFound styles into global app.module.css #2539

Open
wants to merge 4 commits into
base: develop-postgres
Choose a base branch
from

Conversation

mandeepnh5
Copy link

@mandeepnh5 mandeepnh5 commented Dec 1, 2024

What kind of change does this PR introduce?

Refactoring CSS files: merged PageNotFound styles into global app.module.css

Issue Number:

Fixes #2524

Did you add tests for your changes?

Yes

Summary

It is my first PR on Palisadoes Foundation and I am looking forward to contribute more to this organization.
This PR solves the problem of having a single global CSS file instead of having many CSS files in sub directories.

Does this PR introduce a breaking change?

No

Have you read the contributing guide?

Yes

Summary by CodeRabbit

  • New Features
    • Enhanced styling for the "Page Not Found" component, ensuring a visually distinct and responsive design across various devices.
  • Bug Fixes
    • Updated the import of styles for the "Page Not Found" component to reference a new CSS module, improving consistency in styling.

Copy link

coderabbitai bot commented Dec 1, 2024

Walkthrough

The changes involve the removal of the PageNotFound.module.css file and the migration of its styles to a new section in the src/style/app.module.css file. The PageNotFound.tsx component has been updated to import styles from the global CSS file instead of the now-deleted module. This refactoring aligns with the objective of consolidating CSS files into a single global file for improved maintainability and accessibility.

Changes

File Change Summary
src/screens/PageNotFound/PageNotFound.module.css Deleted the CSS module file containing styles for the "Page Not Found" component.
src/screens/PageNotFound/PageNotFound.tsx Updated import statement to reference styles from ../../style/app.module.css.
src/style/app.module.css Added new styles for the "Page Not Found" component, including classes for headings and layout.

Assessment against linked issues

Objective Addressed Explanation
Refactor CSS files in src/screens/PageNotFound (#[2524])
Streamline all CSS into a single global file (#[2524])
Ensure all remaining relevant files reference the global CSS file (#[2524])

Possibly related issues

Possibly related PRs

Suggested reviewers

  • palisadoes
  • AVtheking
  • gautam-divyanshu

Poem

In a world where pages stray,
A rabbit hops to save the day.
With styles now all in one place,
A "Not Found" page finds its grace.
Hopping through code, so neat and bright,
Making sure all's just right! 🐇✨


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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

github-actions bot commented Dec 1, 2024

Our Pull Request Approval Process

Thanks for contributing!

Testing Your Code

Remember, your PRs won't be reviewed until these criteria are met:

  1. We don't merge PRs with poor code quality.
    1. Follow coding best practices such that CodeRabbit.ai approves your PR.
  2. We don't merge PRs with failed tests.
    1. When tests fail, click on the Details link to learn more.
    2. Write sufficient tests for your changes (CodeCov Patch Test). Your testing level must be better than the target threshold of the repository
    3. Tests may fail if you edit sensitive files. Ask to add the ignore-sensitive-files-pr label if the edits are necessary.
  3. We cannot merge PRs with conflicting files. These must be fixed.

Our policies make our code better.

Reviewers

Do not assign reviewers. Our Queue Monitors will review your PR and assign them.
When your PR has been assigned reviewers contact them to get your code reviewed and approved via:

  1. comments in this PR or
  2. our slack channel

Reviewing Your Code

Your reviewer(s) will have the following roles:

  1. arbitrators of future discussions with other contributors about the validity of your changes
  2. point of contact for evaluating the validity of your work
  3. person who verifies matching issues by others that should be closed.
  4. person who gives general guidance in fixing your tests

CONTRIBUTING.md

Read our CONTRIBUTING.md file. Most importantly:

  1. PRs with issues not assigned to you will be closed by the reviewer
  2. Fix the first comment in the PR so that each issue listed automatically closes

Other

  1. 🎯 Please be considerate of our volunteers' time. Contacting the person who assigned the reviewers is not advised unless they ask for your input. Do not @ the person who did the assignment otherwise.
  2. Read the CONTRIBUTING.md file make

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

🧹 Outside diff range and nitpick comments (2)
src/style/app.module.css (2)

564-577: Enhance typography consistency and maintainability

Consider these improvements:

  1. Apply font family consistently
  2. Use rem units for better scaling
  3. Define font sizes using CSS variables for better maintainability
.pageNotFound h3 {
-  font-family: 'Roboto', sans-serif;
  font-weight: normal;
  letter-spacing: 1px;
}

.pageNotFound .brand span {
-  margin-top: 50px;
-  font-size: 40px;
+  margin-top: 3.125rem;
+  font-size: 2.5rem;
}

.pageNotFound .brand h3 {
  font-weight: 300;
-  margin: 10px 0 0 0;
+  margin: 0.625rem 0 0 0;
}

Consider adding these variables to the :root:

:root {
  --font-family-base: 'Roboto', sans-serif;
  --font-size-brand: 2.5rem;
  --spacing-base: 0.625rem;
}

605-667: Enhance media query maintainability

The breakpoints and responsive adjustments are well-structured, but consider these improvements:

  1. Define breakpoints as CSS variables
  2. Create a smoother transition for letter-spacing
  3. Consolidate repeated values
:root {
  --breakpoint-xl: 1024px;
  --breakpoint-lg: 768px;
  --breakpoint-md: 640px;
  --breakpoint-sm: 480px;
  --breakpoint-xs: 320px;
  
  --heading-size-xl: 12.5rem;
  --heading-size-lg: 9.375rem;
  --heading-size-md: 9.375rem;
  --heading-size-sm: 8.125rem;
  --heading-size-xs: 6.25rem;
}

@media (max-width: var(--breakpoint-xl)) {
  .pageNotFound h1.head {
-    font-size: 200px;
+    font-size: var(--heading-size-xl);
    letter-spacing: 20px;
  }
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c2630ae and 8a79af6.

📒 Files selected for processing (3)
  • src/screens/PageNotFound/PageNotFound.module.css (0 hunks)
  • src/screens/PageNotFound/PageNotFound.tsx (1 hunks)
  • src/style/app.module.css (1 hunks)
💤 Files with no reviewable changes (1)
  • src/screens/PageNotFound/PageNotFound.module.css
✅ Files skipped from review due to trivial changes (1)
  • src/screens/PageNotFound/PageNotFound.tsx
🧰 Additional context used
📓 Learnings (1)
src/style/app.module.css (1)
Learnt from: mandeepnh5
PR: PalisadoesFoundation/talawa-admin#2536
File: src/style/app.module.css:564-577
Timestamp: 2024-12-01T10:46:49.756Z
Learning: The `notFound` class is used in the `NotFound` component, whereas the `PageNotFound` page has its own styles. It's important to distinguish between them to avoid confusion.
🔇 Additional comments (1)
src/style/app.module.css (1)

559-667: LGTM! Well-structured CSS changes

The PageNotFound styles have been successfully consolidated into the global CSS file with good organization, responsive design, and isolation from existing styles. The implementation aligns well with the PR objectives.

src/style/app.module.css Outdated Show resolved Hide resolved
src/style/app.module.css Show resolved Hide resolved
Copy link

codecov bot commented Dec 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.75%. Comparing base (0630cff) to head (5bfff63).

Additional details and impacted files
@@                  Coverage Diff                  @@
##           develop-postgres    #2539       +/-   ##
=====================================================
- Coverage             95.73%   83.75%   -11.99%     
=====================================================
  Files                   295      312       +17     
  Lines                  7036     8118     +1082     
  Branches               1516     1830      +314     
=====================================================
+ Hits                   6736     6799       +63     
- Misses                   99     1180     +1081     
+ Partials                201      139       -62     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@palisadoes
Copy link
Contributor

Please fix the failing tests. Our test code coverage system will fail if any of these conditions occur:

  1. The overall code coverage drops below the target threshold of the repository
  2. Any file in the pull request has code coverage levels below the repository threshold
  3. The code does not comply with our linting check or other related formatting requirements

We do this to ensure the overall reliability of the code base is maintained. This is a prerequisite for getting your PR approved. Assigned reviewers regularly review the PR queue and tend to focus on PRs that are passing.

Also ensure that CodeRabbit.ai approves your work

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 2, 2024
@mandeepnh5
Copy link
Author

The checks which were not successful were out the scope of this PR I think because the I followed all linting rules and other and as it was only a CSS file I don't think there is issue in the talawa-api check.

@palisadoes palisadoes added the ignore-sensitive-files-pr The contributor has a legitimate reason for editiing protected files label Dec 7, 2024
@palisadoes
Copy link
Contributor

Please fix the conflicting file

@mandeepnh5
Copy link
Author

@palisadoes But why is it conflicting the task was to put pagenotfound css code to global css file right

@varshith257
Copy link
Member

@mandeepnh5 The conflicts occur because multiple people change this global file from different PRs, just need to take care of them

@mandeepnh5
Copy link
Author

mandeepnh5 commented Dec 9, 2024

@varshith257 Oh then I should just pull the changes and resolve conflicts?

@palisadoes
Copy link
Contributor

Yes

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: 0

🧹 Outside diff range and nitpick comments (3)
src/style/app.module.css (3)

608-622: Improve typography consistency and maintainability

The typography styles could be improved for better maintainability and consistency:

  1. Font-family should use CSS variables
  2. Font sizes should use relative units (rem)

Apply these changes:

.pageNotFound h3 {
-  font-family: 'Roboto', sans-serif;
+  font-family: var(--font-family-base);
  font-weight: normal;
  letter-spacing: 1px;
}

.pageNotFound .brand span {
  margin-top: 50px;
-  font-size: 40px;
+  font-size: 2.5rem;
}

637-653: Improve decorative elements for accessibility and theming

The decorative line elements need improvements:

  1. Use CSS variables for colors
  2. Ensure proper accessibility handling

Apply these changes:

.pageNotFound h1.head span:before,
.pageNotFound h1.head span:after {
  position: absolute;
  top: 50%;
  width: 50%;
  height: 1px;
-  background: #fff;
+  background: var(--decorative-line-color);
  content: '';
}

+ /* Add to :root */
+ :root {
+   --decorative-line-color: #fff;
+ }

655-717: Optimize responsive design implementation

The media queries could be improved:

  1. Use relative units (rem) for font sizes
  2. Consider using CSS clamp() for fluid typography
  3. Consolidate duplicate properties

Example improvement:

@media (max-width: 1024px) {
  .pageNotFound h1.head {
-    font-size: 200px;
+    font-size: 12.5rem;
    letter-spacing: 25px;
  }
}

+ /* Alternative using clamp() to replace multiple breakpoints */
+ .pageNotFound h1.head {
+   font-size: clamp(6.25rem, 15vw, 15.625rem);
+   letter-spacing: clamp(0px, 2vw, 25px);
+ }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8a79af6 and abdd6a9.

📒 Files selected for processing (1)
  • src/style/app.module.css (2 hunks)
🧰 Additional context used
📓 Learnings (1)
src/style/app.module.css (1)
Learnt from: mandeepnh5
PR: PalisadoesFoundation/talawa-admin#2536
File: src/style/app.module.css:564-577
Timestamp: 2024-12-01T10:46:49.756Z
Learning: The `notFound` class is used in the `NotFound` component, whereas the `PageNotFound` page has its own styles. It's important to distinguish between them to avoid confusion.
🔇 Additional comments (3)
src/style/app.module.css (3)

603-606: 🛠️ Refactor suggestion

Consider using flexbox for better layout control

The current relative positioning approach with a bottom offset might cause layout issues across different screen sizes.

Apply this diff for a more robust layout:

.pageNotFound {
-  position: relative;
-  bottom: 20px;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: center;
+  min-height: 100vh;
+  padding: 20px;
}

603-717: Verify removal of the original CSS file

The styles have been successfully consolidated, but let's verify the removal of the original file.

✅ Verification successful

CSS consolidation verified successfully

The absence of any PageNotFound-related CSS files in the search results, combined with the successful consolidation of styles into app.module.css, confirms that the original CSS file has been properly removed and the styles have been migrated correctly.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify that the original CSS file has been removed
if [ -f "src/screens/PageNotFound/PageNotFound.module.css" ]; then
    echo "Warning: Original CSS file still exists and should be removed"
    exit 1
fi

Length of output: 61


Script:

#!/bin/bash
# Let's search for any CSS files related to PageNotFound
fd -e css | grep -i "pagenotfound"

# Also search for any imports of PageNotFound CSS files
rg -l "PageNotFound.*\.css"

Length of output: 64


624-635: 🛠️ Refactor suggestion

Enhance heading accessibility and maintainability

The heading styles need improvements for:

  1. Color accessibility and theming support
  2. Responsive typography using relative units
  3. Proper color contrast for better visibility

Apply these changes:

.pageNotFound h1.head {
-  font-size: 250px;
+  font-size: 15.625rem;
  font-weight: 900;
-  color: #31bb6b;
+  color: var(--primary-color);
  letter-spacing: 25px;
  margin: 10px 0 0 0;
}

+ /* Add to :root */
+ :root {
+   --primary-color: #31bb6b;
+ }

Also, consider adding aria-hidden="true" to decorative spans in the HTML component.

Likely invalid or redundant comment.

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 10, 2024
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: 0

🧹 Outside diff range and nitpick comments (3)
src/style/app.module.css (3)

608-622: Improve typography consistency and maintainability

Consider these improvements:

  1. Use CSS variables for font-family and weights
  2. Use consistent units (prefer rem over px)
  3. Define a consistent spacing system
+ :root {
+   --font-family-base: 'Roboto', sans-serif;
+   --font-weight-normal: 400;
+   --font-weight-light: 300;
+   --spacing-base: 1rem;
+ }

.pageNotFound h3 {
-  font-family: 'Roboto', sans-serif;
-  font-weight: normal;
+  font-family: var(--font-family-base);
+  font-weight: var(--font-weight-normal);
  letter-spacing: 1px;
}

.pageNotFound .brand span {
-  margin-top: 50px;
-  font-size: 40px;
+  margin-top: calc(var(--spacing-base) * 3.125);
+  font-size: 2.5rem;
}

.pageNotFound .brand h3 {
-  font-weight: 300;
-  margin: 10px 0 0 0;
+  font-weight: var(--font-weight-light);
+  margin: var(--spacing-base) 0 0 0;
}

637-653: Improve decorative elements maintainability

The decorative lines should use CSS variables and be properly hidden from screen readers.

+ :root {
+   --decorative-line-color: #fff;
+   --decorative-line-width: 50%;
+ }

.pageNotFound h1.head span:before,
.pageNotFound h1.head span:after {
  position: absolute;
  top: 50%;
-  width: 50%;
+  width: var(--decorative-line-width);
  height: 1px;
-  background: #fff;
+  background: var(--decorative-line-color);
  content: '';
+  aria-hidden="true";
}

655-717: Optimize media queries for better maintainability

The media queries could be improved by:

  1. Using CSS variables for breakpoints
  2. Implementing a more consistent size reduction pattern
  3. Reducing code duplication
+ :root {
+   --breakpoint-xl: 1024px;
+   --breakpoint-lg: 768px;
+   --breakpoint-md: 640px;
+   --breakpoint-sm: 480px;
+   --breakpoint-xs: 320px;
+ }

- @media (max-width: 1024px) {
+ @media (max-width: var(--breakpoint-xl)) {
  .pageNotFound h1.head {
-    font-size: 200px;
+    font-size: 12.5rem;
    letter-spacing: 25px;
  }
}

- @media (max-width: 768px) {
+ @media (max-width: var(--breakpoint-lg)) {
  .pageNotFound h1.head {
-    font-size: 150px;
+    font-size: 9.375rem;
    letter-spacing: 25px;
  }
}

Consider using CSS custom properties for responsive font sizes:

:root {
  --heading-font-size: 15.625rem;
  --heading-font-size-xl: 12.5rem;
  --heading-font-size-lg: 9.375rem;
  /* ... other sizes */
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between abdd6a9 and 5bfff63.

📒 Files selected for processing (1)
  • src/style/app.module.css (1 hunks)
🧰 Additional context used
📓 Learnings (1)
src/style/app.module.css (1)
Learnt from: mandeepnh5
PR: PalisadoesFoundation/talawa-admin#2536
File: src/style/app.module.css:564-577
Timestamp: 2024-12-01T10:46:49.756Z
Learning: The `notFound` class is used in the `NotFound` component, whereas the `PageNotFound` page has its own styles. It's important to distinguish between them to avoid confusion.
🔇 Additional comments (3)
src/style/app.module.css (3)

603-717: Overall changes look good with suggested improvements

The consolidation of PageNotFound styles into the global CSS module is a good improvement for maintainability. The suggested refactors will further enhance accessibility and maintainability, but the current implementation is functional and meets the basic requirements.


603-606: 🛠️ Refactor suggestion

Consider using flexbox for better layout control

The current relative positioning approach might cause layout issues. A flexbox layout would provide better control and responsiveness.

.pageNotFound {
-  position: relative;
-  bottom: 20px;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: center;
+  min-height: 100vh;
+  padding: 20px;
}

624-635: 🛠️ Refactor suggestion

Enhance heading accessibility and maintainability

The heading needs improvements for better accessibility and maintainability:

  1. Use CSS variables for colors
  2. Add screen reader text
  3. Use relative units for font sizes
+ :root {
+   --primary-color: #31bb6b;
+ }

.pageNotFound h1.head {
-  font-size: 250px;
+  font-size: 15.625rem;
  font-weight: 900;
-  color: #31bb6b;
+  color: var(--primary-color);
  letter-spacing: 25px;
  margin: 10px 0 0 0;
}

.pageNotFound h1.head span {
  position: relative;
  display: inline-block;
+  aria-hidden="true";
}

+ .pageNotFound .sr-only {
+   position: absolute;
+   width: 1px;
+   height: 1px;
+   padding: 0;
+   margin: -1px;
+   overflow: hidden;
+   clip: rect(0, 0, 0, 0);
+   white-space: nowrap;
+   border: 0;
+ }

Likely invalid or redundant comment.

@mandeepnh5
Copy link
Author

mandeepnh5 commented Dec 10, 2024

@palisadoes Now all the checks are passing except the talawa api. I am not sure why, is it an issue or can be skipped?

@palisadoes palisadoes requested a review from AVtheking December 12, 2024 14:43
@palisadoes
Copy link
Contributor

@AVtheking @varshith257 PTAL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ignore-sensitive-files-pr The contributor has a legitimate reason for editiing protected files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants