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

Chore/cleanup global css styles #1191

Conversation

John-Paul-Larkin
Copy link
Member

✨ Codu Pull Request 💻

Pull Request details

Refactored PR #1172
Removed the focusable HOC

Inlined Single-Use Classes: The following classes, previously only used in a single location, have had their styles embedded directly into the components. Also, the single use CSS variables have been removed.
.twitter
.github
.discord
.youtube

Removed .rehype-code-title and .highlight-line styles, since they are no longer needed.

Any Breaking changes

None

@John-Paul-Larkin John-Paul-Larkin requested a review from a team as a code owner October 29, 2024 20:56
Copy link

vercel bot commented Oct 29, 2024

@John-Paul-Larkin is attempting to deploy a commit to the Codú Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Oct 29, 2024

Walkthrough

The changes in this pull request primarily focus on enhancing the functionality and user interface of the Create component, along with updates to the ArticleMenu, ArticlePreview, Footer, and global styles. Key modifications include the introduction of new state variables for file uploads, improved error handling in form submissions, and updates to accessibility features in the UI components. Additionally, CSS variables related to social media colors have been removed, and the Tailwind CSS configuration has been updated to use hardcoded color values and gradients instead.

Changes

File Path Change Summary
app/(editor)/create/[[...paramsArr]]/_client.tsx Added uploadStatus and uploadUrl state variables; updated handleUpload, onSubmit, and savePost functions for better error handling and user feedback. Enhanced UI with a new draft link button.
components/ArticleMenu/ArticleMenu.tsx Updated bookmark button class for improved focus styles, enhancing accessibility.
components/ArticlePreview/ArticlePreview.tsx Updated bookmark button class for better accessibility; added check for bookmarkStatus in bookmarkPost function.
components/Footer/Footer.tsx Introduced customStyle property for social media links to allow distinct styling based on hover and focus states.
styles/globals.css Removed several CSS variable declarations and classes related to social media colors and input styles.
tailwind.config.js Changed color definitions for twitter and github to hex values; updated discord and youtube background images to gradients.

Possibly related PRs

Suggested labels

hacktoberfest-accepted, hacktoberfest

Suggested reviewers

  • NiallJoeMaher

Poem

In the garden of code, where changes bloom,
A rabbit hops by, dispelling the gloom.
With uploads and links, our work is refined,
New styles and colors, all carefully aligned.
So here's to the tweaks that make our hearts cheer,
In the world of creation, we hold dear! 🐇✨


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 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.

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
Contributor

@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 (5)
tailwind.config.js (1)

Line range hint 1-22: Consider implementing a comprehensive theming strategy.

While removing single-use CSS variables is a good cleanup step, the current approach of hardcoding values directly in the Tailwind config might make future theme management more challenging. Consider implementing a comprehensive theming strategy that:

  1. Centralizes all brand-related colors and gradients
  2. Maintains flexibility for future theme changes
  3. Provides type safety for theme values (if using TypeScript)

This could involve:

  • Creating a dedicated theme management system
  • Using a design token approach
  • Implementing a theme provider for dynamic theme switching
components/Footer/Footer.tsx (1)

84-84: Optimize transitions and remove unnecessary toLowerCase.

A few suggestions to improve the implementation:

  1. The toLowerCase() call is unnecessary as Tailwind classes are case-sensitive
  2. transition-all might be too broad, consider specifying exact properties to transition
-className={`focus-style rounded-md p-1 transition-all duration-300 hover:scale-105 hover:text-white hover:brightness-110 focus:scale-105 focus:text-white focus:brightness-110 ${item.customStyle.toLowerCase()}`}
+className={`focus-style rounded-md p-1 transition-[transform,background-color] duration-300 hover:scale-105 hover:text-white hover:brightness-110 focus:scale-105 focus:text-white focus:brightness-110 ${item.customStyle}`}
components/ArticlePreview/ArticlePreview.tsx (1)

158-158: LGTM! Consider extracting common focus styles.

The accessibility-focused changes look good. The implementation properly handles keyboard navigation with clear visual feedback using :focus-visible and maintains good contrast with the pink-600 color scheme.

Consider extracting these focus styles into a Tailwind plugin or component class if they're used across multiple interactive elements:

- className="rounded-full p-2 hover:bg-neutral-300 focus:outline-none focus:ring-white focus-visible:ring-2 focus-visible:ring-pink-600 focus-visible:ring-offset-pink-600 dark:hover:bg-neutral-800 lg:mx-auto"
+ className="rounded-full p-2 hover:bg-neutral-300 focus-ring-style dark:hover:bg-neutral-800 lg:mx-auto"

Then in your Tailwind config:

// tailwind.config.js
module.exports = {
  theme: {
    extend: {
      // ... other extensions
    }
  },
  plugins: [
    plugin(function({ addComponents }) {
      addComponents({
        '.focus-ring-style': {
          '&:focus': {
            outline: 'none',
            '--tw-ring-color': 'white'
          },
          '&:focus-visible': {
            '--tw-ring-width': '2px',
            '--tw-ring-color': 'rgb(219 39 119)', // pink-600
            '--tw-ring-offset-color': 'rgb(219 39 119)' // pink-600
          }
        }
      })
    })
  ]
}
app/(editor)/create/[[...paramsArr]]/_client.tsx (2)

Line range hint 7-7: Typo in import path for CustomTextareaAutosize

There seems to be a typo in the import statement for CustomTextareaAutosize. The directory name CustomTextareAutosize is missing an 'a' and should be CustomTextareaAutosize.

Apply this diff to correct the import path:

-import CustomTextareaAutosize from "@/components/CustomTextareAutosize/CustomTextareaAutosize";
+import CustomTextareaAutosize from "@/components/CustomTextareaAutosize/CustomTextareaAutosize";

Line range hint 90-131: Ensure proper file input reset after upload

After a successful file upload, the file input field retains the previous file, preventing the same file from being uploaded again if needed. Consider resetting the file input value to allow users to re-upload the same file if necessary.

Apply this diff to reset the file input:

const handleUpload = async (e: React.ChangeEvent<HTMLInputElement>) => {
  // existing code...
  } catch (error) {
    // existing error handling...
  }
+  // Reset the file input value
+  e.target.value = '';
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 60267e5 and b110e56.

📒 Files selected for processing (6)
  • app/(editor)/create/[[...paramsArr]]/_client.tsx (1 hunks)
  • components/ArticleMenu/ArticleMenu.tsx (1 hunks)
  • components/ArticlePreview/ArticlePreview.tsx (1 hunks)
  • components/Footer/Footer.tsx (2 hunks)
  • styles/globals.css (0 hunks)
  • tailwind.config.js (1 hunks)
💤 Files with no reviewable changes (1)
  • styles/globals.css
✅ Files skipped from review due to trivial changes (1)
  • components/ArticleMenu/ArticleMenu.tsx
🔇 Additional comments (3)
tailwind.config.js (1)

11-12: ⚠️ Potential issue

Review social media brand colors for accuracy.

The current color values appear to deviate from the standard brand colors:

  • Twitter's official brand color is #1DA1F2 (blue), not #282828 (dark gray)
  • GitHub's official brand color is #181717 (near black), not #f17f06 (orange)

Let's verify if these colors are used consistently across the codebase:

Consider updating to the official brand colors:

-        twitter: "#282828",
-        github: "#f17f06",
+        twitter: "#1DA1F2",
+        github: "#181717",
components/Footer/Footer.tsx (1)

22-22: Verify Tailwind color configurations.

Let's ensure that the social media platform colors are properly configured in Tailwind and not used elsewhere in the codebase.

Also applies to: 28-28, 34-34, 40-40, 84-84

✅ Verification successful

Tailwind color configurations are properly set up

The social media platform colors are correctly configured in the Tailwind config:

  • Twitter and GitHub are defined under colors
  • Discord and YouTube are defined under backgroundImage for gradient effects
  • These color classes are only used in Footer.tsx for hover and focus states of social media links
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check Tailwind config for color definitions
echo "Checking Tailwind config for social media colors..."
rg -A 1 "twitter:|github:|discord:|youtube:" tailwind.config.*

# Check for any other usage of these color classes in the codebase
echo "Checking for other usage of social media color classes..."
rg -l "bg-(?:twitter|github|discord|youtube)\b" --type tsx --type jsx --type css

Length of output: 625


Script:

#!/bin/bash
# Check Tailwind config for color definitions with corrected file type
echo "Checking for other usage of social media color classes..."
rg -l 'bg-(?:twitter|github|discord|youtube)\b' --type ts --type js --type jsx

# Check the actual content of matches to see the context
echo "Checking content of files using these classes..."
rg 'bg-(?:twitter|github|discord|youtube)\b' --type ts --type js --type jsx -C 2

Length of output: 451


Script:

#!/bin/bash
# Search for social media color classes without specifying file types
echo "Checking for usage of social media color classes..."
rg 'bg-(?:twitter|github|discord|youtube)\b' -C 2

# Also check the tailwind config content more thoroughly
echo "Checking Tailwind configuration..."
cat tailwind.config.js

Length of output: 1944

app/(editor)/create/[[...paramsArr]]/_client.tsx (1)

Line range hint 560-565: LGTM: Inline styling replaces single-use CSS classes

The inlined CSS classes effectively replace the previous global styles for the draft link copy button, aligning with the PR objective of removing single-use global styles.

Comment on lines +15 to +16
discord: "linear-gradient(to bottom, #4b83fb, #734df8)",
youtube: "linear-gradient(to top, #6d0202 22%, #c90000 61%)",
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider extracting gradient values for better maintainability.

While moving away from CSS variables aligns with the PR objectives, hardcoding complex gradient values directly in the config file might make future updates challenging.

Consider creating a separate constants file for these values:

// constants/theme.js
export const gradients = {
  discord: "linear-gradient(to bottom, #4b83fb, #734df8)",
  youtube: "linear-gradient(to top, #6d0202 22%, #c90000 61%)"
};

Then import and use them in the config:

+const { gradients } = require('./constants/theme');
 module.exports = {
   // ...
   backgroundImage: {
-        discord: "linear-gradient(to bottom, #4b83fb, #734df8)",
-        youtube: "linear-gradient(to top, #6d0202 22%, #c90000 61%)",
+        discord: gradients.discord,
+        youtube: gradients.youtube,
   },

This approach would:

  • Maintain the goal of removing CSS variables
  • Keep gradient definitions centralized and reusable
  • Make future updates more manageable

@@ -19,21 +19,25 @@ const navigation = {
social: [
{
name: "Twitter",
customStyle: "hover:bg-twitter focus:bg-twitter",
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider reducing style pattern duplication.

The hover/focus pattern is repeated across all social media objects. Consider extracting this to a utility function or constant.

+const createSocialStyle = (platform: string) =>
+  `hover:bg-${platform} focus:bg-${platform}`;

 const navigation = {
   social: [
     {
       name: "Twitter",
-      customStyle: "hover:bg-twitter focus:bg-twitter",
+      customStyle: createSocialStyle("twitter"),
       // ...
     },
     // Apply similar changes to other social objects
   ]
 };

Also applies to: 28-28, 34-34, 40-40

NiallJoeMaher
NiallJoeMaher previously approved these changes Oct 31, 2024
@NiallJoeMaher
Copy link
Contributor

Prettier needed!

Logs form prettier

Copy link
Contributor

@NiallJoeMaher NiallJoeMaher left a comment

Choose a reason for hiding this comment

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

🌮 🦖

@NiallJoeMaher NiallJoeMaher merged commit b18f913 into codu-code:develop Nov 4, 2024
4 of 5 checks passed
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.

2 participants