2023-10-03 01:29:20 +08:00
|
|
|
<script lang="ts">
|
|
|
|
import { Like } from "@gradio/icons";
|
|
|
|
import { Dislike } from "@gradio/icons";
|
|
|
|
|
2023-11-25 02:03:18 +08:00
|
|
|
export let handle_action: (selected: string | null) => void;
|
2023-10-03 01:29:20 +08:00
|
|
|
|
2023-11-25 02:03:18 +08:00
|
|
|
let selected: "like" | "dislike" | null = null;
|
2023-10-03 01:29:20 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<button
|
|
|
|
on:click={() => {
|
2023-11-25 02:03:18 +08:00
|
|
|
selected = "like";
|
|
|
|
handle_action(selected);
|
2023-10-03 01:29:20 +08:00
|
|
|
}}
|
2023-11-25 02:03:18 +08:00
|
|
|
aria-label={selected === "like" ? "clicked like" : "like"}
|
|
|
|
>
|
|
|
|
<Like selected={selected === "like"} />
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<button
|
|
|
|
on:click={() => {
|
|
|
|
selected = "dislike";
|
|
|
|
handle_action(selected);
|
2023-10-03 01:29:20 +08:00
|
|
|
}}
|
2023-11-25 02:03:18 +08:00
|
|
|
aria-label={selected === "dislike" ? "clicked dislike" : "dislike"}
|
2023-10-03 01:29:20 +08:00
|
|
|
>
|
2023-11-25 02:03:18 +08:00
|
|
|
<Dislike selected={selected === "dislike"} />
|
2023-10-03 01:29:20 +08:00
|
|
|
</button>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
button {
|
|
|
|
position: relative;
|
|
|
|
top: 0;
|
|
|
|
right: 0;
|
|
|
|
cursor: pointer;
|
|
|
|
color: var(--body-text-color-subdued);
|
|
|
|
width: 17px;
|
|
|
|
height: 17px;
|
|
|
|
margin-right: 5px;
|
|
|
|
}
|
|
|
|
|
|
|
|
button:hover,
|
|
|
|
button:focus {
|
|
|
|
color: var(--body-text-color);
|
|
|
|
}
|
|
|
|
</style>
|