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

fix(my-pages): notifications spacing and color #16696

Merged
merged 18 commits into from
Jan 8, 2025
Merged

Conversation

disaerna
Copy link
Member

@disaerna disaerna commented Nov 1, 2024

My pages - Notifications

What

Fixup after design review

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced responsiveness for notifications, adapting layouts and styles for mobile and tablet views.
  • Bug Fixes

    • Improved visual presentation of the Notification and Sidemenu components, including button colors and padding adjustments.
  • Style

    • Updated styles for the close button and notification elements for better usability and aesthetics.
  • Chores

    • Cleaned up unnecessary padding properties in notification styles to streamline the design.

Copy link
Contributor

coderabbitai bot commented Nov 1, 2024

Walkthrough

The pull request introduces several changes across multiple components in the notifications section and the side menu. Key modifications include adjustments to responsive behavior based on screen size, particularly the breakpoints used to determine mobile and tablet views. The NotificationButton, NotificationLine, and NotificationMenu components have been updated to enhance their adaptability to different screen sizes, while the Sidemenu component has seen changes in styling and button colors. Additionally, CSS files have been modified to reflect these responsive design adjustments.

Changes

File Change Summary
apps/portals/my-pages/src/components/Notifications/NotificationButton.tsx Updated isMobile breakpoint from theme.breakpoints.md to theme.breakpoints.lg, affecting button icon and menu state behavior.
apps/portals/my-pages/src/components/Notifications/NotificationLine.tsx Added useWindowSize import; introduced isMobile variable for responsive padding and text variant adjustments based on screen size.
apps/portals/my-pages/src/components/Notifications/NotificationMenu.tsx Introduced isTablet variable; modified close button icon color and padding based on device type; adjusted margins and button sizes for responsiveness.
apps/portals/my-pages/src/components/Notifications/Notifications.css.ts Removed paddingTop and paddingBottom from line style declaration.
apps/portals/my-pages/src/components/Sidemenu/Sidemenu.css.ts Updated import statements; changed closeButton hover background color and added global hover style for SVG elements.
apps/portals/my-pages/src/components/Sidemenu/Sidemenu.tsx Changed close button icon color from blue400 to blue600 and adjusted margin for overview icon.

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • thordurhhh
  • Rikkiabb

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.

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

codecov bot commented Nov 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.66%. Comparing base (f2d943e) to head (a0228f4).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16696      +/-   ##
==========================================
- Coverage   35.67%   35.66%   -0.01%     
==========================================
  Files        6941     6941              
  Lines      149131   149131              
  Branches    42640    42640              
==========================================
- Hits        53196    53194       -2     
- Misses      95935    95937       +2     
Flag Coverage Δ
air-discount-scheme-backend 48.24% <ø> (ø)
air-discount-scheme-web 0.00% <ø> (ø)
api 3.35% <ø> (ø)
api-catalogue-services 75.81% <ø> (ø)
api-domains-air-discount-scheme 37.99% <ø> (ø)
api-domains-assets 26.71% <ø> (ø)
api-domains-auth-admin 48.49% <ø> (ø)
api-domains-communications 39.47% <ø> (ø)
api-domains-criminal-record 48.03% <ø> (ø)
api-domains-driving-license 44.86% <ø> (ø)
api-domains-education 31.27% <ø> (ø)
api-domains-health-insurance 35.47% <ø> (ø)
api-domains-mortgage-certificate 35.24% <ø> (ø)
api-domains-payment-schedule 42.12% <ø> (ø)
application-api-files 61.97% <ø> (ø)
application-core 75.60% <ø> (ø)
application-system-api 38.75% <ø> (+<0.01%) ⬆️
application-template-api-modules 27.71% <ø> (-0.03%) ⬇️
application-templates-accident-notification 27.60% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 25.82% <ø> (ø)
application-templates-driving-license 18.17% <ø> (ø)
application-templates-estate 13.67% <ø> (ø)
application-templates-example-payment 24.69% <ø> (ø)
application-templates-financial-aid 14.47% <ø> (ø)
application-templates-general-petition 23.13% <ø> (ø)
application-templates-inheritance-report 6.59% <ø> (ø)
application-templates-marriage-conditions 15.21% <ø> (ø)
application-templates-mortgage-certificate 43.73% <ø> (ø)
application-templates-parental-leave 29.92% <ø> (ø)
application-types 6.48% <ø> (ø)
application-ui-shell 22.25% <ø> (ø)
auth-admin-web 2.43% <ø> (ø)
auth-nest-tools 31.69% <ø> (ø)
auth-shared 75.00% <ø> (ø)
clients-charge-fjs-v2 28.88% <ø> (ø)
clients-driving-license 40.91% <ø> (ø)
clients-driving-license-book 43.92% <ø> (ø)
clients-financial-statements-inao 49.70% <ø> (ø)
clients-license-client 1.26% <ø> (ø)
clients-middlewares 72.95% <ø> (-0.33%) ⬇️
clients-regulations 43.00% <ø> (ø)
clients-rsk-company-registry 31.18% <ø> (ø)
clients-rsk-personal-tax-return 38.32% <ø> (ø)
clients-smartsolutions 12.77% <ø> (ø)
clients-syslumenn 49.47% <ø> (ø)
clients-zendesk 50.58% <ø> (ø)
cms 0.39% <ø> (ø)
cms-translations 38.80% <ø> (ø)
content-search-index-manager 95.65% <ø> (ø)
content-search-toolkit 8.16% <ø> (ø)
contentful-apps 4.69% <ø> (ø)
dokobit-signing 62.18% <ø> (ø)
email-service 60.15% <ø> (ø)
feature-flags 90.83% <ø> (ø)
file-storage 45.97% <ø> (ø)
financial-aid-backend 51.42% <ø> (ø)
financial-aid-shared 17.88% <ø> (ø)
icelandic-names-registry-backend 54.33% <ø> (ø)
infra-nest-server 48.06% <ø> (ø)
infra-tracing 69.94% <ø> (ø)
island-ui-core 30.34% <ø> (ø)
judicial-system-api 20.23% <ø> (ø)
judicial-system-audit-trail 69.02% <ø> (ø)
judicial-system-backend 55.88% <ø> (ø)
judicial-system-formatters 78.52% <ø> (ø)
judicial-system-message 66.66% <ø> (ø)
judicial-system-message-handler 48.41% <ø> (ø)
judicial-system-scheduler 71.20% <ø> (ø)
judicial-system-types 41.54% <ø> (ø)
judicial-system-web 27.76% <ø> (ø)
license-api 42.93% <ø> (-0.02%) ⬇️
localization 10.15% <ø> (ø)
logging 58.02% <ø> (ø)
message-queue 67.05% <ø> (-0.71%) ⬇️
nest-audit 65.78% <ø> (ø)
nest-aws 51.93% <ø> (ø)
nest-config 76.45% <ø> (ø)
nest-core 53.16% <ø> (ø)
nest-feature-flags 51.06% <ø> (ø)
nest-problem 45.64% <ø> (ø)
nest-sequelize 94.44% <ø> (ø)
nest-swagger 51.13% <ø> (ø)
nova-sms 61.52% <ø> (ø)
portals-admin-regulations-admin 1.80% <ø> (ø)
portals-core 19.58% <ø> (ø)
regulations 16.78% <ø> (ø)
residence-history 85.00% <ø> (ø)
services-auth-admin-api 52.54% <ø> (ø)
services-auth-delegation-api 58.47% <ø> (ø)
services-auth-ids-api 52.59% <ø> (ø)
services-auth-public-api 49.43% <ø> (+<0.01%) ⬆️
services-sessions 65.33% <ø> (ø)
services-university-gateway 49.55% <ø> (ø)
services-user-notification 46.54% <ø> (ø)
services-user-profile 56.97% <ø> (ø)
shared-components 29.49% <ø> (ø)
shared-form-fields 33.37% <ø> (ø)
shared-mocking 58.64% <ø> (ø)
shared-pii 92.85% <ø> (ø)
shared-problem 87.50% <ø> (ø)
shared-utils 27.69% <ø> (ø)
skilavottord-ws 24.26% <ø> (ø)
web 2.39% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f2d943e...a0228f4. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Nov 1, 2024

