Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
55 changes: 48 additions & 7 deletions docs/components/dropdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import FwbDropdownExamplePlacement from './dropdown/examples/FwbDropdownExamplePlacement.vue'
import FwbDropdownExampleAlignment from './dropdown/examples/FwbDropdownExampleAlignment.vue'
import FwbDropdownExampleListGroup from './dropdown/examples/FwbDropdownExampleListGroup.vue'
import FwbDropdownExampleColors from './dropdown/examples/FwbDropdownExampleColors.vue'
import FwbDropdownExampleTrigger from './dropdown/examples/FwbDropdownExampleTrigger.vue'
</script>

Expand Down Expand Up @@ -199,6 +200,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 +301,14 @@ 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` | `''` |
| color | `ButtonVariant` | `'default'` |
| transition | `string` | `''` |
| closeInside | `boolean` | `false` |
| alignToEnd | `boolean` | `false` |

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