|
1 | 1 | <script lang="ts"> |
2 | | - import { onDestroy, createEventDispatcher } from "svelte"; |
| 2 | + import { getContext, onDestroy, createEventDispatcher } from "svelte"; |
3 | 3 |
|
4 | | - import type { HSV, RGB, FillChoice } from "@graphite/messages"; |
5 | | - import type { MenuDirection } from "@graphite/messages"; |
| 4 | + import type { HSV, RGB, FillChoice, MenuDirection } from "@graphite/messages"; |
6 | 5 | import { Color, contrastingOutlineFactor, Gradient } from "@graphite/messages"; |
| 6 | + import type { TooltipState } from "@graphite/state-providers/tooltip"; |
7 | 7 | import { clamp } from "@graphite/utility-functions/math"; |
8 | 8 |
|
9 | 9 | import FloatingMenu from "@graphite/components/layout/FloatingMenu.svelte"; |
|
40 | 40 | ]; |
41 | 41 |
|
42 | 42 | const dispatch = createEventDispatcher<{ colorOrGradient: FillChoice; startHistoryTransaction: undefined }>(); |
| 43 | + const tooltip = getContext<TooltipState>("tooltip"); |
43 | 44 |
|
44 | 45 | export let colorOrGradient: FillChoice; |
45 | 46 | export let allowNone = false; |
|
424 | 425 | "--opaque-color-contrasting": (newColor.opaque() || new Color(0, 0, 0, 1)).contrastingColor(), |
425 | 426 | }} |
426 | 427 | > |
| 428 | + {@const hueDescription = "The shade along the spectrum of the rainbow."} |
| 429 | + {@const saturationDescription = "The vividness from grayscale to full color."} |
| 430 | + {@const valueDescription = "The brightness from black to full color."} |
427 | 431 | <LayoutCol class="pickers-and-gradient"> |
428 | 432 | <LayoutRow class="pickers"> |
429 | 433 | <LayoutCol |
430 | 434 | class="saturation-value-picker" |
431 | 435 | data-tooltip-label="Saturation and Value" |
432 | | - data-tooltip-description={disabled ? "Disabled (read-only)." : ""} |
| 436 | + data-tooltip-description={`To move only along the saturation (X) or value (Y) axis, perform the shortcut shown.${disabled ? "\n\nDisabled (read-only)." : ""}`} |
| 437 | + data-tooltip-shortcut={$tooltip.shiftClickShortcut?.shortcut ? JSON.stringify($tooltip.shiftClickShortcut.shortcut) : undefined} |
433 | 438 | on:pointerdown={onPointerDown} |
434 | 439 | data-saturation-value-picker |
435 | 440 | > |
|
449 | 454 | <LayoutCol |
450 | 455 | class="hue-picker" |
451 | 456 | data-tooltip-label="Hue" |
452 | | - data-tooltip-description={`The shade along the spectrum of the rainbow.${disabled ? "\n\nDisabled (read-only)." : ""}`} |
| 457 | + data-tooltip-description={`${hueDescription}${disabled ? "\n\nDisabled (read-only)." : ""}`} |
453 | 458 | on:pointerdown={onPointerDown} |
454 | 459 | data-hue-picker |
455 | 460 | > |
|
522 | 527 | </LayoutRow> |
523 | 528 | <!-- <DropdownInput entries={[[{ label: "sRGB" }]]} selectedIndex={0} disabled={true} tooltipDescription="Color model, color space, and HDR (coming soon)." /> --> |
524 | 529 | <LayoutRow> |
525 | | - <TextLabel |
526 | | - tooltipLabel="Hex Color Code" |
527 | | - tooltipDescription="Color code in hexadecimal format. 6 digits if opaque, 8 with alpha.\nAccepts input of CSS color values including named colors.">Hex</TextLabel |
528 | | - > |
| 530 | + {@const hexDescription = "Color code in hexadecimal format. 6 digits if opaque, 8 with alpha. Accepts input of CSS color values including named colors."} |
| 531 | + <TextLabel tooltipLabel="Hex Color Code" tooltipDescription={hexDescription}>Hex</TextLabel> |
529 | 532 | <Separator type="Related" /> |
530 | 533 | <LayoutRow> |
531 | 534 | <TextInput |
|
537 | 540 | }} |
538 | 541 | centered={true} |
539 | 542 | tooltipLabel="Hex Color Code" |
540 | | - tooltipDescription="Color code in hexadecimal format. 6 digits if opaque, 8 with alpha.\nAccepts input of CSS color values including named colors." |
| 543 | + tooltipDescription={hexDescription} |
541 | 544 | bind:this={hexCodeInputWidget} |
542 | 545 | /> |
543 | 546 | </LayoutRow> |
|
601 | 604 | v: "Value Component", |
602 | 605 | }[channel]} |
603 | 606 | tooltipDescription={{ |
604 | | - h: "The shade along the spectrum of the rainbow.", |
605 | | - s: "The vividness from grayscale to full color.", |
606 | | - v: "The brightness from black to full color.", |
| 607 | + h: hueDescription, |
| 608 | + s: saturationDescription, |
| 609 | + v: valueDescription, |
607 | 610 | }[channel]} |
608 | 611 | /> |
609 | 612 | {/each} |
610 | 613 | </LayoutRow> |
611 | 614 | </LayoutRow> |
612 | 615 | <LayoutRow> |
613 | | - <TextLabel tooltipLabel="Alpha" tooltipDescription="The level of translucency, from transparent (0%) to opaque (100%).">Alpha</TextLabel> |
| 616 | + {@const alphaDescription = "The level of translucency, from transparent (0%) to opaque (100%)."} |
| 617 | + <TextLabel tooltipLabel="Alpha" tooltipDescription={alphaDescription}>Alpha</TextLabel> |
614 | 618 | <Separator type="Related" /> |
615 | 619 | <NumberInput |
616 | 620 | value={!isNone ? alpha * 100 : undefined} |
|
630 | 634 | mode="Range" |
631 | 635 | displayDecimalPlaces={1} |
632 | 636 | tooltipLabel="Alpha" |
633 | | - tooltipDescription="The level of translucency, from transparent (0%) to opaque (100%)." |
| 637 | + tooltipDescription={alphaDescription} |
634 | 638 | /> |
635 | 639 | </LayoutRow> |
636 | 640 | <LayoutRow class="leftover-space" /> |
|
670 | 674 | data-pure-tile={name.toLowerCase()} |
671 | 675 | style:--pure-color={color} |
672 | 676 | style:--pure-color-gray={gray} |
673 | | - data-tooltip-label="Set to Red" |
| 677 | + data-tooltip-label={`Set to ${name}`} |
674 | 678 | data-tooltip-description={disabled ? "Disabled (read-only)." : ""} |
675 | 679 | /> |
676 | 680 | {/each} |
|
0 commit comments