Skip to content

Commit 926f0f8

Browse files
committed
client/note color picker: refactor
1 parent e4c928a commit 926f0f8

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

apps/client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"autocomplete.js": "0.38.1",
3737
"bootstrap": "5.3.8",
3838
"boxicons": "2.1.4",
39+
"clsx": "2.1.1",
3940
"color": "5.0.3",
4041
"dayjs": "1.11.19",
4142
"dayjs-plugin-utc": "0.1.2",

apps/client/src/menus/custom-items/NoteColorPicker.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { t } from "../../services/i18n";
33
import { useCallback, useEffect, useRef, useState} from "preact/hooks";
44
import {ComponentChildren} from "preact";
55
import attributes from "../../services/attributes";
6+
import clsx from "clsx";
67
import Color, { ColorInstance } from "color";
78
import Debouncer from "../../utils/debouncer";
89
import FNote from "../../entities/fnote";
@@ -105,7 +106,11 @@ interface ColorCellProps {
105106
}
106107

107108
function ColorCell(props: ColorCellProps) {
108-
return <div class={`color-cell ${props.isSelected ? "selected" : ""} ${props.isDisabled ? "disabled-color-cell" : ""} ${props.className ?? ""}`}
109+
return <div className={clsx(props.className, {
110+
"color-cell": true,
111+
"selected": props.isSelected,
112+
"disabled-color-cell": props.isDisabled
113+
})}
109114
style={`${(props.color !== null) ? `--color: ${props.color}` : ""}`}
110115
title={props.tooltip}
111116
onClick={() => props.onSelect?.(props.color)}>
@@ -151,7 +156,9 @@ function CustomColorCell(props: ColorCellProps) {
151156
return <div style={`--foreground: ${getForegroundColor(props.color)};`}>
152157
<ColorCell {...props}
153158
color={pickedColor}
154-
className={`custom-color-cell ${(pickedColor === null) ? "custom-color-cell-empty" : ""}`}
159+
className={clsx("custom-color-cell", {
160+
"custom-color-cell-empty": (pickedColor === null)
161+
})}
155162
onSelect={onSelect}>
156163

157164
<input ref={colorInput}

pnpm-lock.yaml

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)