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

[WEB-4242] Mobile navigation fixes #2486

Merged
merged 13 commits into from
Mar 21, 2025
Merged

Conversation

jamiehenson
Copy link
Member

@jamiehenson jamiehenson commented Mar 20, 2025

Addresses all the items on this ticket, as well as this support thread, and iOS compatibility feedback passed to @aralovelace.

Requires ably/ably-ui#703. This won't merge until that package is available and introduced here.

Review link: https://ably-docs-web-4242-docs-gg1ahr.herokuapp.com/

Summary by CodeRabbit

  • Chores

    • Upgraded external UI dependencies and the documentation viewer library for improved performance.
  • User Interface Enhancements

    • Refined header functionality and search button styling for a cleaner navigation experience.
    • Enhanced sidebar interactivity with smooth scrolling and a new home navigation option.
    • Improved responsive design across layouts, code blocks, tables, and lists to ensure optimal viewing on all devices.

Copy link

coderabbitai bot commented Mar 20, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes update the @ably/ui dependency version in package.json and refactor various UI components. In the header components, state management related to menu visibility is removed in favor of passing the location as a prop. Several tests are updated with new mocks for routing and language selection. Height constants previously imported locally are now sourced from a centralized module, and corresponding utilities have been removed. Additionally, responsive styling adjustments have been made in multiple components, and the Redoc dependency script URL has been updated.

Changes

File(s) Change Summary
package.json Updated @ably/ui dependency from "15.7.0" to "15.8.1-dev.1a27ad3f".
src/components/Layout/Header.tsx, src/components/Layout/Header.test.tsx Removed state management for showMenu, added useLocation prop to AblyHeader, and introduced new mocks for routing and the LanguageSelector; updated user context structure.
src/components/Layout/LeftSidebar.tsx Added onClick handlers to product navigation entries and a conditional "Home" entry, triggering smooth scrolling or route navigation.
src/components/Layout/LanguageSelector.tsx, src/components/Layout/RightSidebar.tsx, src/components/Layout/utils/heights.ts, src/components/Layout/utils/nav.ts Migrated height constants from local to @ably/ui/core/utils/heights, removed unused constants/functions, and refined CSS class definitions.
src/components/Layout/Layout.tsx, src/components/Markdown/CodeBlock.tsx, src/components/blocks/list/Dl/index.tsx, src/components/blocks/software/Pre.tsx, src/components/blocks/table/Table.tsx Enhanced responsive styling by updating gap and max-width classes and consolidated styling using a new constant (codeClassName).
src/components/Redoc/Loader.tsx Updated the Redoc dependency script URL from the latest version to a specific version (v2.4.0).

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant LS as LeftSidebar
    participant DOM as DOM/Accordion

    U->>LS: Click a product nav entry
    LS->>LS: Determine target accordion (left-nav/mobile-nav)
    LS->>LS: Wait briefly using setTimeout
    LS->>DOM: Scroll to open accordion element
Loading
sequenceDiagram
    participant U as User
    participant LS as LeftSidebar
    participant Router as Router

    U->>LS: Click "Home" nav entry
    LS->>Router: Trigger navigate('/docs')
Loading

Assessment against linked issues

Objective (Linked Issue) Addressed Explanation
Mobile Navigation Tweaks [WEB-4242]

Possibly related PRs

Suggested reviewers

  • kennethkalmer
  • m-hulbert

Poem

I'm a coding rabbit on a hop so light,
Skipping through updates from morning to night.
Dependencies change and styles shine bright,
With clicks and scrolls now feeling just right.
In this garden of code, every line is a delight!


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

@ably-ci ably-ci temporarily deployed to ably-docs-web-4242-docs-gg1ahr March 20, 2025 16:51 Inactive
@jamiehenson jamiehenson force-pushed the web-4242-docs-mobile-tweaks branch from 5ad391c to 6b28e72 Compare March 20, 2025 16:54
@jamiehenson jamiehenson temporarily deployed to ably-docs-web-4242-docs-gg1ahr March 20, 2025 16:54 Inactive
@jamiehenson jamiehenson force-pushed the web-4242-docs-mobile-tweaks branch from 6b28e72 to 8f851ab Compare March 20, 2025 17:09
@jamiehenson jamiehenson temporarily deployed to ably-docs-web-4242-docs-gg1ahr March 20, 2025 17:09 Inactive
@@ -33,30 +34,6 @@ const Header: React.FC<HeaderProps> = ({ searchBar = true }) => {
// }
// };

useEffect(() => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This now lives in ably-ui and was left behind after the back-merge

@@ -86,7 +63,7 @@ const Header: React.FC<HeaderProps> = ({ searchBar = true }) => {
mobileNav={<LeftSidebar inHeader key="nav-mobile-documentation-tab" />}
searchButton={
<button
className="cursor-pointer focus-base rounded"
className="cursor-pointer focus-base rounded px-0 pt-4 text-neutral-1300 dark:text-neutral-000"
Copy link
Member Author

Choose a reason for hiding this comment

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

🍎 overrides button colouring with its own blue, how thoughtful

@@ -125,6 +102,7 @@ const Header: React.FC<HeaderProps> = ({ searchBar = true }) => {
]}
sessionState={sessionState}
logoHref="/docs"
location={location}
Copy link
Member Author

Choose a reason for hiding this comment

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

Piping this in instructs the header menu to close when it changes.

@@ -130,6 +130,26 @@ const constructProductNavData = (
return {
name: product.name,
icon: activePageTree[0]?.page.name === product.name ? product.icon.open : product.icon.closed,
onClick: () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

When a top-level accordion item is clicked, then it tries to bring the header row into view if it isn't visible - this happens after the opening animation has concluded, to ensure that the scrollTo has the right point of reference.

* @param {...number} heights - An array of heights in pixels.
* @returns {string} The CSS calc expression for the maximum height.
*/
export const componentMaxHeight = (...heights: number[]): string => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This lives in ably-ui now, along with the HEADER_* values

@@ -29,7 +29,7 @@ export const CodeBlock: FC<{ children: React.ReactNode; language: string }> = ({
};

return (
<pre className="bg-cool-black text-white p-0 rounded-lg relative">
<pre className="bg-cool-black text-white p-0 rounded-lg relative max-w-[calc(100vw-48px)]">
Copy link
Member Author

Choose a reason for hiding this comment

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

@kennethkalmer this is the thing that caps the page width

Copy link
Member

Choose a reason for hiding this comment

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

@jamiehenson ooi would this need dvw instead of vw, or am I overeager to apply my new knowledge? 😃

Copy link
Member Author

Choose a reason for hiding this comment

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

It's nifty isn't it. Such a clean solution. There's less of a need for it for width I would imagine (less funny business going on horizontally, only scrollbars really), but for height, yes. I think the best foot forward would be to lead with dvh and offer an equivalent vh class as well as a fallback - to appease our Firefox user

Copy link
Member Author

Choose a reason for hiding this comment

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

I've included a fallback for the 100vh helper in ably-ui, but not doing anything here with the 100vws

@@ -131,7 +131,7 @@ export const commonAccordionOptions = (
{
'my-12': topLevel && inHeader,
'h-40 ui-text-menu1 !font-bold md:ui-text-menu4 px-16': topLevel,
'h-[1rem] ui-text-menu2 !font-semibold md:ui-text-menu4': !topLevel,
'h-[1.625em] md:h-[1.375em] ui-text-menu2 !font-semibold md:ui-text-menu4': !topLevel,
Copy link
Member Author

Choose a reason for hiding this comment

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

Make the height respect the line-height properties of the surrounding text

@jamiehenson jamiehenson force-pushed the web-4242-docs-mobile-tweaks branch from 8f851ab to abffc0a Compare March 20, 2025 17:15
@jamiehenson jamiehenson temporarily deployed to ably-docs-web-4242-docs-gg1ahr March 20, 2025 17:15 Inactive
@jamiehenson jamiehenson force-pushed the web-4242-docs-mobile-tweaks branch from abffc0a to 2c17ca5 Compare March 20, 2025 17:34
@jamiehenson jamiehenson temporarily deployed to ably-docs-web-4242-docs-gg1ahr March 20, 2025 17:34 Inactive
@jamiehenson jamiehenson force-pushed the web-4242-docs-mobile-tweaks branch from 2c17ca5 to 3371098 Compare March 20, 2025 17:34
@jamiehenson jamiehenson temporarily deployed to ably-docs-web-4242-docs-gg1ahr March 20, 2025 17:35 Inactive
@jamiehenson
Copy link
Member Author

@coderabbitai review

Copy link

coderabbitai bot commented Mar 20, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

🧹 Nitpick comments (1)
src/components/Markdown/CodeBlock.tsx (1)

32-32: Consider adding responsive breakpoint for consistency

The max-w-[calc(100vw-48px)] constraint is added to prevent overflow on mobile, but unlike the <dl> component, there's no responsive class to restore full width on larger screens (e.g., sm:max-w-full). Consider adding this for consistency with other components, unless the capped width is intentional at all screen sizes.

-    <pre className="bg-cool-black text-white p-0 rounded-lg relative max-w-[calc(100vw-48px)]">
+    <pre className="bg-cool-black text-white p-0 rounded-lg relative max-w-[calc(100vw-48px)] sm:max-w-full">
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2099c1c and 3371098.

⛔ Files ignored due to path filters (3)
  • src/components/blocks/software/__snapshots__/Pre.test.tsx.snap is excluded by !**/*.snap
  • src/components/blocks/wrappers/__snapshots__/ConditionalChildrenLanguageDisplay.test.js.snap is excluded by !**/*.snap
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (14)
  • package.json (1 hunks)
  • src/components/Layout/Header.test.tsx (2 hunks)
  • src/components/Layout/Header.tsx (3 hunks)
  • src/components/Layout/LanguageSelector.tsx (1 hunks)
  • src/components/Layout/Layout.tsx (1 hunks)
  • src/components/Layout/LeftSidebar.tsx (4 hunks)
  • src/components/Layout/RightSidebar.tsx (1 hunks)
  • src/components/Layout/utils/heights.ts (1 hunks)
  • src/components/Layout/utils/nav.ts (2 hunks)
  • src/components/Markdown/CodeBlock.tsx (1 hunks)
  • src/components/Redoc/Loader.tsx (1 hunks)
  • src/components/blocks/list/Dl/index.tsx (1 hunks)
  • src/components/blocks/software/Pre.tsx (2 hunks)
  • src/components/blocks/table/Table.tsx (1 hunks)
🔇 Additional comments (20)
package.json (1)

42-42: Remember to update the development dependency before merging

This development version (15.8.1-dev.1a27ad3f) of the @ably/ui package should be replaced with a stable version before merging, as noted in your previous comment.

src/components/Layout/Layout.tsx (1)

27-27: Good responsive design improvement

The change from a fixed gap to responsive gap sizes (md:gap-48, lg:gap-64, xl:gap-80) improves the mobile experience by providing appropriate spacing at different viewport sizes.

src/components/blocks/list/Dl/index.tsx (1)

9-9: Appropriate mobile width constraint added

Adding max-w-[calc(100vw-48px)] sm:max-w-full prevents content overflow on small screens while maintaining full width on larger screens. This is a good responsive design pattern.

src/components/blocks/table/Table.tsx (1)

15-15: Good enhancement for responsive design.

Adding the responsive width constraints ensures that tables display properly on mobile devices without overflowing, while still using the full available width on larger screens.

src/components/Redoc/Loader.tsx (1)

7-7: Good practice to pin the Redoc version to a specific release.

Changing from latest to a specific version (v2.4.0) improves stability by:

  1. Preventing unexpected breaking changes from newer versions
  2. Ensuring consistent behavior across all environments
  3. Allowing controlled dependency upgrades
src/components/Layout/LanguageSelector.tsx (1)

8-8: Good refactoring of height constants to a centralized location.

Moving common height constants (componentMaxHeight, HEADER_BOTTOM_MARGIN, HEADER_HEIGHT) to the shared @ably/ui package while keeping app-specific constants local is a good architectural decision that promotes reusability and maintainability.

Also applies to: 14-14

src/components/Layout/utils/heights.ts (1)

6-6: Appropriate cleanup after constants migration.

The constants have been properly moved to @ably/ui as mentioned in previous feedback, while keeping app-specific constants in this file.

src/components/Layout/Header.tsx (2)

1-1: LGTM: Good refactoring to use location prop for menu state

The removal of local state management in favor of passing the location prop to AblyHeader is a cleaner approach. This matches the implementation in the ably-ui repository and ensures the mobile menu closes when navigation occurs.

Also applies to: 7-7, 14-14, 105-105


66-66: Improved button styling for better iOS compatibility

The updated classname addresses the iOS-specific styling issue mentioned in the PR description.

src/components/blocks/software/Pre.tsx (1)

67-68: Good refactoring: Extracted duplicated class names into a constant

Extracting the duplicate class name string into a codeClassName constant improves maintainability and ensures consistency across multiple usage points. This is a good application of the DRY principle.

Also applies to: 74-74, 84-84

src/components/Layout/RightSidebar.tsx (1)

6-6: Improved organization: Centralized height constants

Good refactoring to source common height constants from the central @ably/ui package rather than local modules. This promotes consistency across the codebase and makes future height-related changes easier to manage.

Also applies to: 12-12

src/components/Layout/utils/nav.ts (2)

3-3: Centralized height constants import

Good update to import height constants from the shared @ably/ui package, maintaining consistency with the rest of the codebase.


134-134: Improved responsive styling with dynamic height

The change from fixed height to minimum height using em units will ensure that the accordion header respects the line-height properties of the surrounding text, fixing the mobile responsiveness issue mentioned in the PR.

src/components/Layout/Header.test.tsx (3)

32-34: Appropriate mock for location-based navigation

The addition of the @reach/router mock provides the necessary useLocation function for testing, which is a good practice since it allows for testing location-dependent behavior in the Header component.


36-38: Good test isolation with LanguageSelector mock

Mocking the LanguageSelector component properly isolates the Header tests from implementation details of the language selection functionality.


103-107: Enhanced test coverage with expanded account object

The expanded account object structure with id, name, and links properties provides more comprehensive coverage of the user context state that the Header component likely consumes.

src/components/Layout/LeftSidebar.tsx (4)

2-2: Correctly updated imports for navigation

The addition of navigate and useLocation imports supports the new navigation capabilities in the component.


133-152: Useful accordion scrolling for improved UX

The onClick handler improves navigation usability by automatically scrolling to open accordion items after clicking. This is especially helpful on mobile devices.


186-196: Good addition of Home navigation option

Adding a Home entry to the navigation when in header mode provides users with a clear way to return to the documentation landing page.


227-238: Simplified component structure

The refactored Accordion rendering creates a more maintainable and cleaner component structure by dynamically determining the ID based on context rather than using conditional rendering.

@jamiehenson jamiehenson force-pushed the web-4242-docs-mobile-tweaks branch from 3371098 to b4db9b4 Compare March 21, 2025 12:41
@jamiehenson jamiehenson temporarily deployed to ably-docs-web-4242-docs-gg1ahr March 21, 2025 12:42 Inactive
@jamiehenson jamiehenson force-pushed the web-4242-docs-mobile-tweaks branch from b4db9b4 to 5f381ed Compare March 21, 2025 12:44
@jamiehenson jamiehenson temporarily deployed to ably-docs-web-4242-docs-gg1ahr March 21, 2025 12:44 Inactive
@jamiehenson jamiehenson temporarily deployed to ably-docs-web-4242-docs-gg1ahr March 21, 2025 13:01 Inactive
@jamiehenson jamiehenson temporarily deployed to ably-docs-web-4242-docs-gg1ahr March 21, 2025 13:09 Inactive
@jamiehenson jamiehenson force-pushed the web-4242-docs-mobile-tweaks branch from bc69064 to 971fd52 Compare March 21, 2025 13:12
@jamiehenson jamiehenson temporarily deployed to ably-docs-web-4242-docs-gg1ahr March 21, 2025 13:12 Inactive
@jamiehenson jamiehenson force-pushed the web-4242-docs-mobile-tweaks branch from 971fd52 to 58b4d5a Compare March 21, 2025 13:30
@jamiehenson jamiehenson temporarily deployed to ably-docs-web-4242-docs-gg1ahr March 21, 2025 13:31 Inactive
@jamiehenson jamiehenson force-pushed the web-4242-docs-mobile-tweaks branch from 58b4d5a to 54dcb88 Compare March 21, 2025 13:50
@jamiehenson jamiehenson temporarily deployed to ably-docs-web-4242-docs-gg1ahr March 21, 2025 13:50 Inactive
Copy link
Member

@kennethkalmer kennethkalmer left a comment

Choose a reason for hiding this comment

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

📱

@jamiehenson jamiehenson merged commit 14b71ad into main Mar 21, 2025
5 checks passed
@jamiehenson jamiehenson deleted the web-4242-docs-mobile-tweaks branch March 21, 2025 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants