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

feat: remove old css stuff and use @unkey/ui #2737

Merged
merged 2 commits into from
Dec 11, 2024
Merged

feat: remove old css stuff and use @unkey/ui #2737

merged 2 commits into from
Dec 11, 2024

Conversation

chronark
Copy link
Collaborator

@chronark chronark commented Dec 10, 2024

@ogzhanolguncu this starts using @unkey/ui components (only button for now as proof of concept) in the dashboard
it's mostly about ensuring the tailwind stuff works correctly and we have access to the components and colors

In followup PRs, we need to remove the old colors over time.

I also cleaned up a lot of orphaned css and font stuff that we no longer used

Summary by CodeRabbit

  • New Features

    • Introduced a new refresh prop in the ShinyCardGroup component for dynamic reinitialization of container dimensions.
    • Enhanced mouse tracking functionality in the ShinyCardGroup for improved interactivity.
  • Bug Fixes

    • Improved error handling and clarity in the pythonCodeBlock of the AnalyticsBento component.
  • Style

    • Simplified button styling and structure across various components.
    • Updated font management in the application to streamline typography.
  • Chores

    • Removed obsolete CSS files related to Tailwind styles, focusing on a more modular approach.
    • Updated dependencies to include a new UI library for buttons.

Copy link

vercel bot commented Dec 10, 2024

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 Dec 10, 2024 9:43pm
engineering ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 10, 2024 9:43pm
play ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 10, 2024 9:43pm
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 10, 2024 9:43pm

Copy link

changeset-bot bot commented Dec 10, 2024

⚠️ No Changeset found

Latest commit: 63f6717

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

Copy link
Contributor

coderabbitai bot commented Dec 10, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

This pull request introduces significant changes across several files in the dashboard application. Key modifications include the transition of button components to a new library, @unkey/ui, affecting their styling and usage. Additionally, font management is streamlined by replacing previous font imports with GeistMono and GeistSans. Several CSS files are deleted, leading to a restructuring of the Tailwind CSS setup, which now utilizes a more modular approach. Overall, the changes reflect a shift towards a more unified and simplified design system.

Changes

File Path Change Summary
apps/dashboard/app/(app)/apis/client.tsx Updated Button import to @unkey/ui, modified usage in ApiList, simplified CreateApiButton.
apps/dashboard/app/(app)/apis/create-api-button.tsx Changed Button import to @unkey/ui, updated variant prop, simplified button structure.
apps/dashboard/app/layout.tsx Replaced font imports with GeistMono and GeistSans, updated class names in RootLayout.
apps/dashboard/package.json Added dependency "geist": "^1.3.1".
apps/dashboard/styles/tailwind/base.css Deleted file containing foundational CSS styles and custom properties.
apps/dashboard/styles/tailwind/components.css Deleted file that imported Tailwind component styles.
apps/dashboard/styles/tailwind/tailwind.css Restructured to use Tailwind's utility-first approach, added new CSS variables.
apps/dashboard/styles/tailwind/typography.css Deleted file containing typography styles.
apps/dashboard/styles/tailwind/utilities.css Deleted file that imported Tailwind utilities.
apps/dashboard/tailwind.config.js Updated import source for default theme, modified theme configuration to centralize definitions.
apps/www/components/analytics/analytics-bento.tsx Adjusted pythonCodeBlock for clarity, minor changes in BentoText styling.
apps/www/components/shiny-card.tsx Added refresh prop to ShinyCardGroup, updated mouse position handling.

Possibly related PRs

Suggested labels

Feature, Dashboard, 🕹️ oss.gg, :joystick: 300 points, hacktoberfest

Suggested reviewers

  • mcstepp
  • perkinsjr
  • MichaelUnkey
  • chronark

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6419b53 and 63f6717.

📒 Files selected for processing (1)
  • apps/dashboard/tailwind.config.js (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/dashboard/tailwind.config.js

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. (Experiment)
  • @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

github-actions bot commented Dec 10, 2024

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

🧹 Outside diff range and nitpick comments (4)
apps/dashboard/app/(app)/apis/client.tsx (1)

90-93: Specify variant prop for the Button component

The Button component used in the "Read the docs" link does not have a variant prop specified. For consistency and to ensure the button displays with the correct styling, consider adding the variant prop.

Here's how you can update it:

                <Link href="/docs" target="_blank">
-                  <Button>
+                  <Button variant="secondary">
                    <BookOpen />
                    Read the docs
                  </Button>
                </Link>

Choose the appropriate variant ("primary", "secondary", etc.) based on your design guidelines.

apps/dashboard/tailwind.config.js (2)

4-4: Consider moving more theme settings to @unkey/ui

The import of defaultTheme from @unkey/ui is good, but as noted in the comment, consider moving more theme settings (colors, font sizes) to @unkey/ui for better maintainability and consistency.

Also applies to: 15-19


Line range hint 149-164: Consider enhancing the merge function

While the merge function works, consider these improvements:

  1. Add type safety using TypeScript
  2. Handle arrays more explicitly
  3. Add protection against circular references
-export function merge(obj1, obj2) {
+export function merge<T extends Record<string, any>>(obj1: T, obj2: T): T {
+  // Prevent circular references
+  const seen = new WeakSet();
+
   for (const key in obj2) {
-    // biome-ignore lint/suspicious/noPrototypeBuiltins: don't tell me what to do
-    if (obj2.hasOwnProperty(key)) {
+    if (Object.prototype.hasOwnProperty.call(obj2, key)) {
       if (typeof obj2[key] === "object" && !Array.isArray(obj2[key])) {
+        if (seen.has(obj2[key])) {
+          continue; // Skip circular reference
+        }
+        seen.add(obj2[key]);
         if (!obj1[key]) {
           obj1[key] = {};
         }
         obj1[key] = merge(obj1[key], obj2[key]);
       } else {
         obj1[key] = obj2[key];
       }
     }
   }
   return obj1;
 }
apps/www/components/analytics/analytics-bento.tsx (1)

Line range hint 704-755: Consider extracting the API key display component

There's duplication in the API key display UI between the header and details section. Consider extracting this into a reusable component.

type ApiKeyDisplayProps = {
  apiKey: string;
  className?: string;
};

function ApiKeyDisplay({ apiKey, className }: ApiKeyDisplayProps) {
  return (
    <div className={cn("flex items-center gap-2 px-2 py-1 font-mono text-xs rounded-lg bg-white/5 font-sm text-white/40", className)}>
      {apiKey}
      <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
        {/* ... copy icon path ... */}
      </svg>
    </div>
  );
}

Usage:

- <div className="flex items-center gap-2 px-3 py-1 font-mono text-xs rounded-lg bg-white/5 font-sm text-white/40">
-   api_UNWrXjYp6AF2h7Nx
-   <svg>...</svg>
- </div>
+ <ApiKeyDisplay apiKey="api_UNWrXjYp6AF2h7Nx" className="px-3" />
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b395e0f and 6419b53.

⛔ Files ignored due to path filters (6)
  • apps/dashboard/public/fonts/PangeaAfrikanTrial-Medium.woff2 is excluded by !**/*.woff2
  • apps/dashboard/styles/Satoshi-Bold.ttf is excluded by !**/*.ttf
  • apps/dashboard/styles/fonts/CalSans-SemiBold.ttf is excluded by !**/*.ttf
  • apps/dashboard/styles/fonts/CalSans-SemiBold.woff2 is excluded by !**/*.woff2
  • apps/dashboard/styles/fonts/Mona-Sans.var.woff2 is excluded by !**/*.woff2
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (12)
  • apps/dashboard/app/(app)/apis/client.tsx (2 hunks)
  • apps/dashboard/app/(app)/apis/create-api-button.tsx (3 hunks)
  • apps/dashboard/app/layout.tsx (2 hunks)
  • apps/dashboard/package.json (1 hunks)
  • apps/dashboard/styles/tailwind/base.css (0 hunks)
  • apps/dashboard/styles/tailwind/components.css (0 hunks)
  • apps/dashboard/styles/tailwind/tailwind.css (1 hunks)
  • apps/dashboard/styles/tailwind/typography.css (0 hunks)
  • apps/dashboard/styles/tailwind/utilities.css (0 hunks)
  • apps/dashboard/tailwind.config.js (4 hunks)
  • apps/www/components/analytics/analytics-bento.tsx (4 hunks)
  • apps/www/components/shiny-card.tsx (0 hunks)
💤 Files with no reviewable changes (5)
  • apps/dashboard/styles/tailwind/components.css
  • apps/dashboard/styles/tailwind/utilities.css
  • apps/dashboard/styles/tailwind/typography.css
  • apps/dashboard/styles/tailwind/base.css
  • apps/www/components/shiny-card.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
apps/dashboard/styles/tailwind/tailwind.css

[error] 122-122: Expected a string but instead found ')'.

Expected a string here.

(parse)

🔇 Additional comments (6)
apps/dashboard/app/layout.tsx (1)

8-10: Verify font imports and usage

Ensure that GeistMono and GeistSans are correctly imported from "geist/font/mono" and "geist/font/sans", and that these fonts are properly configured and loaded in the application. Double-check if additional setup is required for these fonts to work as intended.

To confirm the correct imports and usage, you can run the following script:

✅ Verification successful

Font imports and usage are correctly implemented

The imports of GeistMono and GeistSans from "geist/font/mono" and "geist/font/sans" are correctly implemented and consistently used across multiple apps in the monorepo. The fonts are properly configured in the layout files:

  • The dashboard app correctly applies both fonts using CSS variables: className={${GeistSans.variable} ${GeistMono.variable}}
  • Similar implementations are found in other apps (www, engineering, play) confirming this is the standard pattern
  • The fonts are used appropriately with Next.js's font system
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for imports of Geist fonts and verify usage.

# Test: Find all import statements of Geist fonts.
rg 'import.*from ["\']geist/font/.*["\']' -A 2

# Expected: Imports of GeistMono and GeistSans with correct paths.

Length of output: 116


Script:

#!/bin/bash
# Search for Geist font imports with proper quoting
rg "import.*from ['\"]geist/font" -A 2

# Search for any mentions of Geist fonts in the codebase
rg "GeistMono|GeistSans"

# Check package.json for geist dependency
cat package.json | grep -A 5 -B 5 "geist"

Length of output: 2951

apps/dashboard/app/(app)/apis/create-api-button.tsx (1)

54-54: ⚠️ Potential issue

Fix incomplete Tailwind CSS class in DialogContent

The className prop for DialogContent includes an incomplete Tailwind class "max-sm: ". The max-sm: prefix requires a utility class to follow. Please complete the class or remove it if unnecessary.

Here's a suggested fix:

-            <DialogContent className="w-11/12 max-sm: ">
+            <DialogContent className="w-11/12 max-sm:w-full">

Replace w-full with the intended utility class if different.

Likely invalid or redundant comment.

apps/dashboard/app/(app)/apis/client.tsx (1)

7-7: Verify the integration of the Button component from @unkey/ui

Ensure that the Button component imported from @unkey/ui is correctly integrated and that all instances of Button across the application are updated accordingly. Confirm that the buttons render as expected with the new styling.

You can run the following script to find all usages of the Button component:

✅ Verification successful

Let me search for both the imports and actual usage of the Button component to verify its integration. The first command will help us find where the Button is imported from @unkey/ui, and the second command will show us where Button components are being used in the codebase.


I see the imports are correctly set up across multiple files. Let's now verify the actual usage of the Button component in the codebase, particularly in the file we're reviewing.


Button component from @unkey/ui is correctly integrated

The verification shows that:

  1. The Button component is properly imported from @unkey/ui across multiple files
  2. In the specific file under review (apps/dashboard/app/(app)/apis/client.tsx), the Button is correctly imported and used with appropriate props in the "Read the docs" button
  3. The Button component is consistently used throughout the codebase with various props (variant, size, className) and appears to be working as expected with different styling options
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all usages of the Button component.

# Test: Search for Button imports and usages.
rg 'import {.*Button.*} from ["\']@unkey/ui["\']' -A 5

# Expected: All Button components are imported from @unkey/ui and used correctly.

Length of output: 116


Script:

#!/bin/bash
# Search for Button imports from @unkey/ui
rg "import.*Button.*from.*@unkey/ui"

# Search for Button usage patterns in TSX/JSX files
rg "<Button" --type tsx

Length of output: 1013


Script:

#!/bin/bash
# Search for Button usage patterns in all files
rg "<Button"

# Let's also check the specific file we're reviewing to see its Button usage
cat "apps/dashboard/app/(app)/apis/client.tsx"

Length of output: 27507

apps/dashboard/package.json (1)

86-86: Verify Geist package version

The addition of the Geist package aligns with the transition to @unkey/ui. However, let's verify the version.

✅ Verification successful

✓ Geist package version is up-to-date and secure

The installed version (1.3.1) matches the latest version from npm registry, and there are no security vulnerabilities reported for this package.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check latest version and any potential issues with geist package
curl -s https://registry.npmjs.org/geist | jq -r '.["dist-tags"].latest'

# Check for any security advisories
gh api graphql -f query='
{
  securityVulnerabilities(first: 5, ecosystem: NPM, package: "geist") {
    nodes {
      advisory {
        summary
        severity
        publishedAt
      }
      vulnerableVersionRange
      firstPatchedVersion {
        identifier
      }
    }
  }
}'

Length of output: 419

apps/dashboard/tailwind.config.js (1)

136-137: LGTM: Font family configuration updated for Geist

The font family configuration correctly uses the Geist font CSS variables, aligning with the PR objective.

apps/www/components/analytics/analytics-bento.tsx (1)

631-631: LGTM: Updated styling for consistency

The styling changes align with the transition to @unkey/ui and maintain consistency across the application.

Comment on lines +21 to +22
--warn: 46, 97%, 65%;
--warn-foreground: 46, 97%, 15%;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix inconsistent HSL color syntax in CSS variables

The HSL color values in the CSS variables use commas in some places and spaces in others. According to CSS syntax, spaces should separate HSL components when not using the hsl() function. Please ensure consistency by using spaces throughout.

Apply this diff to correct the syntax:

-        --warn: 46, 97%, 65%;
-        --warn-foreground: 46, 97%, 15%;
-        --success: 152, 56%, 39%;
+        --warn: 46 97% 65%;
+        --warn-foreground: 46 97% 15%;
+        --success: 152 56% 39%;

And in the .dark theme:

-        --warn: 46, 100%, 45%;
-        --warn-foreground: 46, 97%, 5%;
-        --success: 152, 56%, 39%;
+        --warn: 46 100% 45%;
+        --warn-foreground: 46 97% 5%;
+        --success: 152 56% 39%;

Also applies to: 27-27, 74-75, 80-80

--warn-foreground: 46, 97%, 15%;

--alert: 0 100% 65%;
--alert-foreground: 0 100% 980%;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Correct invalid lightness value in --alert-foreground

The --alert-foreground CSS variable has an invalid lightness value of 980%. Lightness values in HSL should be between 0% and 100%. Please correct this value to ensure proper rendering.

Here's the fix:

-        --alert-foreground: 0 100% 980%;
+        --alert-foreground: 0 100% 98%;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
--alert-foreground: 0 100% 980%;
--alert-foreground: 0 100% 98%;

counter-increment: line;
content: counter(line);
@apply mr-8 inline-block w-4 text-right text-gray-500;
@-moz-document url-prefix() {
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix syntax error in @-moz-document rule

At line 122, the @-moz-document url-prefix() rule is missing a string argument inside url-prefix(). This causes a syntax error. To target all URLs, use an empty string as the argument.

Apply this diff:

-@-moz-document url-prefix() {
+@-moz-document url-prefix("") {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@-moz-document url-prefix() {
@-moz-document url-prefix("") {
🧰 Tools
🪛 Biome (1.9.4)

[error] 122-122: Expected a string but instead found ')'.

Expected a string here.

(parse)

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.

1 participant