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: Banner components #317

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

Conversation

ogzcode
Copy link
Contributor

@ogzcode ogzcode commented Aug 7, 2024

#207

Hi,

  1. I created the Banner component according to the code layout of the project.
  2. I followed the examples and style scheme provided on the Flowbite and React-Flowbite sites.
  3. I created the documentation page for the Banner component and included it in the navigation.
  4. I developed sample components for the documentation page and demonstrated their usage.
  5. I did not include all descriptive content from the Flowbite site; instead, I focused on examples for positioning and added them to the documentation page.

I hope the component turned out the way you wanted.
I'll be waiting for your feedback and advice. Have a nice day.

@Sqrcz @cogor @zoltanszogyenyi @robert1508

Summary by CodeRabbit

  • New Features

    • Introduced a new "Banner" component for displaying marketing messages and CTAs.
    • Added documentation for the fwb-banner component, including usage examples.
    • Implemented examples for default and bottom-positioned banners.
  • Bug Fixes

    • Enhanced accessibility in the banner and collapse button components.
  • Documentation

    • Improved navigational structure by adding the "Banner" component to the documentation.
    • Updated examples to illustrate banner integration and usage.
  • Chores

    • Expanded module exports to include FwbBanner and FwbBannerCollapseButton.

The code changes introduce two new components, FwbBanner and FwbBannerCollapseButton, which are used for displaying a banner and a collapse button respectively. These components are added to the index.ts file for easier import and usage.
The code changes include adding the Banner component to the documentation. This component allows users to display a banner on their website. The Banner component is now listed in the navigation menu with a link to its documentation page.
Copy link

coderabbitai bot commented Aug 7, 2024

Walkthrough

This update introduces a new "Banner" component to both the documentation and implementation within a Vue.js application. The update includes detailed guides for using the fwb-banner, enhancing user engagement with marketing messages. These additions improve navigation and usability, providing developers with effective tools for creating interactive banners, all supported by Tailwind CSS and Flowbite functionality.

Changes

Files Change Summary
docs/.vitepress/config.mts Added "Banner" component entry to getComponents function.
docs/components/banner.md New documentation for fwb-banner, including usage examples and Flowbite references.
docs/components/banner/examples/FwbBannerBottomExample.vue New example showcasing a bottom-positioned banner with Flowbite features.
docs/components/banner/examples/FwbBannerDefaultExample.vue New example highlighting a collapsible default banner for user engagement.
src/components/FwbBanner/FwbBanner.vue Introduced a customizable banner component with props for class and position.
src/components/FwbBanner/FwbBannerCollapseButton.vue Created a collapse button component for user interaction with the banner.
src/index.ts Exported FwbBanner and FwbBannerCollapseButton to enhance library functionality.

Poem

🐰 In the meadow where the banners fly,
A new feature blooms, oh my, oh my!
With messages bright and buttons to fold,
User delights in stories told.
Hop along, dear friends, and see,
The joy of banners, wild and free! 🌼✨


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

netlify bot commented Aug 7, 2024

Deploy Preview for sensational-seahorse-8635f8 ready!

Name Link
🔨 Latest commit 7330c52
🔍 Latest deploy log https://app.netlify.com/sites/sensational-seahorse-8635f8/deploys/66c44b14f741e10008fbf15d
😎 Deploy Preview https://deploy-preview-317--sensational-seahorse-8635f8.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

@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: 9

Outside diff range, codebase verification and nitpick comments (1)
docs/components/banner/examples/FwbBannerBottomExample.vue (1)

1-3: Consider reducing the height of the container.

The height of 25rem might be too large for some use cases. Consider making it configurable or reducing it.

-  <div class="vp-raw h-[25rem] overflow-y-scroll relative border border-gray-200 rounded-md dark:bg-gray-900 dark:border-gray-800">
+  <div class="vp-raw h-[20rem] overflow-y-scroll relative border border-gray-200 rounded-md dark:bg-gray-900 dark:border-gray-800">
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bce8477 and cba7e22.

Files selected for processing (7)
  • docs/.vitepress/config.mts (1 hunks)
  • docs/components/banner.md (1 hunks)
  • docs/components/banner/examples/FwbBannerBottomExample.vue (1 hunks)
  • docs/components/banner/examples/FwbBannerDefaultExample.vue (1 hunks)
  • src/components/FwbBanner/FwbBanner.vue (1 hunks)
  • src/components/FwbBanner/FwbBannerCollapseButton.vue (1 hunks)
  • src/index.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • docs/.vitepress/config.mts
Additional context used
LanguageTool
docs/components/banner.md

[uncategorized] ~16-~16: This verb does not appear to agree with the subject. Consider using a different form.
Context: ... or bottom part of the page as the user scroll down the main content area. ## Default...

(AI_EN_LECTOR_REPLACEMENT_VERB_AGREEMENT)


[misspelling] ~20-~20: Did you mean “free sample”?
Context: ...ea. ## Default sticky banner Use this free example to show a text message for announcement...

(FREE_EXAMPLE)


[uncategorized] ~20-~20: You might be missing the article “an” here.
Context: ...free example to show a text message for announcement with a CTA link, an icon element and a ...

(AI_EN_LECTOR_MISSING_DETERMINER_AN)


[uncategorized] ~55-~55: The preposition “on” seems more likely in this position.
Context: ...n be used to position the sticky banner to the bottom side of the page instead of ...

(AI_EN_LECTOR_REPLACEMENT_PREPOSITION)


[uncategorized] ~88-~88: Possible missing comma found.
Context: ...# More Examples For more sticky banner examples you can check [banner sections](https:/...

(AI_HYDRA_LEO_MISSING_COMMA)

Markdownlint
docs/components/banner.md

8-8: Expected: h2; Actual: h3
Heading levels should only increment by one level at a time

(MD001, heading-increment)

Additional comments not posted (8)
src/components/FwbBanner/FwbBanner.vue (2)

1-10: Template section looks good!

The template is well-structured and follows accessibility guidelines.


12-38: Script section looks good!

The TypeScript types, props with defaults, and computed property are correctly implemented.

Ensure that all props are used correctly throughout the codebase.

Verification successful

Props are used correctly in the FwbBanner component.

The class and position props are correctly applied in the instances of FwbBanner found in the codebase.

  • class is used to apply CSS classes.
  • position is set to bottom in one instance, which aligns with the defined BannerPosition type.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all prop usages for `FwbBanner`.

# Test: Search for the component usage. Expect: Correct prop usage.
rg --type vue -A 5 $'<fwb-banner'

Length of output: 62


Script:

#!/bin/bash
# Description: Verify all prop usages for `FwbBanner`.

# Find all Vue files and search for the component usage
fd --extension vue --exec rg '<fwb-banner' {}

Length of output: 188


Script:

#!/bin/bash
# Description: Verify all prop usages for `FwbBanner`.

# Find all Vue files and search for the component usage with more context lines
fd --extension vue --exec rg -A 10 '<fwb-banner' {}

Length of output: 1658

src/components/FwbBanner/FwbBannerCollapseButton.vue (2)

1-26: Template section looks good!

The template is well-structured and follows accessibility guidelines.


28-56: Script section looks good!

The TypeScript types, props with defaults, computed property, and event handler are correctly implemented.

Ensure that all props are used correctly throughout the codebase.

Verification successful

Let's re-verify the prop usage by correctly searching for the component in .vue files.


Let's verify the usage of the class prop in the found instances of <fwb-banner-collapse-button />.


The class prop for FwbBannerCollapseButton is not being used in the current codebase.

  • Instances of <fwb-banner-collapse-button /> were found without any class prop usage.
  • This means the default class will always be applied.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all prop usages for `FwbBannerCollapseButton`.

# Test: Search for the component usage. Expect: Correct prop usage.
rg --type vue -A 5 $'<fwb-banner-collapse-button'

Length of output: 78


Script:

#!/bin/bash
# Description: Verify all prop usages for `FwbBannerCollapseButton`.

# Find all .vue files and search for the component usage.
fd --type f --extension vue --exec rg '<fwb-banner-collapse-button' {}

Length of output: 152


Script:

#!/bin/bash
# Description: Verify the usage of the `class` prop for `FwbBannerCollapseButton`.

# Find all .vue files and search for the component usage with surrounding lines.
fd --type f --extension vue --exec rg -A 5 -B 5 '<fwb-banner-collapse-button' {}

Length of output: 566

docs/components/banner/examples/FwbBannerDefaultExample.vue (2)

92-94: Script section looks good!

The imports are correct and necessary.


1-90: Template section looks good!

The template is well-structured, follows accessibility guidelines, and uses the Banner and CollapseButton components correctly.

Ensure that the components are used correctly throughout the codebase.

Verification successful

Let's modify the shell script to search for the components in .vue files without specifying the file type.


Let's modify the shell script to use fd to find .vue files and then use rg to search for the components within those files.


Template section looks good!

The template is well-structured, follows accessibility guidelines, and uses the FwbBanner and FwbBannerCollapseButton components correctly. The verification confirms that these components are used appropriately throughout the codebase.

  • Instances of <fwb-banner> and <fwb-banner-collapse-button> are used correctly in multiple .vue files.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all usages of `FwbBanner` and `FwbBannerCollapseButton`.

# Test: Search for the component usage. Expect: Correct usage.
rg --type vue -A 5 $'<fwb-banner'
rg --type vue -A 5 $'<fwb-banner-collapse-button'

Length of output: 141


Script:

#!/bin/bash
# Description: Verify all usages of `FwbBanner` and `FwbBannerCollapseButton`.

# Test: Search for the component usage. Expect: Correct usage.
rg -t vue -A 5 '<fwb-banner'
rg -t vue -A 5 '<fwb-banner-collapse-button'

Length of output: 133


Script:

#!/bin/bash
# Description: Verify all usages of `FwbBanner` and `FwbBannerCollapseButton`.

# Find all .vue files and search for the component usage within those files.
fd -e vue -x rg -A 5 '<fwb-banner' {}
fd -e vue -x rg -A 5 '<fwb-banner-collapse-button' {}

Length of output: 1244

docs/components/banner.md (1)

1-4: Imports look good!

The imports for the example components are correct.

src/index.ts (1)

10-11: Export statements look good!

The export statements for FwbBanner and FwbBannerCollapseButton are correct and consistent with the existing structure.

docs/components/banner/examples/FwbBannerBottomExample.vue Outdated Show resolved Hide resolved
docs/components/banner/examples/FwbBannerBottomExample.vue Outdated Show resolved Hide resolved
docs/components/banner/examples/FwbBannerBottomExample.vue Outdated Show resolved Hide resolved
docs/components/banner.md Outdated Show resolved Hide resolved
docs/components/banner.md Outdated Show resolved Hide resolved
docs/components/banner.md Outdated Show resolved Hide resolved
docs/components/banner.md Outdated Show resolved Hide resolved
docs/components/banner.md Outdated Show resolved Hide resolved
docs/components/banner.md Outdated Show resolved Hide resolved
Copy link

@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, codebase verification and nitpick comments (7)
docs/components/banner.md (7)

6-14: Fix heading level.

The heading level should increment by one level at a time.

-  ## Use the banner component to show marketing messages and CTA buttons at the top or bottom side of your website based on the utility classes from Tailwind CSS
+  # Use the banner component to show marketing messages and CTA buttons at the top or bottom side of your website based on the utility classes from Tailwind CSS

16-22: Fix verb agreement.

The verb "scroll" should be "scrolls" to agree with the subject "user."

-  part of the page as the user scroll down
+  part of the page as the user scrolls down
Tools
LanguageTool

[misspelling] ~20-~20: Did you mean “free sample”?
Context: ...ea. ## Default sticky banner Use this free example to show a text message for an announcem...

(FREE_EXAMPLE)


20-20: Fix article usage.

The sentence is missing the article "an" before "announcement."

-  text message for announcement
+  text message for an announcement
Tools
LanguageTool

[misspelling] ~20-~20: Did you mean “free sample”?
Context: ...ea. ## Default sticky banner Use this free example to show a text message for an announcem...

(FREE_EXAMPLE)


25-50: Fix class attribute syntax.

The class attribute in Vue should use class instead of className.

-  <div className="flex w-full justify-between bg-gray-50 p-4 dark:bg-gray-700">
+  <div class="flex w-full justify-between bg-gray-50 p-4 dark:bg-gray-700">

55-55: Use correct preposition.

The preposition "on" seems more likely in this position.

-  position the sticky banner to the bottom side
+  position the sticky banner on the bottom side

59-84: Fix class attribute syntax.

The class attribute in Vue should use class instead of className.

-  <div className="flex w-full justify-between bg-gray-50 p-4 dark:bg-gray-700">
+  <div class="flex w-full justify-between bg-gray-50 p-4 dark:bg-gray-700">

1-4: Remove unused imports

The components FwbBannerDefaultExample and FwbBannerBottomExample are imported but not used anywhere in the file. Please remove these unused imports to clean up the code.

  • docs/components/banner.md: Lines 2-3
Analysis chain

Ensure imports are necessary and used.

Verify that both FwbBannerDefaultExample and FwbBannerBottomExample are used in the file. Unused imports should be removed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify usage of imported components in the file.

# Test: Search for the usage of imported components. Expect: Both components are used.
rg --type markdown -A 5 'FwbBannerDefaultExample|FwbBannerBottomExample'

Length of output: 618


Script:

#!/bin/bash
# Description: Verify usage of imported components in the entire file.

# Test: Search for the usage of imported components. Expect: Both components are used somewhere in the file.
rg 'FwbBannerDefaultExample|FwbBannerBottomExample' docs/components/banner.md

Length of output: 245

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cba7e22 and 6a83ec8.

Files selected for processing (3)
  • docs/components/banner.md (1 hunks)
  • docs/components/banner/examples/FwbBannerBottomExample.vue (1 hunks)
  • docs/components/banner/examples/FwbBannerDefaultExample.vue (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • docs/components/banner/examples/FwbBannerBottomExample.vue
  • docs/components/banner/examples/FwbBannerDefaultExample.vue
Additional context used
LanguageTool
docs/components/banner.md

[misspelling] ~20-~20: Did you mean “free sample”?
Context: ...ea. ## Default sticky banner Use this free example to show a text message for an announcem...

(FREE_EXAMPLE)

@Sqrcz Sqrcz self-assigned this Aug 14, 2024
@Sqrcz Sqrcz added the 📦 new component New component implementation label Aug 14, 2024
Copy link
Collaborator

@Sqrcz Sqrcz left a comment

Choose a reason for hiding this comment

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

Hey @ogzcode

Thank you for another addition 🙌

Do we really need separate "FwbBannerCollapseButton" component?

I think it could be done with closable prop like we did it with alerts. then it should be simpler to use ;)

Apart from that everything else is 👌

@ogzcode
Copy link
Contributor Author

ogzcode commented Aug 19, 2024

@Sqrcz
Hello,
Does closable need to be customizable like in Alert or is this functionality sufficient?
Like in the link below

https://flowbite-vue.com/components/alert#additional-content

@Sqrcz
Copy link
Collaborator

Sqrcz commented Aug 19, 2024

@ogzcode

Hi, I would start with something simple first and iterate later... let's make it just a simple X like in the main design for now. We can always improve it later... but it's good to have solid foundation working now... ;)

@ogzcode
Copy link
Contributor Author

ogzcode commented Aug 20, 2024

@Sqrcz
I made the edit, I hope it turned out the way you wanted.

Thank you for your feedback. Good work.🫡

Copy link

@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

Outside diff range, codebase verification and nitpick comments (6)
docs/components/banner/examples/FwbBannerDefaultExample.vue (1)

7-11: Improve SVG accessibility.

The SVG used in the example should have a descriptive aria-label or title for screen readers.

- <svg class="w-6 h-6 text-gray-800 dark:text-gray-400" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"
+ <svg class="w-6 h-6 text-gray-800 dark:text-gray-400" aria-label="Icon description" xmlns="http://www.w3.org/2000/svg"
docs/components/banner/examples/FwbBannerBottomExample.vue (1)

46-50: Improve SVG accessibility.

The SVG used in the example should have a descriptive aria-label or title for screen readers.

- <svg class="w-6 h-6 text-gray-800 dark:text-gray-400" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"
+ <svg class="w-6 h-6 text-gray-800 dark:text-gray-400" aria-label="Icon description" xmlns="http://www.w3.org/2000/svg"
docs/components/banner.md (4)

8-8: Clarify the heading.

The heading is quite long and could be broken into a main heading and a subheading for clarity.

## Use the banner component for marketing messages

### Show CTA buttons at the top or bottom using Tailwind CSS

16-16: Clarify the sentence structure.

The sentence is long and could be broken into two for better readability.

- Get started with the sticky banner component coded with Tailwind CSS and Flowbite to show marketing, informational and CTA messages to your website visitors fixed to the top or bottom part of the page as the user scrolls down the main content area.
+ Get started with the sticky banner component coded with Tailwind CSS and Flowbite. Use it to show marketing, informational, and CTA messages fixed to the top or bottom of the page as the user scrolls through the main content area.

20-20: Consider rephrasing for clarity.

The phrase "free example" might be misleading. Consider rephrasing to clarify what is meant.

- Use this free example to show a text message for an announcement with a CTA link, an icon element and a close button to dismiss the banner.
+ Use this example to display a text message for an announcement with a CTA link, an icon element, and a close button to dismiss the banner.
Tools
LanguageTool

[misspelling] ~20-~20: Did you mean “free sample”?
Context: ...ea. ## Default sticky banner Use this free example to show a text message for an announcem...

(FREE_EXAMPLE)


81-81: Add a comma for clarity.

Add a comma after "examples" for better readability.

