Skip to content

feat: Move settings card and new inline link#3198

Merged
MichaelUnkey merged 4 commits intomainfrom
move-settings-card-to-unkey-ui
Apr 28, 2025
Merged

feat: Move settings card and new inline link#3198
MichaelUnkey merged 4 commits intomainfrom
move-settings-card-to-unkey-ui

Conversation

@MichaelUnkey
Copy link
Collaborator

@MichaelUnkey MichaelUnkey commented Apr 25, 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?

  1. Ensure SettingCard still functions in dashboard like it should.
  2. InlineLink functions and looks the way we want it to.
  3. Review the docs to make sure they represent what the component does.

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

image

  • 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 InlineLink component for easily adding inline links with optional icons and new tab support.
    • Added comprehensive documentation and interactive examples for both InlineLink and SettingCard components.
  • Enhancements

    • Updated various settings and billing pages to use the standardized SettingCard component from the UI library, ensuring a more consistent look and feel.
    • Improved settings descriptions with clearer inline documentation links and simplified button layouts.
  • Documentation

    • Added detailed usage guides and accessibility notes for InlineLink and SettingCard components, including code examples.

@changeset-bot
Copy link

changeset-bot bot commented Apr 25, 2025

⚠️ No Changeset found

Latest commit: e5dc548

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

@vercel
Copy link

vercel bot commented Apr 25, 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 Apr 25, 2025 7:30pm
engineering ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 25, 2025 7:30pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 25, 2025

📝 Walkthrough

Walkthrough

This change set migrates usage of the SettingCard component across multiple dashboard and settings files from a local import path to the external @unkey/ui package. It also introduces a new InlineLink component in the UI library, with corresponding documentation and usage examples. The DeleteProtection and UpdateIpWhitelist components are updated to use the new InlineLink for external documentation links, replacing previous button or anchor implementations. Additionally, new documentation and example files are added for both SettingCard and InlineLink, and the UI library's entry point is updated to export these components.

Changes

File(s) Change Summary
apps/dashboard/app/(app)/apis/[apiId]/settings/components/copy-api-id.tsx
.../default-bytes.tsx
.../default-prefix.tsx
.../delete-api.tsx
.../update-api-name.tsx
.../authorization/permissions/[permissionId]/settings-client.tsx
.../authorization/roles/[roleId]/settings-client.tsx
.../ratelimits/[namespaceId]/settings/components/settings-client.tsx
.../settings/billing/client.tsx
.../settings/billing/components/usage.tsx
.../settings/billing/page.tsx
Changed the import source of the SettingCard component from a local path to the external @unkey/ui package. No other logic or code structure was altered.
apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-protection.tsx Updated to import SettingCard and InlineLink from @unkey/ui. Replaced a custom anchor/button "Learn more" link with the new InlineLink component, adjusted icon size, and slightly changed the enabled state message text.
apps/dashboard/app/(app)/apis/[apiId]/settings/components/update-ip-whitelist.tsx Updated imports to use SettingCard, Button, and InlineLink from @unkey/ui. Enhanced the description with an inline "Learn more" link using InlineLink. Simplified the "Upgrade to Enterprise" button and removed the separate "Learn more" button in the disabled state. Adjusted SettingCard's contentWidth prop.
apps/engineering/content/design/components/inline-link.example.tsx Added new example file demonstrating four variations of the InlineLink component: basic usage, with icons, with target for new tab, and with custom styling. Each example is wrapped in a RenderComponentWithSnippet for documentation/demo purposes.
apps/engineering/content/design/components/inline-link.mdx Added new documentation file for InlineLink, including usage examples, feature highlights, prop documentation, and accessibility notes.
apps/engineering/content/design/components/settings-card.example.tsx Added new example file demonstrating various usages of the SettingCard component, including different border configurations and content layouts. Each example is wrapped in a RenderComponentWithSnippet.
apps/engineering/content/design/components/settings-card.mdx Added new documentation file for SettingCard, covering usage, features, prop documentation, and accessibility.
internal/ui/src/components/inline-link.tsx Introduced a new InlineLink React component with support for label, icon, icon position, className, and target (open in new tab).
internal/ui/src/components/settings-card.tsx Changed React import to explicit namespace import for linting compliance. Updated the import path for the cn utility to a relative path.
internal/ui/src/index.ts Added exports for InlineLink and SettingCard components.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DashboardPage
    participant @unkey/ui
    participant Documentation

    User->>DashboardPage: Loads settings page
    DashboardPage->>@unkey/ui: Render SettingCard
    DashboardPage->>@unkey/ui: Render InlineLink (for "Learn more")
    User->>InlineLink: Clicks "Learn more"
    InlineLink->>Documentation: Opens documentation in new tab
Loading

Suggested reviewers

  • perkinsjr
  • mcstepp
  • chronark
✨ 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.
    • 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.
  • @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.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 25, 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: 0

🧹 Nitpick comments (4)
apps/engineering/content/design/components/settings-card.mdx (2)

20-20: Fix typo in description text.

There's a spelling error: "visualy" should be "visually".

-Two SettingCard components sharing a common edge. Useful when settings might be related or make sense visualy together. 
+Two SettingCard components sharing a common edge. Useful when settings might be related or make sense visually together. 

24-24: Fix typo in section heading.

There's a spelling error: "seperating" should be "separating".

-## Settings Cards With seperating border
+## Settings Cards With separating border
apps/engineering/content/design/components/settings-card.example.tsx (2)

101-107: Typo & Description Clarification
There’s a typo in the title prop and a mismatch in the description:

  • Title: "Square corncers Example""Square corners Example".
  • Description says “default to rounded corners” but the example name emphasizes square edges when no border prop is passed. Please adjust the text to accurately convey the intended behavior.

Proposed fix:

-        title="Square corncers Example"
-        description="Not passing in border prop will default to rounded corners."
+        title="Square corners Example"
+        description="Not passing in the `border` prop will render square edges by default."

15-18: Optional DRY Refactor: Extract Repeated Layout
The wrapper <div className="flex gap-2 items-center justify-center w-full">…</div> is duplicated in all examples. Consider extracting it into a small helper component (e.g., SettingCardActions) to improve readability and maintenance.

Example addition at the top (after your imports):

+import type { FC, ReactNode } from 'react';
+
+// Reusable wrapper for card action controls
+const SettingCardActions: FC<{children: ReactNode}> = ({ children }) => (
+  <div className="flex gap-2 items-center justify-center w-full">{children}</div>
+);

Then replace each block:

-<div className="flex gap-2 items-center justify-center w-full">
-  <Input … />
-  <Button … />
-</div>
+<SettingCardActions>
+  <Input … />
+  <Button … />
+</SettingCardActions>

This reduces markup duplication and centralizes layout tweaks.

Also applies to: 34-37, 72-74, 108-110

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b089583 and e5dc548.

📒 Files selected for processing (20)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/copy-api-id.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/default-bytes.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/default-prefix.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-api.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-protection.tsx (2 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/update-api-name.tsx (1 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/settings/components/update-ip-whitelist.tsx (3 hunks)
  • apps/dashboard/app/(app)/authorization/permissions/[permissionId]/settings-client.tsx (1 hunks)
  • apps/dashboard/app/(app)/authorization/roles/[roleId]/settings-client.tsx (1 hunks)
  • apps/dashboard/app/(app)/ratelimits/[namespaceId]/settings/components/settings-client.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/billing/client.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/billing/components/usage.tsx (1 hunks)
  • apps/dashboard/app/(app)/settings/billing/page.tsx (1 hunks)
  • apps/engineering/content/design/components/inline-link.example.tsx (1 hunks)
  • apps/engineering/content/design/components/inline-link.mdx (1 hunks)
  • apps/engineering/content/design/components/settings-card.example.tsx (1 hunks)
  • apps/engineering/content/design/components/settings-card.mdx (1 hunks)
  • internal/ui/src/components/inline-link.tsx (1 hunks)
  • internal/ui/src/components/settings-card.tsx (1 hunks)
  • internal/ui/src/index.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
apps/dashboard/app/(app)/apis/[apiId]/settings/components/update-ip-whitelist.tsx (2)
internal/ui/src/components/inline-link.tsx (1)
  • InlineLink (32-56)
internal/icons/src/icons/arrow-up-right.tsx (1)
  • ArrowUpRight (15-40)
apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-protection.tsx (2)
internal/ui/src/components/inline-link.tsx (1)
  • InlineLink (32-56)
internal/icons/src/icons/arrow-up-right.tsx (1)
  • ArrowUpRight (15-40)
apps/engineering/content/design/components/inline-link.example.tsx (2)
apps/engineering/app/components/render.tsx (1)
  • RenderComponentWithSnippet (12-67)
internal/ui/src/components/inline-link.tsx (1)
  • InlineLink (32-56)
🔇 Additional comments (28)
apps/dashboard/app/(app)/settings/billing/client.tsx (1)

6-6: Centralized SettingCard import
The import path has been updated to pull SettingCard from the shared @unkey/ui library. This aligns with the PR’s goal of consolidating UI components. Please verify that @unkey/ui exports SettingCard correctly.

apps/dashboard/app/(app)/settings/billing/components/usage.tsx (1)

2-2: Centralized SettingCard import
The import for SettingCard now references @unkey/ui, matching the new library structure. Confirm that the export exists and behaves identically to the previous local component.

apps/dashboard/app/(app)/authorization/permissions/[permissionId]/settings-client.tsx (1)

9-9: Centralized SettingCard import
Updated the import source for SettingCard to the external UI package. Ensure @unkey/ui exports this component without breaking the existing UI contract.

apps/dashboard/app/(app)/apis/[apiId]/settings/components/default-prefix.tsx (1)

7-7: Centralized SettingCard import
The import path for SettingCard has been changed to @unkey/ui, consistent with the rest of the settings components. Verify that no styles or props have been affected by this relocation.

apps/dashboard/app/(app)/apis/[apiId]/settings/components/copy-api-id.tsx (1)

3-3: Centralized SettingCard import
Switching the SettingCard import to the shared UI library is correct. Please confirm that the component renders and functions as before under @unkey/ui.

apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-api.tsx (1)

9-9: SettingCard import updated correctly
The import of SettingCard has been switched to @unkey/ui as intended, aligning with the shared UI library refactor. No changes to functionality are introduced.

apps/dashboard/app/(app)/apis/[apiId]/settings/components/default-bytes.tsx (1)

7-7: SettingCard import updated correctly
Switching SettingCard to be imported from @unkey/ui centralizes the component in the UI library and matches other settings components. Behavior remains unchanged.

apps/dashboard/app/(app)/ratelimits/[namespaceId]/settings/components/settings-client.tsx (1)

8-8: SettingCard import updated correctly
The SettingCard import from @unkey/ui reflects the new shared component path. This is consistent with the refactor and has no impact on existing logic.

apps/dashboard/app/(app)/authorization/roles/[roleId]/settings-client.tsx (1)

8-8: SettingCard import updated correctly
Importing SettingCard from @unkey/ui centralizes this UI element and matches the updated pattern across settings pages. No logic changes here.

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

6-6: SettingCard import updated correctly
Changing the import to @unkey/ui aligns billing settings with the shared UI library approach. Functionality remains the same.

apps/dashboard/app/(app)/apis/[apiId]/settings/components/update-api-name.tsx (1)

8-8: Import migration looks good.

The SettingCard import is now sourced from the centralized @unkey/ui package rather than a local path. This change aligns with the PR's objective of moving UI components to a shared library.

internal/ui/src/components/settings-card.tsx (1)

1-3: Import adjustments follow best practices.

The changes to the React import and the relative path for the cn utility align with Biome linting rules. The explicit comment about why the React import is structured this way is helpful for future maintainers.

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

5-5: Exports properly expose the components.

The inline-link and settings-card components are now correctly exported from the main UI package, making them available to consumers of @unkey/ui.

Also applies to: 11-11

apps/engineering/content/design/components/inline-link.mdx (1)

1-64: Documentation is comprehensive and follows best practices.

The documentation for the InlineLink component is well-structured with:

  • Clear description of purpose and usage
  • Multiple examples demonstrating different configurations
  • Complete props documentation with types and defaults
  • Accessibility considerations

This thorough documentation will help developers understand how to properly use the component.

apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-protection.tsx (2)

8-8: Import consolidation looks good.

Importing both InlineLink and SettingCard from the centralized @unkey/ui package aligns with the PR's objective of standardizing UI components.


159-166: New InlineLink implementation improves code quality.

The new InlineLink component provides a more consistent, accessible, and maintainable approach to inline links with icons. The implementation:

  • Properly opens links in a new tab with security attributes
  • Consistently positions the icon
  • Maintains the same visual style as other links in the application

This change successfully meets the PR objective of introducing the new InlineLink component.

apps/engineering/content/design/components/settings-card.mdx (1)

1-55: Well-structured documentation!

The documentation is comprehensive and follows a clear structure with examples, features, and props section. Good job providing full details of the component's capabilities.

internal/ui/src/components/inline-link.tsx (2)

5-31: Well-documented props with JSDoc comments.

The component's props are thoroughly documented with clear JSDoc comments that explain the purpose of each prop. This is excellent practice that improves code maintainability.


32-56: Accessible component implementation.

Good implementation with proper accessibility considerations:

  • Icon is marked with aria-hidden="true" to indicate it's decorative
  • Security attributes (rel="noopener noreferrer") when opening links in new tabs
  • Proper conditional rendering based on icon position

The component follows best practices for building accessible UI elements.

apps/dashboard/app/(app)/apis/[apiId]/settings/components/update-ip-whitelist.tsx (4)

9-9: Clean import refactoring.

The import has been refactored to use the UI components from the shared @unkey/ui package, aligning with the PR objective of moving the SettingsCard component.


83-89: Good UX enhancement with inline documentation link.

Adding the InlineLink component with the "Learn more" text and external link icon improves the user experience by providing contextual access to documentation without cluttering the interface.


93-93: Simplified content width property.

The contentWidth property has been simplified to use a standard width class instead of responsive constraints. This change should make the component more consistent with other instances.


127-133: UI streamlining for disabled state.

The disabled state UI has been streamlined by removing unnecessary width classes and the separate "Learn more" ghost button, resulting in a cleaner interface that aligns with the design system.

apps/engineering/content/design/components/inline-link.example.tsx (1)

1-66: Comprehensive examples covering all component variations.

These examples effectively demonstrate the various ways the InlineLink component can be used:

  • Basic usage within text
  • Icon placement options (left/right)
  • External link behavior
  • Custom styling

Each example is properly isolated and clearly shows a single feature, making it easy for other developers to understand how to use the component.

apps/engineering/content/design/components/settings-card.example.tsx (4)

1-4: Imports & Client Directive Look Good
The "use client" directive ensures this example runs in the browser for interactive components, and all import paths (RenderComponentWithSnippet, Clone, Button, Input, SettingCard) appear correct and consistent with your project’s conventions.


6-22: Basic Example Demonstrates border="both" Correctly
The SettingsCardBasic component cleanly shows how to use border="both", contentWidth, and children layout inside RenderComponentWithSnippet. This is clear and easy to follow.


24-59: Shared-Edge Example Usage Is Accurate
SettingsCardsWithSharedEdge correctly stacks two cards with only top and bottom borders. The sequence of border="top" and border="bottom" props illustrates the shared-edge pattern clearly.


61-97: Divider Example Correctly Uses className="border-b"
SettingsCardsWithDivider shows an explicit bottom border on the first card via className="border-b". This approach effectively demonstrates how to insert a visual divider between cards.

@ogzhanolguncu ogzhanolguncu self-assigned this Apr 28, 2025
Copy link
Contributor

@ogzhanolguncu ogzhanolguncu left a comment

Choose a reason for hiding this comment

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

  • Docs look good
  • Permission and roles pages look good
  • Inline links looking good

@MichaelUnkey MichaelUnkey added this pull request to the merge queue Apr 28, 2025
Merged via the queue into main with commit 6284d83 Apr 28, 2025
33 of 39 checks passed
@MichaelUnkey MichaelUnkey deleted the move-settings-card-to-unkey-ui branch April 28, 2025 13:53
@coderabbitai coderabbitai bot mentioned this pull request Apr 28, 2025
18 tasks
@coderabbitai coderabbitai bot mentioned this pull request Jun 4, 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.

2 participants