@redseed/redseed-ui-vue3 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -16,6 +16,8 @@ import ButtonTertiaryFull from './src/components/Button/ButtonTertiaryFull.vue'
16
16
  import ButtonTertiaryFullRounded from './src/components/Button/ButtonTertiaryFullRounded.vue'
17
17
  import ButtonTertiaryRounded from './src/components/Button/ButtonTertiaryRounded.vue'
18
18
  import Card from './src/components/Card/Card.vue'
19
+ import DropdownMenu from './src/components/DropdownMenu/DropdownMenu.vue'
20
+ import DropdownOption from './src/components/DropdownMenu/DropdownOption.vue'
19
21
  import FormFieldCheckbox from './src/components/FormField/FormFieldCheckbox.vue'
20
22
  import FormFieldEmail from './src/components/FormField/FormFieldEmail.vue'
21
23
  import FormFieldHidden from './src/components/FormField/FormFieldHidden.vue'
@@ -61,6 +63,8 @@ export {
61
63
  ButtonTertiaryFullRounded,
62
64
  ButtonTertiaryRounded,
63
65
  Card,
66
+ DropdownMenu,
67
+ DropdownOption,
64
68
  FormFieldCheckbox,
65
69
  FormFieldEmail,
66
70
  FormFieldHidden,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redseed/redseed-ui-vue3",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "RedSeed UI Vue 3 components",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -150,15 +150,18 @@ const buttonSlotIconClass = computed(() => [
150
150
  @apply px-1.5;
151
151
  }
152
152
  .button-slot__icon {
153
- @apply w-3 h-3;
153
+ @apply w-4 h-4;
154
154
  }
155
155
  }
156
156
  // modifier sm size
157
157
  &--sm {
158
158
  @apply text-sm;
159
- @apply px-3 py-1.5;
159
+ @apply px-3 py-2;
160
160
  &--icon {
161
- @apply px-1.5;
161
+ @apply px-2;
162
+ }
163
+ .button-slot__icon {
164
+ @apply w-5 h-5;
162
165
  }
163
166
  }
164
167
  // modifier md size
@@ -168,6 +171,12 @@ const buttonSlotIconClass = computed(() => [
168
171
  &--icon {
169
172
  @apply px-2;
170
173
  }
174
+ .button-slot__icon {
175
+ @apply w-5 h-5;
176
+ &--only {
177
+ @apply w-6 h-6;
178
+ }
179
+ }
171
180
  }
172
181
  // modifier lg size
173
182
  &--lg {
@@ -178,6 +187,9 @@ const buttonSlotIconClass = computed(() => [
178
187
  }
179
188
  .button-slot__icon {
180
189
  @apply w-5 h-5;
190
+ &--only {
191
+ @apply w-7 h-7;
192
+ }
181
193
  }
182
194
  }
183
195
  // modifier icon at the end
@@ -0,0 +1,123 @@
1
+ <script setup>
2
+ import { computed, onMounted, onUnmounted, ref } from 'vue'
3
+ import ButtonTertiary from '../Button/ButtonTertiary.vue'
4
+
5
+ const props = defineProps({
6
+ right: {
7
+ type: Boolean,
8
+ default: false,
9
+ },
10
+ left: {
11
+ type: Boolean,
12
+ default: false,
13
+ },
14
+ })
15
+
16
+ const isOpen = ref(false)
17
+
18
+ const defaultAlignment = computed(() => !props.right && !props.left)
19
+
20
+ const containerClass = computed(() => [
21
+ 'dropdown-menu__container',
22
+ {
23
+ 'dropdown-menu__container--open': isOpen.value,
24
+ 'dropdown-menu__container--left': props.left || defaultAlignment.value,
25
+ 'dropdown-menu__container--right': props.right,
26
+ },
27
+ ])
28
+
29
+ function open() {
30
+ isOpen.value = true
31
+ }
32
+
33
+ function close() {
34
+ isOpen.value = false
35
+ }
36
+
37
+ function closeOnEscape(e) {
38
+ if (isOpen.value && e.key === 'Escape') {
39
+ isOpen.value = false
40
+ }
41
+ }
42
+
43
+ onMounted(() => document.addEventListener('keydown', closeOnEscape))
44
+ onUnmounted(() => document.removeEventListener('keydown', closeOnEscape))
45
+ </script>
46
+ <template>
47
+ <div class="dropdown-menu">
48
+ <slot name="trigger" :open="open">
49
+ <ButtonTertiary @click="open">
50
+ <template #icon v-if="$slots['trigger-icon']">
51
+ <slot name=trigger-icon></slot>
52
+ </template>
53
+ <template #default v-if="$slots['trigger-label']">
54
+ <slot name="trigger-label"></slot>
55
+ </template>
56
+ </ButtonTertiary>
57
+ </slot>
58
+
59
+ <!-- Full Screen Dropdown Overlay -->
60
+ <div v-show="isOpen"
61
+ class="dropdown-menu__overlay"
62
+ @click="close"
63
+ ></div>
64
+
65
+ <transition
66
+ enter-active-class="enter-active-class"
67
+ enter-from-class="enter-from-class"
68
+ enter-to-class="enter-to-class"
69
+ leave-active-class="leave-active-class"
70
+ leave-from-class="leave-from-class"
71
+ leave-to-class="leave-to-class"
72
+ >
73
+ <div
74
+ v-show="isOpen"
75
+ :class="containerClass"
76
+ @click="close"
77
+ >
78
+ <slot></slot>
79
+ </div>
80
+ </transition>
81
+ </div>
82
+ </template>
83
+ <style lang="scss" scoped>
84
+ .enter-active-class {
85
+ @apply transition ease-out duration-200;
86
+ }
87
+ .enter-from-class {
88
+ @apply transform opacity-0 scale-95;
89
+ }
90
+ .enter-to-class {
91
+ @apply transform opacity-100 scale-100;
92
+ }
93
+ .leave-active-class {
94
+ @apply transition ease-in duration-75;
95
+ }
96
+ .leave-from-class {
97
+ @apply transform opacity-100 scale-100;
98
+ }
99
+ .leave-to-class {
100
+ @apply transform opacity-0 scale-95;
101
+ }
102
+
103
+ .dropdown-menu {
104
+ @apply w-fit relative;
105
+ &__overlay {
106
+ @apply fixed inset-0 z-40;
107
+ }
108
+ &__container {
109
+ @apply hidden absolute z-50 mt-2 p-2 w-76 origin-top;
110
+ @apply rounded-md shadow-full-light bg-white;
111
+ @apply flex flex-col space-y-2;
112
+ &--open {
113
+ @apply block;
114
+ }
115
+ &--left {
116
+ @apply origin-top-left left-0;
117
+ }
118
+ &--right {
119
+ @apply origin-top-right right-0;
120
+ }
121
+ }
122
+ }
123
+ </style>
@@ -0,0 +1,16 @@
1
+ <script setup>
2
+ const emit = defineEmits(['click'])
3
+ </script>
4
+ <template>
5
+ <div class="dropdown-option"
6
+ @click="$emit('click')"
7
+ >
8
+ <slot></slot>
9
+ </div>
10
+ </template>
11
+ <style lang="scss" scoped>
12
+ .dropdown-option {
13
+ @apply cursor-pointer p-4 bg-white rounded-md text-base transition;
14
+ @apply hover:bg-gray-200;
15
+ }
16
+ </style>
@@ -77,13 +77,13 @@ watch(() => props.show, () => {
77
77
  }
78
78
  })
79
79
 
80
- const close = () => {
80
+ function close() {
81
81
  if (props.closeable) {
82
82
  emit('close')
83
83
  }
84
84
  }
85
85
 
86
- const closeOnEscape = (e) => {
86
+ function closeOnEscape(e) {
87
87
  if (e.key === 'Escape' && props.show) {
88
88
  close()
89
89
  }
@@ -115,12 +115,12 @@ onUnmounted(() => {
115
115
  </transition>
116
116
 
117
117
  <transition
118
- enter-active-class="ease-out duration-200"
119
- enter-from-class="opacity-0 xs:scale-80"
120
- enter-to-class="opacity-100 xs:scale-100"
121
- leave-active-class="ease-in duration-100"
122
- leave-from-class="opacity-100 xs:scale-100"
123
- leave-to-class="opacity-0 xs:scale-80"
118
+ enter-active-class="enter-active-class"
119
+ enter-from-class="enter-from-class"
120
+ enter-to-class="enter-to-class"
121
+ leave-active-class="leave-active-class"
122
+ leave-from-class="leave-from-class"
123
+ leave-to-class="leave-to-class"
124
124
  >
125
125
  <div v-if="show"
126
126
  :class="modalContentClass"
@@ -150,6 +150,25 @@ onUnmounted(() => {
150
150
  </teleport>
151
151
  </template>
152
152
  <style lang="scss" scoped>
153
+ .enter-active-class {
154
+ @apply transition ease-out duration-200;
155
+ }
156
+ .enter-from-class {
157
+ @apply transform opacity-0 scale-95;
158
+ }
159
+ .enter-to-class {
160
+ @apply transform opacity-100 scale-100;
161
+ }
162
+ .leave-active-class {
163
+ @apply transition ease-in duration-75;
164
+ }
165
+ .leave-from-class {
166
+ @apply transform opacity-100 scale-100;
167
+ }
168
+ .leave-to-class {
169
+ @apply transform opacity-0 scale-95;
170
+ }
171
+
153
172
  .modal {
154
173
  @apply fixed inset-0 overflow-y-auto px-4 py-6 md:px-0 z-50;
155
174
  &__background-wrapper {