Files
Graphite/frontend/src/components/widgets/buttons/ImageButton.svelte
T
Keavon Chambers e8ebcc2c21 Replace text-only tooltips with custom richly styled tooltips (#3436)
* Replace the title attribute with custom FloatingMenu tooltips

* Separate tooltip labels and descriptions into two styled blocks

* Move keyboard shortcut tooltips to a separate section at the bottom

* Update shortcut key styling in tooltips and hints bar

* Fix .to_string()
2025-11-30 13:32:58 -08:00

45 lines
1.1 KiB
Svelte

<script lang="ts">
import { IMAGE_BASE64_STRINGS } from "@graphite/utility-functions/images";
let className = "";
export { className as class };
export let classes: Record<string, boolean> = {};
export let image: string;
export let width: string | undefined;
export let height: string | undefined;
export let tooltipLabel: string | undefined = undefined;
export let tooltipDescription: string | undefined = undefined;
export let tooltipShortcut: string | undefined = undefined;
// Callbacks
export let action: (e?: MouseEvent) => void;
$: extraClasses = Object.entries(classes)
.flatMap(([className, stateName]) => (stateName ? [className] : []))
.join(" ");
</script>
<img
src={IMAGE_BASE64_STRINGS[image]}
style:width
style:height
class={`image-button ${className} ${extraClasses}`.trim()}
data-tooltip-label={tooltipLabel}
data-tooltip-description={tooltipDescription}
data-tooltip-shortcut={tooltipShortcut}
alt=""
on:click={action}
/>
<style lang="scss" global>
.image-button {
width: auto;
height: auto;
border-radius: 2px;
+ .image-button.image-button {
margin-left: 8px;
}
}
</style>