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(skeleton): added Skeleton Loading with Examples #1332

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

dhavalveera
Copy link
Contributor

@dhavalveera dhavalveera commented Mar 31, 2024

This Pull Request introduces Skeleton Loading components to Flowbite-React, leveraging the Flowbite package. Skeleton Loading provides users with a seamless loading experience by displaying placeholders while content is being fetched or loaded. This enhancement includes various Skeleton components such as Skeleton, Skeleton Video, Skeleton Image, Skeleton Card, Skeleton List, and Skeleton Testimonial, ensuring a consistent loading UI across different types of content. With these additions, users will enjoy smoother transitions and improved usability, enhancing the overall user experience of Flowbite-React applications.

Pardon me for the variable names, please suggest a better naming convention.

Summary by CodeRabbit

  • New Features
    • Introduced a new Skeleton component in the Flowbite library for creating loading indicators, mimicking the content being loaded such as text, images, and videos. This includes variants like Default, Circular, Rectangular, and Rounded.
    • Added examples for implementing skeleton placeholders for images, videos, cards, lists, and testimonials.
    • Provided customization options for the appearance of the Skeleton component.
  • Documentation
    • Added documentation for the Skeleton component, including usage examples and customization guides.
  • Tests
    • Introduced test cases for the Skeleton component to ensure proper functionality.
  • Style
    • Integrated theme configuration for styling skeleton loading components, offering a variety of visual appearances.

Copy link

stackblitz bot commented Mar 31, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

changeset-bot bot commented Mar 31, 2024

⚠️ No Changeset found

Latest commit: 031c7b4

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

vercel bot commented Mar 31, 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 Mar 31, 2024 11:51am
flowbite-react-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 31, 2024 11:51am

Copy link
Contributor

coderabbitai bot commented Mar 31, 2024

Walkthrough

The update introduces a new Skeleton component in the Flowbite library, enhancing UI design with loading indicators that mimic the content being loaded. This includes various shapes and forms like cards, images, and lists, alongside customization options for their appearance, significantly improving the user experience during content loading.

Changes

Files Change Summary
apps/web/content/docs/components/skeleton.mdx Introduced documentation for the new Skeleton component in the Flowbite library.
apps/web/data/components.tsx
apps/web/data/docs-sidebar.ts
Added Skeleton component to components list and docs sidebar.
apps/web/examples/index.ts
apps/web/examples/skeleton/index.ts
Exported skeleton component examples.
packages/ui/src/components/Skeleton/...
(Skeleton.spec.tsx, Skeleton.stories.tsx, Skeleton.tsx, SkeletonCard.tsx, SkeletonImage.tsx, SkeletonList.tsx, SkeletonTestimonial.tsx, SkeletonVideo.tsx, index.ts, theme.ts)
Introduced and implemented the Skeleton component and its variations, including tests and stories.
packages/ui/src/components/Flowbite/FlowbiteTheme.ts
packages/ui/src/index.ts
packages/ui/src/theme.ts
Added FlowbiteSkeletonTheme interface and exported the Skeleton component and theme.

Possibly related issues

  • Improve per-component theme documentation #808: The introduction of the Skeleton component, along with its comprehensive documentation and theming capabilities, directly addresses the issue's objectives by enhancing usability, allowing for effective customization, and improving the developer experience with clear references for the theme object.

Poem

In the land of code where the bits do hop,
A Skeleton dances, never does it stop.
Mimicking content, it plays its part,
Loading placeholders, an artful start.
🐰 With every shape and form it takes,
A smoother web, this rabbit makes.
Celebrate the change, for progress we cheer, 🎉
With Skeleton components, the future is here!

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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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: 2

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 40e4e87 and c5775eb.
Files ignored due to path filters (2)
  • apps/web/public/images/components/skeleton-dark.svg is excluded by !**/*.svg
  • apps/web/public/images/components/skeleton.svg is excluded by !**/*.svg
