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

feat(web): Manual chapter links #16314

Merged
merged 4 commits into from
Oct 8, 2024
Merged

Conversation

RunarVestmann
Copy link
Member

@RunarVestmann RunarVestmann commented Oct 8, 2024

Manual chapter links

What

  • At the bottom of each chapter will be a link to previous and next chapter
  • Also some padding and link style changes

Why

  • Simplifies navigation

Screenshots / Gifs

Screen.Recording.2024-10-08.at.12.36.24.mov

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

  • New Features

    • Enhanced organization headers and footers with theme-specific rendering.
    • Improved navigation within manual chapters with new previous and next buttons.
  • Bug Fixes

    • Adjusted layout spacing for better visual clarity in manual components.
  • Chores

    • Removed unused styling for small links in the manual.

@RunarVestmann RunarVestmann added the automerge Merge this PR as soon as all checks pass label Oct 8, 2024
@RunarVestmann RunarVestmann requested review from a team as code owners October 8, 2024 12:35
Copy link
Contributor

coderabbitai bot commented Oct 8, 2024

Walkthrough

The pull request introduces modifications to the OrganizationWrapper.tsx, Manual.css.ts, ManualChapter.tsx, and ManualChangelog.tsx files. Key changes include enhanced rendering logic for organization-specific headers and footers based on themes in OrganizationWrapper.tsx, the removal of a style export in Manual.css.ts, and improvements to navigation functionality in ManualChapter.tsx. Additionally, layout adjustments and spacing modifications were made in the ManualChangelog.tsx component. These changes collectively enhance component flexibility and navigation experience.

Changes

File Path Change Summary
apps/web/components/Organization/Wrapper/OrganizationWrapper.tsx Updated rendering logic for OrganizationHeader and OrganizationFooter to support multiple organization themes. Added unfocusable property to back link button and adjusted sidebar rendering logic. Method signatures updated for several components.
apps/web/screens/Manual/Manual.css.ts Removed smallLink export, which was previously defined with a font size of 14px.
apps/web/screens/Manual/ManualChapter.tsx Introduced useMemo to compute previousChapterUrl and nextChapterUrl for navigation. Adjusted layout spacing and added localized navigation buttons.
apps/web/screens/Manual/ManualChangelog.tsx Increased spacing in Stack component, changed class name in LinkV2, and modified Accordion behavior to allow multiple expansions.

Possibly related PRs

Suggested reviewers

  • mannipje

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
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 (2)
apps/web/screens/Manual/ManualChapter.tsx (2)

96-129: Include manualChapter?.slug in the dependency array of useMemo

The useMemo hook depends on manualChapter?.slug because it determines when the memoized value should be recalculated. Currently, manualChapter?.id is included, but if manualChapter?.slug can change independently, it should be added to the dependency array to ensure consistency.

Update the dependency array:

      }, [
        linkResolver,
        manual?.chapters,
        manual?.slug,
        manualChapter?.id,
+       manualChapter?.slug,
      ])

195-240: Adjust justifyContent for consistent button alignment

The Inline component uses justifyContent="spaceBetween", which spreads the navigation buttons to the edges. If the intention is to have the navigation buttons next to each other or centered, consider changing justifyContent to "center" or removing it for default alignment.

Example adjustment:

<Inline space={3} alignY="center" justifyContent="spaceBetween">
+ <Inline space={3} alignY="center">
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6ce1b55 and 69413fd.

📒 Files selected for processing (4)
  • apps/web/components/Organization/Wrapper/OrganizationWrapper.tsx (1 hunks)
  • apps/web/screens/Manual/Manual.css.ts (0 hunks)
  • apps/web/screens/Manual/ManualChapter.tsx (3 hunks)
  • apps/web/screens/Manual/components/ManualWrapper.tsx (1 hunks)
💤 Files with no reviewable changes (1)
  • apps/web/screens/Manual/Manual.css.ts
🧰 Additional context used
📓 Path-based instructions (3)
apps/web/components/Organization/Wrapper/OrganizationWrapper.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/web/screens/Manual/ManualChapter.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/web/screens/Manual/components/ManualWrapper.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 (3)
apps/web/screens/Manual/components/ManualWrapper.tsx (2)

36-36: Spacing adjustment aligns with PR objectives

The change from space={3} to space={5} in the Stack component increases the vertical spacing between the ManualHeader and the children components. This adjustment aligns with the PR objective of improving the overall user experience by enhancing the layout and readability of the manual chapters.

The modification is subtle yet effective, providing more breathing room between elements without drastically altering the layout. This change contributes to a cleaner, more organized appearance, which can improve navigation and readability for users.


Line range hint 1-45: Well-structured component implementation

The ManualWrapper component is well-implemented and aligns with NextJS and React best practices:

  1. It uses TypeScript for prop types, enhancing type safety.
  2. The component structure is clean and easy to understand.
  3. It utilizes components from the island-ui/core library, promoting consistency across the application.
  4. The implementation of SidebarLayout supports the manual navigation structure mentioned in the PR objectives.

The overall structure and implementation of this component provide a solid foundation for the manual chapter navigation feature.

apps/web/components/Organization/Wrapper/OrganizationWrapper.tsx (1)

1149-1149: ⚠️ Potential issue

Verify if unfocusable is a valid prop for Button

The unfocusable prop has been added to the Button component. Please ensure that unfocusable is a valid prop for the Button component from @island.is/island-ui/core. If it's not a recognized prop, it may not have the intended effect and could cause unexpected behavior.

Run the following script to verify if unfocusable is defined in the Button component:

apps/web/screens/Manual/ManualChapter.tsx Outdated Show resolved Hide resolved
apps/web/screens/Manual/ManualChapter.tsx Outdated Show resolved Hide resolved
apps/web/screens/Manual/ManualChapter.tsx Outdated Show resolved Hide resolved
Copy link

codecov bot commented Oct 8, 2024

Codecov Report

Attention: Patch coverage is 0% with 30 lines in your changes missing coverage. Please review.

Project coverage is 36.87%. Comparing base (1c660fe) to head (610b675).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
apps/web/screens/Manual/ManualChapter.tsx 0.00% 29 Missing ⚠️
apps/web/screens/Manual/ManualChangelog.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16314      +/-   ##
==========================================
- Coverage   36.87%   36.87%   -0.01%     
==========================================
  Files        6801     6801              
  Lines      140611   140630      +19     
  Branches    39975    39990      +15     
==========================================
  Hits        51852    51852              
- Misses      88759    88778      +19     
Flag Coverage Δ
web 1.83% <0.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
...nents/Organization/Wrapper/OrganizationWrapper.tsx 0.00% <ø> (ø)
...ps/web/screens/Manual/components/ManualWrapper.tsx 0.00% <ø> (ø)
apps/web/screens/Manual/ManualChangelog.tsx 0.00% <0.00%> (ø)
apps/web/screens/Manual/ManualChapter.tsx 0.00% <0.00%> (ø)

... and 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 bc3f47a...610b675. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Oct 8, 2024

Datadog Report

Branch report: feature/web-manual-chapter-links
Commit report: 468f074
Test service: web

✅ 0 Failed, 84 Passed, 0 Skipped, 29.47s Total Time
➡️ Test Sessions change in coverage: 1 no change

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

🧹 Outside diff range and nitpick comments (1)
apps/web/screens/Manual/ManualChapter.tsx (1)

145-151: LGTM: Improved layout and styling

The changes to the Stack spacing, LinkV2 className, and Box padding improve the overall layout and styling of the component. Good job!

Consider using a constant for the Stack's space prop to improve maintainability:

const STACK_SPACING = 5;

// ...

<Stack space={STACK_SPACING}>
  {/* ... */}
</Stack>

Also applies to: 159-159

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 69413fd and faaa540.

📒 Files selected for processing (1)
  • apps/web/screens/Manual/ManualChapter.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
apps/web/screens/Manual/ManualChapter.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 (4)
apps/web/screens/Manual/ManualChapter.tsx (4)

10-12: LGTM: New imports added for navigation buttons

The addition of Button and Inline components from '@island.is/island-ui/core' is appropriate for implementing the new navigation functionality.


Line range hint 1-258: Overall assessment: Good implementation with room for minor improvements

The changes in this file successfully implement the new navigation functionality for manual chapters, aligning well with the PR objectives. The layout improvements and conditional rendering of navigation buttons enhance the user experience.

Key points:

  1. The navigation URL computation logic is sound but could be refactored for better readability and maintainability.
  2. Layout and styling changes improve the overall structure of the component.
  3. The accessibility issue with the unfocusable prop on navigation buttons should be addressed.

Once these minor improvements are made, the implementation will be excellent.


202-249: ⚠️ Potential issue

Remove unfocusable prop to improve accessibility

The implementation of navigation buttons aligns well with the PR objectives. However, the use of the unfocusable prop on the Button components (lines 215 and 237) can negatively impact accessibility for keyboard users.

As mentioned in a previous review comment, please remove the unfocusable prop from both Button components to ensure they remain focusable and accessible:

<Button
  // ...other props
- unfocusable
>
  {/* Button content */}
</Button>

To ensure this change is applied consistently, run the following command:

#!/bin/bash
# Check for any remaining usage of unfocusable prop in Button components
rg --type typescript 'unfocusable' apps/web/screens/Manual/ManualChapter.tsx

96-136: 🛠️ Refactor suggestion

Consider refactoring for improved readability and error handling

The useMemo hook effectively computes the navigation URLs. However, consider the following improvements:

  1. Extract the URL computation logic into a separate function for better readability.
  2. Use optional chaining to simplify null checks.
  3. Consider using early returns to reduce nesting.

Here's a suggested refactoring:

const getChapterUrls = (manual, manualChapter, linkResolver) => {
  if (!manual?.slug || !manualChapter?.id) {
    return { previousChapterUrl: '', nextChapterUrl: '' };
  }

  const index = manual.chapters.findIndex(
    (chapter) => chapter.id === manualChapter.id
  );

  if (index < 0) {
    return { previousChapterUrl: '', nextChapterUrl: '' };
  }

  const getUrl = (slug) =>
    slug ? linkResolver('manualchapter', [manual.slug, slug]).href : '';

  const previousChapterSlug = manual.chapters[index - 1]?.slug;
  const nextChapterSlug = manual.chapters[index + 1]?.slug;

  return {
    previousChapterUrl: getUrl(previousChapterSlug),
    nextChapterUrl: getUrl(nextChapterSlug),
  };
};

const { previousChapterUrl, nextChapterUrl } = useMemo(
  () => getChapterUrls(manual, manualChapter, linkResolver),
  [linkResolver, manual, manualChapter]
);

Please verify that this refactoring doesn't introduce any regressions:

✅ Verification successful

Verified: Refactoring suggestion is safe and does not introduce regressions

No issues found with the proposed changes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the usage of manual, manualChapter, and linkResolver
rg --type typescript 'const \{ previousChapterUrl, nextChapterUrl \}' apps/web/screens/Manual/ManualChapter.tsx

Length of output: 236


Script:

#!/bin/bash
# Corrected command to verify the usage of previousChapterUrl and nextChapterUrl
rg 'const \{ previousChapterUrl, nextChapterUrl \}' apps/web/screens/Manual/ManualChapter.tsx

Length of output: 160

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

🧹 Outside diff range and nitpick comments (2)
apps/web/screens/Manual/ManualChangelog.tsx (2)

55-59: LGTM: Improved link styling and consistency

The changes to the LinkV2 component enhance visual consistency and potentially improve accessibility:

  1. Changing the className from styles.smallLink to styles.link likely aligns this link's appearance with other links in the application.
  2. Adding the color="blue400" prop ensures a consistent color scheme and may improve contrast for better accessibility.

These modifications align well with the PR's objective of adjusting link styles for an improved user experience.

Consider adding a comment explaining the rationale behind these specific style choices, especially if they differ from the default link styles used elsewhere in the application. This would help maintain consistency in future updates.


98-98: LGTM: Enhanced user interaction with Accordion

Setting singleExpand={false} on the Accordion component allows multiple items to be expanded simultaneously. This change enhances the user experience by enabling users to compare information across different years without closing previously opened sections.

To further improve accessibility, consider adding an aria-label to the Accordion component to provide context for screen reader users. For example:

<Accordion singleExpand={false} aria-label="Changelog by year">

This addition would make the purpose of the accordion clearer for users relying on assistive technologies.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between faaa540 and 610b675.

📒 Files selected for processing (2)
  • apps/web/screens/Manual/ManualChangelog.tsx (2 hunks)
  • apps/web/screens/Manual/ManualChapter.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/screens/Manual/ManualChapter.tsx
🧰 Additional context used
📓 Path-based instructions (1)
apps/web/screens/Manual/ManualChangelog.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 (3)
apps/web/screens/Manual/ManualChangelog.tsx (3)

53-53: LGTM: Improved spacing for better readability

The increase in the Stack component's space prop from 2 to 5 enhances the vertical spacing between child components, improving overall readability and user experience. This change aligns well with the PR's objective of enhancing the visual structure of the ManualChangelog component.


67-67: Confirm intent: Removal of paddingTop from Box component

The removal of the paddingTop prop from the Box component may affect the vertical alignment of its content. While this change doesn't impact functionality and could be intentional for layout consistency, it's important to ensure it aligns with the desired design.

Could you please confirm that removing the paddingTop prop was intentional and doesn't negatively impact the layout? If it was unintentional, consider restoring it or adjusting the spacing using the Stack component's properties for consistent spacing throughout the component.


Line range hint 1-146: Summary: Improved ManualChangelog component with enhanced usability and consistency

Overall, the changes to the ManualChangelog component align well with the PR objectives and coding guidelines. The modifications improve usability, visual consistency, and potentially accessibility. Key improvements include:

  1. Enhanced spacing for better readability
  2. Improved link styling and consistency
  3. Adjusted layout with the removal of padding (pending confirmation)
  4. Enhanced user interaction with the Accordion component

The code adheres to NextJS best practices and makes good use of TypeScript for type safety. Minor suggestions have been made to further improve accessibility and code clarity.

These changes are ready to be merged, pending the clarification on the Box component's padding removal. Great work on enhancing the user experience of the manual changelog!

@kodiakhq kodiakhq bot merged commit eb721e9 into main Oct 8, 2024
30 checks passed
@kodiakhq kodiakhq bot deleted the feature/web-manual-chapter-links branch October 8, 2024 14:55
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.

2 participants