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

Visually hidden docs #691

Merged
merged 5 commits into from
Dec 29, 2024
Merged

Conversation

GoldGroove06
Copy link
Contributor

@GoldGroove06 GoldGroove06 commented Dec 28, 2024

#689 Adding visually hidden component to docs in the website with example and api documentation. Need suggestion on how to show the hidden component in example.

Summary by CodeRabbit

  • New Features

    • Added documentation for the VisuallyHidden component.
    • Introduced a new navigation item for the VisuallyHidden component in the documentation.
  • Documentation

    • Created a comprehensive documentation page for the VisuallyHidden component.
    • Added code usage examples and prop details for the VisuallyHidden component.

Copy link
Contributor

coderabbitai bot commented Dec 28, 2024

Caution

Review failed

The pull request is closed.

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

docs/components/navigation/Navigation.js

Oops! Something went wrong! :(

ESLint: 8.56.0

ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct.

The config "next/core-web-vitals" was referenced from the config file in "/docs/.eslintrc.json".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

Walkthrough

This pull request introduces documentation for the VisuallyHidden component in the Radui UI library. It includes a new codeUsage.js file with code snippets demonstrating the usage of the component, a page.js file that documents the component's props and examples, and an update to the navigation structure to include a link to the new documentation.

Changes

File Change Summary
docs/app/docs/components/visually-hidden/docs/codeUsage.js Added new file exporting a constant object with a code snippet demonstrating the usage of the VisuallyHidden component.
docs/app/docs/components/visually-hidden/page.js Created new documentation page component with prop details, example, and metadata for the VisuallyHidden component.
docs/components/navigation/Navigation.js Added "VisuallyHidden" navigation item under Components section.

Possibly related PRs

  • Visually Hidden Component #665: This PR introduces the VisuallyHidden component, which is directly related to the new codeUsage.js file in the main PR that documents the usage of the VisuallyHidden component.
  • Visually Hidden component fixes #666: This PR adds an optional property asChild to the VisuallyHidden component, which is relevant to the main PR's focus on demonstrating the usage of the VisuallyHidden component.
  • Docs Improvements #676: This PR includes improvements to documentation, which may encompass the documentation for the VisuallyHidden component as well, aligning with the main PR's purpose of enhancing documentation.
  • Aspect Ratio docs #690: This PR adds documentation for the AspectRatio component, which is not directly related to the VisuallyHidden component but indicates ongoing documentation efforts in the same context.

Suggested reviewers

  • kotAPI

Poem

🐰 Hop, hop, hidden from sight,
A component so subtle and light,
VisuallyHidden, sneaky and neat,
Accessibility made quite a treat!
Radui's magic, clear and bright! 🌟


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9f77350 and e04d71e.

📒 Files selected for processing (1)
  • docs/components/navigation/Navigation.js (1 hunks)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
docs/app/docs/components/visually-hidden/page.js (1)

26-42: Suggestion: Demonstrate the visible result for testing.

Embedding a short note alongside the visually hidden text could help illustrate how it remains hidden visually but still accessible to screen readers, enabling new users to confirm the behavior in dev tools or usage demos.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4bdfa8b and f12b246.

📒 Files selected for processing (3)
  • docs/app/docs/components/visually-hidden/docs/codeUsage.js (1 hunks)
  • docs/app/docs/components/visually-hidden/page.js (1 hunks)
  • docs/components/navigation/Navigation.js (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • docs/app/docs/components/visually-hidden/docs/codeUsage.js
🔇 Additional comments (3)
docs/app/docs/components/visually-hidden/page.js (2)

1-7: Good addition of metadata and naming convention.

The PAGE_NAME constant and the metadata export align well with the existing documentation standards. No issues spotted.


11-23: Comprehensive table structure.

Your definition of columns and data for the prop table is clear and follows best practices for a compact, well-documented layout. This is helpful for future expansion if more props are added.

docs/components/navigation/Navigation.js (1)

157-160: VisuallyHidden navigation link added successfully.

The path and title match the newly added documentation route. Verify that it is appropriately reachable within the docs site navigation and appears in the correct "Components" list position.

✅ Verification successful

Navigation link for VisuallyHidden component is properly integrated

The verification confirms that:

  • The component documentation exists at the correct path /docs/components/visually-hidden
  • The navigation entry is properly added with the correct title "VisuallyHidden"
  • The component is fully documented with proper examples, code usage, and implementation
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Confirm that the hyperlink to /docs/components/visually-hidden is properly rendered.
rg 'VisuallyHidden' -A 3

Length of output: 7537

import SEO from "../../docsIndex"
export const metadata = SEO.getMetadata(PAGE_NAME)

import codeUsage from "./docs/codeUsage"
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

The import path needs to be corrected

The current import path "./docs/codeUsage" is incorrect. Based on the directory structure and file content verification:

  • The file exists at docs/app/docs/components/visually-hidden/docs/codeUsage.js
  • It exports a default object containing code examples
  • The import statement should be "./docs/codeUsage" since the importing file (page.js) is in the same directory as the docs folder
🔗 Analysis chain

Suggest verifying the import path.

Kindly double-check that "./docs/codeUsage" is the correct relative path for the codeUsage import and that the file indeed exports what you expect.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Validate that codeUsage is exported from docs/app/docs/components/visually-hidden/docs/codeUsage.js
rg --context 3 'export .* codeUsage' 

Length of output: 38


Script:

#!/bin/bash
# Let's first check if the file exists at the expected location
fd "codeUsage" --extension js --extension ts --extension tsx

# Let's also check for any file that might export codeUsage using ast-grep
ast-grep --pattern 'export $_ codeUsage'

# Let's also check the directory structure to understand the context better
ls -R docs/app/docs/components/visually-hidden/

Length of output: 1236


Script:

#!/bin/bash
# Let's check the content of the codeUsage.js file to verify the export
cat docs/app/docs/components/visually-hidden/docs/codeUsage.js

# Let's also check the actual import statement in page.js
cat docs/app/docs/components/visually-hidden/page.js

Length of output: 1872

</VisuallyHidden>
)`
},
scss: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we do this via js as an inline style, we wont need the CSS, this wont work without CSS, thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The component was made this way although it has a line of styling but inline styling might have conflicts with customclass styling. Not tested I might be wrong too.

Copy link
Collaborator

Choose a reason for hiding this comment

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

if people wanna inline style and override, that's fine - but out of the box this should work without CSS

Coz we are a headless library first, without CSS - this component will be visible even though we call it visually hidden :D

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (5)
docs/app/docs/components/visually-hidden/page.js (5)

3-4: Remove unnecessary empty line between imports

Consider removing the extra empty line to maintain consistent spacing between imports.


20-23: Enhance API documentation completeness

The current API documentation could be improved in several ways:

  1. The description for asChild could be more detailed, explaining when and why to use it
  2. Consider documenting additional common props (e.g., className, style) if supported
  3. Add examples of how asChild affects rendering with different HTML elements

Example enhancement for the data array:

 const data = [
-    {prop: 'asChild', type: 'boolean', default: 'false', description: 'renders the children in desired element'},
+    {
+        prop: 'asChild',
+        type: 'boolean',
+        default: 'false',
+        description: 'When true, the component will render its children using the specified element type instead of the default span. Useful for maintaining semantic HTML while applying visual hiding.'
+    },
+    {
+        prop: 'className',
+        type: 'string',
+        default: 'undefined',
+        description: 'Additional CSS classes to apply to the component'
+    }
 ];

29-33: Enhance the example and clean up markup

  1. The empty div wrapper around VisuallyHidden seems unnecessary
  2. Consider adding more practical examples that demonstrate real-world use cases
-<div>
-<VisuallyHidden asChild>
-    <span>This is a visually hidden text</span>
-</VisuallyHidden>
-</div>
+<VisuallyHidden asChild>
+    <h2>Skip to main content</h2>
+</VisuallyHidden>

Consider adding more examples like:

  • Skip navigation links
  • Form labels that need to be hidden
  • Screen reader announcements

37-39: Remove unnecessary div wrapper

The div wrapper around Documentation.Table appears to be unnecessary and adds no semantic value.

-<div >
    <Documentation.Table columns={columns} data={data} />
-</div>

27-27: Enhance accessibility documentation

Since this is an accessibility-focused component, consider expanding the description to include:

  • WCAG guidelines this component helps satisfy
  • Common accessibility pitfalls it helps avoid
  • Best practices for implementation
  • Links to relevant accessibility resources

Example enhancement:

-description={`Use these helpers to visually hide elements but keep them accessible to assistive technologies.`}
+description={`Use these helpers to visually hide elements while maintaining accessibility for screen readers and other assistive technologies. This component follows WCAG techniques for visually hidden content (C7) and helps maintain an inclusive user experience while managing visual complexity.`}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f12b246 and 6afc571.

📒 Files selected for processing (3)
  • docs/app/docs/components/visually-hidden/docs/codeUsage.js (1 hunks)
  • docs/app/docs/components/visually-hidden/page.js (1 hunks)
  • docs/components/navigation/Navigation.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • docs/app/docs/components/visually-hidden/docs/codeUsage.js
  • docs/components/navigation/Navigation.js
🔇 Additional comments (1)
docs/app/docs/components/visually-hidden/page.js (1)

9-9: The import path needs to be corrected

The import path "./docs/codeUsage" needs to be verified.

@kotAPI kotAPI added the automerge A tag that tells kodiak bot to automerge PRs for us when tests and approval conditions are met label Dec 29, 2024
@kodiakhq kodiakhq bot merged commit 5f4967c into rad-ui:main Dec 29, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge A tag that tells kodiak bot to automerge PRs for us when tests and approval conditions are met
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants