@saasmakers/ui 1.4.0 → 1.4.1
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.
|
@@ -15,6 +15,61 @@ const emit = defineEmits<{
|
|
|
15
15
|
|
|
16
16
|
const { getIcon } = useLayerIcons()
|
|
17
17
|
|
|
18
|
+
const actionPillClasses = computed(() => {
|
|
19
|
+
switch (props.status) {
|
|
20
|
+
case 'error':
|
|
21
|
+
return 'bg-red-600/20 text-red-400 hover:bg-red-600/30 focus-visible:ring-red-500 dark:bg-red-400/15 dark:text-red-400 dark:hover:bg-red-400/25'
|
|
22
|
+
case 'info':
|
|
23
|
+
return 'bg-indigo-600/20 text-indigo-400 hover:bg-indigo-600/30 focus-visible:ring-indigo-500 dark:bg-indigo-400/15 dark:text-indigo-400 dark:hover:bg-indigo-400/25'
|
|
24
|
+
case 'success':
|
|
25
|
+
return 'bg-green-600/20 text-green-400 hover:bg-green-600/30 focus-visible:ring-green-500 dark:bg-green-400/15 dark:text-green-400 dark:hover:bg-green-400/25'
|
|
26
|
+
case 'warning':
|
|
27
|
+
return 'bg-orange-600/20 text-orange-400 hover:bg-orange-600/30 focus-visible:ring-orange-500 dark:bg-orange-400/15 dark:text-orange-400 dark:hover:bg-orange-400/25'
|
|
28
|
+
default:
|
|
29
|
+
return ''
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const closeHoverClasses = computed(() => {
|
|
34
|
+
switch (props.status) {
|
|
35
|
+
case 'error':
|
|
36
|
+
return 'hover:text-red-600 dark:hover:text-red-400'
|
|
37
|
+
case 'info':
|
|
38
|
+
return 'hover:text-indigo-600 dark:hover:text-indigo-400'
|
|
39
|
+
case 'success':
|
|
40
|
+
return 'hover:text-green-600 dark:hover:text-green-400'
|
|
41
|
+
case 'warning':
|
|
42
|
+
return 'hover:text-orange-600 dark:hover:text-orange-400'
|
|
43
|
+
default:
|
|
44
|
+
return ''
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const isDismissibleByClick = computed(() => {
|
|
49
|
+
return props.hasClose && !props.action
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const rootInteractiveBindings = computed(() => {
|
|
53
|
+
if (!isDismissibleByClick.value) {
|
|
54
|
+
return {}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
onClick: onClose,
|
|
59
|
+
onKeydown: (event: KeyboardEvent) => {
|
|
60
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
61
|
+
if (event.key === ' ') {
|
|
62
|
+
event.preventDefault()
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
onClose(event)
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
role: 'button' as const,
|
|
69
|
+
tabindex: 0,
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
|
|
18
73
|
function onAction(event: KeyboardEvent | MouseEvent) {
|
|
19
74
|
if (props.action) {
|
|
20
75
|
emit('action', event as MouseEvent, props)
|
|
@@ -30,13 +85,9 @@ function onClose(event: KeyboardEvent | MouseEvent) {
|
|
|
30
85
|
|
|
31
86
|
<template>
|
|
32
87
|
<div
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
tabindex="0"
|
|
37
|
-
@click="onClose"
|
|
38
|
-
@keydown.enter="onClose"
|
|
39
|
-
@keydown.space.prevent="onClose"
|
|
88
|
+
v-bind="rootInteractiveBindings"
|
|
89
|
+
class="group flex select-none items-center rounded-full bg-gray-900 px-3 py-2 text-base text-white font-normal dark:bg-gray-800 dark:text-gray-100 dark:ring-1 dark:ring-gray-700"
|
|
90
|
+
:class="{ 'cursor-pointer': isDismissibleByClick }"
|
|
40
91
|
>
|
|
41
92
|
<BaseIcon
|
|
42
93
|
class="pointer-events-none flex-initial"
|
|
@@ -44,40 +95,46 @@ function onClose(event: KeyboardEvent | MouseEvent) {
|
|
|
44
95
|
:text="text"
|
|
45
96
|
/>
|
|
46
97
|
|
|
47
|
-
<
|
|
48
|
-
|
|
98
|
+
<button
|
|
99
|
+
v-if="action"
|
|
100
|
+
class="ml-2 rounded-full px-2.5 py-1 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-gray-900 dark:focus-visible:ring-offset-gray-800"
|
|
101
|
+
:class="actionPillClasses"
|
|
102
|
+
type="button"
|
|
103
|
+
@click.stop="onAction"
|
|
104
|
+
>
|
|
105
|
+
<BaseText
|
|
106
|
+
bold
|
|
107
|
+
class="pointer-events-none"
|
|
108
|
+
no-wrap
|
|
109
|
+
:text="action.label"
|
|
110
|
+
uppercase
|
|
111
|
+
/>
|
|
112
|
+
</button>
|
|
113
|
+
|
|
114
|
+
<template v-if="hasClose">
|
|
115
|
+
<div class="ml-2 mr-1.5 h-5 border-l border-gray-700 flex-initial dark:border-gray-600" />
|
|
49
116
|
|
|
50
117
|
<button
|
|
51
|
-
|
|
118
|
+
v-if="action"
|
|
119
|
+
class="cursor-pointer bg-transparent text-gray-500 flex-initial dark:text-gray-500"
|
|
120
|
+
:class="closeHoverClasses"
|
|
52
121
|
type="button"
|
|
53
|
-
@click.stop="
|
|
122
|
+
@click.stop="onClose"
|
|
54
123
|
>
|
|
55
|
-
<
|
|
56
|
-
bold
|
|
124
|
+
<BaseIcon
|
|
57
125
|
class="pointer-events-none"
|
|
58
|
-
:
|
|
59
|
-
'text-red-400 dark:text-red-600': status === 'error',
|
|
60
|
-
'text-indigo-400 dark:text-indigo-600': status === 'info',
|
|
61
|
-
'text-orange-400 dark:text-orange-600': status === 'warning',
|
|
62
|
-
'text-teal-400 dark:text-teal-600': status === 'success',
|
|
63
|
-
}"
|
|
64
|
-
no-wrap
|
|
65
|
-
:text="action.label"
|
|
66
|
-
uppercase
|
|
126
|
+
:icon="getIcon('close')"
|
|
67
127
|
/>
|
|
68
128
|
</button>
|
|
69
|
-
</template>
|
|
70
|
-
|
|
71
|
-
<template v-if="hasClose">
|
|
72
|
-
<div class="ml-2 mr-1.5 h-5 border-l border-gray-700 flex-initial dark:border-gray-300" />
|
|
73
129
|
|
|
74
130
|
<BaseIcon
|
|
131
|
+
v-else
|
|
75
132
|
class="text-gray-500 flex-initial dark:text-gray-500"
|
|
76
133
|
:class="{
|
|
77
134
|
'group-hover:text-red-600 dark:group-hover:text-red-400': status === 'error',
|
|
78
135
|
'group-hover:text-indigo-600 dark:group-hover:text-indigo-400': status === 'info',
|
|
136
|
+
'group-hover:text-green-600 dark:group-hover:text-green-400': status === 'success',
|
|
79
137
|
'group-hover:text-orange-600 dark:group-hover:text-orange-400': status === 'warning',
|
|
80
|
-
'group-hover:text-teal-600 dark:group-hover:text-teal-400': status === 'success',
|
|
81
138
|
}"
|
|
82
139
|
:icon="getIcon('close')"
|
|
83
140
|
/>
|