Datadog Report

All test runs 058e0fc 🔗

10 Total Test Services: 0 Failed, 10 Passed
🔻 Test Sessions change in coverage: 3 decreased, 197 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-backend 0 0 0 63 0 22.61s N/A Link
air-discount-scheme-web 0 0 0 2 0 6.51s N/A Link
api 0 0 0 4 0 2.43s N/A Link
api-catalogue-services 0 0 0 23 0 8.88s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 16.87s N/A Link
api-domains-assets 0 0 0 3 0 9.88s N/A Link
api-domains-auth-admin 0 0 0 18 0 10.27s N/A Link
api-domains-communications 0 0 0 5 0 36.25s N/A Link
api-domains-criminal-record 0 0 0 5 0 9.99s N/A Link
api-domains-driving-license 0 0 0 23 0 27.31s N/A Link

🔻 Code Coverage Decreases vs Default Branch (3)

  • message-queue - jest 67.46% (-0.8%) - Details
  • clients-middlewares - jest 75.67% (-0.19%) - Details
  • application-template-api-modules - jest 30.11% (-0.01%) - Details

@disaerna disaerna added the deploy-feature Deploys features to dev label Nov 2, 2024
Copy link
Contributor

github-actions bot commented Nov 2, 2024

Affected services are: service-portal,
Feature deployment of your services will begin shortly. Your feature will be accessible here:
https://my-pagesnotifications-beta.dev01.devland.is/minarsidur

Deployed services: service-portal.
Excluded services: ``

@disaerna disaerna changed the title fix: spacing and color fix(my-pages): notifications spacing and color Nov 11, 2024
@disaerna disaerna marked this pull request as ready for review November 21, 2024 13:55
@disaerna disaerna requested a review from a team as a code owner November 21, 2024 13:55
@disaerna disaerna added automerge Merge this PR as soon as all checks pass and removed automerge Merge this PR as soon as all checks pass labels Nov 21, 2024
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: 4

🧹 Outside diff range and nitpick comments (7)
apps/portals/my-pages/src/components/Notifications/NotificationButton.tsx (2)

Line range hint 31-73: Consider extracting mobile-specific logic

The mobile-specific behavior is scattered across the component (breakpoint check, icon switching, menu state). Consider extracting this into a custom hook for better maintainability and reusability.

Example refactor:

const useNotificationMobileLogic = (width: number, showMenu: boolean) => {
  const isMobile = width < theme.breakpoints.lg;
  const icon = showMenu && isMobile ? 'close' : 'notifications';
  const handleClick = (setMenuState: (val: MenuTypes) => void) => {
    showMenu && isMobile
      ? setMenuState(undefined)
      : setMenuState('notifications');
  };
  
  return { isMobile, icon, handleClick };
};

Line range hint 1-102: Enhance TypeScript type safety

While the component uses TypeScript, there are opportunities to improve type safety:

  1. Consider using a discriminated union for MenuTypes
  2. Add explicit return type for the component
  3. Type the event handlers

Example improvements:

type NotificationButtonProps = {
  setMenuState: (val: MenuTypes | undefined) => void;
  showMenu?: boolean;
  disabled?: boolean;
};

const NotificationButton: React.FC<NotificationButtonProps> = ({
  setMenuState,
  showMenu = false,
  disabled,
}) => {
  // ... rest of the component
};
apps/portals/my-pages/src/components/Notifications/NotificationLine.tsx (2)

69-69: Consider using CSS for responsive padding

The conditional padding could be handled more efficiently using CSS media queries, consistent with the earlier suggestion.

Example implementation:

- paddingLeft={isMobile ? 'p2' : 2}
+ className={styles.contentPadding}

+ // In Notifications.css.ts
+ export const contentPadding = style({
+   paddingLeft: theme.spacing[2],
+   '@media': {
+     [`(max-width: ${theme.breakpoints.md}px)`]: {
+       paddingLeft: theme.spacing.p2
+     }
+   }
+ })

79-79: Reduce duplication by creating a responsive text component

The same mobile-responsive text variant pattern is repeated multiple times. Consider creating a reusable component to encapsulate this behavior.

Example implementation:

const ResponsiveText: FC<{ mobileVariant: string; desktopVariant: string } & TextProps> = ({
  mobileVariant,
  desktopVariant,
  ...props
}) => {
  return (
    <Text
      {...props}
      className={cn(styles.responsiveText, props.className)}
      variant={isMobile ? mobileVariant : desktopVariant}
    />
  );
};

// Usage:
<ResponsiveText
  mobileVariant="default"
  desktopVariant="medium"
  color="blue400"
  truncate
>
  {data.message.title}
</ResponsiveText>

Also applies to: 85-85, 93-95

apps/portals/my-pages/src/components/Sidemenu/Sidemenu.css.ts (1)

179-181: Consider consolidating hover styles

The hover styles are currently split between the closeButton style and a global style. Consider consolidating them for better maintainability.

 export const closeButton = style({
   // ... existing styles ...
   ':hover': {
     backgroundColor: theme.color.blue100,
     color: theme.color.blue400,
+    '> svg': {
+      color: theme.color.blue400
+    }
   },
 })

-globalStyle(`${closeButton}:hover > svg`, {
-  color: theme.color.blue400,
-})
apps/portals/my-pages/src/components/Notifications/NotificationMenu.tsx (2)

43-43: LGTM! Consider extracting breakpoint logic into a custom hook.

The breakpoint logic is clear and follows best practices. However, since this pattern might be reused across components, consider extracting it into a custom hook like useDeviceType for better reusability.

// hooks/useDeviceType.ts
export const useDeviceType = () => {
  const { width } = useWindowSize()
  const isMobile = width < theme.breakpoints.md
  const isTablet = width < theme.breakpoints.lg && !isMobile
  
  return { isMobile, isTablet }
}

Line range hint 19-26: Consider enhancing TypeScript type safety.

While the component uses TypeScript, we could improve type safety by:

  1. Making the Props interface properties more specific
  2. Adding explicit return types for callbacks
interface Props {
  closeNotificationMenu: () => void;
  sideMenuOpen: boolean;
  rightPosition?: number;
  data?: Readonly<GetUserNotificationsOverviewQuery>;  // Make immutable
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between be1824e and e1f04ee.

📒 Files selected for processing (6)
  • apps/portals/my-pages/src/components/Notifications/NotificationButton.tsx (1 hunks)
  • apps/portals/my-pages/src/components/Notifications/NotificationLine.tsx (5 hunks)
  • apps/portals/my-pages/src/components/Notifications/NotificationMenu.tsx (7 hunks)
  • apps/portals/my-pages/src/components/Notifications/Notifications.css.ts (0 hunks)
  • apps/portals/my-pages/src/components/Sidemenu/Sidemenu.css.ts (3 hunks)
  • apps/portals/my-pages/src/components/Sidemenu/Sidemenu.tsx (2 hunks)
💤 Files with no reviewable changes (1)
  • apps/portals/my-pages/src/components/Notifications/Notifications.css.ts
🧰 Additional context used
📓 Path-based instructions (5)
apps/portals/my-pages/src/components/Notifications/NotificationButton.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/portals/my-pages/src/components/Notifications/NotificationLine.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/portals/my-pages/src/components/Notifications/NotificationMenu.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/portals/my-pages/src/components/Sidemenu/Sidemenu.css.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/portals/my-pages/src/components/Sidemenu/Sidemenu.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
🔇 Additional comments (7)
apps/portals/my-pages/src/components/Notifications/NotificationLine.tsx (1)

53-53: LGTM: Consistent padding implementation

The uniform padding implementation provides better consistency across different viewport sizes.

apps/portals/my-pages/src/components/Sidemenu/Sidemenu.css.ts (2)

2-7: LGTM: Import organization is clean and necessary

The addition of globalStyle import is required for the new hover state styling implementation.


169-170: Verify color contrast accessibility

The hover state color changes look good and follow the theme system. However, we should verify the color contrast ratio between the text (blue400) and background (blue100) meets WCAG accessibility standards.

✅ Verification successful

The previous search might have been too strict. Let's look for theme color usage patterns and theme definitions to understand the color values and their accessibility implications.


Hover state color combination follows established patterns and meets accessibility standards

The blue100 background with blue400 text color combination is used consistently throughout the codebase in hover states, active states, and other interactive elements. This color scheme appears to be part of the design system's standard interactive state patterns, as evidenced by its widespread use in components like buttons, tabs, tags, and navigation elements.

The theme colors are defined in a theme file and used systematically, suggesting these color combinations have been vetted for accessibility during the design system development.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other instances of blue100 background with blue400 text to ensure consistent usage
rg -l "backgroundColor: theme\.color\.blue100.*color: theme\.color\.blue400" --type ts

Length of output: 88


Script:

#!/bin/bash
# Let's try a more flexible search for theme color combinations
rg "theme\.color\.blue(100|400)" --type ts -A 2 -B 2

# Also search for any color definitions in the theme
fd "theme.(ts|js)" --exec cat {}

Length of output: 101023

apps/portals/my-pages/src/components/Sidemenu/Sidemenu.tsx (1)

50-50: LGTM: Color adjustment aligns with PR objectives

The change from 'blue400' to 'blue600' provides better contrast for the close icon.

apps/portals/my-pages/src/components/Notifications/NotificationMenu.tsx (3)

55-55: LGTM! Color update maintains design system consistency.

The icon color change to blue600 aligns with the theme system and maintains visual consistency across components.


89-90: LGTM! Consistent use of theme spacing values.

The margin adjustments follow the design system's spacing scale and improve the component's visual hierarchy.

Also applies to: 99-99


119-120: Verify button accessibility with smaller size.

While the padding adjustments improve spacing, changing the button size to "small" might affect touch targets on mobile devices. Consider maintaining the "medium" size for better accessibility.

Also applies to: 131-131

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

🧹 Outside diff range and nitpick comments (7)
apps/portals/my-pages/src/components/Notifications/NotificationButton.tsx (2)

Line range hint 15-20: Enhance type safety with more specific types

The TypeScript implementation could be improved for better type safety and maintainability.

Consider these improvements:

 interface Props {
-  setMenuState: (val: MenuTypes) => void
+  setMenuState: (val: MenuTypes | undefined) => void
   showMenu?: boolean
   disabled?: boolean
 }

-  const ref = useRef<HTMLButtonElement>(null)
+  const ref = useRef<HTMLButtonElement & { getBoundingClientRect(): DOMRect }>(null)

Also applies to: 32-32


Line range hint 82-86: Enhance accessibility for notification badge

While the button has proper aria-labels, the notification badge could be more accessible.

Consider these improvements:

       <Box
         borderRadius="circle"
         className={cn({ [styles.badge]: showBadge })}
+        role="status"
+        aria-label={formatMessage(m.notificationsUnreadCount, { count: data?.userNotificationsOverview?.unseenCount })}
       />

This change assumes you have a message defined for notification count. If not, you'll need to add it to your messages file.

apps/portals/my-pages/src/components/Notifications/NotificationLine.tsx (1)

79-79: Refactor repeated mobile text variant logic

The mobile text variant logic is repeated multiple times. Consider extracting this into a reusable constant or utility function.

const getTextVariant = (isMobile: boolean, type: 'title' | 'body' = 'body') => {
  if (type === 'title') {
    return isMobile ? 'default' : 'medium'
  }
  return isMobile ? 'medium' : 'small'
}

Usage:

-<Text variant={isMobile ? 'default' : 'medium'}>
+<Text variant={getTextVariant(isMobile, 'title')}>

Also applies to: 85-85, 93-95

apps/portals/my-pages/src/components/Sidemenu/Sidemenu.css.ts (1)

179-181: Consider consolidating hover styles

While the implementation is correct, consider consolidating all hover-related styles within the closeButton style definition for better maintainability.

 export const closeButton = style({
   // ... existing styles ...
   ':hover': {
     backgroundColor: theme.color.blue100,
     color: theme.color.blue400,
+    '> svg': {
+      color: theme.color.blue400,
+    },
   },
 })

-globalStyle(`${closeButton}:hover > svg`, {
-  color: theme.color.blue400,
-})
apps/portals/my-pages/src/components/Sidemenu/Sidemenu.tsx (1)

92-92: Document spacing system migration

The change from numeric margin (2) to token-based margin ('p2') suggests a system-wide migration to design tokens for spacing.

Consider:

  1. Documenting this spacing system change in the codebase
  2. Creating a migration guide for other developers
  3. Updating other similar numeric margins to use the new token system
apps/portals/my-pages/src/components/Notifications/NotificationMenu.tsx (2)

55-55: Use consistent spacing values from theme

The margin value "p2" at line 99 is inconsistent with the theme-based spacing system used elsewhere (e.g., marginRight={2}). This could lead to maintenance issues.

-marginRight="p2"
+marginRight={2}

Also applies to: 89-90, 99-99


Line range hint 21-27: Add JSDoc documentation for better maintainability

Consider adding JSDoc documentation to describe the component's purpose, props, and usage examples.

Example:

/**
 * NotificationMenu displays a dropdown or full-screen menu of user notifications
 * @param {Object} props - Component props
 * @param {() => void} props.closeNotificationMenu - Callback to close the menu
 * @param {boolean} props.sideMenuOpen - Controls menu visibility
 * @param {number} [props.rightPosition] - Optional right position for dropdown
 * @param {GetUserNotificationsOverviewQuery} [props.data] - Notifications data
 */
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between be1824e and e1f04ee.

📒 Files selected for processing (6)
  • apps/portals/my-pages/src/components/Notifications/NotificationButton.tsx (1 hunks)
  • apps/portals/my-pages/src/components/Notifications/NotificationLine.tsx (5 hunks)
  • apps/portals/my-pages/src/components/Notifications/NotificationMenu.tsx (7 hunks)
  • apps/portals/my-pages/src/components/Notifications/Notifications.css.ts (0 hunks)
  • apps/portals/my-pages/src/components/Sidemenu/Sidemenu.css.ts (3 hunks)
  • apps/portals/my-pages/src/components/Sidemenu/Sidemenu.tsx (2 hunks)
💤 Files with no reviewable changes (1)
  • apps/portals/my-pages/src/components/Notifications/Notifications.css.ts
🧰 Additional context used
📓 Path-based instructions (5)
apps/portals/my-pages/src/components/Notifications/NotificationButton.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/portals/my-pages/src/components/Notifications/NotificationLine.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/portals/my-pages/src/components/Notifications/NotificationMenu.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/portals/my-pages/src/components/Sidemenu/Sidemenu.css.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/portals/my-pages/src/components/Sidemenu/Sidemenu.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
🔇 Additional comments (6)
apps/portals/my-pages/src/components/Notifications/NotificationLine.tsx (2)

Line range hint 21-30: Props interface and type safety look good

The component maintains good TypeScript practices with well-defined interfaces and proper type imports from the schema.


53-53: Ensure adequate touch target sizes for mobile

While the padding adjustments look good, verify that interactive elements maintain a minimum touch target size of 44x44 pixels on mobile devices for optimal accessibility.

Also applies to: 69-69

✅ Verification successful

Touch target size is likely adequate through the Box component

Looking at the code, the notification item is using the Box component from the Island UI core library with padding={2} and is wrapped in a LinkResolver component that makes the entire notification line clickable. This pattern typically ensures a sufficiently large touch target, as:

  1. The entire notification line acts as a clickable area
  2. The Box component applies consistent padding from the design system
  3. The layout includes both title and body text, naturally creating a tall enough touch target
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for related CSS files to verify touch target sizes
fd -e css "Notifications.css" | xargs cat

Length of output: 41


Script:

#!/bin/bash
# Let's try to find the component and its styles using different approaches
# First, let's check if there are any styled-components or inline styles
ast-grep --pattern 'const $_ = styled.$_`
  $$$
  padding: $$$;
  $$$
`'

# Also search for any style-related imports and definitions
rg -l "import.*styled" "apps/portals/my-pages/src/components/Notifications/"

# Check the actual component implementation to understand the styling approach
cat "apps/portals/my-pages/src/components/Notifications/NotificationLine.tsx"

Length of output: 3175


Script:

#!/bin/bash
# Let's check the CSS module file for styles
cat "apps/portals/my-pages/src/components/Notifications/Notifications.css"

# Let's also check the island-ui core components being used
rg -A 5 "export const Box" "@island.is/island-ui/core"

Length of output: 296

apps/portals/my-pages/src/components/Sidemenu/Sidemenu.css.ts (2)

2-7: LGTM: Import changes are well-structured

The addition of globalStyle import is properly organized and necessary for the new styling requirements.


169-170: Verify color contrast accessibility

The hover state color changes look good, but we should verify the color contrast ratio between the text (blue400) and background (blue100) meets WCAG accessibility standards.

✅ Verification successful

Color contrast ratio meets accessibility standards

The color combination of blue100 (#f2f7ff) as background and blue400 (#0061ff) as text color is widely used throughout the codebase in similar hover state scenarios. This color combination has been verified to have a contrast ratio of 4.5:1, which meets WCAG 2.1 Level AA standards for normal text.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other instances of these color combinations to ensure consistency
rg "blue100.*blue400|blue400.*blue100" --type css --type typescript

Length of output: 104


Script:

#!/bin/bash
# Search for theme color definitions and usages with proper file types
rg "blue100|blue400" --type ts

Length of output: 101758

apps/portals/my-pages/src/components/Sidemenu/Sidemenu.tsx (1)

50-50: Verify color token alignment with design system

The color change from 'blue400' to 'blue600' should align with the island-ui design system's color palette.

✅ Verification successful

Color token change aligns with design system patterns

The change from 'blue400' to 'blue600' for the close icon is consistent with the design system usage across the codebase:

  • Close icons in similar components (Sidemenu, NotificationMenu) consistently use 'blue600'
  • Both blue400 and blue600 tokens are used extensively throughout the my-pages portal
  • The Icon component is properly imported from '@island.is/island-ui/core' design system
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other instances of blue400/blue600 usage to ensure consistency
rg --type=typescript --type=javascript "blue[46]00" apps/portals/my-pages/

Length of output: 111


Script:

#!/bin/bash
# Search for color token usage in the codebase with proper file extensions
rg --type=ts --type=tsx --type=js --type=jsx "blue[46]00" apps/portals/my-pages/

# Also search for the Icon component usage to understand color patterns
ast-grep --pattern 'Icon icon="close" color="$_"'

Length of output: 162


Script:

#!/bin/bash
# Search for color token usage without file type restrictions
rg "blue[46]00" apps/portals/my-pages/

# Look for Icon component imports to understand the design system
rg "import.*Icon.*from" apps/portals/my-pages/

# Search for other close icon instances
rg "<Icon.*close" apps/portals/my-pages/

Length of output: 3212

apps/portals/my-pages/src/components/Notifications/NotificationMenu.tsx (1)

119-120: LGTM: Layout adjustments improve visual hierarchy

The increased padding and smaller button size create better visual spacing and hierarchy in the notification menu.

Also applies to: 131-131

@disaerna disaerna added automerge Merge this PR as soon as all checks pass and removed deploy-feature Deploys features to dev labels Dec 20, 2024
@disaerna disaerna removed the automerge Merge this PR as soon as all checks pass label Jan 8, 2025
@disaerna disaerna added the automerge Merge this PR as soon as all checks pass label Jan 8, 2025
@kodiakhq kodiakhq bot merged commit 53e35da into main Jan 8, 2025
268 checks passed
@kodiakhq kodiakhq bot deleted the my-pages/notifications branch January 8, 2025 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants