From fb65cdcef886f2a1cfb6a1a49d8e965779debf39 Mon Sep 17 00:00:00 2001 From: Alexandr Date: Mon, 11 Jul 2022 15:49:24 +0300 Subject: [PATCH] feat: gap dropdown --- .../examples/DropdownPlacementExample.vue | 15 +++++++++++++-- .../Dropdown/composables/useDropdownClasses.ts | 10 ++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/docs/guide/dropdown/examples/DropdownPlacementExample.vue b/docs/guide/dropdown/examples/DropdownPlacementExample.vue index 6f69e78..3714ebd 100644 --- a/docs/guide/dropdown/examples/DropdownPlacementExample.vue +++ b/docs/guide/dropdown/examples/DropdownPlacementExample.vue @@ -12,8 +12,19 @@ -
- Padding content + diff --git a/src/components/Dropdown/composables/useDropdownClasses.ts b/src/components/Dropdown/composables/useDropdownClasses.ts index 44e15ae..deca50d 100644 --- a/src/components/Dropdown/composables/useDropdownClasses.ts +++ b/src/components/Dropdown/composables/useDropdownClasses.ts @@ -5,6 +5,8 @@ import type { DropdownPlacement } from '../types' const defaultDropdownClasses = 'absolute z-10 bg-white divide-y divide-gray-100 rounded shadow dark:bg-gray-700' +const defaultGapInPx = 8 + const placementDropdownClasses: Record = { bottom: '', left: 'top-0', @@ -20,16 +22,16 @@ export type UseDropdownClassesProps = { const placementCalculators: Record string> = { bottom(rect: DOMRect): string { - return `bottom: -${rect.height}px;` + return `bottom: -${rect.height + defaultGapInPx}px;` }, left(rect: DOMRect): string { - return `left: -${rect.width}px;` + return `left: -${rect.width + defaultGapInPx}px;` }, right(rect: DOMRect): string { - return `right: -${rect.width}px;` + return `right: -${rect.width + defaultGapInPx}px;` }, top(rect: DOMRect): string { - return `top: -${rect.height}px;` + return `top: -${rect.height + defaultGapInPx}px;` }, }