Skip to content

Conversation

@jindaljyoti
Copy link
Contributor

@jindaljyoti jindaljyoti commented Jan 30, 2025

Summary by CodeRabbit

  • Style
    • Enhanced type safety in story files for Modal, Progress, and Quote components
    • Added explicit type annotations to function parameters in Storybook story files
    • Updated React import statements to improve type handling

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 30, 2025

Walkthrough

This pull request focuses on enhancing type safety across several story files for UI components. The changes involve adding explicit type annotations to function parameters in story files for Modal, Progress, and Quote components. Specifically, the modifications include updating import statements and defining type annotations for args parameters, primarily using any or React.JSX.IntrinsicAttributes types to improve type clarity and consistency.

Changes

File Change Summary
src/components/ui/Modal/stories/Modal.stories.tsx Added type annotation args: any to Template function
src/components/ui/Progress/stories/Progress.stories.tsx Updated React import and added args: React.JSX.IntrinsicAttributes type to render function
src/components/ui/Quote/stories/Quote.stories.tsx Added React import and typed render function parameter as args: any

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • kotAPI

Poem

🐰 Typeful Rabbit's Coding Delight
Annotations dance with might
From any to precise and clear
Type safety brings us cheer!
Code now sings a cleaner song 🎵


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

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

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

CodeRabbit Commands (Invoked using PR comments)

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

Other keywords and placeholders

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

CodeRabbit Configuration File (.coderabbit.yaml)

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

Documentation and Community

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (2)
src/components/ui/Quote/stories/Quote.stories.tsx (1)

Line range hint 8-15: Use proper Storybook types for better type safety.

The story configuration should use proper Storybook types instead of any. Since this is using CSF 3.0 format, we should use the Meta and StoryObj types.

+import type { Meta, StoryObj } from '@storybook/react';

-export default {
+const meta: Meta<typeof Quote> = {
    title: 'Components/Quote',
    component: Quote,
-    render: (args:any) => <SandboxEditor>
+    render: (args) => <SandboxEditor>
        <div className='text-gray-950'>
            <Text className='text-gray-950'> <Quote> {`I'm not a monkey
I will not dance even if the beat's funky`}</Quote>  - Mike Shinoda </Text>
        </div>
    </SandboxEditor>
};
+export default meta;
+type Story = StoryObj<typeof Quote>;
src/components/ui/Progress/stories/Progress.stories.tsx (1)

Line range hint 8-25: Use proper Storybook types and remove console.log.

Several improvements needed:

  1. Use proper Storybook types instead of React.JSX.IntrinsicAttributes
  2. Remove the console.log statement
+import type { Meta, StoryObj } from '@storybook/react';

-export default {
+const meta: Meta<typeof Progress> = {
    title: 'Components/Progress',
    component: Progress,
    render: (args) => {
        const [value, setValue] = useState(10);
-        console.log(value);
        return (<SandboxEditor>
            <div className='my-10 space-y-4'>
                <Progress value={value} maxValue={100} minValue={0} {...args}/>
                <Button
                    {...args}
                    onClick={() => {
                        setValue(Math.floor(Math.random() * 100));
                    }}>Animate!</Button>
            </div>
        </SandboxEditor>);
    }
};
+export default meta;
+type Story = StoryObj<typeof Progress>;
🧹 Nitpick comments (1)
src/components/ui/Progress/stories/Progress.stories.tsx (1)

1-1: Consider a more structured TypeScript migration approach.

I notice a pattern of using any or overly generic types across the story files. For a more effective TypeScript migration:

  1. Use Storybook's built-in types (Meta, StoryObj) consistently across all story files
  2. Avoid using any or overly generic types like React.JSX.IntrinsicAttributes
  3. Consider adding a TypeScript configuration file (tsconfig.json) if not already present
  4. Add ESLint rules to prevent usage of any (e.g., @typescript-eslint/no-explicit-any)

This will help maintain better type safety and consistency across the codebase.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 82fc759 and 2efadd2.

📒 Files selected for processing (3)
  • src/components/ui/Modal/stories/Modal.stories.tsx (1 hunks)
  • src/components/ui/Progress/stories/Progress.stories.tsx (2 hunks)
  • src/components/ui/Quote/stories/Quote.stories.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build

};

const Template = (args) => {
const Template = (args: any) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use proper Storybook types instead of any.

Using any defeats the purpose of TypeScript migration. Instead, use Storybook's built-in types for better type safety.

-const Template = (args: any) => {
+import type { ComponentStory } from '@storybook/react';
+const Template: ComponentStory<typeof Modal> = (args) => {

Committable suggestion skipped: line range outside the PR's diff.

@kotAPI kotAPI added the automerge A tag that tells kodiak bot to automerge PRs for us when tests and approval conditions are met label Jan 30, 2025
@kodiakhq kodiakhq bot merged commit 05b0636 into rad-ui:main Jan 30, 2025
5 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge A tag that tells kodiak bot to automerge PRs for us when tests and approval conditions are met

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants