mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-21 06:38:11 +08:00
* 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()
45 lines
1.1 KiB
Svelte
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>
|