mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-29 07:48:11 +08:00
Add support for clicking checkboxes via their labels (#2667)
This commit is contained in:
@@ -549,8 +549,10 @@
|
||||
|
||||
// Layer hierarchy
|
||||
.list-area {
|
||||
margin: 4px 0;
|
||||
position: relative;
|
||||
margin-top: 4px;
|
||||
// Combine with the bottom bar to avoid a double border
|
||||
margin-bottom: -1px;
|
||||
|
||||
.layer {
|
||||
flex: 0 0 auto;
|
||||
|
||||
@@ -12,11 +12,13 @@
|
||||
export let disabled = false;
|
||||
export let icon: IconName = "Checkmark";
|
||||
export let tooltip: string | undefined = undefined;
|
||||
export let forLabel: bigint | undefined = undefined;
|
||||
|
||||
let inputElement: HTMLInputElement | undefined;
|
||||
|
||||
let id = String(Math.random()).substring(2);
|
||||
const backupId = String(Math.random()).substring(2);
|
||||
|
||||
$: id = forLabel !== undefined ? String(forLabel) : backupId;
|
||||
$: displayIcon = (!checked && icon === "Checkmark" ? "Empty12px" : icon) as IconName;
|
||||
|
||||
export function isChecked() {
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
export let minWidth = 0;
|
||||
export let multiline = false;
|
||||
export let tooltip: string | undefined = undefined;
|
||||
export let checkboxId: bigint | undefined = undefined;
|
||||
|
||||
$: extraClasses = Object.entries(classes)
|
||||
.flatMap(([className, stateName]) => (stateName ? [className] : []))
|
||||
@@ -22,7 +23,7 @@
|
||||
.join(" ");
|
||||
</script>
|
||||
|
||||
<span
|
||||
<label
|
||||
class={`text-label ${className} ${extraClasses}`.trim()}
|
||||
class:disabled
|
||||
class:bold
|
||||
@@ -33,9 +34,10 @@
|
||||
style:min-width={minWidth > 0 ? `${minWidth}px` : undefined}
|
||||
style={`${styleName} ${extraStyles}`.trim() || undefined}
|
||||
title={tooltip}
|
||||
for={checkboxId !== undefined ? `checkbox-input-${checkboxId}` : undefined}
|
||||
>
|
||||
<slot />
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<style lang="scss" global>
|
||||
.text-label {
|
||||
|
||||
Reference in New Issue
Block a user