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

Guide page setup #31

Merged
merged 18 commits into from
Nov 18, 2024
Merged

Guide page setup #31

merged 18 commits into from
Nov 18, 2024

Conversation

nahbee10
Copy link

@nahbee10 nahbee10 commented Nov 12, 2024

Description

  • stylized breadcrumbs
  • stylized TOC, evaluation module, prev/next, edit this page
  • didn't remove the side nav on tablet view since it is what Sohee is working on

Type(s) of changes

  • Bug fix
  • New feature
  • Update to an existing feature

Motivation for PR

How Has This Been Tested?

Tested on local

Applicable screenshots

https://www.loom.com/share/a699a961c2c54c68bce79a43b0634ed2?sid=48a51aea-afee-4946-85e4-c3d708d253d0

Follow-up PR

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced new React components for icons: Moon, Edit, Happy, Neutral, and Sad.
    • Added a new SentimentButton component for improved sentiment tracking.
    • Enhanced styling and layout for various components, including breadcrumbs and pagination navigation.
    • Implemented a responsive document item layout with a table of contents.
  • Bug Fixes

    • Simplified the DocBreadcrumbs component by removing unnecessary prop forwarding and components.
  • Chores

    • Updated package.json with new dependencies for improved functionality.
    • Introduced a new PostCSS configuration for better CSS processing capabilities.
    • Adjusted Tailwind CSS configuration for expanded class name scanning.
  • Documentation

    • Adjusted ESLint rules for better code quality and flexibility in TypeScript and React usage.

Copy link

vercel bot commented Nov 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
uniswap-docs-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2024 5:05pm

@nahbee10 nahbee10 marked this pull request as draft November 12, 2024 19:59
Copy link

coderabbitai bot commented Nov 12, 2024

Walkthrough

The pull request introduces several changes across multiple files, primarily focusing on updating dependencies, enhancing CSS styles, and modifying React components. Key updates include the addition of new packages in package.json, the introduction of a PostCSS configuration file, and the enhancement of various CSS classes. React components such as DocBreadcrumbs, DocItemLayout, and SentimentTracking have been modified for improved functionality and structure. Additionally, new components like SentimentButton have been created to facilitate sentiment tracking.

Changes

File Change Summary
package.json Added dependencies: @headlessui/react, classnames, js-cookie, @types/js-cookie, postcss-import. Unchanged: typescript.
postcss.config.js New configuration file created with plugins: postcss-import, tailwindcss, autoprefixer.
src/css/custom.css Added new CSS classes and modified existing ones for layout and styling enhancements.
src/theme/DocBreadcrumbs.tsx Modified to render without props and removed SentimentTracking component.
src/theme/DocItem/Layout/index.js Introduced new component for document item layout with responsive TOC handling.
src/theme/DocItem/Layout/styles.module.css Adjusted CSS rules for consistent spacing and maximum width.
tailwind.config.js Updated content property to include docusaurus.config.js and modified spacing configuration.
src/components/Icons/index.tsx Added new icon components: Moon, Edit, Happy, Neutral, Sad and updated IconMap.
src/components/SentimentTracking/index.tsx Restructured layout and functionality, replacing external icons with local ones.
src/components/SentimentTracking/SentimentButton.tsx New component created for sentiment buttons with dynamic styling and event handling.
src/css/infima-overrides.css Added new rule for .navbar class to reset styles.
src/theme/Navbar.tsx Changed <nav> class name to "navbar" for consistency.
.eslintrc.json Adjusted ESLint rules for flexibility in prop-types, TypeScript enums, and variable usage.
.prettierignore Added ignore patterns for *.hbs and *.gif files.

Assessment against linked issues

Objective Addressed Explanation
Breadcrumbs
Side nav (on this page)
Edit this page button No implementation for an edit button present.
Prev/next on the bottom Pagination navigation styles and layout added.
Feedback module Sentiment tracking component serves this purpose.

Possibly related PRs

  • feat: add navigation #30: The changes in package.json regarding the addition of new dependencies like classnames and @headlessui/react are directly related to the enhancements made in the navigation and theme toggle features introduced in this PR.

Suggested reviewers

  • mokaymokay

Poem

In the garden where code does play,
New icons bloom, brightening the day.
With breadcrumbs to guide and styles anew,
A sentiment tracker, just for you!
So hop along, let’s celebrate this cheer,
For every change brings us closer, my dear! 🐰✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0824f68 and f0b5092.

📒 Files selected for processing (1)
  • src/theme/DocItem/Layout/index.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/theme/DocItem/Layout/index.js

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

@nahbee10 nahbee10 changed the title Guide page setup [WIP] Guide page setup Nov 12, 2024
Copy link

⚡️ Lighthouse Report

Mobile (view report)

Category Score
🟠 Performance 78
🟢 Accessibility 96
🟠 Best practices 83
🟠 SEO 85

Desktop (view report)

Category Score
🟢 Performance 98
🟢 Accessibility 96
🟠 Best practices 83
🟠 SEO 82

Lighthouse ran on https://uniswap-docs-staging-42ghrqjtd-uniswap.vercel.app

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

🧹 Outside diff range and nitpick comments (36)
src/theme/DocPage/Layout/styles.module.css (2)

1-5: Consider enhancing responsive behavior

The flex properties could be improved for better responsiveness:

  1. Consider allowing shrinking by changing flex: 1 0 to flex: 1
  2. Add flex-direction property to handle different screen sizes
 .docPage {
   display: flex;
   width: 100%;
-  flex: 1 0;
+  flex: 1;
+  flex-direction: column;
 }

7-10: Enhance content wrapper flexibility

The wrapper could benefit from additional flex properties for better content handling:

 .docsWrapper {
   display: flex;
-  flex: 1 0 auto;
+  flex: 1;
+  flex-wrap: wrap;
+  align-items: flex-start;
 }
src/theme/DocItem/Metadata/index.js (2)

1-3: Consider sorting imports for better organization.

While the imports are correct, they can be better organized. The conventional order is:

  1. External packages (React)
  2. Docusaurus packages
  3. Internal modules

Apply this diff to sort the imports:

-import React from 'react';
-import {PageMetadata} from '@docusaurus/theme-common';
-import {useDoc} from '@docusaurus/theme-common/internal';
+import React from 'react';
+import {PageMetadata} from '@docusaurus/theme-common';
+import {useDoc} from '@docusaurus/theme-common/internal';
🧰 Tools
🪛 GitHub Check: Check uniswap Benchmarks

[failure] 1-1:
Run autofix to sort these imports!

🪛 GitHub Check: Run linters

[failure] 1-1:
Run autofix to sort these imports!

🪛 eslint

[error] 1-3: Run autofix to sort these imports!

(simple-import-sort/imports)


4-14: Implementation looks good with room for type safety improvement.

The component is well-implemented with clean destructuring and proper fallback handling for the image prop. It effectively serves the guide page metadata requirements.

Consider adding TypeScript or PropTypes to improve type safety and documentation. Example with PropTypes:

import PropTypes from 'prop-types';

DocItemMetadata.propTypes = {
  metadata: PropTypes.shape({
    title: PropTypes.string.isRequired,
    description: PropTypes.string.isRequired,
  }),
  frontMatter: PropTypes.shape({
    keywords: PropTypes.arrayOf(PropTypes.string),
    image: PropTypes.string,
  }),
  assets: PropTypes.shape({
    image: PropTypes.string,
  }),
};
src/theme/DocItem/Paginator/index.js (1)

1-3: Consider grouping related imports.

While the current import order is logical (React core, internal utilities, theme components), consider maintaining this consistent pattern across all new files in the guide page implementation.

 import React from 'react';
 import {useDoc} from '@docusaurus/theme-common/internal';
 import DocPaginator from '@theme/DocPaginator';
🧰 Tools
🪛 eslint

[error] 1-3: Run autofix to sort these imports!

(simple-import-sort/imports)

src/theme/DocItem/TOC/Desktop/index.js (2)

5-15: Consider adding prop validation and error handling

The component could benefit from some improvements:

  1. Add prop-types or TypeScript types for better type safety
  2. Handle cases where frontMatter TOC level properties are undefined
  3. Consider memoization for performance optimization

Here's a suggested implementation:

+import PropTypes from 'prop-types';
+import {memo} from 'react';

-export default function DocItemTOCDesktop() {
+function DocItemTOCDesktop({className}) {
   const {toc, frontMatter} = useDoc();
+  const minLevel = frontMatter?.toc_min_heading_level;
+  const maxLevel = frontMatter?.toc_max_heading_level;
+
   return (
     <TOC
       toc={toc}
-      minHeadingLevel={frontMatter.toc_min_heading_level}
-      maxHeadingLevel={frontMatter.toc_max_heading_level}
-      className={ThemeClassNames.docs.docTocDesktop}
+      minHeadingLevel={minLevel}
+      maxHeadingLevel={maxLevel}
+      className={`${ThemeClassNames.docs.docTocDesktop} ${className ?? ''}`}
     />
   );
 }
+
+DocItemTOCDesktop.propTypes = {
+  className: PropTypes.string,
+};
+
+export default memo(DocItemTOCDesktop);

1-15: Consider adding documentation for TOC configuration

Since this component reads TOC configuration from frontMatter, it would be helpful to document these options for content authors.

Would you like me to help create a documentation file explaining the available TOC configuration options (toc_min_heading_level and toc_max_heading_level)?

🧰 Tools
🪛 eslint

[error] 1-4: Run autofix to sort these imports!

(simple-import-sort/imports)

src/theme/DocItem/TOC/Mobile/index.js (2)

1-6: Sort imports according to convention

The imports are all necessary but should be sorted according to convention:

  1. External dependencies (react, clsx)
  2. Docusaurus dependencies
  3. Local imports
-import React from 'react';
-import clsx from 'clsx';
-import {ThemeClassNames} from '@docusaurus/theme-common';
-import {useDoc} from '@docusaurus/theme-common/internal';
-import TOCCollapsible from '@theme/TOCCollapsible';
-import styles from './styles.module.css';
+import React from 'react';
+import clsx from 'clsx';
+import {ThemeClassNames} from '@docusaurus/theme-common';
+import {useDoc} from '@docusaurus/theme-common/internal';
+import TOCCollapsible from '@theme/TOCCollapsible';
+import styles from './styles.module.css';
🧰 Tools
🪛 eslint

[error] 1-6: Run autofix to sort these imports!

(simple-import-sort/imports)


7-17: Consider adding error boundaries and loading states

The implementation is clean and follows React best practices. However, consider handling potential error states and loading conditions for a more robust user experience.

 export default function DocItemTOCMobile() {
   const {toc, frontMatter} = useDoc();
+  
+  if (!toc?.length) {
+    return null;
+  }
+
   return (
     <TOCCollapsible
       toc={toc}
       minHeadingLevel={frontMatter.toc_min_heading_level}
       maxHeadingLevel={frontMatter.toc_max_heading_level}
       className={clsx(ThemeClassNames.docs.docTocMobile, styles.tocMobile)}
     />
   );
 }
src/theme/DocItem/index.js (2)

1-5: Consider reordering imports for consistency.

While the current import grouping is logical (React core, Docusaurus core, local components), consider following the project's import sorting rules for consistency.

-import React from 'react';
-import {HtmlClassNameProvider} from '@docusaurus/theme-common';
-import {DocProvider} from '@docusaurus/theme-common/internal';
-import DocItemMetadata from '@theme/DocItem/Metadata';
-import DocItemLayout from '@theme/DocItem/Layout';
+import React from 'react';
+import {HtmlClassNameProvider} from '@docusaurus/theme-common';
+import {DocProvider} from '@docusaurus/theme-common/internal';
+import DocItemLayout from '@theme/DocItem/Layout';
+import DocItemMetadata from '@theme/DocItem/Metadata';
🧰 Tools
🪛 eslint

[error] 1-5: Run autofix to sort these imports!

(simple-import-sort/imports)


9-18: Consider adding error boundary for MDX rendering.

The component structure looks good and follows Docusaurus patterns. However, consider wrapping the MDX rendering with an error boundary to gracefully handle potential runtime errors in markdown content.

+import {ErrorBoundary} from '@docusaurus/theme-common';

 export default function DocItem(props) {
   // ...
   return (
     <DocProvider content={props.content}>
       <HtmlClassNameProvider className={docHtmlClassName}>
         <DocItemMetadata />
         <DocItemLayout>
+          <ErrorBoundary fallback={({error}) => (
+            <div className="text-red-600">
+              Failed to render document content: {error.message}
+            </div>
+          )}>
           <MDXComponent />
+          </ErrorBoundary>
         </DocItemLayout>
       </HtmlClassNameProvider>
     </DocProvider>
   );
 }
🧰 Tools
🪛 eslint

[error] 10-10: 'content' is missing in props validation

(react/prop-types)

src/theme/DocPage/Layout/Sidebar/styles.module.css (2)

6-8: Consider adding mobile sidebar transition and accessibility.

While hiding the sidebar by default is good for mobile-first design, consider adding:

  1. Smooth transitions for mobile sidebar visibility
  2. Touch-friendly interaction patterns
  3. ARIA attributes for accessibility

Example enhancement:

 .docSidebarContainer {
   display: none;
+  transition: transform var(--ifm-transition-fast) ease;
+  transform: translateX(-100%);
 }
+
+.docSidebarContainer.visible {
+  display: block;
+  transform: translateX(0);
+}

26-31: Consider fallback for mobile browser viewport height.

Using 100vh can cause issues on mobile browsers due to dynamic toolbar behavior. Consider using the newer viewport units or a fallback.

 .sidebarViewport {
   top: 0;
   position: sticky;
   height: 100%;
-  max-height: 100vh;
+  max-height: 100vh; /* fallback */
+  max-height: 100dvh; /* dynamic viewport height */
 }
src/theme/DocPage/Layout/Main/index.js (2)

5-5: Add PropTypes for type safety

Consider adding prop type definitions to improve type safety and documentation:

+import PropTypes from 'prop-types';
+
 export default function DocPageLayoutMain({hiddenSidebarContainer, children}) {
   // ... component implementation ...
 }
+
+DocPageLayoutMain.propTypes = {
+  hiddenSidebarContainer: PropTypes.bool,
+  children: PropTypes.node.isRequired,
+};
🧰 Tools
🪛 eslint

[error] 5-5: 'hiddenSidebarContainer' is missing in props validation

(react/prop-types)


[error] 5-5: 'children' is missing in props validation

(react/prop-types)


8-21: Consider adding ARIA landmarks for better accessibility

The semantic structure is good, but we can enhance accessibility:

     <main
+      role="main"
+      aria-label="Documentation main content"
       className={clsx(
         styles.docMainContainer,
         (hiddenSidebarContainer || !sidebar) && styles.docMainContainerEnhanced,
       )}>
src/css/custom.css (1)

24-26: Consider accessibility for hidden breadcrumb items.

While visually hiding the first breadcrumb item works, consider maintaining accessibility by using visually-hidden class instead of !hidden.

-.breadcrumbs__item:first-child, .breadcrumbs__item:first-child:after {
-  @apply !hidden;
+.breadcrumbs__item:first-child, .breadcrumbs__item:first-child:after {
+  @apply sr-only;
+}
src/theme/DocPage/Layout/Sidebar/ExpandButton/index.js (2)

1-4: Consider sorting imports according to convention.

While the imports are logically grouped, they should be sorted according to the project's conventions:

-import React from 'react';
-import {translate} from '@docusaurus/Translate';
-import IconArrow from '@theme/Icon/Arrow';
-import styles from './styles.module.css';
+import React from 'react';
+import {translate} from '@docusaurus/Translate';
+import styles from './styles.module.css';
+import IconArrow from '@theme/Icon/Arrow';
🧰 Tools
🪛 eslint

[error] 1-4: Run autofix to sort these imports!

(simple-import-sort/imports)


5-5: Add PropTypes validation for better type safety.

The toggleSidebar prop should be validated using PropTypes to ensure type safety and improve documentation.

+import PropTypes from 'prop-types';
 import React from 'react';
 // ... other imports

 export default function DocPageLayoutSidebarExpandButton({toggleSidebar}) {
   // ... component implementation
 }
+
+DocPageLayoutSidebarExpandButton.propTypes = {
+  toggleSidebar: PropTypes.func.isRequired,
+};
🧰 Tools
🪛 eslint

[error] 5-5: 'toggleSidebar' is missing in props validation

(react/prop-types)

src/theme/DocPage/Layout/index.js (3)

1-7: Sort imports for better organization

Group imports in the following order: React core, external (@Docusaurus), and local imports.

-import React, {useState} from 'react';
-import {useDocsSidebar} from '@docusaurus/theme-common/internal';
-import Layout from '@theme/Layout';
-import BackToTopButton from '@theme/BackToTopButton';
-import DocPageLayoutSidebar from '@theme/DocPage/Layout/Sidebar';
-import DocPageLayoutMain from '@theme/DocPage/Layout/Main';
-import styles from './styles.module.css';
+import React, {useState} from 'react';
+
+import {useDocsSidebar} from '@docusaurus/theme-common/internal';
+import BackToTopButton from '@theme/BackToTopButton';
+import Layout from '@theme/Layout';
+import DocPageLayoutMain from '@theme/DocPage/Layout/Main';
+import DocPageLayoutSidebar from '@theme/DocPage/Layout/Sidebar';
+
+import styles from './styles.module.css';
🧰 Tools
🪛 eslint

[error] 1-7: Run autofix to sort these imports!

(simple-import-sort/imports)


9-10: Consider persisting sidebar state

To improve user experience, consider persisting the sidebar visibility state in localStorage so it remains consistent across page refreshes.

-const [hiddenSidebarContainer, setHiddenSidebarContainer] = useState(false);
+const [hiddenSidebarContainer, setHiddenSidebarContainer] = useState(() => {
+  try {
+    return JSON.parse(localStorage.getItem('docsSidebarHidden')) ?? false;
+  } catch {
+    return false;
+  }
+});
+
+useEffect(() => {
+  localStorage.setItem('docsSidebarHidden', JSON.stringify(hiddenSidebarContainer));
+}, [hiddenSidebarContainer]);

11-27: Enhance accessibility with ARIA labels

The layout structure looks good, but could benefit from improved accessibility.

 return (
-  <Layout wrapperClassName={styles.docsWrapper}>
+  <Layout wrapperClassName={styles.docsWrapper} role="main" aria-label="Documentation page">
     <BackToTopButton />
-    <div className={styles.docPage}>
+    <div className={styles.docPage} role="region" aria-label="Documentation content">
       {sidebar && (
         <DocPageLayoutSidebar
           sidebar={sidebar.items}
           hiddenSidebarContainer={hiddenSidebarContainer}
           setHiddenSidebarContainer={setHiddenSidebarContainer}
+          aria-label="Documentation sidebar"
         />
       )}
       <DocPageLayoutMain hiddenSidebarContainer={hiddenSidebarContainer}>
         {children}
       </DocPageLayoutMain>
     </div>
   </Layout>
 );
src/css/font.css (1)

40-71: Consider using consistent font formats

The Basel Grotesk fonts use .woff2 format while Riegraf fonts use .otf format. Consider converting all fonts to .woff2 format for better browser compatibility and performance.

Rationale:

  • .woff2 offers better compression than .otf
  • .woff2 is widely supported by modern browsers
  • Consistent formats are easier to maintain
src/theme/DocPage/index.js (3)

1-16: Sort imports according to project conventions.

The imports should be sorted according to the project's linting rules.

Apply this diff to sort the imports:

 import React from 'react';
 import clsx from 'clsx';
+import NotFound from '@theme/NotFound';
+import DocPageLayout from '@theme/DocPage/Layout';
+import SearchMetadata from '@theme/SearchMetadata';
 import {
   HtmlClassNameProvider,
   ThemeClassNames,
   PageMetadata,
 } from '@docusaurus/theme-common';
 import {
   docVersionSearchTag,
   DocsSidebarProvider,
   DocsVersionProvider,
   useDocRouteMetadata,
 } from '@docusaurus/theme-common/internal';
-import DocPageLayout from '@theme/DocPage/Layout';
-import NotFound from '@theme/NotFound';
-import SearchMetadata from '@theme/SearchMetadata';
🧰 Tools
🪛 eslint

[error] 1-16: Run autofix to sort these imports!

(simple-import-sort/imports)


46-52: Consider extracting className logic to a utility function.

The className concatenation logic could be simplified and made more maintainable by extracting it to a utility function.

Consider refactoring to:

+const getDocPageClassName = (baseClassName, versionMetadata) => 
+  clsx(
+    ThemeClassNames.page.docsDocPage,
+    versionMetadata.className,
+    // TODO: Remove wrapper.docsPages as noted
+    ThemeClassNames.wrapper.docsPages,
+  );
+
 <HtmlClassNameProvider
-  className={clsx(
-    ThemeClassNames.wrapper.docsPages,
-    ThemeClassNames.page.docsDocPage,
-    props.versionMetadata.className,
-  )}>
+  className={getDocPageClassName(ThemeClassNames.page.docsDocPage, versionMetadata)}>
🧰 Tools
🪛 eslint

[error] 51-51: 'versionMetadata' is missing in props validation

(react/prop-types)


[error] 51-51: 'versionMetadata.className' is missing in props validation

(react/prop-types)


53-57: Consider error boundaries for provider components.

The nested providers could benefit from error boundaries to gracefully handle potential issues.

Consider wrapping the providers with an error boundary component to catch and handle potential provider-related errors gracefully. Would you like me to provide an example implementation?

src/theme/DocItem/Layout/index.js (3)

1-13: Consider sorting imports for better organization

While the imports are functionally correct, sorting them would improve code organization and maintainability.

Apply this sorting pattern:

  1. React/external dependencies
  2. Docusaurus imports
  3. Theme components
  4. Local imports/styles
-import React from 'react';
-import clsx from 'clsx';
-import {useWindowSize} from '@docusaurus/theme-common';
-import {useDoc} from '@docusaurus/theme-common/internal';
-import DocItemPaginator from '@theme/DocItem/Paginator';
-import DocVersionBanner from '@theme/DocVersionBanner';
-import DocVersionBadge from '@theme/DocVersionBadge';
-import DocItemFooter from '@theme/DocItem/Footer';
-import DocItemTOCMobile from '@theme/DocItem/TOC/Mobile';
-import DocItemTOCDesktop from '@theme/DocItem/TOC/Desktop';
-import DocItemContent from '@theme/DocItem/Content';
-import DocBreadcrumbs from '@theme/DocBreadcrumbs';
-import styles from './styles.module.css';
+import React from 'react';
+import clsx from 'clsx';
+
+import {useWindowSize} from '@docusaurus/theme-common';
+import {useDoc} from '@docusaurus/theme-common/internal';
+
+import DocBreadcrumbs from '@theme/DocBreadcrumbs';
+import DocItemContent from '@theme/DocItem/Content';
+import DocItemFooter from '@theme/DocItem/Footer';
+import DocItemPaginator from '@theme/DocItem/Paginator';
+import DocItemTOCDesktop from '@theme/DocItem/TOC/Desktop';
+import DocItemTOCMobile from '@theme/DocItem/TOC/Mobile';
+import DocVersionBadge from '@theme/DocVersionBadge';
+import DocVersionBanner from '@theme/DocVersionBanner';
+
+import styles from './styles.module.css';
🧰 Tools
🪛 GitHub Check: Check uniswap Benchmarks

[failure] 1-1:
Run autofix to sort these imports!

🪛 GitHub Check: Run linters

[failure] 1-1:
Run autofix to sort these imports!

🪛 eslint

[error] 1-13: Run autofix to sort these imports!

(simple-import-sort/imports)


17-32: Well-structured hook with clear responsibilities

The hook effectively manages TOC visibility based on viewport and frontmatter configuration. The SSR handling is properly implemented.

Consider enhancing the JSDoc comment to document the return type:

/**
 * Decide if the toc should be rendered, on mobile or desktop viewports
 * @returns {{
 *   hidden: boolean,
 *   mobile: React.ReactNode | undefined,
 *   desktop: React.ReactNode | undefined
 * }}
 */

34-52: Well-implemented layout structure

The component successfully implements the guide page layout with:

  • Responsive grid structure
  • Proper integration of breadcrumbs (addressing PR objective)
  • Conditional TOC rendering
  • Clear content hierarchy

However, consider internationalizing the "On this page" text on line 50 for better localization support.

-      {docTOC.desktop && <div className="col col--3">On this page {docTOC.desktop}</div>}
+      {docTOC.desktop && <div className="col col--3"><Translate>On this page</Translate> {docTOC.desktop}</div>}
src/theme/DocItem/Footer/index.js (3)

1-8: Sort imports for better maintainability

The imports should be sorted according to the following convention:

  1. React/external dependencies
  2. Docusaurus theme imports
  3. Local imports
-import React from 'react';
-import clsx from 'clsx';
-import {ThemeClassNames} from '@docusaurus/theme-common';
-import {useDoc} from '@docusaurus/theme-common/internal';
-import LastUpdated from '@theme/LastUpdated';
-import EditThisPage from '@theme/EditThisPage';
-import TagsListInline from '@theme/TagsListInline';
-import styles from './styles.module.css';
+import React from 'react';
+import clsx from 'clsx';
+import {ThemeClassNames} from '@docusaurus/theme-common';
+import {useDoc} from '@docusaurus/theme-common/internal';
+import EditThisPage from '@theme/EditThisPage';
+import LastUpdated from '@theme/LastUpdated';
+import TagsListInline from '@theme/TagsListInline';
+import styles from './styles.module.css';
🧰 Tools
🪛 GitHub Check: Check uniswap Benchmarks

[failure] 1-1:
Run autofix to sort these imports!

🪛 GitHub Check: Run linters

[failure] 1-1:
Run autofix to sort these imports!

🪛 eslint

[error] 1-8: Run autofix to sort these imports!

(simple-import-sort/imports)


44-68: Add JSDoc documentation for the main component

The component logic is well-structured, but adding documentation would improve maintainability.

+/**
+ * Footer component for documentation pages.
+ * Renders tags and edit metadata when available.
+ * 
+ * @returns {React.ReactElement|null} The footer element or null if no content
+ */
 export default function DocItemFooter() {
   const {metadata} = useDoc();
   const {editUrl, lastUpdatedAt, formattedLastUpdatedAt, lastUpdatedBy, tags} =
     metadata;

Also, consider extracting the display logic conditions into named constants for better readability:

-  const canDisplayTagsRow = tags.length > 0;
-  const canDisplayEditMetaRow = !!(editUrl || lastUpdatedAt || lastUpdatedBy);
+  const hasTagsToDisplay = tags.length > 0;
+  const hasEditMetadata = !!(editUrl || lastUpdatedAt || lastUpdatedBy);

1-68: Implementation aligns well with PR objectives

The DocItemFooter component successfully implements the "edit this page" functionality mentioned in the PR objectives. The code is well-structured and follows Docusaurus conventions.

Consider implementing the planned Table of Contents (TOC) and navigation features in separate components to maintain good separation of concerns.

🧰 Tools
🪛 GitHub Check: Check uniswap Benchmarks

[failure] 1-1:
Run autofix to sort these imports!


[failure] 23-23:
'editUrl' is missing in props validation


[failure] 24-24:
'lastUpdatedAt' is missing in props validation


[failure] 25-25:
'lastUpdatedBy' is missing in props validation


[failure] 26-26:
'formattedLastUpdatedAt' is missing in props validation

🪛 GitHub Check: Run linters

[failure] 1-1:
Run autofix to sort these imports!


[failure] 23-23:
'editUrl' is missing in props validation


[failure] 24-24:
'lastUpdatedAt' is missing in props validation


[failure] 25-25:
'lastUpdatedBy' is missing in props validation


[failure] 26-26:
'formattedLastUpdatedAt' is missing in props validation

🪛 eslint

[error] 1-8: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 23-23: 'editUrl' is missing in props validation

(react/prop-types)


[error] 24-24: 'lastUpdatedAt' is missing in props validation

(react/prop-types)


[error] 25-25: 'lastUpdatedBy' is missing in props validation

(react/prop-types)


[error] 26-26: 'formattedLastUpdatedAt' is missing in props validation

(react/prop-types)

src/theme/DocPage/Layout/Sidebar/index.js (5)

1-8: Sort imports according to project conventions.

The imports should be sorted to maintain consistency with the project's linting rules.

Apply this diff to sort the imports:

-import React, {useState, useCallback} from 'react';
-import clsx from 'clsx';
-import {prefersReducedMotion, ThemeClassNames} from '@docusaurus/theme-common';
-import {useDocsSidebar} from '@docusaurus/theme-common/internal';
-import {useLocation} from '@docusaurus/router';
-import DocSidebar from '@theme/DocSidebar';
-import ExpandButton from '@theme/DocPage/Layout/Sidebar/ExpandButton';
-import styles from './styles.module.css';
+import {useLocation} from '@docusaurus/router';
+import {prefersReducedMotion, ThemeClassNames} from '@docusaurus/theme-common';
+import {useDocsSidebar} from '@docusaurus/theme-common/internal';
+import React, {useCallback, useState} from 'react';
+import clsx from 'clsx';
+import DocSidebar from '@theme/DocSidebar';
+import ExpandButton from '@theme/DocPage/Layout/Sidebar/ExpandButton';
+import styles from './styles.module.css';
🧰 Tools
🪛 eslint

[error] 1-8: Run autofix to sort these imports!

(simple-import-sort/imports)


12-19: Add PropTypes validation for the children prop.

For better type safety and documentation, add PropTypes validation.

Add this at the end of the file:

+import PropTypes from 'prop-types';
+
+ResetOnSidebarChange.propTypes = {
+  children: PropTypes.node.isRequired,
+};
🧰 Tools
🪛 eslint

[error] 12-12: 'children' is missing in props validation

(react/prop-types)


20-24: Add PropTypes validation for component props.

For better type safety and documentation, add PropTypes validation for the component props.

Add this at the end of the file:

+DocPageLayoutSidebar.propTypes = {
+  sidebar: PropTypes.object.isRequired,
+  hiddenSidebarContainer: PropTypes.bool.isRequired,
+  setHiddenSidebarContainer: PropTypes.func.isRequired,
+};
🧰 Tools
🪛 eslint

[error] 21-21: 'sidebar' is missing in props validation

(react/prop-types)


[error] 22-22: 'hiddenSidebarContainer' is missing in props validation

(react/prop-types)


[error] 23-23: 'setHiddenSidebarContainer' is missing in props validation

(react/prop-types)


27-37: Consider extracting transition logic into a custom hook.

The sidebar toggle logic with reduced motion handling could be extracted into a custom hook for better reusability and testing.

Consider creating a hook like this:

function useSidebarToggle(setHiddenSidebarContainer) {
  const [hiddenSidebar, setHiddenSidebar] = useState(false);
  
  const toggleSidebar = useCallback(() => {
    if (hiddenSidebar) {
      setHiddenSidebar(false);
    }
    if (!hiddenSidebar && prefersReducedMotion()) {
      setHiddenSidebar(true);
    }
    setHiddenSidebarContainer((value) => !value);
  }, [setHiddenSidebarContainer, hiddenSidebar]);

  return [hiddenSidebar, setHiddenSidebar, toggleSidebar];
}

45-52: Consider extracting transition handler to a named function.

The transition end handler logic is complex enough to warrant extraction into a named function for better readability.

Consider refactoring like this:

+const handleTransitionEnd = (e, hiddenSidebarContainer, setHiddenSidebar) => {
+  if (!e.currentTarget.classList.contains(styles.docSidebarContainer)) {
+    return;
+  }
+  if (hiddenSidebarContainer) {
+    setHiddenSidebar(true);
+  }
+};

-onTransitionEnd={(e) => {
-  if (!e.currentTarget.classList.contains(styles.docSidebarContainer)) {
-    return;
-  }
-  if (hiddenSidebarContainer) {
-    setHiddenSidebar(true);
-  }
-}}
+onTransitionEnd={(e) => handleTransitionEnd(e, hiddenSidebarContainer, setHiddenSidebar)}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9b2b4ea and 30d2966.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (27)
  • docusaurus.config.js (1 hunks)
  • package.json (1 hunks)
  • postcss.config.js (1 hunks)
  • src/css/custom.css (1 hunks)
  • src/css/font.css (1 hunks)
  • src/theme/DocBreadcrumbs.tsx (1 hunks)
  • src/theme/DocItem/Content/index.js (1 hunks)
  • src/theme/DocItem/Footer/index.js (1 hunks)
  • src/theme/DocItem/Footer/styles.module.css (1 hunks)
  • src/theme/DocItem/Layout/index.js (1 hunks)
  • src/theme/DocItem/Layout/styles.module.css (1 hunks)
  • src/theme/DocItem/Metadata/index.js (1 hunks)
  • src/theme/DocItem/Paginator/index.js (1 hunks)
  • src/theme/DocItem/TOC/Desktop/index.js (1 hunks)
  • src/theme/DocItem/TOC/Mobile/index.js (1 hunks)
  • src/theme/DocItem/TOC/Mobile/styles.module.css (1 hunks)
  • src/theme/DocItem/index.js (1 hunks)
  • src/theme/DocPage/Layout/Main/index.js (1 hunks)
  • src/theme/DocPage/Layout/Main/styles.module.css (1 hunks)
  • src/theme/DocPage/Layout/Sidebar/ExpandButton/index.js (1 hunks)
  • src/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css (1 hunks)
  • src/theme/DocPage/Layout/Sidebar/index.js (1 hunks)
  • src/theme/DocPage/Layout/Sidebar/styles.module.css (1 hunks)
  • src/theme/DocPage/Layout/index.js (1 hunks)
  • src/theme/DocPage/Layout/styles.module.css (1 hunks)
  • src/theme/DocPage/index.js (1 hunks)
  • tailwind.config.js (1 hunks)
✅ Files skipped from review due to trivial changes (5)
  • src/theme/DocItem/Footer/styles.module.css
  • src/theme/DocItem/Layout/styles.module.css
  • src/theme/DocItem/TOC/Mobile/styles.module.css
  • src/theme/DocPage/Layout/Main/styles.module.css
  • src/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css
🧰 Additional context used
🪛 eslint
docusaurus.config.js

[error] 222-222: 'require' is not defined.

(no-undef)

postcss.config.js

[error] 2-2: 'module' is not defined.

(no-undef)

src/theme/DocItem/Content/index.js

[error] 1-6: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 26-26: 'children' is missing in props validation

(react/prop-types)

src/theme/DocItem/Footer/index.js

[error] 1-8: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 23-23: 'editUrl' is missing in props validation

(react/prop-types)


[error] 24-24: 'lastUpdatedAt' is missing in props validation

(react/prop-types)


[error] 25-25: 'lastUpdatedBy' is missing in props validation

(react/prop-types)


[error] 26-26: 'formattedLastUpdatedAt' is missing in props validation

(react/prop-types)

src/theme/DocItem/Layout/index.js

[error] 1-13: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 33-33: 'children' is missing in props validation

(react/prop-types)

src/theme/DocItem/Metadata/index.js

[error] 1-3: Run autofix to sort these imports!

(simple-import-sort/imports)

src/theme/DocItem/Paginator/index.js

[error] 1-3: Run autofix to sort these imports!

(simple-import-sort/imports)

src/theme/DocItem/TOC/Desktop/index.js

[error] 1-4: Run autofix to sort these imports!

(simple-import-sort/imports)

src/theme/DocItem/TOC/Mobile/index.js

[error] 1-6: Run autofix to sort these imports!

(simple-import-sort/imports)

src/theme/DocItem/index.js

[error] 1-5: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 7-7: 'content' is missing in props validation

(react/prop-types)


[error] 7-7: 'content.metadata' is missing in props validation

(react/prop-types)


[error] 7-7: 'content.metadata.unversionedId' is missing in props validation

(react/prop-types)


[error] 8-8: 'content' is missing in props validation

(react/prop-types)


[error] 10-10: 'content' is missing in props validation

(react/prop-types)

src/theme/DocPage/Layout/Main/index.js

[error] 1-4: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 5-5: 'hiddenSidebarContainer' is missing in props validation

(react/prop-types)


[error] 5-5: 'children' is missing in props validation

(react/prop-types)

src/theme/DocPage/Layout/Sidebar/ExpandButton/index.js

[error] 1-4: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 5-5: 'toggleSidebar' is missing in props validation

(react/prop-types)

src/theme/DocPage/Layout/Sidebar/index.js

[error] 1-8: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 12-12: 'children' is missing in props validation

(react/prop-types)


[error] 21-21: 'sidebar' is missing in props validation

(react/prop-types)


[error] 22-22: 'hiddenSidebarContainer' is missing in props validation

(react/prop-types)


[error] 23-23: 'setHiddenSidebarContainer' is missing in props validation

(react/prop-types)

src/theme/DocPage/Layout/index.js

[error] 1-7: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 8-8: 'children' is missing in props validation

(react/prop-types)

src/theme/DocPage/index.js

[error] 1-16: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 18-18: 'versionMetadata' is missing in props validation

(react/prop-types)


[error] 22-22: 'versionMetadata.version' is missing in props validation

(react/prop-types)


[error] 24-24: 'versionMetadata.pluginId' is missing in props validation

(react/prop-types)


[error] 25-25: 'versionMetadata.version' is missing in props validation

(react/prop-types)


[error] 29-29: 'versionMetadata.noIndex' is missing in props validation

(react/prop-types)


[error] 37-37: 'versionMetadata' is missing in props validation

(react/prop-types)


[error] 51-51: 'versionMetadata' is missing in props validation

(react/prop-types)


[error] 51-51: 'versionMetadata.className' is missing in props validation

(react/prop-types)

🪛 GitHub Check: Check uniswap Benchmarks
src/theme/DocItem/Content/index.js

[failure] 1-1:
Run autofix to sort these imports!


[failure] 26-26:
'children' is missing in props validation

src/theme/DocItem/Footer/index.js

[failure] 1-1:
Run autofix to sort these imports!


[failure] 23-23:
'editUrl' is missing in props validation


[failure] 24-24:
'lastUpdatedAt' is missing in props validation


[failure] 25-25:
'lastUpdatedBy' is missing in props validation


[failure] 26-26:
'formattedLastUpdatedAt' is missing in props validation

src/theme/DocItem/Layout/index.js

[failure] 1-1:
Run autofix to sort these imports!


[failure] 33-33:
'children' is missing in props validation

src/theme/DocItem/Metadata/index.js

[failure] 1-1:
Run autofix to sort these imports!

🪛 GitHub Check: Run linters
src/theme/DocItem/Content/index.js

[failure] 1-1:
Run autofix to sort these imports!


[failure] 26-26:
'children' is missing in props validation

src/theme/DocItem/Footer/index.js

[failure] 1-1:
Run autofix to sort these imports!


[failure] 23-23:
'editUrl' is missing in props validation


[failure] 24-24:
'lastUpdatedAt' is missing in props validation


[failure] 25-25:
'lastUpdatedBy' is missing in props validation


[failure] 26-26:
'formattedLastUpdatedAt' is missing in props validation

src/theme/DocItem/Layout/index.js

[failure] 1-1:
Run autofix to sort these imports!


[failure] 33-33:
'children' is missing in props validation

src/theme/DocItem/Metadata/index.js

[failure] 1-1:
Run autofix to sort these imports!

🔇 Additional comments (24)
src/theme/DocPage/Layout/styles.module.css (1)

12-18: ⚠️ Potential issue

Address TODO comment with a more robust theme fallback

The current implementation has several concerns:

  1. The TODO comment indicates this is a temporary solution
  2. Using display: initial might cause inconsistent behavior across browsers
  3. This approach might not be the best for accessibility when JS is disabled

Consider implementing a proper CSS-only fallback theme system:

-/*
-JS disabled??? Show light version by default => better than showing nothing
-TODO bad, but we currently always show light mode when there's no data-theme
- */
-html:not([data-theme]) .themedComponent--light {
-  display: initial;
-}
+/* Fallback for when JS is disabled */
+:root {
+  color-scheme: light;
+}
+
+html:not([data-theme]) {
+  /* Define all theme variables with light theme values */
+  --background-color: #ffffff;
+  --text-color: #000000;
+  /* Add other necessary theme variables */
+}
+
+html:not([data-theme]) .themedComponent--light {
+  display: block;
+}

Let's check if there are any other theme-related styles that might need similar updates:

✅ Verification successful

Verified: Suggested CSS fallback is appropriate

The changes proposed in the review comment are appropriate and only affect src/theme/DocPage/Layout/styles.module.css. No other theme-related styles were found that require similar updates.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other theme-related styles
rg -t css "data-theme|themedComponent" 

Length of output: 252

src/theme/DocBreadcrumbs.tsx (1)

Line range hint 7-15: Verify breadcrumb functionality across different page depths

Please ensure that the breadcrumbs are working correctly at various documentation depths and that the styling meets the requirements from issue #15.

Let's verify the breadcrumb implementation across the docs:

🧰 Tools
🪛 GitHub Check: Check uniswap Benchmarks

[warning] 7-7:
'props' is defined but never used. Allowed unused args must match /_/u

🪛 GitHub Check: Run linters

[warning] 7-7:
'props' is defined but never used. Allowed unused args must match /_/u

src/theme/DocItem/Metadata/index.js (1)

1-14: Verify integration with parent DocItem component.

Let's ensure this metadata component is properly integrated with the parent DocItem component and the broader theme structure.

🧰 Tools
🪛 GitHub Check: Check uniswap Benchmarks

[failure] 1-1:
Run autofix to sort these imports!

🪛 GitHub Check: Run linters

[failure] 1-1:
Run autofix to sort these imports!

🪛 eslint

[error] 1-3: Run autofix to sort these imports!

(simple-import-sort/imports)

src/theme/DocItem/Paginator/index.js (3)

8-11: LGTM! Clean implementation of document pagination.

The component effectively implements the pagination requirement from issue #15, providing a clean bridge between doc metadata and the generic paginator component. The use of the useDoc hook demonstrates good separation of concerns.


4-7: Well-documented component purpose.

The documentation clearly explains why this wrapper component is necessary, which is crucial for maintainability. It helps future contributors understand the distinction between this specialized paginator and the generic one.


1-11: Verify integration with other guide page components.

Since this is part of the broader guide page implementation, let's verify the integration with other new components.

✅ Verification successful

Integration Verified with Other Guide Page Components.

No issues found in integration with other components.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for proper integration with related components

# Check for other related theme components
echo "Checking for related DocItem components..."
fd "DocItem.*index.js$" src/theme

# Verify proper imports of this component
echo "Checking where this paginator is used..."
rg "DocItemPaginator" src/

Length of output: 486

🧰 Tools
🪛 eslint

[error] 1-3: Run autofix to sort these imports!

(simple-import-sort/imports)

src/theme/DocItem/TOC/Desktop/index.js (1)

1-15: Verify TOC visibility conditions

Since this is a desktop-specific TOC component, we should ensure it's properly integrated with responsive design and visibility controls.

Let's check how the TOC visibility is managed across the codebase:

🧰 Tools
🪛 eslint

[error] 1-4: Run autofix to sort these imports!

(simple-import-sort/imports)

src/theme/DocItem/TOC/Mobile/index.js (1)

7-17: Verify integration with planned navigation features

The mobile TOC implementation looks good, but since the PR objectives mention additional navigation features (prev/next, edit button), ensure this component's styling and positioning won't conflict with those upcoming features.

Run this script to check for potential styling conflicts:

✅ Verification successful

Styling Verified with No Conflicts Detected

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for other mobile navigation components and their styling
rg -t css "\.tocMobile|\.navigation|\.pagination" --glob "src/theme/**/*.css"

Length of output: 203

src/theme/DocPage/Layout/Sidebar/styles.module.css (2)

1-4: LGTM! Well-structured CSS custom properties.

The sidebar width values are appropriate for documentation navigation, and using CSS custom properties makes the values easily maintainable.


11-24: LGTM! Well-implemented sidebar transitions and layout.

The implementation includes:

  • Smooth width transitions
  • Proper use of CSS custom properties
  • Clean collapsed state handling
src/theme/DocPage/Layout/Main/index.js (2)

6-6: LGTM!

Proper usage of the Docusaurus hook for sidebar state management.


1-23: Verify integration with planned features

This layout component will need to accommodate upcoming features mentioned in the PR objectives:

  • Table of Contents
  • Evaluation module
  • Previous/Next navigation
  • "Edit this page" button
✅ Verification successful

Integration with planned features confirmed

All planned features can be accommodated without conflicts.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for existing navigation components that might conflict
rg -l "nav|navigation|toc|contents|edit.*page" --type js

# Look for any existing pagination patterns
ast-grep --pattern 'className=$_("prev"|"next")' 

Length of output: 260

🧰 Tools
🪛 eslint

[error] 1-4: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 5-5: 'hiddenSidebarContainer' is missing in props validation

(react/prop-types)


[error] 5-5: 'children' is missing in props validation

(react/prop-types)

src/css/custom.css (2)

21-23: LGTM! Verify the typography class.

The breadcrumb link styling implementation looks good with proper theme handling.

Let's verify the body-3 typography class exists:

✅ Verification successful

Typography class verified.

The body-3 typography class is defined in src/css/custom.css and src/css/types.css.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if body-3 typography class is defined
rg -l "body-3" "src/css/*.css"

Length of output: 84


Script:

#!/bin/bash
# Description: Check if body-3 typography class is defined
rg -l "body-3" src/css/*.css

Length of output: 123


27-29: LGTM! Verify color token consistency.

The separator styling implementation looks good with proper theme handling.

Let's verify the color tokens are consistently used across the project:

✅ Verification successful

Color token consistency verified.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check color token usage consistency
rg "(!text-light-neutral-1|!text-dark-neutral-1)" "src/**/*.css"

Length of output: 119


Script:

#!/bin/bash
# Description: Locate all CSS files in the repository
fd --extension css

Length of output: 431


Script:

#!/bin/bash
# Description: Check color token usage consistency in discovered CSS files
rg "(!text-light-neutral-1|!text-dark-neutral-1)" src/css/custom.css src/css/font.css src/css/index.css src/css/types.css src/theme/DocItem/Footer/styles.module.css src/theme/DocItem/Layout/styles.module.css src/theme/DocItem/TOC/Mobile/styles.module.css src/theme/DocPage/Layout/Main/styles.module.css src/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css src/theme/DocPage/Layout/Sidebar/styles.module.css src/theme/DocPage/Layout/styles.module.css

Length of output: 645

src/theme/DocPage/Layout/Sidebar/ExpandButton/index.js (1)

1-28: Overall implementation looks good!

The component is well-structured with good attention to:

  • Accessibility support
  • Internationalization
  • Event handling
  • Style organization

The suggested improvements are minor and the component aligns well with the PR objectives for enhancing guide page navigation.

🧰 Tools
🪛 eslint

[error] 1-4: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 5-5: 'toggleSidebar' is missing in props validation

(react/prop-types)

src/theme/DocItem/Content/index.js (1)

17-25: LGTM! Well-implemented hook with clear logic.

The useSyntheticTitle hook effectively determines when to render a synthetic title based on frontmatter configuration and existing content. The implementation is clean and follows React best practices.

src/css/font.css (2)

5-5: Verify font file existence in the new static directory

The font URLs have been updated to use the '/static/fonts/' directory. Let's verify that all font files exist in the new location.

Also applies to: 12-12, 19-19, 26-26, 33-33, 40-40, 47-47, 54-54, 61-61, 68-68


Line range hint 1-71: Verify impact of removed Basel Grotesk Medium Italic

The Basel Grotesk Medium Italic font face declaration has been removed. Let's verify that this font variant isn't used anywhere in the codebase.

src/theme/DocPage/index.js (1)

48-49: Address the TODO comment about className removal.

The comment suggests this className should be removed. Please clarify the reason and create a tracking issue.

Let's check if this className is used elsewhere:

✅ Verification successful

wrapper.docsPages is only used in src/theme/DocPage/index.js and can be safely removed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other usages of this className
rg "wrapper\.docsPages" --type js

Length of output: 107

src/theme/DocPage/Layout/Sidebar/index.js (1)

39-69: LGTM! Well-structured sidebar implementation.

The sidebar implementation is well-structured with proper:

  • Accessibility considerations (reduced motion)
  • Semantic HTML usage
  • State management
  • Transition handling
package.json (1)

79-80: LGTM! Verify PostCSS plugin compatibility.

The addition of postcss-import aligns with the PR objectives for enhanced styling capabilities. The version ^16.1.0 is compatible with your existing PostCSS stack.

Let's verify the PostCSS plugin compatibility:

✅ Verification successful

PostCSS plugin compatibility verified.

The addition of postcss-import version ^16.1.0 is compatible with your existing PostCSS stack.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for compatibility issues between PostCSS plugins

# Check if postcss-import has any known compatibility issues with current postcss version
curl -s "https://registry.npmjs.org/postcss-import" | jq -r '.versions["16.1.0"].peerDependencies.postcss'

# Check if there are any recent issues mentioning compatibility problems
gh api graphql -f query='
{
  search(query: "repo:postcss/postcss-import is:issue state:open postcss compatibility", type: ISSUE, first: 5) {
    nodes {
      ... on Issue {
        title
        url
        createdAt
      }
    }
  }
}'

Length of output: 388

tailwind.config.js (1)

31-31: LGTM! Consider scanning additional Docusaurus files.

The addition of docusaurus.config.js to content paths is appropriate for the guide page styling requirements.

Let's verify the config location and check if other Docusaurus files need scanning:

✅ Verification successful

Tailwind configuration verified. No additional Docusaurus files need to be scanned.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify docusaurus.config.js location and find other potential files to scan

# Check if docusaurus.config.js exists in root
if [ -f "./docusaurus.config.js" ]; then
  echo "✓ docusaurus.config.js found in root"
else
  echo "⚠ docusaurus.config.js not found in root"
fi

# Find other potential Docusaurus files that might need Tailwind scanning
echo "Potential Docusaurus files to consider for Tailwind scanning:"
fd -e js -e ts -e tsx --exclude node_modules "theme|swizzle|docusaurus"

Length of output: 346

docusaurus.config.js (2)

Line range hint 234-324: Consider enhancing the redirect configuration

While the redirect structure is well-organized, consider the following improvements:

  1. Add handling for trailing slashes to prevent potential 404s
  2. Verify there are no redirect chains that could impact performance
  3. Consider adding reverse redirects where applicable

Example enhancement for trailing slash handling:

 createRedirects(existingPath) {
+  // Handle trailing slashes
+  const normalizedPath = existingPath.replace(/\/$/, '');
   
   // V3 Redirects
-  if (existingPath.includes('/concepts/overview')) {
+  if (normalizedPath.includes('/concepts/overview')) {

Consider splitting the redirect configuration into a separate file for better maintainability, especially as more redirects are added. This would make it easier to:

  • Track redirect changes
  • Prevent redirect chains
  • Test redirect configurations
  • Document redirect purposes
#!/bin/bash
# Description: Check for potential redirect chains and missing reverse redirects

# Check for potential redirect chains
echo "Checking for potential redirect chains..."
for path in $(rg -o 'to: .+' | cut -d"'" -f2); do
  rg "from.*$path" && echo "Potential redirect chain found for: $path"
done

# Check if destination paths are also used as source paths
echo "Checking for missing reverse redirects..."
for dest in $(rg -o 'to: .+' | cut -d"'" -f2); do
  if ! rg -q "from.*$dest"; then
    echo "No reverse redirect found for: $dest"
  fi
done
🧰 Tools
🪛 eslint

[error] 219-219: 'require' is not defined.

(no-undef)


[error] 220-220: 'require' is not defined.

(no-undef)


[error] 221-221: 'require' is not defined.

(no-undef)


[error] 222-222: 'require' is not defined.

(no-undef)


Line range hint 234-324: Verify scope alignment with PR objectives

The extensive redirect configuration seems to go beyond the stated PR objective of "Guide page setup". While these changes might be necessary, they should either:

  1. Be documented in the PR description
  2. Be moved to a separate PR focused on URL structure updates

This could impact existing bookmarks and SEO. Let's check for existing traffic to these URLs:

#!/bin/bash
# Description: Search for references to old URLs in documentation and issues

# Search for old URLs in markdown files
echo "Checking for references to old URLs in documentation..."
rg -t md "/sdk/v3/guides/quick-start|/sdk/v3/guides/creating-a-pool|/sdk/v3/guides/fetching-prices"

# Search for mentions in issues
echo "Checking for mentions in GitHub issues..."
gh issue list --search "sdk/v3/guides/quick-start OR sdk/v3/guides/creating-a-pool OR sdk/v3/guides/fetching-prices" --json number,title,body
🧰 Tools
🪛 eslint

[error] 219-219: 'require' is not defined.

(no-undef)


[error] 220-220: 'require' is not defined.

(no-undef)


[error] 221-221: 'require' is not defined.

(no-undef)


[error] 222-222: 'require' is not defined.

(no-undef)

Copy link

⚡️ Lighthouse Report

Mobile (view report)

Category Score
🟠 Performance 54
🟢 Accessibility 96
🟢 Best practices 92
🟠 SEO 85

Desktop (view report)

Category Score
🟢 Performance 98
🟢 Accessibility 96
🟢 Best practices 92
🟠 SEO 82

Lighthouse ran on https://uniswap-docs-staging-ptwk2276o-uniswap.vercel.app

Copy link

⚡️ Lighthouse Report

Mobile (view report)

Category Score
🟠 Performance 65
🟢 Accessibility 96
🟢 Best practices 92
🟠 SEO 85

Desktop (view report)

Category Score
🟢 Performance 99
🟢 Accessibility 96
🟠 Best practices 83
🟠 SEO 82

Lighthouse ran on https://uniswap-docs-staging-dib9jtyce-uniswap.vercel.app

@nahbee10 nahbee10 changed the title [WIP] Guide page setup Guide page setup Nov 15, 2024
@nahbee10 nahbee10 marked this pull request as ready for review November 15, 2024 05:31
Copy link

⚡️ Lighthouse Report

Mobile (view report)

Category Score
🟠 Performance 60
🟢 Accessibility 96
🟢 Best practices 92
🟠 SEO 85

Desktop (view report)

Category Score
🟢 Performance 98
🟢 Accessibility 96
🟠 Best practices 83
🟠 SEO 82

Lighthouse ran on https://uniswap-docs-staging-lfhtw6xbs-uniswap.vercel.app

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

🧹 Outside diff range and nitpick comments (29)
postcss.config.js (1)

2-8: Consider adding specific configuration options for better optimization.

While the basic setup is correct, you might want to consider adding specific configuration options:

 module.exports = {
   plugins: {
-    'postcss-import': {},
+    'postcss-import': {
+      path: ['src/css']  // Add your CSS source directories
+    },
-    tailwindcss: {},
+    tailwindcss: {
+      // Reference your tailwind config explicitly
+      config: './tailwind.config.js'
+    },
-    autoprefixer: {},
+    autoprefixer: {
+      // Target specific browsers if needed
+      flexbox: 'no-2009'
+    },
   },
 }

These configurations would:

  • Help organize CSS imports better
  • Ensure explicit Tailwind config loading
  • Optimize autoprefixer behavior for modern browsers
🧰 Tools
🪛 eslint

[error] 2-2: 'module' is not defined.

(no-undef)

src/utils/storage.ts (1)

1-9: Add JSDoc documentation and input validation.

The class could benefit from proper documentation and input validation.

Consider applying these improvements:

 import Cookies from 'js-cookie'

+/**
+ * Generic storage manager using cookies for persistent storage.
+ * @template T The type of value to be stored
+ */
 export class StorageManager<T> {
   key: string

   constructor(key: string) {
+    if (!key || key.trim() === '') {
+      throw new Error('Storage key cannot be empty')
+    }
     this.key = key
   }
src/theme/DocItem/index.js (1)

1-19: Consider component composition for feature scalability.

As this component will integrate multiple features (TOC, navigation, evaluation module), consider:

  1. Using React.Suspense for lazy-loading heavy components
  2. Implementing feature flags for gradual rollout
  3. Creating a clear composition boundary between core rendering and feature components

This will help maintain flexibility as features are added incrementally.

🧰 Tools
🪛 eslint

[error] 7-7: 'content' is missing in props validation

(react/prop-types)


[error] 7-7: 'content.metadata' is missing in props validation

(react/prop-types)


[error] 7-7: 'content.metadata.unversionedId' is missing in props validation

(react/prop-types)


[error] 8-8: 'content' is missing in props validation

(react/prop-types)


[error] 10-10: 'content' is missing in props validation

(react/prop-types)

src/theme/DocPage/Layout/Main/index.js (1)

8-14: Consider removing the important modifier from margin class.

The !mt-12 class uses Tailwind's important modifier (!), which might make the styling harder to override and maintain. Consider handling this through proper CSS specificity or component hierarchy.

-        '!mt-12',
+        'mt-12',
src/theme/DocItem/Content/index.js (1)

25-37: Consider memoizing the component for better performance

Since this component is likely to be rendered frequently in the documentation site, consider memoizing it to prevent unnecessary re-renders when parent components update.

Here's how you could optimize it:

-export default function DocItemContent({ children }) {
+const DocItemContent = React.memo(function DocItemContent({ children }) {
   const syntheticTitle = useSyntheticTitle()
   return (
     <div className={clsx(ThemeClassNames.docs.docMarkdown, 'markdown')}>
       {syntheticTitle && (
         <header>
           <Heading as="h1">{syntheticTitle}</Heading>
         </header>
       )}
       <MDXContent>{children}</MDXContent>
     </div>
   )
-}
+})
+
+export default DocItemContent
🧰 Tools
🪛 GitHub Check: Check uniswap Benchmarks

[failure] 25-25:
'children' is missing in props validation

🪛 GitHub Check: Run linters

[failure] 25-25:
'children' is missing in props validation

🪛 eslint

[error] 25-25: 'children' is missing in props validation

(react/prop-types)

src/theme/Navbar.tsx (2)

7-10: Consider adding ARIA landmarks and roles

While the basic structure is good, consider enhancing accessibility by:

  1. Adding role="navigation" (although the nav element implicitly has this role)
  2. Adding aria-label="Main" to distinguish this from other potential navigation regions
-    <nav className="Navbar navbar fixed left-0 right-0 z-nav flex w-screen justify-center bg-light-surface-1 dark:border-dark-surface-3 dark:bg-dark-surface-1">
+    <nav className="Navbar navbar fixed left-0 right-0 z-nav flex w-screen justify-center bg-light-surface-1 dark:border-dark-surface-3 dark:bg-dark-surface-1" aria-label="Main">

26-36: Consider moving the feedback form URL to configuration

The feedback form URL is hardcoded, which could make it difficult to maintain or change in the future. Consider moving it to a configuration file or environment variable.

+// In a config file (e.g., src/config/constants.ts)
+export const FEEDBACK_FORM_URL = 'https://docs.google.com/forms/d/e/1FAIpQLSdjSkZam8KiatL9XACRVxCHjDJjaPGbls77PCXDKFn4JwykXg/viewform';

+// In Navbar.tsx
+import { FEEDBACK_FORM_URL } from '../config/constants';
// ...
           <a
             className="button-label-4 py-2 px-3 bg-light-accent-2 dark:bg-dark-accent-2 rounded-small ml-2"
-            href="https://docs.google.com/forms/d/e/1FAIpQLSdjSkZam8KiatL9XACRVxCHjDJjaPGbls77PCXDKFn4JwykXg/viewform"
+            href={FEEDBACK_FORM_URL}
             target="_blank"
             rel="noreferrer"
           >
src/theme/DocPage/index.js (2)

28-30: Enhance error handling with more context.

The error handling could be more informative by providing context about why the page wasn't found.

-    return <NotFound />
+    return <NotFound message="The requested documentation page could not be found. Please check the URL and try again." />

25-51: Consider splitting into smaller components for better maintainability.

While the implementation is functionally correct, the DocPage component handles multiple responsibilities (metadata, layout, routing). Consider splitting it into smaller, more focused components:

  • RouteHandler (for metadata and routing logic)
  • PageWrapper (for className and provider setup)
  • MainContent (for the actual page content)

This would improve maintainability and make the code easier to test.

🧰 Tools
🪛 eslint

[error] 26-26: 'versionMetadata' is missing in props validation

(react/prop-types)


[error] 40-40: 'versionMetadata' is missing in props validation

(react/prop-types)


[error] 40-40: 'versionMetadata.className' is missing in props validation

(react/prop-types)

src/components/ThemeSwitch/index.tsx (3)

10-11: Consider improving type safety and initial state handling.

  1. The theme type could be defined as a constant to prevent magic strings
  2. Initial state could be derived from system preferences to prevent flash of wrong theme

Consider applying these improvements:

+const THEMES = {
+  LIGHT: 'light',
+  DARK: 'dark'
+} as const;
+type Theme = typeof THEMES[keyof typeof THEMES];

-const ThemeSwitch: FC<{ className?: string }> = ({ className }) => {
-  const [theme, setTheme] = useState<'light' | 'dark'>('light')
+const ThemeSwitch: FC<{ className?: string }> = ({ className }) => {
+  const [theme, setTheme] = useState<Theme>(() => 
+    typeof window !== 'undefined' && window.matchMedia('(prefers-color-scheme: dark)').matches
+      ? THEMES.DARK
+      : THEMES.LIGHT
+  )

33-36: Consider consolidating theme application.

The theme is being applied twice to the document element. Consider using either data-theme or class, but not both, to avoid unnecessary DOM updates.

-document.documentElement.setAttribute('data-theme', theme)
-document.documentElement.setAttribute('class', theme)
+document.documentElement.setAttribute('data-theme', theme)

38-54: Consider enhancing keyboard interaction feedback.

While the component is accessible, it could benefit from visual feedback for keyboard interactions.

Consider adding focus styles:

 className={cn('group relative inline-flex h-8 w-[3.75rem] items-center rounded-full', className, {
   'bg-light-surface-3': theme === 'light',
   'bg-dark-surface-3': theme === 'dark',
+  'focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2': true,
 })}
src/theme/DocPage/Layout/Sidebar/index.js (2)

19-29: Add explanatory comments for the complex state transitions

The toggleSidebar logic handles multiple states and special cases. Consider adding more detailed comments explaining the state transitions.

Add comments like this:

 const toggleSidebar = useCallback(() => {
+  // When sidebar is hidden, simply show it
   if (hiddenSidebar) {
     setHiddenSidebar(false)
   }
+  // Special handling for users who prefer reduced motion
+  // Immediately update the hidden state without waiting for transition
   if (!hiddenSidebar && prefersReducedMotion()) {
     setHiddenSidebar(true)
   }
+  // Toggle the container visibility which triggers the transition
   setHiddenSidebarContainer((value) => !value)
 }, [setHiddenSidebarContainer, hiddenSidebar])

37-44: Consider extracting transition handler to a named function

The onTransitionEnd logic is complex enough to warrant its own named function for better readability and maintainability.

Consider refactoring like this:

const handleSidebarTransition = (e) => {
  if (!e.currentTarget.classList.contains(styles.docSidebarContainer)) {
    return;
  }
  if (hiddenSidebarContainer) {
    setHiddenSidebar(true);
  }
};

// Then use it in JSX:
<aside
  // ...other props
  onTransitionEnd={handleSidebarTransition}
>
src/components/base/Button/index.tsx (2)

7-15: Consider consolidating className props.

The textClassName prop seems redundant with the base className prop. Consider using a single className prop and providing clear documentation on how to style different parts of the button.

-interface TextButtonProps extends ButtonBaseProps {
-  label: string
-  textClassName?: string
-}
+interface TextButtonProps extends ButtonBaseProps {
+  label: string
+  /** Class name applied to the text content */
+  className?: string
+}

-interface TextLinkProps extends LinkBaseProps {
-  label: string
-  textClassName?: string
-}
+interface TextLinkProps extends LinkBaseProps {
+  label: string
+  /** Class name applied to the text content */
+  className?: string
+}

41-62: Enhance type safety and accessibility.

The implementation is good but could benefit from stronger typing and additional accessibility attributes.

Consider these improvements:

 type ButtonBaseProps = {
   className?: string
-  onClick?: () => void
+  onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void
   ariaLabel?: string
   role?: string
   type?: 'button' | 'submit' | 'reset'
+  disabled?: boolean
 }

 export const ButtonBase: FC<PropsWithChildren<ButtonBaseProps>> = ({
   className,
   onClick,
   children,
   ariaLabel,
   role,
   type = 'button',
+  disabled,
 }) => {
   return (
     <button 
       onClick={onClick} 
       className={className} 
       aria-label={ariaLabel} 
       role={role} 
       type={type}
+      disabled={disabled}
+      aria-disabled={disabled}
     >
       {children}
     </button>
   )
 }
src/components/SentimentTracking/index.tsx (1)

25-75: Consider extracting sentiment button into a reusable component

The current implementation repeats similar code structure for each sentiment button. This could be simplified by creating a reusable SentimentButton component.

Consider refactoring to reduce code duplication:

type SentimentButtonProps = {
  sentiment: Sentiment;
  icon: React.ComponentType<{ className: string }>;
  selected: boolean;
  onSelect: (sentiment: Sentiment) => void;
  analyticsSection: DocsSentimentSection;
}

function SentimentButton({ sentiment, icon: Icon, selected, onSelect, analyticsSection }: SentimentButtonProps) {
  const sentimentToElement = {
    [Sentiment.POSITIVE]: DocsSentiment.POSITIVE_SENTIMENT,
    [Sentiment.NEUTRAL]: DocsSentiment.NEUTRAL_SENTIMENT,
    [Sentiment.NEGATIVE]: DocsSentiment.NEGATIVE_SENTIMENT,
  };

  return (
    <TraceEvent
      element={sentimentToElement[sentiment]}
      name={SharedEventName.SENTIMENT_SUBMITTED}
      events={[BrowserEvent.onClick]}
      section={analyticsSection}
    >
      <button
        onClick={() => onSelect(sentiment)}
        className={cn(`group/${sentiment.toLowerCase()}`, { selected })}
      >
        <Icon className="h-5 w-5" />
      </button>
    </TraceEvent>
  );
}

Usage:

{[
  { sentiment: Sentiment.POSITIVE, icon: Happy },
  { sentiment: Sentiment.NEUTRAL, icon: Neutral },
  { sentiment: Sentiment.NEGATIVE, icon: Sad },
].map(({ sentiment, icon }) => (
  <SentimentButton
    key={sentiment}
    sentiment={sentiment}
    icon={icon}
    selected={isSentimentSelected(sentiment)}
    onSelect={setSelectedSentiment}
    analyticsSection={analyticsSection}
  />
))}
src/css/font.css (2)

65-95: Consider adding modern font formats for Riegraf.

While the current declarations are correct, consider adding woff2 and woff formats for better browser compatibility and faster loading times. The woff2 format, in particular, offers superior compression.

Example structure for one of the declarations:

@font-face {
  font-family: 'Riegraf';
-  src: url('/font/riegraf/Riegraf-Regular.otf') format('opentype');
+  src: 
+    url('/font/riegraf/Riegraf-Regular.woff2') format('woff2'),
+    url('/font/riegraf/Riegraf-Regular.woff') format('woff'),
+    url('/font/riegraf/Riegraf-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
}

Line range hint 1-2: Consider self-hosting Fragment Mono for consistent performance.

Currently, Fragment Mono is loaded from Google Fonts while other fonts are self-hosted. Consider self-hosting Fragment Mono as well to:

  • Reduce external dependencies
  • Ensure consistent loading behavior
  • Maintain better control over font loading performance
  • Improve privacy by eliminating third-party requests
src/css/custom.css (3)

79-81: Optimize dark mode transitions and reduce selector specificity.

The current implementation might cause flickering during theme switches due to background image changes.

Consider these improvements:

.pagination-nav__link {
-  @apply md:w-full !flex !flex-col !space-y-1 bg-light-accent-2 dark:bg-dark-accent-2 hover:bg-light-accent-2-hovered hover:dark:bg-dark-accent-2-hovered text-light-accent-1 !rounded-lg !p-4 !border-0 !min-h-fit !h-auto;
+  @apply md:w-full flex flex-col space-y-1 rounded-lg p-4 border-0 min-h-fit h-auto transition-colors duration-200;
+  @apply bg-light-accent-2 dark:bg-dark-accent-2;
+  @apply hover:bg-light-accent-2-hovered hover:dark:bg-dark-accent-2-hovered;
+  @apply text-light-accent-1;
}

113-114: Consider using more flexible width constraints.

The fixed 75% width on desktop might not be optimal for all content types.

Consider using a more flexible approach:

.col.docItemCol_src-theme-DocItem-Layout-styles-module {
-  @apply !max-w-full md:max-w-[75%];
+  @apply !max-w-full md:max-w-[min(75%,_900px)];
}

Line range hint 9-17: Consider organizing CSS imports for better maintainability.

The current import structure mixes different types of styles. Consider organizing imports by purpose:

/* Base styles */
@import './infima-overrides.css';
@import './font.css';

/* Utility frameworks */
@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';

/* Component styles */
@import './types.css';

Also, consider splitting the custom styles into separate files by component (breadcrumbs.css, toc.css, etc.) for better maintainability.

docusaurus.config.js (1)

Line range hint 74-156: LGTM: Comprehensive redirect configuration.

The redirect logic is well-structured and handles all necessary cases. Consider adding a comment block documenting the redirect strategy for future maintenance.

Add a documentation block like:

/**
 * Redirect configuration for various documentation sections:
 * - V3 SDK Guide redirects (updated 1/9/23)
 * - Protocol documentation (V2 & V3)
 * - Permit2 documentation
 * - Swap Widget documentation
 */
🧰 Tools
🪛 eslint

[error] 69-69: 'require' is not defined.

(no-undef)

src/theme/Footer.tsx (3)

7-93: Consider extracting footer data to a separate configuration file.

The current implementation has several potential improvements:

  1. Move the footerData to a separate configuration file to improve maintainability and reusability
  2. Consider using environment variables for URLs to support different environments (development, staging, production)
  3. Consider flattening the data structure for easier maintenance

Example structure:

// src/config/footer.config.ts
export const footerConfig = {
  sections: {
    developers: {
      title: 'Developers',
      links: [
        { label: 'Concepts', href: process.env.DOCS_URL + '/concepts/overview' },
        // ... other links
      ]
    },
    // ... other sections
  },
  social: {
    github: process.env.GITHUB_URL,
    twitter: process.env.TWITTER_URL,
    discord: process.env.DISCORD_URL,
  }
}

108-127: Simplify conditional rendering logic.

The current implementation using empty fragments and nested ternaries can be simplified.

-            {footerData.footerLinks && footerData.footerLinks.length > 0 ? (
-              <>
-                {footerData.footerLinks.map((section) => (
-                  // ... section content
-                ))}
-              </>
-            ) : null}
+            {footerData.footerLinks?.map((section) => (
+              // ... section content
+            ))}

136-150: Reduce duplication in social media links section.

Extract the social media links rendering logic to reduce code duplication.

const SocialLink: FC<{ href?: string; icon: ReactNode; label: string }> = ({ href, icon, label }) => {
  if (!href) return null;
  return (
    <LinkBase className="group" href={href} ariaLabel={label}>
      {icon}
    </LinkBase>
  );
};

// Usage:
<SocialLink 
  href={footerData.footerGithubLink}
  icon={<Github className="h-6 w-6" />}
  label="Link to Uniswap Labs Github"
/>
src/css/types.css (2)

15-104: LGTM: Well-structured mobile typography system

The mobile typography classes follow a consistent scaling pattern, making the text more readable on smaller screens. The proportional reduction in font sizes and line heights is well-thought-out.

Consider adding a comment at the top of the file documenting the scaling ratios used (e.g., "Mobile typography uses ~75% scaling for font sizes with proportional line heights"). This would help maintain consistency when adding new styles in the future.


Line range hint 1-3: Consider adding typography system documentation

The file implements a comprehensive typography system. Consider adding a comment block at the top documenting:

  • The relationship between desktop and mobile sizes
  • The font weight system
  • The naming convention for classes
    This will help maintain consistency as the system grows.
src/components/Icons/index.tsx (1)

351-367: Enhance type safety in IconMap component.

Consider these improvements:

  1. Use template literals for the warning message
  2. Make the switch exhaustive to leverage TypeScript's type checking

Here's a more type-safe implementation:

 export type Icon = 'sun' | 'moon'

 export const IconMap: FC<{
   icon: Icon
   className?: string
   color?: 'neutral-2'
 }> = ({ icon, color, className }) => {
   switch (icon) {
     case 'sun':
       return <Sun color={color} className={className} />
     case 'moon':
       return <Moon color={color} className={className} />
-    default:
-      console.warn(`Icon ${icon} not found`)
-      return null
   }
+  const _exhaustiveCheck: never = icon
+  console.warn(`Unexpected icon type: ${icon}`)
+  return null
 }

This change:

  1. Uses template literals for string interpolation
  2. Adds compile-time checking for exhaustive handling of the Icon type
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 30d2966 and 8294ed2.

⛔ Files ignored due to path filters (30)
  • static/font/baselGrotesk/Basel-Grotesk-Book-Italic.otf is excluded by !**/*.otf
  • static/font/baselGrotesk/Basel-Grotesk-Book-Italic.woff is excluded by !**/*.woff
  • static/font/baselGrotesk/Basel-Grotesk-Book-Italic.woff2 is excluded by !**/*.woff2
  • static/font/baselGrotesk/Basel-Grotesk-Book.otf is excluded by !**/*.otf
  • static/font/baselGrotesk/Basel-Grotesk-Book.woff is excluded by !**/*.woff
  • static/font/baselGrotesk/Basel-Grotesk-Book.woff2 is excluded by !**/*.woff2
  • static/font/baselGrotesk/Basel-Grotesk-Medium-Italic.otf is excluded by !**/*.otf
  • static/font/baselGrotesk/Basel-Grotesk-Medium-Italic.woff is excluded by !**/*.woff
  • static/font/baselGrotesk/Basel-Grotesk-Medium-Italic.woff2 is excluded by !**/*.woff2
  • static/font/baselGrotesk/Basel-Grotesk-Medium.otf is excluded by !**/*.otf
  • static/font/baselGrotesk/Basel-Grotesk-Medium.woff is excluded by !**/*.woff
  • static/font/baselGrotesk/Basel-Grotesk-Medium.woff2 is excluded by !**/*.woff2
  • static/font/baselGrotesk/Basel-Grotesk-Regular-Italic.otf is excluded by !**/*.otf
  • static/font/baselGrotesk/Basel-Grotesk-Regular-Italic.woff is excluded by !**/*.woff
  • static/font/baselGrotesk/Basel-Grotesk-Regular-Italic.woff2 is excluded by !**/*.woff2
  • static/font/baselGrotesk/Basel-Grotesk-Regular.otf is excluded by !**/*.otf
  • static/font/baselGrotesk/Basel-Grotesk-Regular.woff is excluded by !**/*.woff
  • static/font/baselGrotesk/Basel-Grotesk-Regular.woff2 is excluded by !**/*.woff2
  • static/font/riegraf/Riegraf-Bold.otf is excluded by !**/*.otf
  • static/font/riegraf/Riegraf-Light.otf is excluded by !**/*.otf
  • static/font/riegraf/Riegraf-Medium.otf is excluded by !**/*.otf
  • static/font/riegraf/Riegraf-Regular-Italic.otf is excluded by !**/*.otf
  • static/font/riegraf/Riegraf-Regular.otf is excluded by !**/*.otf
  • static/img/arrow-left-dark.svg is excluded by !**/*.svg
  • static/img/arrow-left.svg is excluded by !**/*.svg
  • static/img/arrow-right-dark.svg is excluded by !**/*.svg
  • static/img/arrow-right.svg is excluded by !**/*.svg
  • static/img/chevron.svg is excluded by !**/*.svg
  • static/img/edit.svg is excluded by !**/*.svg
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (41)
  • .coderabbit.yaml (1 hunks)
  • .eslintrc.json (1 hunks)
  • .github/PULL_REQUEST_TEMPLATE.md (1 hunks)
  • docusaurus.config.js (3 hunks)
  • package.json (3 hunks)
  • postcss.config.js (1 hunks)
  • src/components/Icons/index.tsx (1 hunks)
  • src/components/SentimentTracking/index.tsx (2 hunks)
  • src/components/ThemeSwitch/index.tsx (1 hunks)
  • src/components/base/Button/index.tsx (1 hunks)
  • src/css/custom.css (2 hunks)
  • src/css/font.css (1 hunks)
  • src/css/infima-overrides.css (1 hunks)
  • src/css/types.css (13 hunks)
  • src/theme/DocBreadcrumbs.tsx (1 hunks)
  • src/theme/DocItem/Content/index.js (1 hunks)
  • src/theme/DocItem/Footer/index.js (1 hunks)
  • src/theme/DocItem/Footer/styles.module.css (1 hunks)
  • src/theme/DocItem/Layout/index.js (1 hunks)
  • src/theme/DocItem/Layout/styles.module.css (1 hunks)
  • src/theme/DocItem/Metadata/index.js (1 hunks)
  • src/theme/DocItem/Paginator/index.js (1 hunks)
  • src/theme/DocItem/TOC/Desktop/index.js (1 hunks)
  • src/theme/DocItem/TOC/Mobile/index.js (1 hunks)
  • src/theme/DocItem/TOC/Mobile/styles.module.css (1 hunks)
  • src/theme/DocItem/index.js (1 hunks)
  • src/theme/DocPage/Layout/Main/index.js (1 hunks)
  • src/theme/DocPage/Layout/Main/styles.module.css (1 hunks)
  • src/theme/DocPage/Layout/Sidebar/ExpandButton/index.js (1 hunks)
  • src/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css (1 hunks)
  • src/theme/DocPage/Layout/Sidebar/index.js (1 hunks)
  • src/theme/DocPage/Layout/Sidebar/styles.module.css (1 hunks)
  • src/theme/DocPage/Layout/index.js (1 hunks)
  • src/theme/DocPage/Layout/styles.module.css (1 hunks)
  • src/theme/DocPage/index.js (1 hunks)
  • src/theme/Footer.tsx (1 hunks)
  • src/theme/Navbar.tsx (1 hunks)
  • src/theme/NavbarItem.tsx (0 hunks)
  • src/theme/Root.tsx (1 hunks)
  • src/utils/storage.ts (1 hunks)
  • tailwind.config.js (2 hunks)
💤 Files with no reviewable changes (1)
  • src/theme/NavbarItem.tsx
✅ Files skipped from review due to trivial changes (4)
  • .coderabbit.yaml
  • .github/PULL_REQUEST_TEMPLATE.md
  • src/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css
  • src/theme/Root.tsx
🚧 Files skipped from review as they are similar to previous changes (12)
  • package.json
  • src/theme/DocItem/Footer/styles.module.css
  • src/theme/DocItem/Layout/styles.module.css
  • src/theme/DocItem/Metadata/index.js
  • src/theme/DocItem/Paginator/index.js
  • src/theme/DocItem/TOC/Desktop/index.js
  • src/theme/DocItem/TOC/Mobile/index.js
  • src/theme/DocItem/TOC/Mobile/styles.module.css
  • src/theme/DocPage/Layout/Main/styles.module.css
  • src/theme/DocPage/Layout/Sidebar/styles.module.css
  • src/theme/DocPage/Layout/styles.module.css
  • tailwind.config.js
🧰 Additional context used
🪛 eslint
docusaurus.config.js

[error] 69-69: 'require' is not defined.

(no-undef)

postcss.config.js

[error] 2-2: 'module' is not defined.

(no-undef)

src/components/Icons/index.tsx

[error] 224-224: Unknown property 'stroke-width' found, use 'strokeWidth' instead

(react/no-unknown-property)


[error] 250-250: Unknown property 'stroke-width' found, use 'strokeWidth' instead

(react/no-unknown-property)


[error] 251-251: Unknown property 'stroke-linecap' found, use 'strokeLinecap' instead

(react/no-unknown-property)


[error] 271-271: Unknown property 'stroke-width' found, use 'strokeWidth' instead

(react/no-unknown-property)


[error] 297-297: Unknown property 'stroke-width' found, use 'strokeWidth' instead

(react/no-unknown-property)


[error] 298-298: Unknown property 'stroke-linecap' found, use 'strokeLinecap' instead

(react/no-unknown-property)


[error] 318-318: Unknown property 'stroke-width' found, use 'strokeWidth' instead

(react/no-unknown-property)


[error] 344-344: Unknown property 'stroke-width' found, use 'strokeWidth' instead

(react/no-unknown-property)


[error] 345-345: Unknown property 'stroke-linecap' found, use 'strokeLinecap' instead

(react/no-unknown-property)

src/theme/DocItem/Content/index.js

[error] 25-25: 'children' is missing in props validation

(react/prop-types)

src/theme/DocItem/Footer/index.js

[error] 17-17: 'editUrl' is missing in props validation

(react/prop-types)


[error] 17-17: 'lastUpdatedAt' is missing in props validation

(react/prop-types)


[error] 17-17: 'lastUpdatedBy' is missing in props validation

(react/prop-types)


[error] 17-17: 'formattedLastUpdatedAt' is missing in props validation

(react/prop-types)

src/theme/DocItem/Layout/index.js

[error] 32-32: 'children' is missing in props validation

(react/prop-types)

src/theme/DocItem/index.js

[error] 7-7: 'content' is missing in props validation

(react/prop-types)


[error] 7-7: 'content.metadata' is missing in props validation

(react/prop-types)


[error] 7-7: 'content.metadata.unversionedId' is missing in props validation

(react/prop-types)


[error] 8-8: 'content' is missing in props validation

(react/prop-types)


[error] 10-10: 'content' is missing in props validation

(react/prop-types)

src/theme/DocPage/Layout/Main/index.js

[error] 5-5: 'hiddenSidebarContainer' is missing in props validation

(react/prop-types)


[error] 5-5: 'children' is missing in props validation

(react/prop-types)

src/theme/DocPage/Layout/Sidebar/ExpandButton/index.js

[error] 5-5: 'toggleSidebar' is missing in props validation

(react/prop-types)

src/theme/DocPage/Layout/Sidebar/index.js

[error] 12-12: 'children' is missing in props validation

(react/prop-types)


[error] 16-16: 'sidebar' is missing in props validation

(react/prop-types)


[error] 16-16: 'hiddenSidebarContainer' is missing in props validation

(react/prop-types)


[error] 16-16: 'setHiddenSidebarContainer' is missing in props validation

(react/prop-types)

src/theme/DocPage/Layout/index.js

[error] 8-8: 'children' is missing in props validation

(react/prop-types)

src/theme/DocPage/index.js

[error] 14-14: 'versionMetadata' is missing in props validation

(react/prop-types)


[error] 18-18: 'versionMetadata.version' is missing in props validation

(react/prop-types)


[error] 19-19: 'versionMetadata.pluginId' is missing in props validation

(react/prop-types)


[error] 19-19: 'versionMetadata.version' is missing in props validation

(react/prop-types)


[error] 21-21: 'versionMetadata.noIndex' is missing in props validation

(react/prop-types)


[error] 26-26: 'versionMetadata' is missing in props validation

(react/prop-types)


[error] 40-40: 'versionMetadata' is missing in props validation

(react/prop-types)


[error] 40-40: 'versionMetadata.className' is missing in props validation

(react/prop-types)

🪛 GitHub Check: Check uniswap Benchmarks
src/components/Icons/index.tsx

[failure] 224-224:
Unknown property 'stroke-width' found, use 'strokeWidth' instead


[failure] 250-250:
Unknown property 'stroke-width' found, use 'strokeWidth' instead


[failure] 251-251:
Unknown property 'stroke-linecap' found, use 'strokeLinecap' instead


[failure] 271-271:
Unknown property 'stroke-width' found, use 'strokeWidth' instead


[failure] 297-297:
Unknown property 'stroke-width' found, use 'strokeWidth' instead


[failure] 298-298:
Unknown property 'stroke-linecap' found, use 'strokeLinecap' instead


[failure] 318-318:
Unknown property 'stroke-width' found, use 'strokeWidth' instead


[failure] 344-344:
Unknown property 'stroke-width' found, use 'strokeWidth' instead


[failure] 345-345:
Unknown property 'stroke-linecap' found, use 'strokeLinecap' instead

src/theme/DocItem/Content/index.js

[failure] 25-25:
'children' is missing in props validation

src/theme/DocItem/Footer/index.js

[warning] 17-17:
'editUrl' is defined but never used. Allowed unused args must match /_/u

🪛 GitHub Check: Run linters
src/components/Icons/index.tsx

[failure] 224-224:
Unknown property 'stroke-width' found, use 'strokeWidth' instead


[failure] 250-250:
Unknown property 'stroke-width' found, use 'strokeWidth' instead


[failure] 251-251:
Unknown property 'stroke-linecap' found, use 'strokeLinecap' instead


[failure] 271-271:
Unknown property 'stroke-width' found, use 'strokeWidth' instead


[failure] 297-297:
Unknown property 'stroke-width' found, use 'strokeWidth' instead


[failure] 298-298:
Unknown property 'stroke-linecap' found, use 'strokeLinecap' instead


[failure] 318-318:
Unknown property 'stroke-width' found, use 'strokeWidth' instead


[failure] 344-344:
Unknown property 'stroke-width' found, use 'strokeWidth' instead


[failure] 345-345:
Unknown property 'stroke-linecap' found, use 'strokeLinecap' instead

src/theme/DocItem/Content/index.js

[failure] 25-25:
'children' is missing in props validation

src/theme/DocItem/Footer/index.js

[warning] 17-17:
'editUrl' is defined but never used. Allowed unused args must match /_/u

🔇 Additional comments (56)
postcss.config.js (1)

1-1: LGTM! Type annotation is correctly defined.

The TypeScript type annotation properly declares this as a PostCSS configuration file, providing good type safety and IDE support.

src/theme/DocBreadcrumbs.tsx (1)

7-7: ⚠️ Potential issue

Critical: Props forwarding issue remains unresolved

The breadcrumb component still isn't forwarding props to OriginalDocBreadcrumbs, which will break navigation functionality. This is particularly critical as implementing proper breadcrumb navigation is one of the main objectives of this PR.

Please refer to the previous review comment for the fix:

-      <OriginalDocBreadcrumbs />
+      <OriginalDocBreadcrumbs {...props} />
src/utils/storage.ts (1)

30-33: Verify theme usage and consider future extensibility.

The theme implementation looks good, but let's verify its usage and consider future requirements.

Let's check the theme usage across the application:

Consider these future-proofing suggestions:

  1. Move THEME_STORAGE_NAME to a central configuration file
  2. Consider using an enum for Theme type to enable better IDE support
  3. Consider adding support for system theme preference
src/theme/DocItem/index.js (3)

1-5: LGTM! Imports are well-organized and necessary.

All imports are being used and follow React conventions.


6-8: Previous PropTypes validation comment is still applicable.

The component still lacks proper props validation for the nested content structure.

🧰 Tools
🪛 eslint

[error] 7-7: 'content' is missing in props validation

(react/prop-types)


[error] 7-7: 'content.metadata' is missing in props validation

(react/prop-types)


[error] 7-7: 'content.metadata.unversionedId' is missing in props validation

(react/prop-types)


[error] 8-8: 'content' is missing in props validation

(react/prop-types)


9-18: Clean component structure, but verify feature integration.

The component structure is well-organized. However, let's verify the integration points for planned features.

✅ Verification successful

Integration points for planned features are already in place

The DocItemLayout component already includes all the planned features:

  • Table of Contents (TOC) with both mobile and desktop versions
  • Navigation through DocItemPaginator
  • Edit button via EditThisPage component
  • Breadcrumbs via DocBreadcrumbs

The component structure not only follows clean React patterns but is also fully prepared for the mentioned features.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of planned features in related components

# Check DocItemLayout implementation for planned features
echo "Checking DocItemLayout for feature integration..."
ast-grep --pattern 'export default function DocItemLayout({ children }) {
  return (
    $$$
    {children}
    $$$
  )
}'

# Check DocItemMetadata implementation for breadcrumbs
echo "Checking DocItemMetadata for breadcrumbs..."
ast-grep --pattern 'export default function DocItemMetadata() {
  $$$
  return (
    $$$
    <Breadcrumbs
      $$$
    />
    $$$
  )
}'

# Look for TOC component references
echo "Checking for TOC integration..."
rg -l "TableOfContents|TOC" src/theme/DocItem/Layout

Length of output: 632


Script:

#!/bin/bash
# Let's check the actual implementation of Layout/index.js to see TOC integration
echo "Checking Layout implementation..."
rg -A 10 "TableOfContents|TOC" src/theme/DocItem/Layout/index.js

# Check for navigation components
echo "Checking for navigation components..."
rg -l "DocPaginator|Pagination|Navigation" src/theme/DocItem/Layout

# Check for edit button components
echo "Checking for edit button..."
rg -l "EditThisPage|EditButton" src/theme/DocItem/Layout

Length of output: 2404

🧰 Tools
🪛 eslint

[error] 10-10: 'content' is missing in props validation

(react/prop-types)

src/theme/DocPage/Layout/Main/index.js (3)

1-4: LGTM! Dependencies are properly imported.

The imports are well-organized and include all necessary dependencies for the component's functionality.


6-6: LGTM! Proper hook usage for sidebar state management.

The useDocsSidebar hook is appropriately used to determine sidebar visibility.


15-24: Verify the CSS module implementation.

Let's ensure the CSS module contains all the required style classes and they properly handle the responsive layout mentioned in the PR objectives.

✅ Verification successful

CSS module implementation is properly structured and responsive

The CSS module contains all the necessary classes with appropriate responsive behavior:

  • Base styles handle the flex layout and full width
  • Media query for larger screens (997px+) properly implements:
    • Flexible growth with sidebar-aware max-width
    • Enhanced states for both container and wrapper
  • Calculations use the correct CSS variables for sidebar widths
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the CSS module contains all required classes
cat src/theme/DocPage/Layout/Main/styles.module.css

# Look for any other custom styles that might affect the layout
rg -t css "docMainContainer|docItemWrapper" --type css

Length of output: 884

src/theme/DocPage/Layout/Sidebar/ExpandButton/index.js (1)

7-25: Use semantic HTML button element instead of div.

The previous review comment about using a semantic button element instead of a div is still valid. This change would improve accessibility by leveraging native button behavior.

src/theme/DocPage/Layout/index.js (5)

1-7: LGTM! Imports are clean and well-organized.

The imports are appropriate for implementing a documentation page layout with sidebar functionality.


8-8: Skip generating PropTypes comment as it was already addressed in a past review.

🧰 Tools
🪛 eslint

[error] 8-8: 'children' is missing in props validation

(react/prop-types)


9-10: LGTM! State management is well-implemented.

The combination of useDocsSidebar hook and local state for sidebar visibility provides clean and efficient state management.


11-26: LGTM! Layout structure is well-organized.

The component implements a clean and maintainable layout structure with proper conditional rendering of the sidebar.


22-22: Verify implementation of required features in DocPageLayoutMain.

The PR objectives mention several features (breadcrumbs, TOC, navigation, edit button) that should be implemented. Let's verify their integration.

✅ Verification successful

Let me try a different approach to verify the implementation by searching for the component file and examining its contents directly.


Let me check if these features are implemented in a parent component or in the children being passed to DocPageLayoutMain.


Let me check the content of the children being passed to DocPageLayoutMain by examining the DocItem component, which is likely where these features are implemented.


Based on the examination of the codebase, I can now provide a final response:

The required features are properly implemented in the component hierarchy.

Looking at the DocItemLayout component (src/theme/DocItem/Layout/index.js), we can see that all the required features are present:

  • Breadcrumbs: <DocBreadcrumbs />
  • Table of Contents: Both mobile and desktop versions via docTOC.mobile and docTOC.desktop
  • Navigation: <DocItemPaginator /> at the bottom of the layout
  • Edit button: <EditThisPage editUrl={editUrl} /> in the TOC container

The DocPageLayoutMain component correctly serves as a container that receives these features through its children prop, maintaining a clean separation of concerns.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify implementation of required features in DocPageLayoutMain

# Search for breadcrumbs implementation
echo "Checking breadcrumbs implementation..."
ast-grep --pattern 'function DocPageLayoutMain($$$) {
  $$$
  <$_Breadcrumb$_>
  $$$
}'

# Search for TOC implementation
echo "Checking TOC implementation..."
ast-grep --pattern 'function DocPageLayoutMain($$$) {
  $$$
  <$_TableOfContents$_>
  $$$
}'

# Search for navigation implementation
echo "Checking navigation implementation..."
ast-grep --pattern 'function DocPageLayoutMain($$$) {
  $$$
  <$_PreviousNext$_>
  $$$
}'

# Search for edit button implementation
echo "Checking edit button implementation..."
ast-grep --pattern 'function DocPageLayoutMain($$$) {
  $$$
  <$_EditThisPage$_>
  $$$
}'

Length of output: 698


Script:

#!/bin/bash
# Find and show the DocPageLayoutMain component implementation
echo "Searching for DocPageLayoutMain component file..."
fd "DocPageLayoutMain" --type f

echo "\nChecking content of the component file..."
rg -A 20 "function DocPageLayoutMain" 

Length of output: 1665


Script:

#!/bin/bash
# Check the DocPage component and its imports
echo "Checking DocPage component structure..."
rg -A 20 "function DocPage" 

echo "\nChecking imports in DocPage related files..."
rg "import.*\{.*(Breadcrumb|TableOfContents|PreviousNext|EditThisPage).*\}" src/theme/DocPage/

Length of output: 8696


Script:

#!/bin/bash
# Find and examine DocItem component
echo "Searching for DocItem component..."
fd "DocItem" --type f

echo "\nChecking DocItem component content..."
rg -A 30 "function DocItem" 

echo "\nChecking imports in DocItem files..."
rg "import.*\{.*(Breadcrumb|TableOfContents|PreviousNext|EditThisPage).*\}" $(fd "DocItem" --type f)

Length of output: 8234

src/theme/DocItem/Content/index.js (2)

7-16: Well-documented implementation details!

The comments effectively explain the synthetic title implementation, including the different ways titles can be declared and the conditions for rendering. The GitHub PR reference provides valuable context for future maintainers.


17-24: Consider handling edge case where metadata.title is undefined

While the function handles the conditions for rendering the synthetic title, it might be worth adding a fallback for cases where metadata.title is undefined to prevent rendering an empty heading.

Consider adding a safety check:

-  return metadata.title
+  return metadata.title || null
src/theme/Navbar.tsx (3)

1-6: LGTM: Imports are well-organized and necessary

The imports are clean and properly structured, with clear separation between external and internal dependencies.


11-14: LGTM: Logo section is well-implemented with proper accessibility

The logo implementation includes proper aria-label and semantic HTML structure.


1-42: Verify integration with guide page navigation features

While the navbar implementation is solid, we should verify how it integrates with other guide page features mentioned in the PR objectives (breadcrumbs, TOC, prev/next navigation).

Let's verify the integration points:

✅ Verification successful

Navigation components are properly integrated

The verification shows that the Navbar component is part of a well-structured navigation system:

  • DocBreadcrumbs.tsx extends the original Docusaurus breadcrumbs
  • DocPaginator.tsx implements pagination with sentiment tracking
  • DocSidebarItem.tsx handles sidebar navigation with analytics integration

The Navbar implementation aligns well with these existing navigation components, each extending Docusaurus originals while adding custom functionality. No integration issues found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for related navigation components
echo "Searching for related navigation components..."
rg -l "breadcrumb|TableOfContents|TOC|pagination|prev.*next" --type=typescript --type=javascript

# Check for theme customization files that might affect navigation
echo "Checking theme customization files..."
fd -e tsx -e ts "^(?!.*test).*.(Breadcrumb|TOC|Navigation)" src/theme/

Length of output: 747


Script:

#!/bin/bash
# Search for related navigation components with simpler patterns
echo "Searching for navigation-related files..."
fd -e tsx -e ts . src/theme/

echo "Searching for navigation-related content..."
rg -i "breadcrumb|tableofcontents|toc|pagination|prevnext" --type ts --type tsx

echo "Checking imports of Navbar..."
rg -l "import.*Navbar" --type ts --type tsx

Length of output: 685


Script:

#!/bin/bash
# Check content of navigation-related files
echo "Content of DocBreadcrumbs.tsx:"
cat src/theme/DocBreadcrumbs.tsx

echo -e "\nContent of DocPaginator.tsx:"
cat src/theme/DocPaginator.tsx

echo -e "\nContent of DocSidebarItem.tsx:"
cat src/theme/DocSidebarItem.tsx

echo -e "\nSearching for Navbar imports (without file type filter):"
rg -l "import.*Navbar"

Length of output: 2082

src/theme/DocPage/index.js (4)

1-12: LGTM! Well-organized imports.

The imports are properly structured and include all necessary dependencies for the component's functionality.


13-24: Add PropTypes validation for better type safety.

The component needs PropTypes validation as previously suggested. This is still a valid concern from the past review.

🧰 Tools
🪛 eslint

[error] 14-14: 'versionMetadata' is missing in props validation

(react/prop-types)


[error] 18-18: 'versionMetadata.version' is missing in props validation

(react/prop-types)


[error] 19-19: 'versionMetadata.pluginId' is missing in props validation

(react/prop-types)


[error] 19-19: 'versionMetadata.version' is missing in props validation

(react/prop-types)


[error] 21-21: 'versionMetadata.noIndex' is missing in props validation

(react/prop-types)


43-47: LGTM! Well-structured context providers.

The nested context providers for version and sidebar are properly implemented, following React best practices for state management.


37-38: Address the TODO comment.

The TODO comment indicates that the className ThemeClassNames.wrapper.docsPages should be removed. This technical debt should be addressed.

Would you like me to help track this TODO by creating a GitHub issue?

src/components/ThemeSwitch/index.tsx (3)

1-9: LGTM! Imports are well-organized and necessary.

All imports are being utilized effectively in the component.


25-31: LGTM! Theme toggle implementation is clean and efficient.

The implementation correctly uses functional state updates and properly syncs with storage.


13-23: Verify theme initialization order.

The current implementation might have a race condition between system preference detection and stored theme retrieval. Consider consolidating the theme initialization logic into a single effect or utility function.

Let's check if ThemeManager handles system preferences:

src/css/infima-overrides.css (5)

27-32: LGTM! Following box-sizing best practices

The implementation follows the recommended pattern for consistent box-sizing across all elements.


58-64: LGTM! Good body defaults

The body defaults are well-chosen and enhance user experience with smooth scrolling and optimized text rendering.


72-86: LGTM! Good practices for links, images, and spacing

The implementation follows best practices for:

  • Link decoration skipping
  • Responsive images
  • Consistent article spacing

88-94: LGTM! Good form element defaults

Inheriting fonts for form elements is a good practice for consistency.


96-104: LGTM! Good accessibility support

Excellent implementation of reduced motion preferences for accessibility.

src/theme/DocItem/Footer/index.js (2)

32-54: Well-structured implementation with clear conditional logic

The DocItemFooter component is well implemented with:

  • Clear semantic HTML structure
  • Proper conditional rendering
  • Good variable naming
  • Efficient metadata handling

32-54: Implementation aligns with PR objectives

The DocItemFooter component successfully contributes to the guide page enhancement objectives by:

  • Providing clear metadata display
  • Supporting the documentation navigation structure
  • Maintaining consistent styling with Docusaurus theme
✅ Verification successful

Let me check the integration details by examining the Layout component that imports DocItemFooter.


Based on the verification results, I can now provide the final response:

Implementation verified: DocItemFooter properly integrated in guide page structure

The DocItemFooter component is correctly integrated within the document layout hierarchy:

  • Properly imported and used in src/theme/DocItem/Layout/index.js
  • Positioned appropriately in the article section, after the main content
  • Works alongside other essential doc components (breadcrumbs, content, paginator)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify integration with other guide page components
rg -l "DocItemFooter" --type js

Length of output: 99


Script:

#!/bin/bash
# Check how DocItemFooter is used in the Layout component
rg "DocItemFooter" src/theme/DocItem/Layout/index.js -A 5 -B 5

Length of output: 988

src/theme/DocPage/Layout/Sidebar/index.js (2)

1-8: LGTM! Imports are well-organized and appropriate

All necessary dependencies are properly imported for the sidebar functionality.


46-51: LGTM! Good implementation of sidebar viewport

The implementation correctly handles:

  • Sidebar state reset on changes
  • Viewport visibility transitions
  • Expand button rendering when sidebar is hidden
src/components/base/Button/index.tsx (1)

1-6: LGTM! Well-structured imports and security-conscious constants.

The imports are appropriate, and the constants properly handle security considerations for external links using noreferrer noopener.

src/components/SentimentTracking/index.tsx (3)

22-24: Well-structured component layout

The component layout is well organized with proper spacing and flex containers. The state management implementation is clean and follows React best practices.


35-37: Verify Tailwind CSS classes configuration

Ensure that the custom classes (selected, group/happy, group/neutral, group/sad) are properly configured in the Tailwind CSS configuration.

#!/bin/bash
# Check Tailwind config for custom classes
rg -l "selected|group" tailwind.config.*

Also applies to: 52-54, 69-71


4-4: 🛠️ Refactor suggestion

Ensure custom icons meet accessibility standards

The custom icons should include proper ARIA labels for screen readers. Consider adding aria-label attributes to improve accessibility.

Consider wrapping the icons with proper accessibility attributes:

- <Happy className="h-5 w-5 group/happy" />
+ <Happy className="h-5 w-5 group/happy" aria-label="positive sentiment" role="img" />
src/css/font.css (1)

5-60: LGTM! Font declarations follow best practices.

The Basel Grotesk font declarations are well structured with:

  • Optimal font format ordering (woff2 → woff → opentype) for better browser compatibility
  • Correct font-weight numerical values
  • Proper font-style declarations

Let's verify the existence of the font files:

✅ Verification successful

Font files are correctly placed and match the declarations

All 18 Basel Grotesk font files (6 variants × 3 formats) are present in the correct location at static/font/baselGrotesk/. The file paths in the CSS declarations correctly reference these files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if all Basel Grotesk font files exist in the specified paths

# Find all Basel Grotesk font files
fd -t f "Basel-Grotesk.*\.(woff2|woff|otf)$" static/font/baselGrotesk/

# Verify file count matches the declarations
echo "Expected: 18 files (6 variants × 3 formats)"

Length of output: 1144

src/css/custom.css (2)

58-60: Review sticky positioning calculation for edge cases.

The sticky positioning calculation uses complex viewport height calculations that might break in certain scenarios:

  1. Browsers with dynamic toolbars (like mobile Safari)
  2. Different viewport heights on mobile devices

Consider using CSS custom properties for better maintainability:

.Toc__container {
-  @apply max-h-[calc(100vh-(theme(spacing.nav-h)+2rem))] overflow-y-auto sticky top-[calc(theme(spacing.nav-h)+1rem)] hidden md:block;
+  @apply overflow-y-auto sticky hidden md:block;
+  max-height: calc(100vh - var(--nav-height, 4rem) - 2rem);
+  top: calc(var(--nav-height, 4rem) + 1rem);
}

29-32: 🛠️ Refactor suggestion

Consider accessibility implications of hidden breadcrumb item.

While visually hiding the first breadcrumb item works, ensure screen readers can still navigate the breadcrumb hierarchy correctly.

Consider adding proper ARIA attributes:

.breadcrumbs__item:first-child,
.breadcrumbs__item:first-child:after {
-  @apply !hidden;
+  @apply !invisible;
+  position: absolute;
+  width: 1px;
+  height: 1px;
+  padding: 0;
+  margin: -1px;
+  overflow: hidden;
+  clip: rect(0, 0, 0, 0);
+  white-space: nowrap;
+  border: 0;
}
docusaurus.config.js (3)

7-7: LGTM: Static directory configuration is correct.

The configuration follows Docusaurus best practices for serving static files.


69-69: Verify breadcrumb styles implementation.

The configuration points to custom.css, but we need to ensure breadcrumb styles (mentioned in PR objectives) are properly implemented.

This concern was previously raised in past reviews. Please ensure breadcrumb styles are added to the appropriate CSS file.

🧰 Tools
🪛 eslint

[error] 69-69: 'require' is not defined.

(no-undef)


36-39: Verify custom navigation implementation.

The comments indicate custom navigation and footer, but let's verify the implementation exists to support the PR objectives (breadcrumbs, TOC, page navigation).

✅ Verification successful

Let me verify the implementation details of these components.


Custom navigation implementation verified successfully

The codebase has proper implementation of custom navigation components:

  • Navbar.tsx: Custom navigation bar with logo, search, theme switch, and feedback button
  • Footer.tsx: Comprehensive footer with sections for developers, ecosystem, company info, and help
  • DocBreadcrumbs.tsx: Breadcrumb navigation component
  • DocItem/Footer/index.js: Document-specific footer with metadata and tags
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for custom navigation and footer implementation files

# Look for navigation-related files
echo "Searching for navigation-related files:"
fd -e js -e jsx -e ts -e tsx . | rg -i "nav|footer|breadcrumb"

# Check for navigation components
echo -e "\nSearching for navigation components:"
rg -l "function.*Nav|function.*Footer|function.*Breadcrumb" -g "*.{js,jsx,ts,tsx}"

Length of output: 495


Script:

#!/bin/bash
# Check the implementation of navigation components

echo "DocBreadcrumbs implementation:"
rg -A 5 "export.*function.*DocBreadcrumbs" src/theme/DocBreadcrumbs.tsx

echo -e "\nNavbar implementation:"
rg -A 5 "export.*function.*Navbar" src/theme/Navbar.tsx

echo -e "\nFooter implementation:"
rg -A 5 "export.*function.*Footer" src/theme/Footer.tsx

echo -e "\nDocItem Footer implementation:"
rg -A 5 "export.*function.*Footer" src/theme/DocItem/Footer/index.js

Length of output: 1004


Script:

#!/bin/bash
# Check for the complete implementation of Navbar and Footer components

echo "Complete Navbar implementation:"
cat src/theme/Navbar.tsx

echo -e "\nComplete Footer implementation:"
cat src/theme/Footer.tsx

# Also check if there are any custom hooks or utilities used for navigation
echo -e "\nChecking for navigation-related hooks and utilities:"
rg -l "useNav|useFooter|useBreadcrumb" -g "*.{js,jsx,ts,tsx}"

Length of output: 7647

src/theme/Footer.tsx (2)

1-5: LGTM! Well-organized imports.

The imports are logically grouped and use relative paths appropriately.


132-134: Consider using a dynamic date for the copyright year.

The current year will be static after build. Consider making it dynamic if needed.

If the site is statically built and deployed frequently, the current implementation is fine. Otherwise, consider using a client-side date:

const CopyrightYear: FC = () => {
  const [year, setYear] = useState(new Date().getFullYear());
  
  useEffect(() => {
    const timer = setInterval(() => setYear(new Date().getFullYear()), 1000 * 60 * 60);
    return () => clearInterval(timer);
  }, []);
  
  return <>{year}</>;
};
src/css/types.css (4)

9-9: LGTM: Line height adjustment improves readability

The adjusted line height creates better vertical spacing for the largest heading size.


161-169: LGTM: New serif subheading style maintains hierarchy

The new .serif-subheading-3 class follows the established pattern and maintains proper visual hierarchy with its 0.8125rem size.

Let's verify where this new style is being used:

#!/bin/bash
# Description: Check usage of the new serif-subheading-3 class
rg "serif-subheading-3" --type html --type jsx --type tsx

236-236: Verify the specific font weight requirement for buttons

The use of font-weight: 535 for button labels is unusual. Most systems use standard weights like 500 or 600.

Let's check if this weight is used consistently:

#!/bin/bash
# Description: Check usage of font-weight 535 across the codebase
rg "font-weight:\s*535" --type css

Also applies to: 246-246, 256-256, 266-266


211-230: Verify all usages of renamed classes are updated

The renaming from caption to body classes better reflects their role in the typography system.

Let's verify all usages have been updated:

✅ Verification successful

Class renaming verified successfully

The verification shows that:

  • No occurrences of old class names (serif-caption-1 or caption-1) were found in any files
  • New class names (serif-body-5 and mono-body-5) are properly defined in src/css/types.css and used in src/css/custom.css
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of old class names
echo "Checking for old caption classes that need updating..."
rg "serif-caption-1|caption-1" --type html --type jsx --type tsx

echo "Verifying usage of new body classes..."
rg "serif-body-5|mono-body-5" --type html --type jsx --type tsx

Length of output: 290


Script:

#!/bin/bash
# Let's try a more comprehensive search including CSS files and different file extensions
echo "Checking for old caption classes in CSS..."
rg "serif-caption-1|caption-1" --type css

echo "Checking for old caption classes in all files..."
rg -l "serif-caption-1|caption-1"

echo "Checking new body classes in CSS..."
rg "serif-body-5|mono-body-5" --type css

echo "Checking new body classes in all files..."
rg -l "serif-body-5|mono-body-5"

Length of output: 731

src/components/Icons/index.tsx (2)

1-4: LGTM! Clean and standard React TypeScript setup.

The imports are appropriate for the component's needs, using React.FC for type definitions and the classnames utility for conditional styling.


13-16: Well-implemented theme support with consistent patterns.

The color prop implementation is consistent across all components, properly handling:

  • Light/dark theme variations
  • Hover states
  • Selected states (for feedback icons)
  • Default neutral-2 color

Also applies to: 92-95, 109-112, 126-129, 142-144, 166-168, 181-183, 200-203, 220-223, 230-233, 239-242, 246-249, 267-270, 277-280, 286-289, 293-296, 314-317, 324-327, 333-336, 340-343

src/theme/DocItem/Layout/index.js (2)

19-31: Function useDocTOC is well-implemented

The custom hook useDocTOC effectively manages the TOC rendering based on the front matter and window size, ensuring responsive design.


32-32: Prop types validation missing for children prop

The component is missing prop types validation for the children prop.

🧰 Tools
🪛 eslint

[error] 32-32: 'children' is missing in props validation

(react/prop-types)

Copy link

⚡️ Lighthouse Report

Mobile (view report)

Category Score
🟠 Performance 79
🟢 Accessibility 96
🟢 Best practices 92
🟠 SEO 85

Desktop (view report)

Category Score
🟢 Performance 99
🟢 Accessibility 96
🟠 Best practices 83
🟠 SEO 82

Lighthouse ran on https://uniswap-docs-staging-dnkdrpvih-uniswap.vercel.app

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
.eslintrc.json (1)

Line range hint 42-50: Follow up on the TODO comment.

The comment indicates that the no-unused-vars warning level is temporary. Consider creating a tracking issue to change it back to "error" after cleaning up unused variables.

Would you like me to:

  1. Create a GitHub issue to track this TODO?
  2. Generate a script to identify all unused variables in the codebase?
src/components/SentimentTracking/index.tsx (1)

Line range hint 13-82: Consider UX improvements for sentiment selection

The current implementation could benefit from some UX enhancements:

  1. Add visual feedback after selection (e.g., a "Thank you" message)
  2. Consider allowing users to change their selection
  3. Add a loading state while the selection is being processed

Here's a suggested implementation:

 export default function SentimentTracking({ analyticsSection }: { analyticsSection: DocsSentimentSection }) {
   const [selectedSentiment, setSelectedSentiment] = useState<null | Sentiment>(null)
+  const [isSubmitting, setIsSubmitting] = useState(false)
+  const [showThankYou, setShowThankYou] = useState(false)
 
   const isSentimentSelected = useCallback(
     (sentiment: Sentiment) => selectedSentiment && selectedSentiment === sentiment,
     [selectedSentiment],
   )
 
+  const handleSentimentClick = async (sentiment: Sentiment) => {
+    if (isSubmitting) return
+    setIsSubmitting(true)
+    try {
+      // If clicking same sentiment, clear selection
+      if (selectedSentiment === sentiment) {
+        setSelectedSentiment(null)
+      } else {
+        setSelectedSentiment(sentiment)
+        setShowThankYou(true)
+        // Hide thank you message after 3 seconds
+        setTimeout(() => setShowThankYou(false), 3000)
+      }
+    } finally {
+      setIsSubmitting(false)
+    }
+  }
+
   return (
     <div className="flex flex-row space-x-4">
-      <div className="Sentiment__question">Was this helpful?</div>
+      <div className="Sentiment__question">
+        {showThankYou ? "Thanks for your feedback!" : "Was this helpful?"}
+      </div>
       {/* Rest of the code remains same, but update onClick to use handleSentimentClick */}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3be58c5 and 608d53d.

📒 Files selected for processing (3)
  • .eslintrc.json (1 hunks)
  • src/components/Icons/index.tsx (2 hunks)
  • src/components/SentimentTracking/index.tsx (2 hunks)
🔇 Additional comments (5)
.eslintrc.json (1)

Line range hint 22-41: LGTM! TypeScript and React rules are well configured.

The rule changes align with modern TypeScript/React development practices:

  • Disabling prop-types in favor of TypeScript's type system
  • Enforcing consistent enum naming and sorting
  • Disabling explicit module boundary types for better DX
src/components/Icons/index.tsx (4)

Line range hint 173-189: LGTM: Moon component implementation.

The Moon component follows the established pattern and best practices for icon components.


190-208: LGTM: Edit component implementation.

The Edit component is well-implemented with proper hover states and dark mode support.


210-349: Previous review feedback still applies: Fix SVG attribute naming.

The SVG attribute naming issues identified in the previous review are still present in the sentiment tracking icons (Happy, Neutral, Sad).


Line range hint 350-367: LGTM: IconMap component updates.

The IconMap component has been properly updated to include the new Moon icon while maintaining the existing pattern and type safety.

@@ -6,7 +6,7 @@ import ThemeSwitch from '../components/ThemeSwitch'

const Navbar: FC = () => {
return (
<nav className="Navbar fixed left-0 right-0 z-nav flex w-screen justify-center bg-light-surface-1 dark:border-dark-surface-3 dark:bg-dark-surface-1">
<nav className="Navbar navbar fixed left-0 right-0 z-nav flex w-screen justify-center bg-light-surface-1 dark:border-dark-surface-3 dark:bg-dark-surface-1">
Copy link
Author

Choose a reason for hiding this comment

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

added this since docusaurus use 'navbar' classname to get the nav bar on docs page!

Copy link

⚡️ Lighthouse Report

Mobile (view report)

Category Score
🟠 Performance 67
🟢 Accessibility 96
🟢 Best practices 92
🟠 SEO 85

Desktop (view report)

Category Score
🟢 Performance 99
🟢 Accessibility 96
🟠 Best practices 83
🟠 SEO 82

Lighthouse ran on https://uniswap-docs-staging-pio6rs91l-uniswap.vercel.app

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (4)
src/components/SentimentTracking/SentimentButton.tsx (2)

7-13: Add JSDoc documentation for the interface

While the interface is well-typed, adding JSDoc documentation would improve maintainability and developer experience.

Consider adding documentation like this:

+/**
+ * Props for the SentimentButton component
+ * @property {Sentiment} sentiment - The sentiment value (POSITIVE, NEUTRAL, NEGATIVE)
+ * @property {React.ReactNode} icon - The icon to display in the button
+ * @property {boolean} selected - Whether this sentiment is currently selected
+ * @property {(sentiment: Sentiment) => void} onSelect - Callback when sentiment is selected
+ * @property {DocsSentimentSection} analyticsSection - The section identifier for analytics
+ */
interface SentimentButtonProps {
  sentiment: Sentiment
  icon: React.ReactNode
  selected: boolean
  onSelect: (sentiment: Sentiment) => void
  analyticsSection: DocsSentimentSection
}

24-39: Consider error boundary for analytics tracking

While the implementation is solid, consider wrapping the TraceEvent in an error boundary to prevent analytics errors from affecting the main functionality.

Example implementation:

class AnalyticsErrorBoundary extends React.Component<{ children: React.ReactNode }> {
  componentDidCatch(error: Error) {
    console.error('Analytics error:', error);
    // Optionally report to error tracking service
  }

  render() {
    return this.props.children;
  }
}

// Usage in component:
return (
  <AnalyticsErrorBoundary>
    <TraceEvent {...props}>
      {/* ... */}
    </TraceEvent>
  </AnalyticsErrorBoundary>
);
src/components/SentimentTracking/index.tsx (1)

22-22: Consider enhancing the question text accessibility

The question text could benefit from being more semantic and accessible.

-<div className="Sentiment__question">Was this helpful?</div>
+<h2 className="Sentiment__question" aria-label="Feedback question">Was this helpful?</h2>
src/components/Icons/index.tsx (1)

210-349: Consider refactoring sentiment icons to reduce duplication.

The Happy, Neutral, and Sad components share very similar structure and could be refactored into a single component with a type prop.

Here's a suggested refactor:

type SentimentType = 'happy' | 'neutral' | 'sad';

interface SentimentIconProps {
  className?: string;
  color?: 'neutral-2';
  type: SentimentType;
}

const sentimentConfig = {
  happy: {
    hoverGroup: 'positive',
    selectedFill: 'status-success-1',
    path: 'M6 12C6 12 7.29032 14 10 14C12.7097 14 14 12 14 12'
  },
  neutral: {
    hoverGroup: 'neutral',
    selectedFill: 'status-warning-1',
    path: 'M7 13C7 13 7.96774 13 10 13C12.0323 13 13 13 13 13'
  },
  sad: {
    hoverGroup: 'negative',
    selectedFill: 'status-critical-1',
    path: 'M14 13C14 13 12.7097 11 10 11C7.29032 11 6 13 6 13'
  }
};

export const SentimentIcon: FC<SentimentIconProps> = ({ className, color = 'neutral-2', type }) => {
  const config = sentimentConfig[type];
  
  return (
    <svg className={className} viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
      <circle
        cx="10"
        cy="10"
        r="9"
        className={cn({
          [`stroke-light-neutral-2 dark:stroke-dark-neutral-2 group-hover/${config.hoverGroup}:stroke-light-neutral-1 group-hover/${config.hoverGroup}:dark:stroke-dark-neutral-1 group-[.selected]/${config.hoverGroup}:fill-light-${config.selectedFill} group-[.selected]/${config.hoverGroup}:dark:fill-dark-${config.selectedFill} group-[.selected]/${config.hoverGroup}:stroke-light-neutral-1 group-[.selected]/${config.hoverGroup}:dark:stroke-dark-neutral-1`]: color === 'neutral-2',
        })}
        strokeWidth="2"
      />
      {/* Eyes */}
      <circle
        cx="7"
        cy="8"
        r="1"
        className={cn({
          [`fill-light-neutral-2 dark:fill-dark-neutral-2 group-hover/${config.hoverGroup}:fill-light-neutral-1 group-hover/${config.hoverGroup}:dark:fill-dark-neutral-1 group-[.selected]/${config.hoverGroup}:fill-light-neutral-1 group-[.selected]/${config.hoverGroup}:dark:fill-dark-neutral-1`]: color === 'neutral-2',
        })}
      />
      <circle
        cx="13"
        cy="8"
        r="1"
        className={cn({
          [`fill-light-neutral-2 dark:fill-dark-neutral-2 group-hover/${config.hoverGroup}:fill-light-neutral-1 group-hover/${config.hoverGroup}:dark:fill-dark-neutral-1 group-[.selected]/${config.hoverGroup}:fill-light-neutral-1 group-[.selected]/${config.hoverGroup}:dark:fill-dark-neutral-1`]: color === 'neutral-2',
        })}
      />
      {/* Mouth */}
      <path
        d={config.path}
        className={cn({
          [`stroke-light-neutral-2 dark:stroke-dark-neutral-2 group-hover/${config.hoverGroup}:stroke-light-neutral-1 group-hover/${config.hoverGroup}:dark:stroke-dark-neutral-1 group-[.selected]/${config.hoverGroup}:stroke-light-neutral-1 group-[.selected]/${config.hoverGroup}:dark:stroke-dark-neutral-1`]: color === 'neutral-2',
        })}
        strokeWidth="2"
        strokeLinecap="round"
      />
    </svg>
  );
};
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 608d53d and e6a2c1a.

📒 Files selected for processing (4)
  • .prettierignore (1 hunks)
  • src/components/Icons/index.tsx (2 hunks)
  • src/components/SentimentTracking/SentimentButton.tsx (1 hunks)
  • src/components/SentimentTracking/index.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .prettierignore
🔇 Additional comments (9)
src/components/SentimentTracking/SentimentButton.tsx (3)

1-5: LGTM! Well-organized imports

The imports are properly structured with clear separation between external dependencies and local imports.


15-40: LGTM! Well-implemented component with proper analytics and accessibility

The component implementation is solid with:

  • Proper analytics tracking
  • Good accessibility via aria-labels
  • Clean event handling

33-33: Verify the group class pattern implementation

The group/${sentiment.toLowerCase()} class pattern seems unusual. Let's verify if this is the intended CSS module pattern being used in the project.

✅ Verification successful

Based on the context from the shell scripts, particularly the presence of Tailwind CSS configuration and imports in the codebase, I can now generate the final response:

The group/${sentiment.toLowerCase()} class pattern is valid Tailwind syntax

The usage of group/${sentiment.toLowerCase()} is a valid Tailwind CSS group naming pattern that allows for targeted group hover states. This is part of Tailwind's group modifier feature, which is commonly used for creating interactive parent-child relationships in components.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for similar group class pattern usage
rg "group/[a-z]+" --type css

# Check for CSS module definitions
fd -e css -e scss | xargs rg "\.group\/"

Length of output: 156


Script:

#!/bin/bash
# Search for similar group class pattern usage with fixed regex
rg "group/" --type-add 'styles:*.{css,scss,module.css,module.scss}' --type styles

# Check for any Tailwind configuration files
fd -e js -e ts -e json | grep -i "tailwind" | xargs cat

# Look for similar className patterns in TSX/JSX files
rg "className.*group/" -t tsx -t jsx

Length of output: 6033


Script:

#!/bin/bash
# Search for similar group patterns in TSX/JSX files with correct file type
rg "className.*group/" --type=typescript --type=javascriptreact --type=typescriptreact

# Look for Tailwind group modifier usage
rg "group[/-]" --type=typescript --type=javascriptreact --type=typescriptreact -A 2 -B 2

# Check if there are any CSS files that might contain group-related styles
fd -e css -e scss -e module.css -e module.scss | xargs cat

Length of output: 17237

src/components/SentimentTracking/index.tsx (3)

1-4: LGTM! Clean and well-organized imports

The imports are properly structured and the transition to custom icons is well implemented.


21-45: LGTM! Well-structured component with clean implementation

The component effectively uses React hooks, maintains a clean layout, and properly implements the sentiment tracking functionality. The previous concerns about code duplication have been well addressed through the SentimentButton component.


Line range hint 6-10: Verify the usage of exported Sentiment enum

The enum is now exported, suggesting it's used in other components. Let's verify its usage across the codebase.

✅ Verification successful

The previous command failed because the typescript file type wasn't recognized. Let's try searching without file type restriction and look for both direct usage of the enum and its imports/exports.


Sentiment enum export is correctly used across the codebase

The exported Sentiment enum is actively used within the SentimentTracking component system:

  • Imported and used in SentimentButton.tsx for mapping sentiment values
  • Used throughout index.tsx for button states and sentiment selection
  • Properly integrated with the analytics events system (DocsSentiment)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for all usages of the Sentiment enum
rg "Sentiment\." --type typescript

Length of output: 71


Script:

#!/bin/bash
# Search for all usages of Sentiment enum using ripgrep
# Using multiple patterns to catch different usage patterns
rg "Sentiment\." 
rg "from.*Sentiment" 
rg "import.*Sentiment"

Length of output: 1776

src/components/Icons/index.tsx (3)

Line range hint 173-189: LGTM: Moon component implementation is consistent.

The component follows established patterns and best practices for icon components.


190-208: Previous review comment about SVG attributes is still applicable.

The SVG attributes need to be updated to follow React conventions.


Line range hint 350-365: LGTM: IconMap update is correct.

The IconMap component has been properly updated to include the new Moon icon while maintaining consistency with the existing pattern.

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

🧹 Outside diff range and nitpick comments (5)
generate_file_tree.sh (2)

42-43: Improve output validation and formatting

The JSON output should be validated and properly formatted before display.

Apply these improvements:

 # Output the generated JSON
-cat file_tree.json
+if ! jq empty file_tree.json 2>/dev/null; then
+  echo "Error: Generated invalid JSON" >&2
+  exit 1
+fi
+# Pretty print the validated JSON
+jq '.' file_tree.json

1-43: Consider adding centralized error logging

The script would benefit from a centralized error logging mechanism to help track and debug issues during execution.

Consider implementing a logging function:

log_error() {
    echo "[ERROR] $(date '+%Y-%m-%d %H:%M:%S'): $1" >&2
}

log_warning() {
    echo "[WARNING] $(date '+%Y-%m-%d %H:%M:%S'): $1" >&2
}

This would provide consistent error reporting and timestamps for debugging purposes.

🧰 Tools
🪛 Shellcheck

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

(SC2148)

file_tree.json (3)

398-400: Improve title clarity for numbered guide files.

Several guide files use their filenames as titles (e.g., "06-token-listing", "03-trade-tokens", "01-fees") which reduces readability and searchability. Consider using descriptive titles that explain the content instead.

Examples of better titles:

  • "06-token-listing" → "Token Listing Guide"
  • "03-trade-tokens" → "Trading Tokens"
  • "01-fees" → "Fee Structure"

Also applies to: 408-410, 558-560


2163-2165: Standardize guide title formatting.

The SDK V3 guide titles are inconsistently formatted, using just the filename pattern (e.g., "03-web3-development-basics", "03-routing", "01-quoting"). This makes it harder for users to scan and understand the content structure.

Consider using descriptive titles:

  • "03-web3-development-basics" → "Web3 Development Basics"
  • "03-routing" → "Routing Guide"
  • "01-quoting" → "Price Quoting"
  • "02-trading" → "Trading Guide"

Also applies to: 2168-2170, 2173-2175, 2178-2180


1303-1305: Standardize title casing in technical guides.

The liquidity mining and flash integration guide titles use inconsistent casing (e.g., "overview", "calling-flash", "Inheritance-constructors"). This makes the documentation look less polished.

Apply title case consistently:

  • "overview" → "Overview"
  • "calling-flash" → "Calling Flash"
  • "Inheritance-constructors" → "Inheritance Constructors"
  • "final-contract" → "Final Contract"
  • "The full function" → "The Full Function"

Also applies to: 1313-1315, 1318-1320, 1323-1325, 1328-1330

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e6a2c1a and 96d2cd1.

📒 Files selected for processing (3)
  • file_tree.json (1 hunks)
  • generate_file_tree.sh (1 hunks)
  • src/css/custom.css (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/css/custom.css
🧰 Additional context used
🪛 Shellcheck
generate_file_tree.sh

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

(SC2148)

🔇 Additional comments (4)
generate_file_tree.sh (3)

1-4: Essential script safeguards are missing

The initialization lacks critical safety measures like shebang, safety flags, and command/directory validation.

The previous review comment suggesting essential script safeguards is still valid and should be implemented.

🧰 Tools
🪛 Shellcheck

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

(SC2148)


6-21: Directory processing needs robustness improvements

The current implementation has issues with filename spaces and potential race conditions.

The previous review comment suggesting directory processing improvements is still valid and should be implemented.


23-40: Markdown processing needs reliability improvements

The current implementation needs improvements for better reliability with filenames and title extraction.

The previous review comment suggesting Markdown processing improvements is still valid and should be implemented.

file_tree.json (1)

1-2552: Well-structured documentation hierarchy.

The overall organization of the documentation is logical and well-structured:

  • Clear separation between different protocol versions
  • Consistent categorization into guides, references, and concepts
  • Good hierarchical organization of related topics

Copy link

⚡️ Lighthouse Report

Mobile (view report)

Category Score
🟠 Performance 89
🟢 Accessibility 96
🟠 Best practices 83
🟠 SEO 85

Desktop (view report)

Category Score
🟢 Performance 99
🟢 Accessibility 96
🟠 Best practices 83
🟠 SEO 82

Lighthouse ran on https://uniswap-docs-staging-4hykpuf8b-uniswap.vercel.app

Copy link

⚡️ Lighthouse Report

Mobile (view report)

Category Score
🟠 Performance 71
🟢 Accessibility 96
🟢 Best practices 92
🟠 SEO 85

Desktop (view report)

Category Score
🟢 Performance 97
🟢 Accessibility 96
🟠 Best practices 83
🟠 SEO 82

Lighthouse ran on https://uniswap-docs-staging-7i6pnobm1-uniswap.vercel.app

Copy link

⚡️ Lighthouse Report

Mobile (view report)

Category Score
🟠 Performance 86
🟢 Accessibility 96
🟠 Best practices 83
🟠 SEO 85

Desktop (view report)

Category Score
🟢 Performance 98
🟢 Accessibility 96
🟠 Best practices 83
🟠 SEO 82

Lighthouse ran on https://uniswap-docs-staging-qf9q37ii0-uniswap.vercel.app

Comment on lines 53 to 56
<>
<p className="Toc__title">On this page</p>
{docTOC.desktop}
</>

Choose a reason for hiding this comment

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

can we wrap toc with

so it's more semantic?

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

🧹 Outside diff range and nitpick comments (2)
src/css/custom.css (2)

26-42: Consider accessibility and asset path improvements

While the breadcrumb styling looks good, there are two concerns:

  1. Hiding the first breadcrumb item might affect accessibility. Consider using aria-hidden="true" instead of !hidden if this item should remain visually hidden but accessible to screen readers.
  2. The hardcoded chevron icon path assumes a specific directory structure. Consider using a variable or importing the asset.
- background: url('/img/chevron.svg') center !important;
+ background: var(--chevron-icon-url) center !important;

116-130: Consider using design tokens for layout values

The layout adjustments use magic numbers and specific values:

  1. md:!max-w-[75%] could be a design token
  2. !mt-nav-h appears multiple times

Consider creating CSS custom properties or Tailwind theme extensions for these commonly used values:

- @apply sm:!max-w-full md:!max-w-[75%];
+ @apply sm:!max-w-full md:!max-w-[theme(spacing.content-width)];

- @apply !mt-nav-h;
+ @apply !mt-[theme(spacing.nav-offset)];
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 96d2cd1 and 0824f68.

📒 Files selected for processing (2)
  • src/css/custom.css (1 hunks)
  • src/theme/Navbar.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/theme/Navbar.tsx
🔇 Additional comments (2)
src/css/custom.css (2)

Line range hint 1-24: LGTM! Base configuration follows best practices

The imports and utility classes are well-structured, with proper responsive grid setup using Tailwind CSS.


55-78: Review mobile TOC accessibility

The TOC is completely hidden on mobile (!hidden). Consider implementing a collapsible/expandable TOC for mobile users instead of completely removing it, as this could impact mobile user experience.

Consider implementing a mobile-friendly TOC solution:

  1. Use a bottom sheet/drawer pattern
  2. Add a floating TOC toggle button
  3. Implement a collapsible sidebar

Copy link

⚡️ Lighthouse Report

Mobile (view report)

Category Score
🟠 Performance 84
🟢 Accessibility 96
🟠 Best practices 83
🟠 SEO 85

Desktop (view report)

Category Score
🟢 Performance 98
🟢 Accessibility 96
🟠 Best practices 83
🟠 SEO 82

Lighthouse ran on https://uniswap-docs-staging-6v407gu90-uniswap.vercel.app

Copy link

⚡️ Lighthouse Report

Mobile (view report)

Category Score
🟠 Performance 67
🟢 Accessibility 96
🟢 Best practices 92
🟠 SEO 85

Desktop (view report)

Category Score
🟢 Performance 99
🟢 Accessibility 96
🟠 Best practices 83
🟠 SEO 82

Lighthouse ran on https://uniswap-docs-staging-mb8otkb1b-uniswap.vercel.app

@nahbee10 nahbee10 merged commit ba6864f into main Nov 18, 2024
6 checks passed
Copy link

⚡️ Lighthouse Report

Mobile (view report)

Category Score
🟠 Performance 71
🟢 Accessibility 96
🟢 Best practices 92
🟠 SEO 85

Desktop (view report)

Category Score
🟢 Performance 98
🟢 Accessibility 96
🟢 Best practices 92
🟠 SEO 82

Lighthouse ran on https://uniswap-docs-staging-8lp1wipy9-uniswap.vercel.app

This was referenced Nov 18, 2024
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.

Guide Page
3 participants