mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-03 01:50:59 +08:00
206af31d7c
* amend like/dislike logic * add like/dislike to chatbot demo and add e2e test * add changeset * e2e test changes * revert chatbot_component changes * tweak * generate notebooks * tweak --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
47 lines
882 B
Svelte
47 lines
882 B
Svelte
<script lang="ts">
|
|
import { Like } from "@gradio/icons";
|
|
import { Dislike } from "@gradio/icons";
|
|
|
|
export let handle_action: (selected: string | null) => void;
|
|
|
|
let selected: "like" | "dislike" | null = null;
|
|
</script>
|
|
|
|
<button
|
|
on:click={() => {
|
|
selected = "like";
|
|
handle_action(selected);
|
|
}}
|
|
aria-label={selected === "like" ? "clicked like" : "like"}
|
|
>
|
|
<Like selected={selected === "like"} />
|
|
</button>
|
|
|
|
<button
|
|
on:click={() => {
|
|
selected = "dislike";
|
|
handle_action(selected);
|
|
}}
|
|
aria-label={selected === "dislike" ? "clicked dislike" : "dislike"}
|
|
>
|
|
<Dislike selected={selected === "dislike"} />
|
|
</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>
|