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

ActivityPub UI design refinements #22242

Merged
merged 6 commits into from
Feb 20, 2025
Merged

ActivityPub UI design refinements #22242

merged 6 commits into from
Feb 20, 2025

Conversation

peterzimon
Copy link
Contributor

ref AP-748

  • Some design details have to be updated for a more consistent and solid UX/visual.

@peterzimon peterzimon changed the title ActiviPub UI design refinements ActivityPub UI design refinements Feb 19, 2025
Copy link
Contributor

coderabbitai bot commented Feb 19, 2025

Warning

Rate limit exceeded

@peterzimon has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 2 minutes and 20 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 066e144 and a6a6d66.

📒 Files selected for processing (1)
  • apps/admin-x-activitypub/src/components/modals/ViewProfileModal.tsx (3 hunks)

Walkthrough

The changes focus on several components within the admin activity stream layout, specifically the Sidebar, ArticleModal, FeedItem, FeedItemStats, Header, NewPostModal, Inbox, ActivityItem, Notifications, Profile, and Search. Key modifications include updates to the Sidebar component to show a modal for new posts instead of changing routes, adjustments to the height of the header in the ArticleModal, and refinements to the styling of buttons and containers in the FeedItem and FeedItemStats components. The Header component has a slight change in icon stroke width and button font weight. The NewPostModal now includes account data loading and layout adjustments, while the Inbox, ActivityItem, Notifications, Profile, and Search components have had their maximum widths increased for a wider presentation. No alterations were made to the declarations of exported or public entities across these changes.

Possibly related PRs

  • Moved NewPostModal component to the Feed page #22199: The changes in the main PR are related to the modifications made to the NewPostModal component, which is also referenced in the retrieved PR that discusses moving this component to a different directory.
  • ActivityPub Shade integration #22150: The changes in the main PR, specifically the modifications to the Sidebar component's button functionality and styling, are related to the updates in the retrieved PR that involve the Button component sourced from @tryghost/shade, indicating a direct connection in the usage and styling of buttons across both PRs.
  • Added skeleton loader to main screens #22158: The changes in the main PR, specifically the introduction of the NewPostModal and modifications to the Sidebar component, are related to the retrieved PR as both involve the integration of the Skeleton component for loading states, enhancing user experience during data fetching.

Suggested labels

browser-tests


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. (Beta)
  • @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: 0

🧹 Nitpick comments (4)
apps/admin-x-activitypub/src/components/feed/FeedItem.tsx (1)

268-268: Consider extracting magic numbers into CSS variables.

The padding values (p-6 px-8 pb-[18px]) could be better managed using CSS variables for improved maintainability.

-    <div className={`group/article relative -mx-4 -my-px cursor-pointer rounded-lg p-6 px-8 pb-[18px]`} data-layout='feed' data-object-id={object.id} onClick={onClick}>
+    <div 
+      className={`
+        group/article relative -mx-4 -my-px cursor-pointer rounded-lg
+        p-6 px-8 pb-[--feed-item-bottom-padding]
+      `}
+      style={{ '--feed-item-bottom-padding': '18px' }}
+      data-layout='feed'
+      data-object-id={object.id}
+      onClick={onClick}
+    >
apps/admin-x-activitypub/src/components/layout/Header.tsx (3)

9-9: Consider addressing the TODO comment.

The comment indicates a pending migration to React Router. This technical debt should be tracked and addressed in a future update.

Would you like me to create an issue to track this React Router migration task?


13-31: Remove unnecessary break statements after return.

The break statements after return in the switch case are unreachable and can be safely removed.

Apply this diff to improve the code:

    case 'inbox':
        return 'Inbox';
-        break;
    case 'feed':
        return 'Feed';
-        break;
    case 'profile':
        return 'Profile';
-        break;
    case 'notifications':
        return 'Notifications';
-        break;
    case 'search':
        return 'Search';
-        break;

    default:
        return 'Inbox';
-        break;
🧰 Tools
🪛 Biome (1.9.4)

[error] 14-14: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


[error] 17-17: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


[error] 20-20: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


[error] 23-23: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


[error] 26-26: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


[error] 30-30: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


44-46: Consider error handling for route updates.

The updateRoute calls could benefit from error handling to gracefully manage navigation failures.

Consider wrapping the updateRoute calls in try-catch blocks:

-onClick={() => {
-    updateRoute('');
-}}
+onClick={async () => {
+    try {
+        await updateRoute('');
+    } catch (error) {
+        console.error('Failed to update route:', error);
+        // Handle error appropriately
+    }
+}}

Also applies to: 63-63

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0f1484b and 46fb73d.

📒 Files selected for processing (7)
  • apps/admin-x-activitypub/src/components/feed/ArticleModal.tsx (1 hunks)
  • apps/admin-x-activitypub/src/components/feed/FeedItem.tsx (3 hunks)
  • apps/admin-x-activitypub/src/components/feed/FeedItemStats.tsx (1 hunks)
  • apps/admin-x-activitypub/src/components/layout/Header.tsx (2 hunks)
  • apps/admin-x-activitypub/src/components/layout/Sidebar/Sidebar.tsx (2 hunks)
  • apps/admin-x-activitypub/src/views/Feed/components/NewPostModal.tsx (3 hunks)
  • apps/admin-x-activitypub/src/views/Inbox/Inbox.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • apps/admin-x-activitypub/src/components/feed/ArticleModal.tsx
  • apps/admin-x-activitypub/src/components/feed/FeedItemStats.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/admin-x-activitypub/src/components/layout/Sidebar/Sidebar.tsx
🔇 Additional comments (9)
apps/admin-x-activitypub/src/components/feed/FeedItem.tsx (2)

254-254: LGTM! Improved button styling consistency.

The conditional border radius for the UserMenuTrigger button enhances visual consistency across different layouts.


271-271: LGTM! Improved text sizing consistency.

The text size adjustments to text-sm for usernames and timestamps enhance readability and maintain visual hierarchy.

Also applies to: 283-283

apps/admin-x-activitypub/src/components/layout/Header.tsx (2)

46-46: LGTM! Icon stroke width adjustment for better visibility.

The subtle increase in stroke width from 1 to 1.1 improves the visual weight of the back arrow icon, aligning with the PR's UI refinement objectives.


63-63: LGTM! Comprehensive button styling improvements.

The button styling changes enhance visual consistency and user experience through:

  • Normalized font weight
  • Consistent text size
  • Improved dark mode hover states
  • Refined dimensions and spacing
apps/admin-x-activitypub/src/views/Feed/components/NewPostModal.tsx (3)

6-8: LGTM! Good addition of account data loading.

The addition of the account loading functionality and routing hook enhances the user experience by showing the account name and handling navigation properly.

Also applies to: 15-16


75-79: LGTM! Enhanced layout with loading state.

Good implementation of the loading state using Skeleton component and improved spacing with flex layout.

Also applies to: 84-84


61-61:

❓ Verification inconclusive

Verify modal width and button changes.

The modal width has been increased and the cancel button label has been removed. Please ensure these UI changes:

  1. Align with the design system's guidelines
  2. Maintain consistency across other modals in the application

Also applies to: 67-68


🏁 Script executed:

#!/bin/bash
# Search for other modal width definitions and cancel button configurations
rg -A 2 'Modal.*width=' 
rg -A 2 'Modal.*cancelLabel'

Length of output: 56


Manual verification required for modal UI updates

The recent changes in apps/admin-x-activitypub/src/views/Feed/components/NewPostModal.tsx (lines 61 and 67-68) indicate that the modal width has been increased and the cancel button label has been removed. Since our automated search for similar references (i.e. Modal.*width= and Modal.*cancelLabel) did not yield any output, please manually verify that:

  • The increased modal width conforms to the design system’s guidelines.
  • The removal of the cancel button label maintains consistency with other modals in the application.

