Skip to content

Commit 618e69a

Browse files
committed
Floating: remove props; class, maxWidth. remove padding on floating-content.
1 parent cfd632a commit 618e69a

File tree

3 files changed

+30
-23
lines changed

3 files changed

+30
-23
lines changed

src/components/Floating.vue

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
// </button>
1010
// </template>
1111
// <template #content>
12-
// My Long Long Long Long Long Long Long Long Long Long Tooltip
12+
// <div style="max-width: 300px;">
13+
// My Long Long Long Long Long Long Long Long Long Long Tooltip
14+
// </div>
1315
// </template>
1416
// </Floating>
1517
//
@@ -19,8 +21,6 @@
1921
// - interactive: keeping the tooltip open when the user hovers over the tooltip, default false
2022
// - delay: [delayEnter, delayLeave] for hover, default 0 (means [0, 0])
2123
// - arrow: boolean, default true
22-
// - class: string as css class, default undefined.
23-
// - maxWidth: string as css width, default undefined.
2424
// - theme: string as data-theme, default 'light'.
2525
// - trigger: boolean to control the tooltip visibility.
2626
// - onShow: () => void, callback when the tooltip is shown.
@@ -55,8 +55,6 @@ type Props = {
5555
interactive?: boolean;
5656
delay?: number | [number, number];
5757
arrow?: boolean;
58-
class?: string;
59-
maxWidth?: number;
6058
theme?: string;
6159
trigger?: boolean;
6260
onShow?: OnShowFn;
@@ -79,8 +77,6 @@ const {
7977
interactive,
8078
delay,
8179
arrow: arrowProp,
82-
class: classProp,
83-
maxWidth: maxWidthProp,
8480
theme: themeProp,
8581
trigger: triggerRef,
8682
} = toRefs(props);
@@ -160,28 +156,20 @@ const arrowStyles = computed(() => {
160156
bottom: "",
161157
};
162158
});
163-
164-
const customFloatingStyles = computed(() => {
165-
return {
166-
...floatingStyles.value,
167-
maxWidth: `${maxWidthProp.value}px`,
168-
};
169-
});
170159
</script>
171160

172161
<template>
173162
<span ref="targetRef">
174163
<slot />
175164
</span>
176-
<Teleport to="body">
165+
<Teleport v-if="slots.content" to="body">
177166
<div
178167
v-if="isTriggered"
179168
ref="floatingRef"
180169
class="floating-wrapper"
181-
:class="classProp"
182170
:data-theme="themeProp"
183171
:data-placement="placed0"
184-
:style="customFloatingStyles"
172+
:style="floatingStyles"
185173
>
186174
<div class="floating-content" :data-theme="themeProp">
187175
<slot name="content" />
@@ -206,11 +194,12 @@ const customFloatingStyles = computed(() => {
206194
background-color: white;
207195
border: 1px solid black;
208196
border-radius: 3px;
209-
padding: 7px;
210197
z-index: 10000;
211198
212199
.floating-content {
213200
display: grid;
201+
background-color: white;
202+
z-index: 10002;
214203
}
215204
216205
.floating-arrow {
@@ -221,13 +210,18 @@ const customFloatingStyles = computed(() => {
221210
height: 8px;
222211
transform: rotate(45deg);
223212
box-sizing: border-box;
213+
z-index: 10001;
224214
}
225215
}
226216
227217
.floating-wrapper[data-theme~="light"] {
228218
background-color: white;
229219
border: 1px solid black;
230220
221+
.floating-content {
222+
background-color: white;
223+
}
224+
231225
.floating-arrow {
232226
background-color: white;
233227
border: 0px solid black;

src/components/MarkdownRendererBlockLink.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ const parseMetadata = (html: string) => {
8484
</a>
8585
</template>
8686
<template #content>
87-
<iframe v-if="url" :src="url" class="small" />
87+
<div class="floating-iframe">
88+
<iframe v-if="url" :src="url" class="small" />
89+
</div>
8890
</template>
8991
</Floating>
9092
</div>
@@ -124,6 +126,7 @@ iframe.small {
124126
transform-origin: top left;
125127
width: 167%; /* = 1.0/0.6 */
126128
height: 162%;
129+
border: 0;
127130
}
128131
.image {
129132
justify-content: right;
@@ -132,4 +135,9 @@ iframe.small {
132135
.image img {
133136
max-width: 200px;
134137
}
138+
.floating-iframe {
139+
overflow: hidden;
140+
padding: 2px;
141+
box-sizing: border-box;
142+
}
135143
</style>

src/components/Preview.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ const render = (text: string) => $md.render(text);
3939
<span class="hover-box">
4040
<Floating
4141
placement="top-start"
42-
:max-width="500"
43-
class="large-font"
4442
theme="warning"
4543
:delay="200"
4644
>
@@ -50,7 +48,9 @@ const render = (text: string) => $md.render(text);
5048
</button>
5149
</template>
5250
<template #content>
53-
Virtual DOM is a programming concept where an ideal, or "virtual", representation of a UI is kept in memory and synced with the "real" DOM by a library such as React. This process is called reconciliation.
51+
<div class="hint">
52+
Virtual DOM is a programming concept where an ideal, or "virtual", representation of a UI is kept in memory and synced with the "real" DOM by a library such as React. This process is called reconciliation.
53+
</div>
5454
</template>
5555
</Floating>
5656
</span>
@@ -98,8 +98,10 @@ code {
9898
display: none;
9999
}
100100
101-
.large-font {
101+
.hint {
102102
font-size: 1.5em;
103+
max-width: 400px;
104+
padding: 6px;
103105
}
104106
105107
.hover-anchor {
@@ -119,6 +121,9 @@ code {
119121
background-color: yellow;
120122
color: red;
121123
border-color: red;
124+
.floating-content {
125+
background-color: yellow;
126+
}
122127
.floating-arrow {
123128
background-color: yellow;
124129
border-color: red;

0 commit comments

Comments
 (0)