- For more sticky banner examples you can check [banner sections](https://flowbite.com/blocks/marketing/banner/) from Flowbite Blocks.
+ For more sticky banner examples, you can check [banner sections](https://flowbite.com/blocks/marketing/banner/) from Flowbite Blocks.
Tools
LanguageTool

[uncategorized] ~81-~81: Possible missing comma found.
Context: ...# More Examples For more sticky banner examples you can check [banner sections](https:/...

(AI_HYDRA_LEO_MISSING_COMMA)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6a83ec8 and 7330c52.

Files selected for processing (5)
  • docs/components/banner.md (1 hunks)
  • docs/components/banner/examples/FwbBannerBottomExample.vue (1 hunks)
  • docs/components/banner/examples/FwbBannerDefaultExample.vue (1 hunks)
  • src/components/FwbBanner/FwbBanner.vue (1 hunks)
  • src/index.ts (1 hunks)
Additional context used
GitHub Check: lint (18.x)
docs/components/banner/examples/FwbBannerBottomExample.vue

[warning] 3-3:
Expected 1 line break before closing bracket, but no line breaks found


[warning] 6-6:
'class' should be on a new line


[warning] 18-18:
'class' should be on a new line


[warning] 20-20:
'aria-label' should be on a new line


[warning] 20-20:
Expected 1 line break before closing bracket, but no line breaks found


[warning] 37-37:
Expected a linebreak before this attribute


[warning] 37-37:
'width' should be on a new line


[warning] 37-37:
'height' should be on a new line


[warning] 38-38:
Expected indentation of 14 spaces but found 8 spaces


[warning] 38-38:
'src' should be on a new line

LanguageTool
docs/components/banner.md

[misspelling] ~20-~20: Did you mean “free sample”?
Context: ...ea. ## Default sticky banner Use this free example to show a text message for an announcem...

(FREE_EXAMPLE)


[uncategorized] ~81-~81: Possible missing comma found.
Context: ...# More Examples For more sticky banner examples you can check [banner sections](https:/...

(AI_HYDRA_LEO_MISSING_COMMA)

Additional comments not posted (5)
src/components/FwbBanner/FwbBanner.vue (2)

2-2: Ensure accessibility roles and attributes are appropriate.

The role="banner" is used correctly, but ensure that all necessary ARIA attributes are included for accessibility. Consider adding aria-live if the content is dynamic.


26-30: Use withDefaults correctly.

Ensure that withDefaults is used correctly for setting default prop values. Verify that defineProps is used as intended in the context of Vue 3.

Verification successful

Consistent Usage of withDefaults and defineProps Verified

The usage of withDefaults and defineProps across various components in the codebase appears consistent. The pattern of defining props with default values is used similarly in multiple components, suggesting a standardized approach.

  • Instances found in components include LinkProps, BannerProps, HeadingProps, TextareaProps, TooltipProps, and many others.

No discrepancies were detected in the usage pattern.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the usage of `withDefaults` and `defineProps` in other components to ensure consistency.
rg --type vue 'withDefaults\(defineProps'

Length of output: 71


Script:

#!/bin/bash
# Find all .vue files and search for the usage of `withDefaults` and `defineProps`.
fd --extension vue --exec rg 'withDefaults\(defineProps' {}

Length of output: 2038

docs/components/banner/examples/FwbBannerDefaultExample.vue (1)

4-23: Ensure example demonstrates accessibility and best practices.

The example demonstrates the closable feature of the banner. Ensure that all interactive elements are accessible and that the example clearly illustrates the component's usage.

docs/components/banner/examples/FwbBannerBottomExample.vue (1)

43-61: Ensure example demonstrates accessibility and best practices.

The example demonstrates the position and closable features of the banner. Ensure that all interactive elements are accessible and that the example clearly illustrates the component's usage.

src/index.ts (1)

10-10: Export addition approved.

The export statement for FwbBanner is correctly added, following the established pattern in the file. This change enhances the module's functionality by making the FwbBanner component accessible for import.

Comment on lines +44 to +51
const handleCollapse = (e: MouseEvent) => {
const collapseButton = e.target as HTMLElement
const banner = collapseButton.closest('[role="banner"]') as HTMLElement | null

if (banner) {
banner.remove()
}
}
Copy link

Choose a reason for hiding this comment

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

Improve the collapse function for better performance.

The handleCollapse function removes the banner element from the DOM. Consider emitting an event instead, allowing the parent component to handle the removal, which can be more flexible and testable.

- const handleCollapse = (e: MouseEvent) => {
-   const collapseButton = e.target as HTMLElement
-   const banner = collapseButton.closest('[role="banner"]') as HTMLElement | null
-   if (banner) {
-     banner.remove()
-   }
+ const handleCollapse = () => {
+   emit('collapse')
}

In the parent component:

<fwb-banner @collapse="handleBannerCollapse" />

Comment on lines +4 to +10
<button v-if="closable" :class="defaultCollapseButtonClass" aria-label="Collapse" type="button" @click="handleCollapse">
<svg class="w-6 h-6" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"
viewBox="0 0 24 24">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M6 18 17.94 6M18 18 6.06 6" />
</svg>
</button>
Copy link

Choose a reason for hiding this comment

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

Consider making the close button more accessible.

The close button uses an SVG for the icon. Ensure the button is accessible by providing a clear aria-label and considering keyboard accessibility.

- <button v-if="closable" :class="defaultCollapseButtonClass" aria-label="Collapse" type="button" @click="handleCollapse">
+ <button v-if="closable" :class="defaultCollapseButtonClass" aria-label="Close banner" type="button" @click="handleCollapse" tabindex="0">
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
<button v-if="closable" :class="defaultCollapseButtonClass" aria-label="Collapse" type="button" @click="handleCollapse">
<svg class="w-6 h-6" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"
viewBox="0 0 24 24">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M6 18 17.94 6M18 18 6.06 6" />
</svg>
</button>
<button v-if="closable" :class="defaultCollapseButtonClass" aria-label="Close banner" type="button" @click="handleCollapse" tabindex="0">
<svg class="w-6 h-6" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"
viewBox="0 0 24 24">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M6 18 17.94 6M18 18 6.06 6" />
</svg>
</button>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 new component New component implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants