Skip to content

fix(www): add missing langs to analytics bento#2214

Merged
chronark merged 7 commits intounkeyed:mainfrom
unrenamed:fix/missing-langs-in-analytics-bento
Oct 5, 2024
Merged

fix(www): add missing langs to analytics bento#2214
chronark merged 7 commits intounkeyed:mainfrom
unrenamed:fix/missing-langs-in-analytics-bento

Conversation

@unrenamed
Copy link
Contributor

@unrenamed unrenamed commented Oct 5, 2024

What does this PR do?

Enhances the landing page realtime analytics component by adding missing programming languages and SDKs along with code snippets, showcasing examples of all SDKs that support the key retrieval API (https://www.unkey.com/docs/api-reference/keys/get).

Also:

  • fixes cURL example
  • moves repeated languages SVGs to separate file
  • moves repeated code editor component to separate file
  • creates a new reusable (in 2 places so far) button component for copying code snippets

Fixes #2190

image

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?

  • Test A
    • Open the landing page.
    • Scroll down to the first code editor with language tabs and API variants in the menu.
    • Verify that the code editor displays the snippets and that the copy button functions correctly.
  • Test B
    • Open the landing page.
    • Scroll down to the second code editor located under the "Show API code" button and click it.
    • Confirm that five languages are now visible in the left menu: cURL, TypeScript, Rust, Golang, and Python.
    • Ensure that all menu items are clickable. When a language is selected, the code snippet should update in the editor.
    • Verify that each language displays the corresponding code snippet.
    • Check that the code snippets contain working and up-to-date SDK code.
    • Ensure that the copy button functions correctly.

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 ⚠️ I ran, but it formatted 1130 files 🤯 . I reverted, since it's not the goal of this PR
  • Checked for warnings, there are none ⚠️ No new warnings 😅
  • 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

Release Notes

  • New Features

    • Introduced a CodeEditor component for displaying syntax-highlighted code snippets.
    • Added a CopyCodeSnippetButton for easy copying of code examples to the clipboard.
    • Enhanced code examples with new language icons for Java, Elixir, Rust, Curl, Python, TypeScript, and Go.
  • Improvements

    • Updated the analytics component to include a LanguageSwitcher for selecting programming languages.
    • Streamlined the presentation of code examples, improving user interaction and experience.
  • Bug Fixes

    • Removed deprecated components to enhance performance and maintainability.

Also, add a copy button to the code editor for one-click code copying, removing the need for manual selection.
Also, rename and move <Editor /> components to components/ui folder.
@changeset-bot
Copy link

changeset-bot bot commented Oct 5, 2024

⚠️ No Changeset found

Latest commit: 204f090

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 Oct 5, 2024

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

Name Status Preview Comments Updated (UTC)
dashboard ❌ Failed (Inspect) Oct 5, 2024 7:10pm
engineering ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 5, 2024 7:10pm
play ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 5, 2024 7:10pm
workflows ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 5, 2024 7:10pm
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 5, 2024 7:10pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 5, 2024

Caution

Review failed

The pull request is closed.

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in this pull request primarily enhance the functionality and presentation of code examples across various programming languages in the application. Key modifications include the introduction of new language icon components, the replacement of the existing code editor with a new CodeEditor component, and the addition of a CopyCodeSnippetButton for improved user interaction. The structure of the code has been updated to utilize new types for icons and languages, promoting better modularity and maintainability.

Changes

File Path Change Summary
apps/www/app/code-examples.tsx Updated imports for new language icons and components; replaced IconProps with LangIconProps; modified languagesList and languages array; replaced Editor with CodeEditor; added CopyCodeSnippetButton.
apps/www/components/analytics/analytics-bento.tsx Removed Highlight component; added new imports for language icons and components; modified theme to a regular constant; added Language type and languagesList; removed codeBlock variable; added LanguageSwitcher.
apps/www/components/svg/lang-icons.tsx Introduced new components for language icons (JavaIcon, ElixirIcon, RustIcon, CurlIcon, PythonIcon, TSIcon, GoIcon) with active prop for visual state management.
apps/www/components/ui/code-editor.tsx Added new CodeEditor component that utilizes Highlight for syntax highlighting of code snippets.
apps/www/components/ui/copy-code-button.tsx Introduced CopyCodeSnippetButton component for copying code snippets to clipboard, including visual feedback for the copy action.

Assessment against linked issues

Objective Addressed Explanation
Showcase examples of all SDKs for the API code button (#2190)

Possibly related PRs

Suggested labels

Feature

Suggested reviewers

  • mcstepp
  • chronark
  • perkinsjr
  • MichaelUnkey

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 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 Oct 5, 2024

@unrenamed is attempting to deploy a commit to the Unkey Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 5, 2024

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

@github-actions github-actions bot added 🕹️ 150 points Bug Something isn't working labels Oct 5, 2024
@vercel vercel bot temporarily deployed to Preview – engineering October 5, 2024 17:02 Inactive
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: 7

🧹 Outside diff range and nitpick comments (12)
apps/www/components/ui/copy-code-button.tsx (3)

8-27: LGTM: Well-implemented component with room for minor enhancements.

The CopyCodeSnippetButton component is well-structured and implements the copy functionality correctly. It's accessible and reusable. However, consider the following improvements:

  1. Add error handling for clipboard operations:
onClick={() => {
  navigator.clipboard.writeText(props.textToCopy).then(
    () => {
      setCopied(true);
      setTimeout(() => setCopied(false), 2000);
    },
    (err) => console.error('Failed to copy text: ', err)
  );
}}
  1. Make the timeout duration configurable:
type Props = {
  textToCopy: string;
  className?: string;
  copyDuration?: number;
};

// In the component
const copyDuration = props.copyDuration ?? 2000;
setTimeout(() => setCopied(false), copyDuration);

These changes will improve error handling and component flexibility.


29-50: LGTM: Well-structured SVG component with potential for enhanced reusability.

The CheckmarkCircle component is well-implemented. To improve its reusability, consider accepting props for customization:

type CheckmarkCircleProps = {
  size?: number;
  circleColor?: string;
  checkColor?: string;
};

function CheckmarkCircle({ size = 52, circleColor = "currentColor", checkColor = "currentColor" }: CheckmarkCircleProps) {
  return (
    <svg
      className="checkmark"
      xmlns="http://www.w3.org/2000/svg"
      width={size}
      height={size}
      viewBox="0 0 52 52"
    >
      <circle
        className="checkmark__circle"
        cx="26"
        cy="26"
        r="25"
        fill="none"
        stroke={circleColor}
      />
      <path
        className="checkmark__check"
        fill="none"
        stroke={checkColor}
        d="M14.1 27.2l7.1 7.2 16.7-16.8"
      />
    </svg>
  );
}

This change allows for easy customization of the icon's size and colors.


52-84: LGTM: Well-implemented SVG icon with room for enhanced reusability.

The CopyIcon component is well-structured but could benefit from increased flexibility. Consider the following improvements:

  1. Accept props for customization:
type CopyIconProps = {
  size?: number;
  gradientColors?: [string, string];
};

function CopyIcon({ size = 24, gradientColors = ["white", "white"] }: CopyIconProps) {
  // Use size and gradientColors in the SVG
}
  1. Use CSS variables for colors to allow easier theming:
<linearGradient id="paint0_linear_840_3800" ...>
  <stop stopColor="var(--copy-icon-start-color, white)" stopOpacity="0.4" />
  <stop offset="1" stopColor="var(--copy-icon-end-color, white)" />
</linearGradient>
  1. Consider extracting the complex path to a separate constant for improved readability:
const COPY_ICON_PATH = "M13 5.00002C13.4886 5.00002 13.6599...";

function CopyIcon({ size = 24 }: CopyIconProps) {
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" ...>
      <path d={COPY_ICON_PATH} ... />
      {/* ... */}
    </svg>
  );
}

These changes will enhance the component's reusability and maintainability.

apps/www/components/svg/lang-icons.tsx (8)

5-26: LGTM with a suggestion for accessibility

The JavaIcon component is well-structured and correctly implements the active prop for styling. The use of SVG ensures scalability.

Consider adding an aria-label attribute to the SVG for better accessibility:

 <svg
   width="24"
   height="24"
   viewBox="0 0 24 24"
   fill="none"
   xmlns="http://www.w3.org/2000/svg"
+  aria-label="Java icon"
 >

This change would improve screen reader support for the icon.


28-44: LGTM with a suggestion for consistency

The ElixirIcon component is well-implemented and consistent with the JavaIcon. For improved accessibility and consistency across all icon components, consider adding an aria-label:

 <svg
   width="24"
   height="24"
   viewBox="0 0 24 24"
   fill="none"
   xmlns="http://www.w3.org/2000/svg"
+  aria-label="Elixir icon"
 >

This change would ensure all icon components have consistent accessibility features.


46-67: LGTM with a suggestion for consistency

The RustIcon component is well-implemented and consistent with the other icon components. It appropriately uses multiple paths for the more complex Rust logo. For improved accessibility and consistency, add an aria-label:

 <svg
   width="24"
   height="24"
   viewBox="0 0 24 24"
   fill="none"
   xmlns="http://www.w3.org/2000/svg"
+  aria-label="Rust icon"
 >

This change ensures all icon components have consistent accessibility features.


69-101: LGTM with a suggestion for consistency

The CurlIcon component is well-implemented and consistent with the other icon components. It appropriately uses multiple paths for the cURL logo. For improved accessibility and consistency, add an aria-label:

 <svg
   width="24"
   height="24"
   viewBox="0 0 24 24"
   fill="none"
   xmlns="http://www.w3.org/2000/svg"
+  aria-label="cURL icon"
 >

This change ensures all icon components have consistent accessibility features.


103-132: LGTM with a suggestion for consistency

The PythonIcon component is well-implemented and consistent with the other icon components. It appropriately uses a single complex path for the Python logo. For improved accessibility and consistency, add an aria-label:

 <svg
   width="24"
   height="24"
   viewBox="0 0 24 24"
   fill="none"
   xmlns="http://www.w3.org/2000/svg"
+  aria-label="Python icon"
 >

This change ensures all icon components have consistent accessibility features.


134-159: LGTM with a suggestion for consistency

The TSIcon component is well-implemented and consistent with the other icon components. It appropriately uses multiple paths for the TypeScript logo. For improved accessibility and consistency, add an aria-label:

 <svg
   width="24"
   height="24"
   viewBox="0 0 24 24"
   fill="none"
   xmlns="http://www.w3.org/2000/svg"
+  aria-label="TypeScript icon"
 >

This change ensures all icon components have consistent accessibility features.


161-177: LGTM with a suggestion for consistency

The GoIcon component is well-implemented and consistent with the other icon components. It appropriately uses a single complex path for the Go logo. For improved accessibility and consistency, add an aria-label:

 <svg
   width="24"
   height="24"
   viewBox="0 0 24 24"
   fill="none"
   xmlns="http://www.w3.org/2000/svg"
+  aria-label="Go icon"
 >

This change ensures all icon components have consistent accessibility features.


1-177: Well-structured file with room for minor improvements

Overall, this file is well-organized and consistently implements icon components for various programming languages. The use of SVG and the active prop for styling is commendable. To further improve the code:

  1. Add aria-label attributes to all SVG elements for better accessibility, as suggested in previous comments.

  2. Consider refactoring to reduce code duplication:

interface IconProps extends LangIconProps {
  paths: string[];
  label: string;
}

const IconWrapper: React.FC<IconProps> = ({ active, paths, label }) => (
  <svg
    width="24"
    height="24"
    viewBox="0 0 24 24"
    fill="none"
    xmlns="http://www.w3.org/2000/svg"
    aria-label={label}
  >
    <g opacity={active ? 1 : 0.3}>
      {paths.map((path, index) => (
        <path
          key={index}
          d={path}
          fill={active ? "url(#paint0_linear_574_1420)" : "white"}
        />
      ))}
    </g>
  </svg>
);

export const JavaIcon: React.FC<LangIconProps> = (props) => (
  <IconWrapper
    {...props}
    label="Java icon"
    paths={[
      "M8.02611 17.8886C7.85846 17.7748 7.69538 17.6535 7.53739 17.5251C7.50312 17.4972 7.46909 17.4691 7.4353 17.4405L7.17192 17.2061C7.08767 17.1283 7.00541 17.0486 6.92519 16.9669C6.84616 16.8865 6.76911 16.8043 6.69411 16.7203C6.21543 16.1844 5.81995 15.5778 5.52221 14.9207C5.13048 14.0561 4.91594 13.1216 4.89129 12.1726C4.86663 11.2235 5.03237 10.2791 5.37868 9.39533C5.725 8.51153 6.24486 7.70625 6.90751 7.02714C7.57015 6.34803 8.36212 5.80889 9.23656 5.44161C10.111 5.07434 11.0501 4.8864 11.9984 4.88891C12.9466 4.89142 13.8848 5.08434 14.7572 5.45623C15.3549 5.71098 15.9134 6.04616 16.4178 6.45143C16.6497 6.63782 16.8703 6.83903 17.0779 7.05407C17.1382 6.97357 17.1964 6.89165 17.2527 6.80841C17.3666 6.63979 17.4721 6.46571 17.5688 6.28681C17.6682 6.10305 17.7583 5.9142 17.8388 5.72097C17.975 6.137 18.1031 6.54279 18.2216 6.93812C18.8792 9.13202 19.2414 11.004 19.0679 12.5183C18.9759 13.8241 18.5247 15.0789 17.7643 16.1438C17.0039 17.2087 15.9639 18.042 14.7596 18.5516C13.5552 19.0612 12.2335 19.2272 10.9408 19.0311C9.89323 18.8722 8.89784 18.4805 8.02611 17.8886ZM19.9532 12.6001C19.8466 14.0624 19.3396 15.4672 18.4877 16.6603C17.6319 17.8587 16.4615 18.7967 15.106 19.3703C13.7504 19.9439 12.2626 20.1307 10.8075 19.9099C9.35233 19.6892 7.98672 19.0695 6.86184 18.1197L6.853 18.1122L6.57487 17.8647L6.56885 17.8591C5.7845 17.1348 5.15331 16.2603 4.71255 15.2875C4.2718 14.3148 4.03043 13.2634 4.0027 12.1957C3.97496 11.1279 4.16142 10.0654 4.55106 9.07103C4.94071 8.07665 5.52564 7.17054 6.2713 6.40636C7.01697 5.64217 7.90822 5.03542 8.89234 4.62208C9.87647 4.20873 10.9335 3.9972 12.0007 4.00003C13.068 4.00285 14.1239 4.21998 15.1058 4.63853C15.7413 4.9094 16.88 5.68372 16.88 5.68372C16.88 5.68372 17.7524 4.53779 18.2216 3.99999L18.6835 5.44426C19.5714 8.15493 20.1764 10.6022 19.9532 12.6001Z",
      "M17.8388 5.72097C17.6413 6.19518 17.3857 6.64298 17.0779 7.05407C16.4188 6.37146 15.6297 5.82813 14.7572 5.45623C13.8848 5.08434 12.9466 4.89142 11.9984 4.88891C11.0501 4.8864 10.111 5.07434 9.23656 5.44161C8.36212 5.80889 7.57015 6.34803 6.90751 7.02714C6.24486 7.70625 5.725 8.51153 5.37868 9.39533C5.03237 10.2791 4.86663 11.2235 4.89129 12.1726C4.91594 13.1216 5.13048 14.0561 5.52221 14.9207C5.91395 15.7853 6.47491 16.5624 7.17192 17.2061L7.4353 17.4405C8.43478 18.2845 9.64807 18.835 10.9408 19.0311C12.2335 19.2272 13.5552 19.0612 14.7596 18.5516C15.9639 18.042 17.0039 17.2087 17.7643 16.1438C18.5247 15.0789 18.9759 13.8241 19.0679 12.5183C19.2727 10.7311 18.7313 8.44577 17.8388 5.72097ZM8.19617 17.2647C8.12094 17.3573 8.01999 17.4254 7.90608 17.4606C7.79217 17.4957 7.67042 17.4963 7.5562 17.4621C7.44199 17.428 7.34044 17.3608 7.26439 17.2689C7.18834 17.177 7.1412 17.0646 7.12894 16.9459C7.11667 16.8272 7.13983 16.7075 7.19548 16.602C7.25113 16.4965 7.33678 16.4098 7.4416 16.353C7.54642 16.2962 7.66571 16.2718 7.78439 16.2828C7.90307 16.2939 8.01582 16.3399 8.10838 16.4151C8.22972 16.518 8.30662 16.6639 8.32298 16.8222C8.33935 16.9806 8.29391 17.1391 8.19617 17.2647ZM17.7949 15.1406C16.0536 17.4698 12.3078 16.6788 9.92277 16.7959C9.92277 16.7959 9.49843 16.8252 9.0741 16.8838C9.0741 16.8838 9.23505 16.8106 9.4399 16.7374C11.1226 16.1514 11.9127 16.0342 12.937 15.5068C14.8538 14.5253 16.7706 12.3718 17.151 10.1451C16.4194 12.2839 14.1954 14.1297 12.1761 14.8769C10.7861 15.3896 8.28397 15.8877 8.28397 15.8877L8.18154 15.8291C6.48421 14.9941 6.42568 11.3024 9.5277 10.1158C10.8885 9.58842 12.1761 9.88141 13.654 9.52982C15.2196 9.16359 17.034 7.99163 17.7656 6.45344C18.585 8.9292 19.58 12.7674 17.7949 15.1406Z"
    ]}
  />
);

// Repeat for other icons...

This refactoring would significantly reduce code duplication and make it easier to add new icons in the future.

apps/www/app/code-examples.tsx (1)

600-602: Consider displaying the 'CopyCodeSnippetButton' on all screen sizes.

Currently, the CopyCodeSnippetButton is hidden on smaller screens due to the hidden lg:flex class names. If users on smaller devices would benefit from this feature, consider making the button visible across all screen sizes by adjusting the class names.

Apply this diff to adjust the class names:

<CopyCodeSnippetButton
  textToCopy={getCodeBlock({ language, framework })} 
-  className="absolute hidden cursor-pointer top-5 right-5 lg:flex" />
+  className="absolute cursor-pointer top-5 right-5" />
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2288ebf and 2bdcaa2.

📒 Files selected for processing (5)
  • apps/www/app/code-examples.tsx (4 hunks)
  • apps/www/components/analytics/analytics-bento.tsx (5 hunks)
  • apps/www/components/svg/lang-icons.tsx (1 hunks)
  • apps/www/components/ui/code-editor.tsx (1 hunks)
  • apps/www/components/ui/copy-code-button.tsx (1 hunks)
🧰 Additional context used
🪛 Biome
apps/www/app/code-examples.tsx

[error] 3-4: Some named imports are only used as types.

This import is only used as a type.

Importing the types with import type ensures that they are removed by the transpilers and avoids loading unnecessary modules.
Safe fix: Use import type.

(lint/style/useImportType)

apps/www/components/analytics/analytics-bento.tsx

[error] 9-10: Some named imports are only used as types.

This import is only used as a type.

Importing the types with import type ensures that they are removed by the transpilers and avoids loading unnecessary modules.
Safe fix: Use import type.

(lint/style/useImportType)

🔇 Additional comments (4)
apps/www/components/ui/copy-code-button.tsx (2)

1-6: LGTM: Imports and type definition are well-structured.

The import statement and Props type definition are correct and follow best practices. The Props type provides good type safety for the component.


1-84: Summary: Well-implemented component that aligns with PR objectives.

The CopyCodeSnippetButton component successfully addresses the PR objective of creating a reusable button for copying code snippets. It provides a good user experience with visual feedback and is generally well-implemented.

The suggested improvements focus on:

  1. Error handling for clipboard operations
  2. Configurable timeout duration
  3. Enhanced reusability of SVG components
  4. Improved maintainability of complex SVG paths

These enhancements will make the component more robust, flexible, and easier to maintain, further improving its alignment with the PR's goals of enhancing the landing page's functionality.

apps/www/components/svg/lang-icons.tsx (1)

1-3: LGTM: Clear and concise type definition

The LangIconProps type is well-defined with a single boolean prop active. This type will be used consistently across all icon components, ensuring type safety.

apps/www/components/ui/code-editor.tsx (1)

22-22: ⚠️ Potential issue

Avoid using array index as part of the key

Using the array index i in keys can lead to issues if the list items change order. Consider using a unique property from line instead.

You can modify the key as follows:

-  <div key={`${line}-${i}`} {...getLineProps({ line })}>
+  <div key={line.toString()} {...getLineProps({ line })}>

Likely invalid or redundant comment.

@vercel vercel bot temporarily deployed to Preview – engineering October 5, 2024 17:11 Inactive
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

🧹 Outside diff range and nitpick comments (1)
apps/www/app/code-examples.tsx (1)

626-633: Enhanced code display and user interaction.

The replacement of the Editor component with CodeEditor and CopyCodeSnippetButton is a positive change that should improve the user experience. The CodeEditor likely provides better syntax highlighting and code display, while the CopyCodeSnippetButton adds a convenient way for users to copy code snippets.

However, there's a potential issue with the positioning of the CopyCodeSnippetButton:

<CopyCodeSnippetButton
  textToCopy={getCodeBlock({ language, framework })} 
  className="absolute hidden cursor-pointer top-5 right-5 lg:flex" />

The button is hidden on smaller screens and only displayed on large (lg) screens. Consider making it visible on smaller screens as well, perhaps by adjusting its position or using a more responsive layout approach.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2bdcaa2 and fef6426.

📒 Files selected for processing (1)
  • apps/www/app/code-examples.tsx (4 hunks)
🧰 Additional context used
🪛 Biome
apps/www/app/code-examples.tsx

[error] 3-4: Some named imports are only used as types.

This import is only used as a type.

Importing the types with import type ensures that they are removed by the transpilers and avoids loading unnecessary modules.
Safe fix: Use import type.

(lint/style/useImportType)

🔇 Additional comments (3)
apps/www/app/code-examples.tsx (3)

4-6: Improved component organization and functionality.

The changes to the imports suggest a positive refactoring:

  1. Language icons are now imported from a centralized location.
  2. New CodeEditor and CopyCodeSnippetButton components have been introduced, likely improving the code display and user interaction.

These changes should enhance maintainability and user experience.


372-372: Type definitions updated for consistency.

The Framework and LanguagesList type definitions have been updated to use LangIconProps instead of IconProps. This change ensures type consistency with the imported language icons.

Also applies to: 513-513


Line range hint 1-683: Summary: Improved code example display aligns with PR objectives.

The changes in this file successfully address the PR objectives and the linked issue #2190:

  1. The introduction of the CodeEditor and CopyCodeSnippetButton components enhances the display of code examples and allows for easy copying of snippets.
  2. The language and framework selection mechanism remains intact, allowing users to view examples for all supported SDKs.
  3. Type definitions have been updated for consistency with the new components.

These improvements directly contribute to a better user experience on the landing page and address the need to showcase examples for all supported SDKs.

To further enhance the implementation:

  1. Consider making the CopyCodeSnippetButton visible on smaller screens for better mobile responsiveness.
  2. Ensure that all language options are clickable and display the correct code snippets as mentioned in the testing instructions.

Overall, these changes successfully meet the objectives of the pull request.

@chronark
Copy link
Collaborator

chronark commented Oct 5, 2024

hey @unrenamed, I just filed an issue for the readabilty due to the shadow and length of code. You don't have to fix that in this PR

@vercel vercel bot temporarily deployed to Preview – engineering October 5, 2024 17:50 Inactive
@vercel vercel bot temporarily deployed to Preview – engineering October 5, 2024 17:52 Inactive
@unrenamed
Copy link
Contributor Author

@chronark Feel free to review the code. I applied coderabbitai comments and synced the branch with the latest main

Copy link
Collaborator

@chronark chronark left a comment

Choose a reason for hiding this comment

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

Great job @unrenamed !

@vercel vercel bot temporarily deployed to Preview – play October 5, 2024 19:03 Inactive
@chronark chronark enabled auto-merge October 5, 2024 19:03
@vercel vercel bot temporarily deployed to Preview – engineering October 5, 2024 19:04 Inactive
@chronark chronark disabled auto-merge October 5, 2024 19:05
@chronark chronark merged commit 34a1533 into unkeyed:main Oct 5, 2024
@oss-gg
Copy link

oss-gg bot commented Oct 5, 2024

Awarding unrenamed: 150 points 🕹️ Well done! Check out your new contribution on oss.gg/unrenamed

@vercel vercel bot temporarily deployed to Preview – play October 5, 2024 19:05 Inactive
@vercel vercel bot temporarily deployed to Preview – workflows October 5, 2024 19:08 Inactive
@vercel vercel bot temporarily deployed to Preview – www October 5, 2024 19:09 Inactive
@vercel vercel bot temporarily deployed to Preview – dashboard October 5, 2024 19:10 Inactive
@unrenamed
Copy link
Contributor Author

@chronark I noticed I received 150 points for this PR, but since I implemented the fixes for multiple languages (curl, Go, TypeScript, Python, etc.), I wanted to check if the points should cover each language as you mentioned in the comments. Could you clarify?

#2190 (comment)

@chronark
Copy link
Collaborator

chronark commented Oct 5, 2024

Ah you're right, my bad
can you create a small issue linking to this comment, then I can award points for that and it's the same in the end

@unrenamed
Copy link
Contributor Author

I'll create the issue and link it. Appreciate it!

harshsbhat pushed a commit to harshsbhat/unkey that referenced this pull request Oct 6, 2024
* fix(www): add missing langs to analytics bento

Also, add a copy button to the code editor for one-click code copying, removing the need for manual selection.

* refactor(www): extract langs SVG icons into separate file

Also, rename and move <Editor /> components to components/ui folder.

* refactor(www): extract copy code snippet button to separate file

* refactor(www): apply coderabbitai review comments

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
chronark added a commit that referenced this pull request Oct 7, 2024
* wip: Who Am I route

* Resolved changes

* 2 tests one still remaining

* fix(www): add missing langs to analytics bento (#2214)

* fix(www): add missing langs to analytics bento

Also, add a copy button to the code editor for one-click code copying, removing the need for manual selection.

* refactor(www): extract langs SVG icons into separate file

Also, rename and move <Editor /> components to components/ui folder.

* refactor(www): extract copy code snippet button to separate file

* refactor(www): apply coderabbitai review comments

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

* fix: create bucket if it doesn't exist

* fix: revalidate cache

* docs: fix typo and remove the weird line (#2223)

* docs: correct spelling of EXPRED to EXPIRED (#2228)

* Added third happy test

* chore: add docs, changesets, fix path

* Update apps/docs/api-reference/keys/whoami.mdx

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: Nazar Poshtarenko <32395926+unrenamed@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: chronark <dev@chronark.com>
Co-authored-by: Anne Deepa Prasanna <anneraj73@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@coderabbitai coderabbitai bot mentioned this pull request Nov 8, 2024
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🕹️] Show API code button only shows curl and not the other sdks

2 participants