Given the absence of automated results, it's advisable to perform a detailed manual review of these UI aspects.

apps/admin-x-activitypub/src/views/Inbox/Inbox.tsx (2)

69-69: LGTM! Improved layout width.

The increased width provides better content visibility while maintaining readability.


70-77: Verify button styling accessibility.

The new post button implementation has several accessibility considerations to verify:

  1. Color contrast for the placeholder text
  2. Focus state visibility
  3. Touch target size
#!/usr/bin/env python3
import requests
from wcag_contrast_ratio import contrast

# Check color contrast
text_color = "#6B7280"  # gray-500
bg_color = "#FFFFFF"    # white
dark_text_color = "#6B7280"  # gray-500
dark_bg_color = "#000000"    # black

print(f"Light theme contrast ratio: {contrast(text_color, bg_color)}")
print(f"Dark theme contrast ratio: {contrast(dark_text_color, dark_bg_color)}")

# Verify touch target size
button_height = 72  # px
min_touch_target = 44  # px (WCAG 2.5.5 Target Size)
print(f"Touch target size compliance: {button_height >= min_touch_target}")

[skip_cloning]

Additionally, consider adding an aria-haspopup attribute since this button opens a modal:

-<Button aria-label='New post' className='text inset-0 h-[72px] w-full justify-start rounded-lg bg-white pl-[68px] text-left text-[1.5rem] font-normal tracking-normal text-gray-500 shadow-[0_5px_24px_0px_rgba(0,0,0,0.02),0px_2px_5px_0px_rgba(0,0,0,0.07),0px_0px_1px_0px_rgba(0,0,0,0.25)] transition-all hover:bg-white hover:shadow-[0_5px_24px_0px_rgba(0,0,0,0.05),0px_14px_12px_-9px_rgba(0,0,0,0.07),0px_0px_1px_0px_rgba(0,0,0,0.25)] dark:border dark:border-gray-950 dark:bg-black dark:shadow-none dark:hover:border-gray-925 dark:hover:bg-black dark:hover:shadow-none' onClick={() => NiceModal.show(NewPostModal)}>
+<Button aria-label='New post' aria-haspopup='dialog' className='text inset-0 h-[72px] w-full justify-start rounded-lg bg-white pl-[68px] text-left text-[1.5rem] font-normal tracking-normal text-gray-500 shadow-[0_5px_24px_0px_rgba(0,0,0,0.02),0px_2px_5px_0px_rgba(0,0,0,0.07),0px_0px_1px_0px_rgba(0,0,0,0.25)] transition-all hover:bg-white hover:shadow-[0_5px_24px_0px_rgba(0,0,0,0.05),0px_14px_12px_-9px_rgba(0,0,0,0.07),0px_0px_1px_0px_rgba(0,0,0,0.25)] dark:border dark:border-gray-950 dark:bg-black dark:shadow-none dark:hover:border-gray-925 dark:hover:bg-black dark:hover:shadow-none' onClick={() => NiceModal.show(NewPostModal)}>

ref AP-748

- Some design details have to be updated for a more consistent and solid UX/visual.
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: 0

🧹 Nitpick comments (1)
apps/admin-x-activitypub/src/views/Feed/components/NewPostModal.tsx (1)

61-61: Consider accessibility implications of empty cancel label.

While the modal's visual refinements look good, having an empty cancelLabel might affect accessibility. Consider providing a meaningful label for screen readers while maintaining the desired visual appearance.

-            cancelLabel=""
+            cancelLabel="Cancel"
+            hideLabels={true}

Also applies to: 67-68

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 46fb73d and 531d23a.

📒 Files selected for processing (11)
  • apps/admin-x-activitypub/src/components/activities/ActivityItem.tsx (1 hunks)
  • apps/admin-x-activitypub/src/components/feed/ArticleModal.tsx (1 hunks)
  • apps/admin-x-activitypub/src/components/feed/FeedItem.tsx (3 hunks)
  • apps/admin-x-activitypub/src/components/feed/FeedItemStats.tsx (1 hunks)
  • apps/admin-x-activitypub/src/components/layout/Header.tsx (2 hunks)
  • apps/admin-x-activitypub/src/components/layout/Sidebar/Sidebar.tsx (2 hunks)
  • apps/admin-x-activitypub/src/views/Feed/components/NewPostModal.tsx (3 hunks)
  • apps/admin-x-activitypub/src/views/Inbox/Inbox.tsx (1 hunks)
  • apps/admin-x-activitypub/src/views/Notifications/Notifications.tsx (1 hunks)
  • apps/admin-x-activitypub/src/views/Profile/Profile.tsx (2 hunks)
  • apps/admin-x-activitypub/src/views/Search/Search.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (4)
  • apps/admin-x-activitypub/src/views/Search/Search.tsx
  • apps/admin-x-activitypub/src/components/activities/ActivityItem.tsx
  • apps/admin-x-activitypub/src/views/Profile/Profile.tsx
  • apps/admin-x-activitypub/src/views/Notifications/Notifications.tsx
🚧 Files skipped from review as they are similar to previous changes (6)
  • apps/admin-x-activitypub/src/components/feed/ArticleModal.tsx
  • apps/admin-x-activitypub/src/components/layout/Header.tsx
  • apps/admin-x-activitypub/src/views/Inbox/Inbox.tsx
  • apps/admin-x-activitypub/src/components/feed/FeedItemStats.tsx
  • apps/admin-x-activitypub/src/components/feed/FeedItem.tsx
  • apps/admin-x-activitypub/src/components/layout/Sidebar/Sidebar.tsx
🔇 Additional comments (4)
apps/admin-x-activitypub/src/views/Feed/components/NewPostModal.tsx (4)

6-8: LGTM! New imports enhance the modal's functionality.

The added imports for Skeleton component, ActivityPub queries hooks, and routing utilities align well with the new features being implemented.


15-16: LGTM! Proper implementation of routing and account data loading.

The addition of routing and account data loading hooks enhances the component's functionality while following React best practices.


29-38: LGTM! Proper route update after successful post.

The implementation correctly updates the route to 'feed' after a successful post, providing a smooth user experience.


75-79: LGTM! Clean implementation of account name display with loading state.

The conditional rendering with Skeleton component provides a smooth loading experience while maintaining visual consistency.

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

🧹 Nitpick comments (1)
apps/shade/styles.css (1)

67-100: Updated Dark Mode Color Variables
The CSS variables within the dark mode block have been updated with new HSL values to support the refreshed design. Please verify that these new values provide the intended contrast and maintain accessibility standards across all affected components. Additionally, confirm consistency with the overall design system for dark mode.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 531d23a and d172e53.

📒 Files selected for processing (6)
  • apps/admin-x-activitypub/src/components/feed/FeedItem.tsx (2 hunks)
  • apps/admin-x-activitypub/src/components/layout/Header.tsx (2 hunks)
  • apps/admin-x-activitypub/src/components/layout/Sidebar/Sidebar.tsx (2 hunks)
  • apps/admin-x-activitypub/src/components/layout/Sidebar/SidebarButton.tsx (2 hunks)
  • apps/admin-x-activitypub/src/views/Inbox/Inbox.tsx (1 hunks)
  • apps/shade/styles.css (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • apps/admin-x-activitypub/src/components/layout/Header.tsx
  • apps/admin-x-activitypub/src/components/feed/FeedItem.tsx
  • apps/admin-x-activitypub/src/views/Inbox/Inbox.tsx
  • apps/admin-x-activitypub/src/components/layout/Sidebar/Sidebar.tsx
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Unit tests (Node 22.13.1)
  • GitHub Check: Unit tests (Node 20.11.1)
  • GitHub Check: Unit tests (Node 18.12.1)
  • GitHub Check: Lint
🔇 Additional comments (5)
apps/admin-x-activitypub/src/components/layout/Sidebar/SidebarButton.tsx (2)

4-7: Well-structured component with proper TypeScript implementation!

The component follows React best practices with proper type definitions, ref forwarding, and clear prop interface.

Also applies to: 9-10


15-16: Verify color contrast ratios for accessibility.

While the styling changes enhance visual consistency, please ensure the color combinations meet WCAG accessibility standards, particularly:

  • Text color (text-gray-500) against background (bg-gray-925/70) in dark mode
  • White text against the semi-transparent background in active state
#!/usr/bin/env python3
from colorsys import rgb_to_hls
import math

def hex_to_rgb(hex_color):
    hex_color = hex_color.lstrip('#')
    return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))

def get_relative_luminance(r, g, b):
    r = r / 255
    g = g / 255
    b = b / 255
    
    r = r / 12.92 if r <= 0.03928 else ((r + 0.055) / 1.055) ** 2.4
    g = g / 12.92 if g <= 0.03928 else ((g + 0.055) / 1.055) ** 2.4
    b = b / 12.92 if b <= 0.03928 else ((b + 0.055) / 1.055) ** 2.4
    
    return 0.2126 * r + 0.7152 * g + 0.0722 * b

def get_contrast_ratio(color1, color2, opacity=1.0):
    # Convert hex to RGB
    rgb1 = hex_to_rgb(color1)
    rgb2 = hex_to_rgb(color2)
    
    # Calculate luminance
    l1 = get_relative_luminance(*rgb1)
    l2 = get_relative_luminance(*rgb2)
    
    # Apply opacity to background
    if opacity < 1.0:
        l2 = l2 * opacity + l1 * (1 - opacity)
    
    # Calculate contrast ratio
    lighter = max(l1, l2)
    darker = min(l1, l2)
    return (lighter + 0.05) / (darker + 0.05)

# Test color combinations
# Assuming Tailwind's gray-500 is #6B7280
# Assuming gray-925 is close to #111111
text_color = "#6B7280"  # gray-500
bg_color = "#111111"    # gray-925
white = "#FFFFFF"

# Calculate contrast ratios
print(f"Dark mode text contrast ratio: {get_contrast_ratio(text_color, bg_color, 0.7):.2f}")
print(f"Active state text contrast ratio: {get_contrast_ratio(white, bg_color, 0.7):.2f}")

# WCAG 2.1 requirements:
# - AA requires 4.5:1 for normal text
# - AAA requires 7:1 for normal text
apps/shade/styles.css (3)

148-150: Apply Text Color for Dark Mode Shade
The selector .dark .shade now assigns a text color of #fafafb, which should improve readability against the updated dark backgrounds. Ensure that this color choice meets the required contrast ratios and aligns with the overall dark mode design.


152-154: Dark Mode Loading Orb Container Styling
The updated rule for .dark .shade .gh-loading-orb-container now sets the background color to #000000. This appears to create a strong, clear backdrop for loading animations in dark mode. Please verify that this styling choice is consistent with the intended design and does not cause any unintended visual issues.


156-158: Ensure Proper Inversion for Loading Orb Icon
The rule for .dark .shade .gh-loading-orb applies filter: invert(100%); to the loading orb icon, which is intended to enhance its visibility on a dark background. Please confirm that this 100% inversion preserves the icon’s design integrity and does not adversely affect its clarity or accessibility.

@peterzimon peterzimon merged commit 4d36d0b into main Feb 20, 2025
20 checks passed
@peterzimon peterzimon deleted the ap-ui-refinements branch February 20, 2025 07:27
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