Skip to content

chore: move code to UI#3396

Merged
MichaelUnkey merged 16 commits intomainfrom
move-code-to-ui
Jun 25, 2025
Merged

chore: move code to UI#3396
MichaelUnkey merged 16 commits intomainfrom
move-code-to-ui

Conversation

@MichaelUnkey
Copy link
Collaborator

@MichaelUnkey MichaelUnkey commented Jun 20, 2025

What does this PR do?

Fixes # (issue)

If there is not an issue for this, please create one first. This is used to tracking purposes and also helps use understand why this PR exists

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • Enhancement (small improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How should this be tested?

  • Code components still styled in dashboard the same as prod.
  • Engineering docs are sufficient

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read Contributing Guide
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand areas
  • Ran pnpm build
  • Ran pnpm fmt
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Unkey Docs if changes were necessary

Summary by CodeRabbit

  • New Features

    • Introduced a new Code component for displaying code snippets with customizable styling and multiple visual variants.
    • Added example components and comprehensive documentation for the new Code component, including usage instructions and best practices.
    • Added a reusable PermissionToggle component to improve UI consistency in settings.
  • Refactor

    • Consolidated imports of the Code component across the dashboard to use a single external UI package for consistency.
    • Simplified copy button usage by integrating it into the Code component’s props.
    • Updated CopyButton to use a standardized button internally with improved accessibility and styling defaults.
    • Enhanced key dialog UI with confirmation flow and improved snippet display for better user clarity.
    • Streamlined SecretKey and snippet display components by simplifying button wrappers and consolidating control elements.
    • Applied consistent "ghost" variant styling to CopyButton instances in multiple UI areas for uniform appearance.
  • Documentation

    • Expanded CopyButton documentation with detailed accessibility, behavior, styling, and usage guidelines.
    • Added new documentation for the Code component highlighting features, variants, and best practices.

@changeset-bot
Copy link

changeset-bot bot commented Jun 20, 2025

⚠️ No Changeset found

Latest commit: b2602ad

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 20, 2025

📝 Walkthrough

Walkthrough

This change introduces a new Code React component in the shared UI library with multiple styling variants and integrated copy and visibility toggle buttons. It adds comprehensive documentation and usage examples for the component. Additionally, it consolidates all imports of the Code component across various application files to use the new shared implementation from @unkey/ui. Minor related UI improvements and refactors accompany this, including enhanced copy button behavior and styling updates.

Changes

File(s) Change Summary
apps/dashboard/app/(app)/identities/[identityId]/page.tsx Changed Code import from local to @unkey/ui; added variant="legacy" prop usage.
apps/dashboard/app/(app)/settings/billing/stripe/checkout/page.tsx Changed Code import from local to @unkey/ui; consolidated Empty import.
apps/dashboard/app/(app)/settings/billing/stripe/portal/page.tsx Consolidated Code and Empty imports from @unkey/ui.
apps/dashboard/app/(app)/settings/root-keys/new/client.tsx Consolidated Code import; added new UI imports; introduced PermissionToggle component; enhanced state and confirmation popover flow for key dialog.
apps/dashboard/app/(app)/settings/vercel/page.tsx Consolidated Code import with other UI components from @unkey/ui.
apps/dashboard/app/integrations/vercel/callback/page.tsx Consolidated Code and Empty imports from @unkey/ui.
apps/dashboard/app/new/create-ratelimit.tsx Consolidated Code import; updated Code usage to include copyButton prop with embedded CopyButton.
apps/dashboard/app/new/keys.tsx Consolidated Code import with other UI components from @unkey/ui.
apps/engineering/content/design/components/code.example.tsx Added new example components CodeExample and CodeVariants demonstrating Code usage and variants.
apps/engineering/content/design/components/code.mdx Added detailed documentation for the Code component, covering usage, props, styling, accessibility, and best practices.
internal/ui/src/components/code.tsx Added new Code React component with three style variants and support for copy and visibility toggle buttons.
internal/ui/src/index.ts Exported the new Code component from the UI library.
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/key-created-success-dialog.tsx Refactored snippet display to use the new Code component with integrated visibility and copy buttons.
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/secret-key.tsx Simplified CopyButton usage by removing extra button wrapper inside SecretKey component.
apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/logs-table.tsx Added variant="ghost" prop to all CopyButton instances inside logs table for styling consistency.
apps/dashboard/components/navigation/copyable-id-button.tsx Added variant="ghost" prop to CopyButton.
apps/engineering/content/design/components/buttons/copy-button.examples.tsx Restructured CopyButton usage examples into grouped vertical layout with multiple variant demonstrations.
apps/engineering/content/design/components/buttons/copy-button.mdx Expanded and enhanced CopyButton documentation with detailed features, props, behavior, accessibility, and best practices.
internal/ui/src/components/copy-button.tsx Refactored CopyButton to extend from shared Button component; added default props and improved event handling.

Sequence Diagram(s)

sequenceDiagram
    participant AppFile as App File (e.g., page.tsx)
    participant UI as @unkey/ui
    participant Code as Code Component

    AppFile->>UI: import { Code } from "@unkey/ui"
    UI->>Code: Provide Code component with variants and buttons
    AppFile->>Code: Render <Code> with snippet, copyButton, visibleButton props
Loading

Possibly related PRs

Suggested reviewers

  • perkinsjr
  • chronark
  • mcstepp
  • ogzhanolguncu

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b5c7d16 and 0a9984e.

📒 Files selected for processing (1)
  • apps/dashboard/components/navigation/copyable-id-button.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (14)
  • GitHub Check: Test Go API Local / Test (Shard 8/8)
  • GitHub Check: Test Go API Local / Test (Shard 5/8)
  • GitHub Check: Test Go API Local / Test (Shard 1/8)
  • GitHub Check: Test Go API Local / Test (Shard 7/8)
  • GitHub Check: Test Go API Local / Test (Shard 6/8)
  • GitHub Check: Test Go API Local / Test (Shard 3/8)
  • GitHub Check: Test Go API Local / Test (Shard 2/8)
  • GitHub Check: Test Go API Local / Test (Shard 4/8)
  • GitHub Check: Build / Build
  • GitHub Check: Test API / API Test Local
  • GitHub Check: Test Packages / Test ./packages/hono
  • GitHub Check: Test Packages / Test ./internal/clickhouse
  • GitHub Check: autofix
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
apps/dashboard/components/navigation/copyable-id-button.tsx (1)

72-72: LGTM! Consistent variant styling applied.

The addition of variant="ghost" aligns with the codebase standardization effort mentioned in the summary. This styling change maintains the existing functionality while ensuring visual consistency across CopyButton components.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

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

CodeRabbit Configuration File (.coderabbit.yaml)

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

Documentation and Community

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

@vercel
Copy link

vercel bot commented Jun 20, 2025

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

Name Status Preview Comments Updated (UTC)
dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 25, 2025 8:20pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
engineering ⬜️ Ignored (Inspect) Visit Preview Jun 25, 2025 8:20pm

@github-actions
Copy link
Contributor

github-actions bot commented Jun 20, 2025

Thank you for following the naming conventions for pull request titles! 🙏

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4ca795b and 5aab8ff.

📒 Files selected for processing (12)
  • apps/dashboard/app/(app)/identities/[identityId]/page.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/billing/stripe/checkout/page.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/billing/stripe/portal/page.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/root-keys/new/client.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/vercel/page.tsx (1 hunks)
  • apps/dashboard/app/integrations/vercel/callback/page.tsx (1 hunks)
  • apps/dashboard/app/new/create-ratelimit.tsx (1 hunks)
  • apps/dashboard/app/new/keys.tsx (1 hunks)
  • apps/engineering/content/design/components/code.example.tsx (1 hunks)
  • apps/engineering/content/design/components/code.mdx (1 hunks)
  • internal/ui/src/components/code.tsx (1 hunks)
  • internal/ui/src/index.ts (1 hunks)
🔇 Additional comments (22)
apps/dashboard/app/(app)/settings/billing/stripe/checkout/page.tsx (1)

4-4: Clean import consolidation to shared UI package.

The import change from local path to @unkey/ui aligns with the broader refactoring to centralize UI components. The Code component usage remains unchanged.

apps/dashboard/app/integrations/vercel/callback/page.tsx (1)

9-9: Efficient import consolidation.

Consolidating both Code and Empty imports from @unkey/ui into a single import statement improves maintainability and follows best practices.

internal/ui/src/index.ts (1)

3-3: Proper export addition for Code component.

The export is correctly added in alphabetical order, making the Code component publicly available from the @unkey/ui package to support the import consolidation across the codebase.

apps/dashboard/app/(app)/identities/[identityId]/page.tsx (1)

18-18: Well-organized import consolidation.

Grouping Button, Code, and CopyButton imports from @unkey/ui into a single statement improves code organization and maintainability without affecting functionality.

apps/dashboard/app/(app)/settings/billing/stripe/portal/page.tsx (1)

4-4: Consistent import consolidation pattern.

The consolidation of Code and Empty imports from @unkey/ui follows the same clean pattern applied across other files in this refactoring, promoting consistency and maintainability.

apps/dashboard/app/new/create-ratelimit.tsx (1)

5-5: Consolidated import for Code component: Looks correct—import Code and CopyButton alongside Button from @unkey/ui matches the new UI library structure and ensures consistency across the codebase.

apps/dashboard/app/new/keys.tsx (1)

13-13: Updated Code import source: Importing Code from @unkey/ui is aligned with the shared UI library refactor. Ensure that the default variant styling applies correctly in all code snippets.

apps/dashboard/app/(app)/settings/vercel/page.tsx (1)

13-13: Standardized import of Code and other UI components: Consolidating Code, Button, and Empty imports from @unkey/ui improves consistency. Confirm that Empty and Code variants render as expected within this error state.

apps/dashboard/app/(app)/settings/root-keys/new/client.tsx (1)

24-24: Unified Code component import: Switching Code to come from @unkey/ui matches the new shared UI library. Check that the styling and preformatted behavior remain correct in dialogs.

internal/ui/src/components/code.tsx (3)

1-4: Validate import patterns: The imports of VariantProps, cva, React, and cn are correct. Ensure cn references the proper utility for merging class names.


22-24: Interface definition is clear: The CodeProps interface correctly extends standard HTML attributes and variant props.


30-32: Exports look good: The component and its variants are properly exported.

apps/engineering/content/design/components/code.example.tsx (4)

1-4: LGTM: Clean imports and client directive.

The imports are well-organized and the "use client" directive is appropriate for interactive components in Next.js.


5-13: LGTM: Well-structured example snippet.

The EXAMPLE_SNIPPET constant provides a realistic curl command example that effectively demonstrates the Code component's usage with sensitive data handling.


21-37: LGTM: Well-implemented interactive code component.

The Code component implementation with overlay controls for visibility toggle and copy functionality is well-structured. The absolute positioning of controls and conditional rendering of sensitive data work correctly together.


45-58: LGTM: Clear variant demonstration.

The CodeVariants component effectively showcases the different styling options available in the Code component, providing a useful reference for developers.

apps/engineering/content/design/components/code.mdx (6)

1-5: LGTM: Proper MDX frontmatter.

The frontmatter is correctly structured with appropriate title and description for the Code component documentation.


6-6: LGTM: Correct example component imports.

The import statement properly references the example components from the accompanying file.


12-19: LGTM: Comprehensive feature list.

The features section clearly outlines the key capabilities of the Code component, providing users with a quick overview of what to expect.


23-29: LGTM: Clear usage example.

The usage section provides a straightforward, practical example of how to import and use the Code component.


46-52: LGTM: Well-formatted props documentation.

The props table is comprehensive and clearly documents the available options with proper types and descriptions.


65-82: LGTM: Excellent best practices and accessibility guidance.

The documentation provides valuable guidance on proper usage patterns and accessibility considerations, which will help ensure consistent and inclusive implementation across the codebase.

@MichaelUnkey MichaelUnkey added this pull request to the merge queue Jun 25, 2025
Merged via the queue into main with commit 9a85c33 Jun 25, 2025
33 of 37 checks passed
@MichaelUnkey MichaelUnkey deleted the move-code-to-ui branch June 25, 2025 20:58
@coderabbitai coderabbitai bot mentioned this pull request Jun 26, 2025
18 tasks
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.

3 participants