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

refactor: ui inbox today #429

Merged
merged 3 commits into from
Oct 29, 2024
Merged

refactor: ui inbox today #429

merged 3 commits into from
Oct 29, 2024

Conversation

deewakar-k
Copy link
Contributor

@deewakar-k deewakar-k commented Oct 29, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Updated the Inbox component's layout for improved spacing.
    • Enhanced the InboxAddItem button label for clarity.
    • Introduced a new ListFilter icon in the InboxPage header for better organization.
    • Replaced DatePicker with DateCycle in the TodayPage for improved date selection.
    • Improved the presentation of date information in the Date component.
  • Bug Fixes

    • Adjusted spacing and layout in various components for a more streamlined appearance.
  • Style

    • Modified text sizes and padding across components for a cleaner user interface.

Copy link

coderabbitai bot commented Oct 29, 2024

Walkthrough

The pull request introduces several modifications across multiple components in the frontend application, primarily focusing on visual presentation and layout adjustments. Changes include reduced padding in the Inbox component, updated button labels and text sizes in InboxAddItem, a new header layout in InboxPage, structural changes in TodayPage, and a restructured date display in Date. These adjustments enhance the user interface without altering the underlying functionality of the components.

Changes

File Path Change Summary
apps/frontend/src/app/(app)/inbox/page.tsx Reduced padding of <section> from p-16 to p-10.
apps/frontend/src/components/Inbox/InboxAddItem.tsx Updated button label from "Click to Add an Item" to "add anything.." and changed text size to text-sm.
apps/frontend/src/components/Inbox/InboxPage.tsx Added ListFilter import, changed header title to "all unorganised items", added subheading "Inbox", and reduced gap from gap-8 to gap-2.
apps/frontend/src/components/Today/TodayPage.tsx Updated layout with new padding and width, replaced DatePicker with DateCycle, and adjusted margins and conditional rendering for TodayMeetings.
apps/frontend/src/components/atoms/Date.tsx Modified formatDate to change weekday format and removed year; restructured rendering logic for better layout.

Possibly related PRs

Suggested labels

community

Suggested reviewers

  • madhav-relish
  • sajdakabir

Poem

🐰 In the inbox where items reside,
Padding reduced, a new look applied.
Buttons now say "add anything,"
With headers fresh, let joy take wing!
Today’s page shines, a cycle anew,
In this cozy space, there’s much to do! 🌼


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.

@deewakar-k deewakar-k requested a review from oliursahin October 29, 2024 10:26
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: 3

🧹 Outside diff range and nitpick comments (6)
apps/frontend/src/components/Inbox/InboxPage.tsx (1)

22-27: Consider text casing and accessibility improvements

The header structure is well-organized with proper heading hierarchy, but consider these minor enhancements:

  1. Use title case for headings (e.g., "All Unorganised Items")
  2. Add an aria-label to the header section for better screen reader context
-        <header className="flex flex-col gap-3 pl-4 text-foreground">
+        <header className="flex flex-col gap-3 pl-4 text-foreground" aria-label="Inbox Section">
           <div className="flex items-center gap-3 text-secondary-foreground">
             <ListFilter size={16} />
-            <h1 className="">all unorganised items</h1>
+            <h1 className="">All Unorganised Items</h1>
           </div>
           <h2 className="text-sm font-semibold">Inbox</h2>
         </header>
apps/frontend/src/components/atoms/Date.tsx (1)

8-12: Remove redundant comment

The format is self-explanatory from the template literal string. The comment // Desired format doesn't add any value and can be removed.

  const weekday = date.toLocaleDateString("en-US", { weekday: "long" })
  const month = date.toLocaleDateString("en-US", { month: "short" })
  const day = date.getDate()

-  return `${weekday}, ${month} ${day}` // Desired format
+  return `${weekday}, ${month} ${day}`
apps/frontend/src/components/Inbox/InboxAddItem.tsx (4)

Line range hint 19-21: Remove unused state variables.

The following states are initialized but never used in the component:

  • description
  • date
  • selectedPages

This could indicate either missing functionality or leftover code from previous implementations.

  const [addingItem, setAddingItem] = useState(false)
  const textareaRefTitle = useRef<HTMLTextAreaElement>(null)
  const [title, setTitle] = useState("")
- const [description, setDescription] = useState("")
- const [date, setDate] = React.useState<Date | undefined>(new Date())
- const [selectedPages, setSelectedPages] = React.useState<string[]>([])

Line range hint 37-37: Address the TODO comment about textarea.

There's a TODO comment about fixing the textarea. Since this component is being refactored, now would be a good time to address this.

Would you like me to help investigate and fix any textarea-related issues? Please let me know what specific problems need to be addressed.


Line range hint 54-67: Add error handling UI feedback.

The error handling only logs to console, which isn't user-friendly. Consider adding toast notifications or inline error messages to inform users when item creation fails.

  try {
    const data: Partial<CycleItem> = {
      title,
    }

    await createItem(session, data)

    setAddingItem(false)
    setTitle("")
-   setDescription("")
  } catch (error) {
    console.error("error adding item to inbox:", error)
+   // Add user-facing error notification
+   toast.error("Failed to add item. Please try again.")
  }

Line range hint 54-58: Consider adding loading state during item creation.

The createItem operation is asynchronous but there's no loading indicator to provide feedback to users while the operation is in progress.

+ const [isCreating, setIsCreating] = useState(false)

  const handleAddItemToInbox = async () => {
    if (!session) {
      console.error("user is not authenticated")
      return
    }

    try {
+     setIsCreating(true)
      const data: Partial<CycleItem> = {
        title,
      }

      await createItem(session, data)
      
      setAddingItem(false)
      setTitle("")
    } catch (error) {
      console.error("error adding item to inbox:", error)
    } finally {
+     setIsCreating(false)
    }
  }

Then update the UI to show a loading state:

  <button
    className="hover-bg rounded-lg p-4"
    onClick={() => setAddingItem(true)}
+   disabled={isCreating}
  >
    <div className="flex items-center gap-2">
-     <p className="text-sm">add anything..</p>
+     <p className="text-sm">{isCreating ? "Adding..." : "add anything.."}</p>
    </div>
  </button>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7c19774 and 5289ec9.

📒 Files selected for processing (5)
  • apps/frontend/src/app/(app)/inbox/page.tsx (1 hunks)
  • apps/frontend/src/components/Inbox/InboxAddItem.tsx (1 hunks)
  • apps/frontend/src/components/Inbox/InboxPage.tsx (2 hunks)
  • apps/frontend/src/components/Today/TodayPage.tsx (1 hunks)
  • apps/frontend/src/components/atoms/Date.tsx (2 hunks)
🔇 Additional comments (7)
apps/frontend/src/app/(app)/inbox/page.tsx (1)

14-14: Verify overflow behavior with reduced padding.

The padding reduction from p-16 to p-10 looks good, but since this section has overflow-y-hidden, please verify that no content is being unintentionally clipped with the smaller padding, especially when the inbox contains many items.

✅ Verification successful

Padding adjustment is safe for overflow behavior

The reduced padding from p-16 to p-10 is safe because:

  • The main content is rendered in InboxItems which has its own scrollable container with overflow-y-auto
  • The parent components maintain proper height constraints with h-full
  • The layout structure shows proper nesting of scroll and height constraints:
    1. Page section: h-full overflow-y-hidden
    2. InboxPage wrapper: h-full
    3. Content container: h-full flex-col
    4. InboxItems: h-full overflow-y-auto
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for height-related styles or scroll containers that might be affected
rg -g '*.tsx' -g '*.css' 'overflow-y|h-\[|height:' apps/frontend/src/components/Inbox/

Length of output: 237


Script:

#!/bin/bash
# Let's check the InboxItems component usage and its parent containers
ast-grep --pattern 'InboxItems'

# Also check for any height-related styles in the inbox page and its immediate parent
rg -g '*.tsx' 'className="[^"]*h-' "apps/frontend/src/app/(app)/inbox/"

Length of output: 543


Script:

#!/bin/bash
# Let's check the InboxPage component to understand the full layout structure
cat apps/frontend/src/components/Inbox/InboxPage.tsx

# Also check if there are any scroll-related styles in parent layouts
rg -g '*.tsx' 'overflow|h-full' "apps/frontend/src/app/(app)/layout.tsx"

Length of output: 1362

apps/frontend/src/components/Inbox/InboxPage.tsx (2)

4-4: LGTM: Clean import addition

The ListFilter import is properly placed and utilized in the component.


18-18: LGTM: Improved layout spacing

The reduced gap spacing creates a more compact and refined layout, aligning well with the UI improvements objective.

apps/frontend/src/components/atoms/Date.tsx (1)

3-4: LGTM: Clean import addition

The ListFilter icon import is properly placed and follows React conventions.

apps/frontend/src/components/Today/TodayPage.tsx (2)

22-36: Well-structured layout with semantic HTML

The new layout structure is clean and well-organized, with proper use of semantic HTML elements and consistent typography.


21-21: ⚠️ Potential issue

Verify overflow behavior with varying content lengths

The overflow-y-hidden class might prevent users from accessing content that extends beyond the viewport height. Consider using overflow-y-auto instead to ensure all content remains accessible.

-    <main className="ml-[180px] h-full overflow-y-hidden bg-background p-10">
+    <main className="ml-[180px] h-full overflow-y-auto bg-background p-10">
apps/frontend/src/components/Inbox/InboxAddItem.tsx (1)

99-99: LGTM! UI text change looks good.

The updated button text is more concise and friendly, aligning well with modern UI patterns.

