Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 50 additions & 11 deletions docs/components/dropdown.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup>
import FwbDropdownExamplePlacement from './dropdown/examples/FwbDropdownExamplePlacement.vue'
import FwbDropdownExampleAlignment from './dropdown/examples/FwbDropdownExampleAlignment.vue'
import FwbDropdownExampleListGroup from './dropdown/examples/FwbDropdownExampleListGroup.vue'
import FwbDropdownExampleTrigger from './dropdown/examples/FwbDropdownExampleTrigger.vue'
import FwbDropdownExamplePlacement from './dropdown/examples/FwbDropdownExamplePlacement.vue';
import FwbDropdownExampleAlignment from './dropdown/examples/FwbDropdownExampleAlignment.vue';
import FwbDropdownExampleListGroup from './dropdown/examples/FwbDropdownExampleListGroup.vue';
import FwbDropdownExampleTrigger from './dropdown/examples/FwbDropdownExampleTrigger.vue';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hey,
We're missing here import of FwbDropdownExampleColors for the new example to work properly.

Also we're missing FwbDropdoenExampleCloseInside import here... and please remove semicolons as we're not using them in the project.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The close inside example is fixed in #333

I corrected the other suggestions - thanks for pointing them out! I'll make sure I got the right code style in the future (my IDE suggested these changes, but I'll take extra care that it will be consistent from now on)

</script>

# Vue Dropdown - Flowbite
Expand Down Expand Up @@ -199,6 +199,45 @@ import { FwbDropdown, FwbListGroup, FwbListGroupItem } from 'flowbite-vue'
</script>
```

## Dropdown - Button colors
<fwb-dropdown-example-colors />
```vue
<template>
<fwb-dropdown text="Default" color="default">
...
</fwb-dropdown>
<fwb-dropdown text="Alternative" color="alternative">
...
</fwb-dropdown>
<fwb-dropdown text="Dark" color="dark">
...
</fwb-dropdown>
<fwb-dropdown text="Light" color="light">
...
</fwb-dropdown>
<fwb-dropdown text="Green" color="green">
...
</fwb-dropdown>
<fwb-dropdown text="Red" color="red">
...
</fwb-dropdown>
<fwb-dropdown text="Yellow" color="yellow">
...
</fwb-dropdown>
<fwb-dropdown text="Purple" color="purple">
...
</fwb-dropdown>
<fwb-dropdown text="Pink" color="pink">
...
</fwb-dropdown>
</template>

