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(components): add Clipboard #1413

Merged
merged 10 commits into from
Jun 19, 2024

Conversation

dhavalveera
Copy link
Contributor

@dhavalveera dhavalveera commented Jun 2, 2024

Changes

bring in https://flowbite.com/docs/components/clipboard/ to flowbite-react

Summary by CodeRabbit

  • New Features
    • Introduced a new "Clipboard" component with functionalities for copying text to the clipboard, including tooltip display and copy action management.
    • Added "ClipboardWithIcon" and "ClipboardWithIconText" components for enhanced clipboard functionalities with icon support and customizable theming.
    • Included example implementations demonstrating the usage of the new clipboard components.

Copy link

changeset-bot bot commented Jun 2, 2024

🦋 Changeset detected

Latest commit: bd1dc36

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
flowbite-react Minor

Not sure what this means? Click here to learn what changesets are.

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

Copy link

vercel bot commented Jun 2, 2024

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

Name Status Preview Comments Updated (UTC)
flowbite-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 3, 2024 1:25am
flowbite-react-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 3, 2024 1:25am

Copy link
Contributor

coderabbitai bot commented Jun 2, 2024

Warning

Rate limit exceeded

@dhavalveera has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 36 minutes and 48 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between b7c3792 and bd1dc36.

Walkthrough

This update introduces a new "Clipboard" component to the flowbite-react package, providing functionalities for copying text to the clipboard. It includes variations like Clipboard.WithIcon and Clipboard.WithIconText, which offer customizable buttons with icons for enhanced user feedback. Additionally, helper functions and themes are incorporated to manage the copy state and styling.

Changes

File Path Summary
.changeset/poor-tools-hide.md Added a summary for the patch introducing the "Clipboard" component to flowbite-react.
apps/web/examples/clipboard/clipboard.withIcon.tsx Introduced Component with a form, input field, and copy button using Clipboard.WithIcon. Exported withIcon containing code data.
apps/web/examples/clipboard/clipboard.withIconText.tsx Introduced Component with a form, input field, and copy button using Clipboard.WithIconText. Exported withIconText containing code data.
packages/ui/src/components/Clipboard/Clipboard.tsx Added the Clipboard component with copy functionality, tooltip display, and theme management.
packages/ui/src/components/Clipboard/ClipboardWithIcon.tsx Introduced ClipboardWithIcon, a button with an icon for copying text, with customizable themes.
packages/ui/src/components/Clipboard/ClipboardWithIconText.tsx Introduced ClipboardWithIconText, a button with an icon and text for copying, with customizable themes.
packages/ui/src/components/Clipboard/helpers.ts Updated copyToClipboard function to manage copy state and indicate success.

Poem

🐇✨

In the realm of code, a clipboard's delight,
Buttons with icons, a wondrous sight.
Copying text with ease and flair,
Success feedback floating in the air.
Flowbite's magic, now shining bright,
Bringing joy to day and night.

🌟📋


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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: 4

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b2640bc and 7a6efab.

Files selected for processing (17)
  • .changeset/poor-tools-hide.md (1 hunks)
  • apps/web/content/docs/components/clipboard.mdx (1 hunks)
  • apps/web/data/docs-sidebar.ts (1 hunks)
  • apps/web/examples/clipboard/clipboard.root.tsx (1 hunks)
  • apps/web/examples/clipboard/clipboard.withIcon.tsx (1 hunks)
  • apps/web/examples/clipboard/clipboard.withIconText.tsx (1 hunks)
  • apps/web/examples/clipboard/index.ts (1 hunks)
  • apps/web/examples/index.ts (1 hunks)
  • packages/ui/src/components/Clipboard/Clipboard.stories.tsx (1 hunks)
  • packages/ui/src/components/Clipboard/Clipboard.tsx (1 hunks)
  • packages/ui/src/components/Clipboard/ClipboardWithIcon.tsx (1 hunks)
  • packages/ui/src/components/Clipboard/ClipboardWithIconText.tsx (1 hunks)
  • packages/ui/src/components/Clipboard/index.ts (1 hunks)
  • packages/ui/src/components/Clipboard/theme.tsx (1 hunks)
  • packages/ui/src/components/Flowbite/FlowbiteTheme.ts (2 hunks)
  • packages/ui/src/index.ts (1 hunks)
  • packages/ui/src/theme.ts (2 hunks)
Files skipped from review due to trivial changes (4)
  • apps/web/data/docs-sidebar.ts
  • apps/web/examples/clipboard/index.ts
  • packages/ui/src/components/Clipboard/index.ts
  • packages/ui/src/index.ts
Additional comments not posted (16)
apps/web/examples/index.ts (1)

12-12: Export statement for the Clipboard component is correctly added.

packages/ui/src/components/Clipboard/theme.tsx (1)

4-28: The theme configuration for the Clipboard component is comprehensive and well-structured.

apps/web/content/docs/components/clipboard.mdx (1)

1-42: The documentation for the Clipboard component is well-written and provides a thorough overview of its usage and configuration.

apps/web/examples/clipboard/clipboard.root.tsx (1)

1-57: The example implementation for the Clipboard component is correctly done, demonstrating its usage effectively.

apps/web/examples/clipboard/clipboard.withIcon.tsx (1)

46-57: Export statement looks good.

The export of withIcon is correctly structured and provides necessary metadata for the example usage of the Clipboard.WithIcon component.

packages/ui/src/components/Clipboard/ClipboardWithIconText.tsx (2)

8-56: Component implementation is robust and well-structured.

The ClipboardWithIconText component is implemented with clear state management for copy actions and theme customization. The use of conditional rendering and icons enhances UX.


28-56: Export with forwardRef is appropriate.

Using forwardRef for the ClipboardWithIconText component allows for ref forwarding, which is useful in many React patterns, especially when dealing with lower-level DOM interactions or third-party libraries.

apps/web/examples/clipboard/clipboard.withIconText.tsx (2)

1-25: Imports and code constant are correctly defined.

The imports and the code constant are appropriately used for setting up the example component for Clipboard.WithIconText.


46-57: Export statement looks good.

The export of withIconText is correctly structured and provides necessary metadata for the example usage of the Clipboard.WithIconText component.

packages/ui/src/components/Clipboard/Clipboard.tsx (2)

12-56: Component implementation is robust and well-structured.

The Clipboard component is implemented with clear state management for copy actions and theme customization. The use of Tooltip enhances user feedback and interaction.


53-56: Export statement is well-structured.

The export structure of the Clipboard component along with its variations (WithIcon and WithIconText) is well-organized and promotes modularity.

packages/ui/src/components/Clipboard/Clipboard.stories.tsx (2)

8-72: Story definitions are comprehensive and well-structured.

The Storybook stories for the Clipboard component and its variations are well-defined, providing clear and interactive examples for users to understand the component's functionality.


30-72: Export statements for stories are correctly structured.

The export of Storybook stories using the bind method ensures that each story is reusable and can be individually configured, which is a best practice in Storybook development.

packages/ui/src/theme.ts (1)

Line range hint 12-58: Theme configuration for Clipboard is correctly integrated.

The addition of clipboardTheme to the main theme configuration ensures that the styling and theming of the Clipboard component are consistent and customizable across the application.

packages/ui/src/components/Flowbite/FlowbiteTheme.ts (2)

12-12: The import of FlowbiteClipboardTheme is correctly placed and follows the existing pattern of importing component themes.


60-60: The addition of clipboard to the FlowbiteTheme interface integrates the new Clipboard component's theme correctly. Ensure that all necessary properties are defined in FlowbiteClipboardTheme to support theming for the Clipboard component.

Verification successful

The FlowbiteClipboardTheme interface is defined in packages/ui/src/components/Clipboard/Clipboard.tsx and includes the following properties:

  • button: An object with base and label properties.
  • withIcon: A property of type FlowbiteClipboardWithIconTheme.
  • withIconText: A property of type FlowbiteClipboardWithIconTextTheme.

This confirms that the necessary properties for theming the Clipboard component are defined.

  • packages/ui/src/components/Clipboard/Clipboard.tsx:12-19
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all necessary properties are defined in `FlowbiteClipboardTheme`.

# Test: Search for the definition of `FlowbiteClipboardTheme` and check for completeness.
ast-grep --lang typescript --pattern $'interface FlowbiteClipboardTheme { $$$ }' ../Clipboard/index.ts

Length of output: 172



Script:

#!/bin/bash
# Description: Locate the definition of `FlowbiteClipboardTheme` in the repository.

# Search for the definition of `FlowbiteClipboardTheme` in the repository.
ast-grep --lang typescript --pattern $'interface FlowbiteClipboardTheme { $$$ }'

Length of output: 81



Script:

#!/bin/bash
# Description: Search for references to `FlowbiteClipboardTheme` in the repository.

# Search for any occurrences of `FlowbiteClipboardTheme` in the repository.
rg 'FlowbiteClipboardTheme'

Length of output: 763



Script:

#!/bin/bash
# Description: Extract the definition of `FlowbiteClipboardTheme` from `Clipboard.tsx`.

# Extract the definition of `FlowbiteClipboardTheme` from `Clipboard.tsx`.
ast-grep --lang typescript --pattern $'interface FlowbiteClipboardTheme { $$$ }' packages/ui/src/components/Clipboard/Clipboard.tsx

Length of output: 758

.changeset/poor-tools-hide.md Outdated Show resolved Hide resolved
packages/ui/src/components/Clipboard/ClipboardWithIcon.tsx Outdated Show resolved Hide resolved
apps/web/examples/clipboard/clipboard.withIcon.tsx Outdated Show resolved Hide resolved
apps/web/examples/clipboard/clipboard.withIconText.tsx Outdated Show resolved Hide resolved
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7a6efab and c2d193f.

Files selected for processing (5)
  • apps/web/examples/clipboard/clipboard.withIcon.tsx (1 hunks)
  • apps/web/examples/clipboard/clipboard.withIconText.tsx (1 hunks)
  • packages/ui/src/components/Clipboard/Clipboard.tsx (1 hunks)
  • packages/ui/src/components/Clipboard/ClipboardWithIcon.tsx (1 hunks)
  • packages/ui/src/components/Clipboard/ClipboardWithIconText.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (5)
  • apps/web/examples/clipboard/clipboard.withIcon.tsx
  • apps/web/examples/clipboard/clipboard.withIconText.tsx
  • packages/ui/src/components/Clipboard/Clipboard.tsx
  • packages/ui/src/components/Clipboard/ClipboardWithIcon.tsx
  • packages/ui/src/components/Clipboard/ClipboardWithIconText.tsx

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c2d193f and cbc4b58.

Files selected for processing (6)
  • apps/web/content/docs/components/clipboard.mdx (1 hunks)
  • apps/web/examples/clipboard/clipboard.root.tsx (1 hunks)
  • apps/web/examples/clipboard/clipboard.withIcon.tsx (1 hunks)
  • apps/web/examples/clipboard/clipboard.withIconText.tsx (1 hunks)
  • packages/ui/src/components/Clipboard/Clipboard.stories.tsx (1 hunks)
  • packages/ui/src/components/Clipboard/Clipboard.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (6)
  • apps/web/content/docs/components/clipboard.mdx
  • apps/web/examples/clipboard/clipboard.root.tsx
  • apps/web/examples/clipboard/clipboard.withIcon.tsx
  • apps/web/examples/clipboard/clipboard.withIconText.tsx
  • packages/ui/src/components/Clipboard/Clipboard.stories.tsx
  • packages/ui/src/components/Clipboard/Clipboard.tsx

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cbc4b58 and 0b44dc2.

Files selected for processing (2)
  • apps/web/examples/clipboard/clipboard.withIcon.tsx (1 hunks)
  • apps/web/examples/clipboard/clipboard.withIconText.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • apps/web/examples/clipboard/clipboard.withIcon.tsx
  • apps/web/examples/clipboard/clipboard.withIconText.tsx

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0b44dc2 and b7c3792.

Files selected for processing (5)
  • .changeset/poor-tools-hide.md (1 hunks)
  • packages/ui/src/components/Clipboard/Clipboard.tsx (1 hunks)
  • packages/ui/src/components/Clipboard/ClipboardWithIcon.tsx (1 hunks)
  • packages/ui/src/components/Clipboard/ClipboardWithIconText.tsx (1 hunks)
  • packages/ui/src/components/Clipboard/helpers.ts (1 hunks)
Files skipped from review as they are similar to previous changes (4)
  • .changeset/poor-tools-hide.md
  • packages/ui/src/components/Clipboard/Clipboard.tsx
  • packages/ui/src/components/Clipboard/ClipboardWithIcon.tsx
  • packages/ui/src/components/Clipboard/ClipboardWithIconText.tsx

packages/ui/src/components/Clipboard/helpers.ts Outdated Show resolved Hide resolved
@SutuSebastian SutuSebastian merged commit 26401bc into themesberg:main Jun 19, 2024
8 checks passed
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