@@ -11,7 +11,7 @@ export const metadata: Metadata = generateMetadata({

const Inbox: React.FC = () => {
return (
<section className="ml-[160px] h-full overflow-y-hidden bg-background p-16 text-secondary-foreground">
<section className="ml-[160px] h-full overflow-y-hidden bg-background p-10 text-secondary-foreground">
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider adding responsive padding.

The fixed left margin (ml-[160px]) and padding (p-10) might not provide the best experience on smaller screens. Consider using Tailwind's responsive prefixes to adjust these values based on screen size.

-    <section className="ml-[160px] h-full overflow-y-hidden bg-background p-10 text-secondary-foreground">
+    <section className="ml-[160px] h-full overflow-y-hidden bg-background p-4 sm:p-6 md:p-8 lg:p-10 text-secondary-foreground">
📝 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
<section className="ml-[160px] h-full overflow-y-hidden bg-background p-10 text-secondary-foreground">
<section className="ml-[160px] h-full overflow-y-hidden bg-background p-4 sm:p-6 md:p-8 lg:p-10 text-secondary-foreground">

Comment on lines 39 to 56
<div className="space-y-2">
<div className="flex items-center justify-between">
<div className="flex w-48 items-center gap-2 text-secondary-foreground">
<ListFilter size={16} />
<p className="text-sm">{formatDate(selectedDate)}</p>
</div>
<div className="flex items-center gap-2">
<button onClick={goToPreviousDay} className="p-2">
<LeftChevron />
</button>
<button onClick={goToNextDay} className="p-2">
<RightChevron />
</button>
</div>
</div>
{isToday && (
<p className="text-sm font-semibold text-foreground">Today</p>
)}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance accessibility and user experience

While the layout structure is clean, consider the following improvements:

  1. Add accessibility attributes to navigation buttons
  2. Consider responsive width instead of fixed width
  3. Add hover/focus states for better interaction feedback
 <div className="space-y-2">
   <div className="flex items-center justify-between">
-    <div className="flex w-48 items-center gap-2 text-secondary-foreground">
+    <div className="flex min-w-[12rem] max-w-full items-center gap-2 text-secondary-foreground">
       <ListFilter size={16} />
       <p className="text-sm">{formatDate(selectedDate)}</p>
     </div>
     <div className="flex items-center gap-2">
-      <button onClick={goToPreviousDay} className="p-2">
+      <button
+        onClick={goToPreviousDay}
+        className="p-2 hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-primary rounded-sm"
+        aria-label="Previous day">
         <LeftChevron />
       </button>
-      <button onClick={goToNextDay} className="p-2">
+      <button
+        onClick={goToNextDay}
+        className="p-2 hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-primary rounded-sm"
+        aria-label="Next day">
         <RightChevron />
       </button>
     </div>
📝 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
<div className="space-y-2">
<div className="flex items-center justify-between">
<div className="flex w-48 items-center gap-2 text-secondary-foreground">
<ListFilter size={16} />
<p className="text-sm">{formatDate(selectedDate)}</p>
</div>
<div className="flex items-center gap-2">
<button onClick={goToPreviousDay} className="p-2">
<LeftChevron />
</button>
<button onClick={goToNextDay} className="p-2">
<RightChevron />
</button>
</div>
</div>
{isToday && (
<p className="text-sm font-semibold text-foreground">Today</p>
)}
<div className="space-y-2">
<div className="flex items-center justify-between">
<div className="flex min-w-[12rem] max-w-full items-center gap-2 text-secondary-foreground">
<ListFilter size={16} />
<p className="text-sm">{formatDate(selectedDate)}</p>
</div>
<div className="flex items-center gap-2">
<button
onClick={goToPreviousDay}
className="p-2 hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-primary rounded-sm"
aria-label="Previous day">
<LeftChevron />
</button>
<button
onClick={goToNextDay}
className="p-2 hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-primary rounded-sm"
aria-label="Next day">
<RightChevron />
</button>
</div>
</div>
{isToday && (
<p className="text-sm font-semibold text-foreground">Today</p>
)}

Comment on lines +37 to +49
<section className="w-[96%] max-w-[300px]">
<div className="flex items-center justify-end gap-4">
<span className="mt-2 text-[11px] font-medium text-foreground">
show agenda
</span>
<ShowAgenda toggle={showAgenda} onToggle={handleToggleAgenda} />
</div>
)}
{showAgenda && (
<div className="my-4 text-secondary-foreground">
<TodayMeetings selectedDate={selectedDate} />
</div>
)}
</section>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider increasing the font size for better accessibility

The "show agenda" label uses an 11px font size, which might be too small for optimal readability. The Web Content Accessibility Guidelines (WCAG) recommend a minimum font size of 12px for body text.

-            <span className="mt-2 text-[11px] font-medium text-foreground">
+            <span className="mt-2 text-xs font-medium text-foreground">

Also, consider adding an aria-label to improve screen reader experience:

-            <ShowAgenda toggle={showAgenda} onToggle={handleToggleAgenda} />
+            <ShowAgenda 
+              toggle={showAgenda} 
+              onToggle={handleToggleAgenda}
+              aria-label="Toggle agenda visibility"
+            />
📝 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
<section className="w-[96%] max-w-[300px]">
<div className="flex items-center justify-end gap-4">
<span className="mt-2 text-[11px] font-medium text-foreground">
show agenda
</span>
<ShowAgenda toggle={showAgenda} onToggle={handleToggleAgenda} />
</div>
)}
{showAgenda && (
<div className="my-4 text-secondary-foreground">
<TodayMeetings selectedDate={selectedDate} />
</div>
)}
</section>
<section className="w-[96%] max-w-[300px]">
<div className="flex items-center justify-end gap-4">
<span className="mt-2 text-xs font-medium text-foreground">
show agenda
</span>
<ShowAgenda
toggle={showAgenda}
onToggle={handleToggleAgenda}
aria-label="Toggle agenda visibility"
/>
</div>
{showAgenda && (
<div className="my-4 text-secondary-foreground">
<TodayMeetings selectedDate={selectedDate} />
</div>
)}
</section>

Copy link
Member

@oliursahin oliursahin left a comment

Choose a reason for hiding this comment

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

@joaorceschini can review!

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 (1)
apps/frontend/src/components/Inbox/InboxPage.tsx (1)

24-32: Consider enhancing accessibility and semantic structure.

While the new header layout improves visual hierarchy, consider these improvements:

  1. Add aria-label to the ListFilter icon
  2. Use more semantic heading structure (h1 for "Inbox" instead of "all unorganised items")
  3. Add aria-live region for the dynamic item count
 <header className="flex flex-col gap-3 pl-4 text-foreground">
   <div className="flex items-center gap-3 text-secondary-foreground">
-    <ListFilter size={16} />
+    <ListFilter size={16} aria-label="Filter list" />
     <h1 className="">all unorganised items</h1>
   </div>
   <div className="flex items-center gap-2">
-    <h2 className="text-sm font-semibold">Inbox</h2>
-    <p className="text-sm text-secondary-foreground">{totalItems}</p>
+    <h1 className="text-sm font-semibold">Inbox</h1>
+    <p className="text-sm text-secondary-foreground" aria-live="polite">
+      {totalItems} {totalItems === 1 ? 'item' : 'items'}
+    </p>
   </div>
 </header>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5289ec9 and f252c6f.

📒 Files selected for processing (2)
  • apps/frontend/src/components/Inbox/InboxPage.tsx (2 hunks)
  • apps/frontend/src/components/atoms/Date.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/frontend/src/components/atoms/Date.tsx
🔇 Additional comments (3)
apps/frontend/src/components/Inbox/InboxPage.tsx (3)

4-4: LGTM: Import statement is correctly placed and utilized.


20-22: LGTM: Layout adjustments maintain component structure.

The reduced gap improves the component's visual density while maintaining the conditional width logic.


13-15: Verify consistent usage of the new store structure.

The state management has been refactored to access items through the inbox object. This structural change might affect other components using the store.

✅ Verification successful

Store structure is consistently used across components

Based on the search results, all components are correctly using the new store structure:

  • InboxPage.tsx uses const { inbox } = useCycleItemStore()
  • Date.tsx uses const { today, overdue } = useCycleItemStore()
  • TodayItems.tsx uses destructured access via const { items: todayItems } = today
  • ThisWeekPage.tsx uses const { items, currentItem } = useCycleItemStore()
  • CustomKanban.tsx uses const { items } = thisWeek

The pattern of accessing items through their respective containers (inbox, today, thisWeek, etc.) is consistently maintained across all components using the store.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistent usage of the new store structure across the codebase

# Test: Search for usages of useCycleItemStore to ensure consistent destructuring
rg -A 3 "useCycleItemStore\(\)" --type tsx --type ts

# Test: Search for direct item access patterns that might need updating
rg "const.*items.*=.*useCycleItemStore" --type tsx --type ts

Length of output: 173


Script:

#!/bin/bash
# Search for usages of useCycleItemStore to ensure consistent destructuring
rg -A 3 "useCycleItemStore"

# Search for direct item access patterns that might need updating
rg "items.*=.*useCycleItemStore"

# Find all TypeScript/React files that might use the store
fd "\.(tsx|ts)$"

Length of output: 15678

@oliursahin oliursahin linked an issue Oct 29, 2024 that may be closed by this pull request
@sajdakabir sajdakabir merged commit 54b6582 into preview Oct 29, 2024
3 checks passed
@deewakar-k deewakar-k deleted the refactor/inbox-today branch October 31, 2024 07:57
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.

fix ui headers of inb and today
3 participants