Skip to content

Commit 6824f55

Browse files
committed
Add hover style to checkboxes when their corresponding labels are hovered
1 parent e1357c5 commit 6824f55

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed

.github/workflows/comment-!build-commands.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101
comment_id: ${{ github.event.comment.id }},
102102
owner: context.repo.owner,
103103
repo: context.repo.repo,
104-
body: '!build ([build link](https://github.com/GraphiteEditor/Graphite/actions/runs/' + context.runId + '))'
104+
body: '!build ([Run ID ' + context.runId + '](https://github.com/GraphiteEditor/Graphite/actions/runs/' + context.runId + '))'
105105
});
106106
107107
- name: 🌐 Build Graphite web code
@@ -111,7 +111,7 @@ jobs:
111111
run: |
112112
cd frontend
113113
mold -run npm run ${{ steps.build_command.outputs.command }}
114-
114+
115115
- name: ❗ Warn on build failure
116116
if: ${{ failure() }}
117117
uses: actions/github-script@v6

frontend/src/components/floating-menus/ColorPicker.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import { Color, contrastingOutlineFactor, Gradient } from "@graphite/messages";
66
import type { TooltipState } from "@graphite/state-providers/tooltip";
77
import { clamp } from "@graphite/utility-functions/math";
8+
import { isDesktop } from "@graphite/utility-functions/platform";
89
910
import FloatingMenu from "@graphite/components/layout/FloatingMenu.svelte";
1011
import { preventEscapeClosingParentFloatingMenu } from "@graphite/components/layout/FloatingMenu.svelte";
@@ -376,6 +377,9 @@
376377
377378
// TODO: Replace this temporary usage of the browser eyedropper API, that only works in Chromium-based browsers, with the custom color sampler system used by the Eyedropper tool
378379
function eyedropperSupported(): boolean {
380+
// TODO: Implement support in the desktop app for OS-level color picking
381+
if (isDesktop()) return false;
382+
379383
// eslint-disable-next-line @typescript-eslint/no-explicit-any
380384
return Boolean((window as any).EyeDropper);
381385
}

frontend/src/components/widgets/inputs/CheckboxInput.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@
9999
}
100100
101101
// Hovered while unchecked
102-
&:hover .checkbox-box {
102+
&:hover .checkbox-box,
103+
&.label-is-hovered .checkbox-box {
103104
background: var(--color-6-lowergray);
104105
}
105106
@@ -120,7 +121,8 @@
120121
}
121122
122123
// Hovered while checked
123-
&:hover .checkbox-box {
124+
&:hover .checkbox-box,
125+
&.label-is-hovered .checkbox-box {
124126
background: var(--color-f-white);
125127
}
126128

frontend/src/components/widgets/labels/TextLabel.svelte

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script lang="ts">
2+
import { onMount, onDestroy } from "svelte";
3+
24
import type { ActionShortcut } from "@graphite/messages";
35
46
let className = "";
@@ -28,12 +30,39 @@
2830
export let tooltipDescription: string | undefined = undefined;
2931
export let tooltipShortcut: ActionShortcut | undefined = undefined;
3032
33+
let self: HTMLLabelElement | undefined;
34+
3135
$: extraClasses = Object.entries(classes)
3236
.flatMap(([className, stateName]) => (stateName ? [className] : []))
3337
.join(" ");
3438
$: extraStyles = Object.entries(styles)
3539
.flatMap((styleAndValue) => (styleAndValue[1] !== undefined ? [`${styleAndValue[0]}: ${styleAndValue[1]};`] : []))
3640
.join(" ");
41+
42+
$: watchForCheckbox(forCheckbox);
43+
44+
function watchForCheckbox(forCheckbox: bigint | undefined) {
45+
if (!self) return;
46+
47+
self.removeEventListener("pointerenter", handlePointerEnter);
48+
self.removeEventListener("pointerleave", handlePointerLeave);
49+
50+
if (forCheckbox !== undefined) {
51+
self.addEventListener("pointerenter", handlePointerEnter);
52+
self.addEventListener("pointerleave", handlePointerLeave);
53+
}
54+
}
55+
56+
function handlePointerEnter() {
57+
document.querySelector(`[for="checkbox-input-${forCheckbox}"]`)?.classList.add("label-is-hovered");
58+
}
59+
60+
function handlePointerLeave() {
61+
document.querySelector(`[for="checkbox-input-${forCheckbox}"]`)?.classList.remove("label-is-hovered");
62+
}
63+
64+
onMount(() => watchForCheckbox(forCheckbox));
65+
onDestroy(() => watchForCheckbox(undefined));
3766
</script>
3867

3968
<label
@@ -52,6 +81,7 @@
5281
data-tooltip-description={tooltipDescription}
5382
data-tooltip-shortcut={tooltipShortcut?.shortcut ? JSON.stringify(tooltipShortcut.shortcut) : undefined}
5483
for={forCheckbox !== undefined ? `checkbox-input-${forCheckbox}` : undefined}
84+
bind:this={self}
5585
>
5686
<slot />
5787
</label>

0 commit comments

Comments
 (0)