<script setup>
import { FwbDropdown } from 'flowbite-vue'
</script>
```


## Dropdown - trigger

<fwb-dropdown-example-trigger />
Expand Down Expand Up @@ -261,13 +300,13 @@ import { FwbDropdown, ListGroup, ListGroupItem } from 'flowbite-vue'
## API

### Props
| Name | Values | Default |
|----------|--------|---------|
| placement | `DropdownPlacement` | `'bottom'` |
| text | `string` | `''` |
| transition | `string` | `''` |
| closeInside | `boolean` | `false` |
| alignToEnd | `boolean` | `false` |
| Name | Values | Default |
|-------------|---------------------|------------|
| placement | `DropdownPlacement` | `'bottom'` |
| text | `string` | `''` |
| transition | `string` | `''` |
| closeInside | `boolean` | `false` |
| alignToEnd | `boolean` | `false` |
Copy link
Contributor

@coderabbitai coderabbitai bot Dec 5, 2024

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add missing color prop documentation

The color prop is missing from the props table in the API section. Please add it to maintain complete documentation.

Add this row to the props table:

 | Name        | Values              | Default    |
 |-------------|---------------------|------------|
+| color       | `ButtonVariant`     | `'default'`|
 | placement   | `DropdownPlacement` | `'bottom'` |
📝 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
| Name | Values | Default |
|-------------|---------------------|------------|
| placement | `DropdownPlacement` | `'bottom'` |
| text | `string` | `''` |
| transition | `string` | `''` |
| closeInside | `boolean` | `false` |
| alignToEnd | `boolean` | `false` |
| Name | Values | Default |
|-------------|---------------------|------------|
| color | `ButtonVariant` | `'default'`|
| placement | `DropdownPlacement` | `'bottom'` |
| text | `string` | `''` |
| transition | `string` | `''` |
| closeInside | `boolean` | `false` |
| alignToEnd | `boolean` | `false` |
🧰 Tools
🪛 Markdownlint (0.35.0)

303-303: null
Tables should be surrounded by blank lines

(MD058, blanks-around-tables)

Copy link
Collaborator

Choose a reason for hiding this comment

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

as CodeRabbitAI said... let's add color prop to this table.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Sqrcz, here's the updated props table with the color prop added:

| Name        | Values              | Default    |
|-------------|---------------------|------------|
| color       | `ButtonVariant`     | `'default'` |
| placement   | `DropdownPlacement` | `'bottom'`  |
| text        | `string`            | `''`        |
| transition  | `string`            | `''`        |
| closeInside | `boolean`           | `false`     |
| alignToEnd  | `boolean`           | `false`     |

This addition will ensure the color prop is properly documented in the API section.


### Events
| Name | Description |
Expand Down
179 changes: 179 additions & 0 deletions docs/components/dropdown/examples/FwbDropdownExampleColors.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
<template>
<div class="vp-raw flex gap-2 flex-wrap">
<fwb-dropdown
text="Default"
color="default"
>
<div class="w-52">
<p class="p-2">
Dropdown content line one
</p>
<p class="p-2">
Dropdown content line two
</p>
<p class="p-2">
Dropdown content line three
</p>
<p class="p-2">
Dropdown content line four
</p>
</div>
</fwb-dropdown>
<fwb-dropdown
text="Alternative"
color="alternative"
>
<div class="w-52">
<p class="p-2">
Dropdown content line one
</p>
<p class="p-2">
Dropdown content line two
</p>
<p class="p-2">
Dropdown content line three
</p>
<p class="p-2">
Dropdown content line four
</p>
</div>
</fwb-dropdown>
<fwb-dropdown
text="Dark"
color="dark"
>
<div class="w-52">
<p class="p-2">
Dropdown content line one
</p>
<p class="p-2">
Dropdown content line two
</p>
<p class="p-2">
Dropdown content line three
</p>
<p class="p-2">
Dropdown content line four
</p>
</div>
</fwb-dropdown>
<fwb-dropdown
text="Light"
color="light"
>
<div class="w-52">
<p class="p-2">
Dropdown content line one
</p>
<p class="p-2">
Dropdown content line two
</p>
<p class="p-2">
Dropdown content line three
</p>
<p class="p-2">
Dropdown content line four
</p>
</div>
</fwb-dropdown>
<fwb-dropdown
text="Green"
color="green"
>
<div class="w-52">
<p class="p-2">
Dropdown content line one
</p>
<p class="p-2">
Dropdown content line two
</p>
<p class="p-2">
Dropdown content line three
</p>
<p class="p-2">
Dropdown content line four
</p>
</div>
</fwb-dropdown>
<fwb-dropdown
text="Red"
color="red"
>
<div class="w-52">
<p class="p-2">
Dropdown content line one
</p>
<p class="p-2">
Dropdown content line two
</p>
<p class="p-2">
Dropdown content line three
</p>
<p class="p-2">
Dropdown content line four
</p>
</div>
</fwb-dropdown>
<fwb-dropdown
text="Yellow"
color="yellow"
>
<div class="w-52">
<p class="p-2">
Dropdown content line one
</p>
<p class="p-2">
Dropdown content line two
</p>
<p class="p-2">
Dropdown content line three
</p>
<p class="p-2">
Dropdown content line four
</p>
</div>
</fwb-dropdown>
<fwb-dropdown
text="Purple"
color="purple"
>
<div class="w-52">
<p class="p-2">
Dropdown content line one
</p>
<p class="p-2">
Dropdown content line two
</p>
<p class="p-2">
Dropdown content line three
</p>
<p class="p-2">
Dropdown content line four
</p>
</div>
</fwb-dropdown>
<fwb-dropdown
text="Pink"
color="pink"
>
<div class="w-52">
<p class="p-2">
Dropdown content line one
</p>
<p class="p-2">
Dropdown content line two
</p>
<p class="p-2">
Dropdown content line three
</p>
<p class="p-2">
Dropdown content line four
</p>
</div>
</fwb-dropdown>
</div>
</template>

<script setup>
import { FwbDropdown } from '../../../../src/index'
</script>
54 changes: 33 additions & 21 deletions src/components/FwbDropdown/FwbDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="inline-flex items-center">
<fwb-slot-listener @click="onToggle">
<slot name="trigger">
<fwb-button>
<fwb-button :color="color">
{{ text }}
<template #suffix>
<svg
Expand Down Expand Up @@ -50,6 +50,7 @@ import type { DropdownPlacement } from './types'
import FwbButton from '@/components/FwbButton/FwbButton.vue'
import FwbSlotListener from '@/components/utils/FwbSlotListener/FwbSlotListener.vue'
import { useDropdownClasses } from './composables/useDropdownClasses'
import type { ButtonVariant } from '@/components/FwbButton/types'

const visible = ref(false)
const onHide = () => {
Expand All @@ -61,34 +62,33 @@ const props = withDefaults(
defineProps<{
placement?: DropdownPlacement
text?: string
color?: ButtonVariant
transition?: string
closeInside?: boolean
alignToEnd?: boolean
}>(),
{
placement: 'bottom',
text: '',
color: 'default',
transition: '',
closeInside: false,
alignToEnd: false,
},
)

const emit = defineEmits<{
'show': []
'hide': []
show: []
hide: []
}>()

watch(
visible,
(isVisible: boolean) => {
if (isVisible) {
emit('show')
} else {
emit('hide')
}
},
)
watch(visible, (isVisible: boolean) => {
if (isVisible) {
emit('show')
} else {
emit('hide')
}
})

const placementTransitionMap: Record<DropdownPlacement, string> = {
bottom: 'to-bottom',
Expand Down Expand Up @@ -132,41 +132,53 @@ onClickOutside(wrapper, () => {
}

/* to top */
.to-top-enter-active, .to-top-leave-to {
.to-top-enter-active,
.to-top-leave-to {
opacity: 0;
transform: translateY(10px);
}
.to-top-leave, .to-top-enter-to {

.to-top-leave,
.to-top-enter-to {
opacity: 1;
transform: translateY(0);
}

/* to right */
.to-right-enter-active, .to-right-leave-to {
.to-right-enter-active,
.to-right-leave-to {
opacity: 0;
transform: translateX(-10px);
}
.to-right-leave, .to-right-enter-to {

.to-right-leave,
.to-right-enter-to {
opacity: 1;
transform: translateX(0);
}

/* to bottom */
.to-bottom-enter-active, .to-bottom-leave-to {
.to-bottom-enter-active,
.to-bottom-leave-to {
opacity: 0;
transform: translateY(-10px);
}
.to-bottom-leave, .to-bottom-enter-to {

.to-bottom-leave,
.to-bottom-enter-to {
opacity: 1;
transform: translateY(0);
}

/* to left */
.to-left-enter-active, .to-left-leave-to {
.to-left-enter-active,
.to-left-leave-to {
opacity: 0;
transform: translateX(10px);
}
.to-left-leave, .to-left-enter-to {

.to-left-leave,
.to-left-enter-to {
opacity: 1;
transform: translateX(0);
}
Expand Down