mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-30 11:00:11 +08:00
8f0fed857d
* add a11y changes and css tweaks * add a11y changes and css tweaks * change like/dislike/copy buttons ux * cleanup * add laout param * tweak * add changeset * fill icon on click * text alignment tweak * format + test * fix browser test * avatar tweaks * add stories * tweak * tweak --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
50 lines
863 B
Svelte
50 lines
863 B
Svelte
<script lang="ts">
|
|
import { Like } from "@gradio/icons";
|
|
import { Dislike } from "@gradio/icons";
|
|
|
|
export let action: "like" | "dislike";
|
|
export let handle_action: () => void;
|
|
|
|
let actioned = false;
|
|
let Icon = action === "like" ? Like : Dislike;
|
|
|
|
function action_feedback(): void {
|
|
actioned = true;
|
|
}
|
|
</script>
|
|
|
|
<button
|
|
on:click={() => {
|
|
action_feedback();
|
|
handle_action();
|
|
}}
|
|
on:keydown={(e) => {
|
|
if (e.key === "Enter") {
|
|
action_feedback();
|
|
handle_action();
|
|
}
|
|
}}
|
|
title={action + " message"}
|
|
aria-label={actioned ? `clicked ${action}` : action}
|
|
>
|
|
<Icon {actioned} />
|
|
</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>
|