Files selected for processing (27)
  • apps/web/content/docs/components/skeleton.mdx (1 hunks)
  • apps/web/data/components.tsx (1 hunks)
  • apps/web/data/docs-sidebar.ts (1 hunks)
  • apps/web/examples/index.ts (1 hunks)
  • apps/web/examples/skeleton/index.ts (1 hunks)
  • apps/web/examples/skeleton/skeleton.card.tsx (1 hunks)
  • apps/web/examples/skeleton/skeleton.circular.tsx (1 hunks)
  • apps/web/examples/skeleton/skeleton.image.tsx (1 hunks)
  • apps/web/examples/skeleton/skeleton.list.tsx (1 hunks)
  • apps/web/examples/skeleton/skeleton.rectangular.tsx (1 hunks)
  • apps/web/examples/skeleton/skeleton.root.tsx (1 hunks)
  • apps/web/examples/skeleton/skeleton.rounded.tsx (1 hunks)
  • apps/web/examples/skeleton/skeleton.testimonial.tsx (1 hunks)
  • apps/web/examples/skeleton/skeleton.video.tsx (1 hunks)
  • packages/ui/src/components/Flowbite/FlowbiteTheme.ts (2 hunks)
  • packages/ui/src/components/Skeleton/Skeleton.spec.tsx (1 hunks)
  • packages/ui/src/components/Skeleton/Skeleton.stories.tsx (1 hunks)
  • packages/ui/src/components/Skeleton/Skeleton.tsx (1 hunks)
  • packages/ui/src/components/Skeleton/SkeletonCard.tsx (1 hunks)
  • packages/ui/src/components/Skeleton/SkeletonImage.tsx (1 hunks)
  • packages/ui/src/components/Skeleton/SkeletonList.tsx (1 hunks)
  • packages/ui/src/components/Skeleton/SkeletonTestimonial.tsx (1 hunks)
  • packages/ui/src/components/Skeleton/SkeletonVideo.tsx (1 hunks)
  • packages/ui/src/components/Skeleton/index.ts (1 hunks)
  • packages/ui/src/components/Skeleton/theme.ts (1 hunks)
  • packages/ui/src/index.ts (1 hunks)
  • packages/ui/src/theme.ts (2 hunks)
Files skipped from review due to trivial changes (3)
  • apps/web/examples/skeleton/index.ts
  • packages/ui/src/components/Skeleton/Skeleton.stories.tsx
  • packages/ui/src/components/Skeleton/index.ts
Additional Context Used
Additional comments not posted (25)
apps/web/examples/skeleton/skeleton.root.tsx (5)

1-3: Ensure that the import paths are correct and consistent across the project. It's good practice to verify that all necessary dependencies are correctly installed and that the import paths align with the project's structure.


4-16: The client-side code example is clear and demonstrates the basic usage of the Skeleton component. However, consider adding more detailed comments within the code to explain the purpose and usage of the Skeleton component, especially for new developers or first-time users of the library.


18-28: Similar to the client-side example, the server-side code example is straightforward. It's beneficial to maintain consistency between client and server examples for clarity. Ensure that the server-side rendering capabilities of the Skeleton component are tested and work as expected.


30-36: The live component example is a crucial part of demonstrating the component's functionality. It's recommended to include various states or variations of the Skeleton component if applicable, to showcase its flexibility and customization options.


38-54: The export structure is well-organized, making it easy to understand the component's purpose and usage. Ensure that the githubSlug accurately reflects the file's location within the project repository for easier navigation and reference.

apps/web/examples/skeleton/skeleton.card.tsx (4)

1-3: Ensure that the import paths are correct and consistent across the project. It's good practice to verify that all necessary dependencies are correctly installed and that the import paths align with the project's structure.


18-28: The server-side code example correctly demonstrates the usage of the SkeletonCard component. As with the client-side example, ensure that comments are added to explain the component's purpose and usage clearly.


30-36: The live component example effectively demonstrates the SkeletonCard component. Consider showcasing different variations or states of the SkeletonCard to highlight its customization options and versatility.


38-54: The export structure is well-organized. Verify that the githubSlug accurately reflects the file's location within the project repository for easier navigation and reference.

apps/web/examples/skeleton/skeleton.rectangular.tsx (1)

1-54: - The example code for both client and server components is identical. Consider abstracting it to a single shared function or component to reduce duplication and improve maintainability.

  • Ensure that the CodeData interface (if it exists) properly supports the structure of the rectangular object, especially the type and code fields.
  • The use client directive in the code snippet suggests that part of the code is intended for client-side execution only. Verify that this aligns with the overall architecture and usage scenarios of the Flowbite-React library.
  • The Skeleton component is used with a variant="rectangular" prop. Confirm that all necessary props are provided for correct functionality and that the prop types are correctly defined in the Skeleton component.
  • The file structure and naming convention (skeleton.rectangular.tsx) seem consistent with the purpose of the file. However, consider if there's a more descriptive name that could be used, especially if the library will include more complex examples in the future.
apps/web/examples/index.ts (1)

28-28: The export of the skeleton module is correctly placed alphabetically among the other exports, which is good for maintainability and readability. Ensure that all necessary files are included in the skeleton directory and that they are correctly referenced in any documentation or index files.

packages/ui/src/components/Skeleton/SkeletonVideo.tsx (1)

1-35: - The SkeletonVideo component is well-structured, making use of the twMerge function for class name merging and mergeDeep for theme customization. This approach is consistent with the theme customization strategy across the library.

  • The use of role="status" and aria-hidden="true" attributes in the SVG element is a good practice for accessibility, ensuring that the loading state is communicated to screen readers.
  • The data-testid attribute is used, which is helpful for testing. Ensure that these test IDs are unique and consistently named across different Skeleton components for ease of testing.
  • Consider adding PropTypes or TypeScript interfaces for the SkeletonVideoProps to enforce type checking and improve developer experience.
packages/ui/src/components/Skeleton/SkeletonList.tsx (1)

1-53: - The SkeletonList component follows a similar structure to SkeletonVideo, utilizing theme customization and accessibility attributes effectively.

  • The repeated structure within the component (lines 29-49) suggests that the list items are statically defined. Consider if a more dynamic approach, such as accepting a count prop to determine the number of list items, could improve flexibility.
  • The use of data-testid for testing and role="status" for accessibility is consistent and appropriate.
  • As with SkeletonVideo, ensure that PropTypes or TypeScript interfaces are defined for SkeletonListProps.
packages/ui/src/components/Skeleton/SkeletonTestimonial.tsx (1)

1-49: - The SkeletonTestimonial component is well-implemented, with attention to theme customization and accessibility.

  • The structure and use of SVG for the user icon within the testimonial skeleton are consistent with the design and functionality of the other skeleton components.
  • The data-testid and accessibility attributes (role="status" and aria-hidden="true") are correctly used.
  • As with other Skeleton components, ensure that PropTypes or TypeScript interfaces are defined for SkeletonTestimonialProps to enforce type checking.
packages/ui/src/index.ts (1)

35-35: The export of the Skeleton component is correctly placed alphabetically among the other exports. This consistency in ordering facilitates easier navigation and maintenance of the codebase. Ensure that the Skeleton component and all its variants are correctly exported and can be imported without issues in consumer applications.

packages/ui/src/components/Skeleton/Skeleton.spec.tsx (1)

1-57: - The test suite for the Skeleton components is comprehensive, covering each variant and ensuring they are rendered correctly in the document.

  • The use of data-testid attributes in the component definitions is effectively leveraged here for selecting elements in tests.
  • Consider adding tests for custom theme props to ensure that theme customization is applied correctly across all Skeleton variants.
  • Ensure that asynchronous rendering behaviors, if any, are correctly handled in the tests, especially since the tests use async without awaiting any operations.
packages/ui/src/components/Skeleton/SkeletonImage.tsx (1)

1-55: - The SkeletonImage component is implemented consistently with the other Skeleton components, utilizing theme customization and accessibility attributes effectively.

  • The detailed SVG and text lines within the component suggest a thoughtful design to mimic the loading state of an image with accompanying text. This attention to detail enhances the user experience during loading states.
  • The use of data-testid for testing and role="status" for accessibility is consistent and appropriate.
  • As with other Skeleton components, ensure that PropTypes or TypeScript interfaces are defined for SkeletonImageProps.
apps/web/content/docs/components/skeleton.mdx (1)

10-10: Near line 10, there's a possible spelling mistake in the context of importing the Skeleton component. However, upon review, the spelling and syntax for the import statement are correct.

packages/ui/src/components/Skeleton/Skeleton.tsx (1)

1-68: Overall, the implementation of the Skeleton component and its variants in Skeleton.tsx appears to be well-structured and follows best practices for React component development. The use of TypeScript for type safety, the application of the twMerge function for conditional class merging, and the modular approach to handling different skeleton types are commendable.

packages/ui/src/components/Skeleton/SkeletonCard.tsx (1)

1-64: The SkeletonCard component is implemented correctly and follows React and TypeScript best practices. The use of twMerge for class merging and mergeDeep for theme customization provides flexibility and modularity. The structure and logic of the component are clear and maintainable.

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

1-71: The theme configuration for the Skeleton components in theme.ts is well-defined and adheres to the design principles of the library. The use of Tailwind CSS classes for styling ensures consistency with the rest of the library. The structure allows for easy customization and extension of the theme.

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

33-33: The integration of the skeletonTheme into the main theme object is correctly implemented. This change ensures that the Skeleton components are properly themed and customizable through the library's theming system.

apps/web/data/docs-sidebar.ts (1)

79-79: The addition of the "Skeleton" entry to the DOCS_SIDEBAR constant is correctly implemented. This update ensures that the Skeleton component is discoverable in the documentation sidebar, improving the user experience for developers seeking information about this component.

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

33-33: The inclusion of the FlowbiteSkeletonTheme in the FlowbiteTheme interface is correctly implemented. This extension allows for comprehensive theming support for the Skeleton components within the Flowbite library, enhancing the library's customization capabilities.

apps/web/data/components.tsx (1)

143-149: The addition of the Skeleton component to the COMPONENTS_DATA array is correctly implemented. This update ensures that the Skeleton component is properly represented in the components list with appropriate metadata, including images and links to documentation.

apps/web/content/docs/components/skeleton.mdx Outdated Show resolved Hide resolved
apps/web/examples/skeleton/skeleton.card.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: 1

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c5775eb and c2eff4d.
Files selected for processing (5)
  • apps/web/content/docs/components/skeleton.mdx (1 hunks)
  • apps/web/examples/skeleton/skeleton.card.tsx (1 hunks)
  • apps/web/examples/skeleton/skeleton.circular.tsx (1 hunks)
  • apps/web/examples/skeleton/skeleton.image.tsx (1 hunks)
  • apps/web/examples/skeleton/skeleton.list.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (4)
  • apps/web/examples/skeleton/skeleton.card.tsx
  • apps/web/examples/skeleton/skeleton.circular.tsx
  • apps/web/examples/skeleton/skeleton.image.tsx
  • apps/web/examples/skeleton/skeleton.list.tsx
Additional Context Used
Additional comments not posted (1)
apps/web/content/docs/components/skeleton.mdx (1)

10-14: Ensure the import statement is correctly formatted and free from spelling mistakes. The static analysis hint suggests a possible issue, but the provided context does not show any spelling mistake in the import statement. This might be a false positive.

apps/web/content/docs/components/skeleton.mdx Show resolved Hide resolved
@dhavalveera
Copy link
Contributor Author

@SutuSebastian - can you please review?

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.

None yet

1 participant