Skip to content

Commit c07756c

Browse files
committed
add left, right position options
1 parent 3e6f80d commit c07756c

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

packages/common-ui/src/components/SkMouseTrapToolTip.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface SkMouseTrapToolTipProps {
2121
* The position of the tooltip relative to the wrapped element.
2222
* @default 'top'
2323
*/
24-
position?: 'top' | 'bottom';
24+
position?: 'top' | 'bottom' | 'left' | 'right';
2525

2626
/**
2727
* Whether to show the tooltip when the Ctrl key is pressed.

packages/common-ui/src/components/SkMouseTrapToolTip.vue

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111
<div
1212
v-if="showTooltip && isControlKeyPressed && !disabled"
1313
class="sk-mousetrap-tooltip"
14-
:class="{ 'sk-mt-tooltip-top': position === 'top', 'sk-mt-tooltip-bottom': position === 'bottom' }"
14+
:class="{
15+
'sk-mt-tooltip-top': position === 'top',
16+
'sk-mt-tooltip-bottom': position === 'bottom',
17+
'sk-mt-tooltip-left': position === 'left',
18+
'sk-mt-tooltip-right': position === 'right'
19+
}"
1520
>
1621
{{ formattedHotkey }}
1722
</div>
@@ -40,7 +45,7 @@ export default defineComponent({
4045
default: false,
4146
},
4247
position: {
43-
type: String as PropType<'top' | 'bottom'>,
48+
type: String as PropType<'top' | 'bottom' | 'left' | 'right'>,
4449
default: 'top',
4550
},
4651
showTooltip: {
@@ -211,18 +216,34 @@ export default defineComponent({
211216
white-space: nowrap;
212217
pointer-events: none;
213218
z-index: 9999;
214-
left: 50%;
215-
transform: translateX(-50%);
216219
}
217220
218221
.sk-mt-tooltip-top {
219222
bottom: 100%;
220223
margin-bottom: 5px;
224+
left: 50%;
225+
transform: translateX(-50%);
221226
}
222227
223228
.sk-mt-tooltip-bottom {
224229
top: 100%;
225230
margin-top: 5px;
231+
left: 50%;
232+
transform: translateX(-50%);
233+
}
234+
235+
.sk-mt-tooltip-left {
236+
right: 100%;
237+
margin-right: 5px;
238+
top: 50%;
239+
transform: translateY(-50%);
240+
}
241+
242+
.sk-mt-tooltip-right {
243+
left: 100%;
244+
margin-left: 5px;
245+
top: 50%;
246+
transform: translateY(-50%);
226247
}
227248
228249
/* Highlight effects when Ctrl is pressed */

0 commit comments

Comments
 (0)