fix: spoiler now work in paragraph wrapped elements

This commit is contained in:
grassblock 2025-05-17 18:11:54 +08:00
parent 98ee7a3527
commit 21025cab50
2 changed files with 16 additions and 1 deletions

View file

@ -1,11 +1,21 @@
---
const { tip = '' } = Astro.props
---
{/* TODO: make it work in paragraph wrapped elements */}
<span class="spoiler" title={tip}>
<slot/>
</span>
<style>
:global(.spoiler p) {
background-color: #252525;
color: #252525;
transition: color 0.5s;
width: fit-content;
}
:global(.spoiler:hover p) {
color: #ffffff;
}
.spoiler {
background-color: #252525;
color: #252525;

View file

@ -14,4 +14,9 @@ testestestest
~~This is the content of the spoiler.~~
</Spoiler>
<Spoiler tip="Spoiler Title">
~~This is the content of another spoiler.~~
</Spoiler>
<FediStatuses instanceDomain='portal.gb0.dev' userId='me' />