generated from tpl/obsidian-sample-plugin
Add clear button to rating input
This commit is contained in:
parent
45d80517a5
commit
25e980eff1
|
@ -1,5 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Star, StarHalf } from "lucide-svelte";
|
import { Star, StarHalf, X } from "lucide-svelte";
|
||||||
import type { Snippet } from "svelte";
|
import type { Snippet } from "svelte";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
@ -125,11 +125,26 @@
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
<button
|
||||||
|
class="clear-rating"
|
||||||
|
type="button"
|
||||||
|
aria-label="Clear rating"
|
||||||
|
class:hidden={value === 0}
|
||||||
|
onclick={() => (value = 0)}
|
||||||
|
>
|
||||||
|
<X color="var(--text-muted)" />
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
$clear-btn-size: 32px;
|
||||||
|
|
||||||
.rating-input {
|
.rating-input {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--size-4-2);
|
||||||
|
padding-left: calc($clear-btn-size + var(--size-4-2));
|
||||||
|
|
||||||
.ctrl {
|
.ctrl {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -140,16 +155,37 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
:global(svg) {
|
|
||||||
position: absolute;
|
|
||||||
width: var(--icon-size);
|
|
||||||
height: var(--icon-size);
|
|
||||||
}
|
|
||||||
|
|
||||||
.rating-item {
|
.rating-item {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: var(--icon-size);
|
width: var(--icon-size);
|
||||||
height: var(--icon-size);
|
height: var(--icon-size);
|
||||||
|
|
||||||
|
:global(svg) {
|
||||||
|
position: absolute;
|
||||||
|
width: var(--icon-size);
|
||||||
|
height: var(--icon-size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.clear-rating {
|
||||||
|
all: unset;
|
||||||
|
box-sizing: border-box;
|
||||||
|
cursor: pointer;
|
||||||
|
height: $clear-btn-size;
|
||||||
|
width: $clear-btn-size;
|
||||||
|
border-radius: 50%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
&:active,
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--background-modifier-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.hidden {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue