Skip to content

Commit

Permalink
tweak tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
taiyme committed Feb 22, 2024
1 parent d15f114 commit 9a00745
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
9 changes: 8 additions & 1 deletion packages/frontend/src/components/MkTooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SPDX-License-Identifier: AGPL-3.0-only
:leaveToClass="defaultStore.state.animation ? $style.transition_tooltip_leaveTo : ''"
appear @afterLeave="emit('closed')"
>
<div v-show="showing" ref="el" :class="$style.root" class="_acrylic _shadow" :style="{ zIndex, maxWidth: maxWidth + 'px' }">
<div v-show="showing" ref="el" :class="[$style.root, { [$style.primary]: primary }]" class="_acrylic _shadow" :style="{ zIndex, maxWidth: maxWidth + 'px' }">
<slot>
<template v-if="text">
<Mfm v-if="asMfm" :text="text"/>
Expand All @@ -38,6 +38,7 @@ const props = withDefaults(defineProps<{
maxWidth?: number;
direction?: 'top' | 'bottom' | 'right' | 'left';
innerMargin?: number;
primary?: boolean;
}>(), {
maxWidth: 250,
direction: 'top',
Expand Down Expand Up @@ -113,5 +114,11 @@ onUnmounted(() => {
border: solid 0.5px var(--divider);
pointer-events: none;
transform-origin: center center;

&.primary {
border: none;
background: var(--accent);
color: var(--fgOnAccent);
}
}
</style>
2 changes: 2 additions & 0 deletions packages/frontend/src/scripts/get-note-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ export function getRenoteMenu(props: {
// @ts-expect-error
targetElement: props.renoteButton.value,
text: i18n.ts._tms.didPakuru,
primary: true,
});
}).catch((err) => {
os.alert({
Expand All @@ -588,6 +589,7 @@ export function getRenoteMenu(props: {
// @ts-expect-error
targetElement: props.renoteButton.value,
text: i18n.ts._tms.didNumberquote,
primary: true,
});
}).catch((err) => {
os.alert({
Expand Down
7 changes: 5 additions & 2 deletions packages/frontend/src/scripts/tms/tooltip-from-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import { popup } from '@/os.js';
export const tooltipFromElement = (props: {
targetElement: HTMLElement;
text: string;
asMfm?: boolean;
maxWidth?: number;
direction?: 'top' | 'bottom' | 'right' | 'left';
primary?: boolean;
}) => {
const showing = ref(true);
window.setTimeout(() => {
Expand All @@ -17,7 +21,6 @@ export const tooltipFromElement = (props: {
popup(defineAsyncComponent(() => import('@/components/MkTooltip.vue')), {
// @ts-expect-error
showing,
targetElement: props.targetElement,
text: props.text,
...props,
}, {}, 'closed');
};

0 comments on commit 9a00745

Please sign in to comment.