Skip to content

Commit 48ff8a6

Browse files
committed
fix: add missing no-color option to note colors
1 parent 1f69077 commit 48ff8a6

2 files changed

Lines changed: 39 additions & 8 deletions

File tree

src/components/Notes/NoteDialog.test.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,22 +269,31 @@ describe('NoteDialog', () => {
269269
})
270270

271271
describe('color swatches', () => {
272-
it('renders 16 swatches in both modes', () => {
272+
it('renders 17 swatches (no-color + 16 colors)', () => {
273273
const wrapper = mount(NoteDialog, {
274274
props: { open: true, note: makeNote() },
275275
})
276-
expect(wrapper.findAll('.note-dialog__swatch')).toHaveLength(16)
276+
expect(wrapper.findAll('.note-dialog__swatch')).toHaveLength(17)
277+
})
278+
279+
it('has no-color swatch active by default when note has no color', () => {
280+
const wrapper = mount(NoteDialog, {
281+
props: { open: true, note: makeNote({ color: null }) },
282+
})
283+
const noColor = wrapper.find('.note-dialog__swatch--none')
284+
expect(noColor.classes()).toContain('note-dialog__swatch--active')
277285
})
278286

279287
it('toggles color on swatch click', async () => {
280288
const wrapper = mount(NoteDialog, {
281289
props: { open: true, note: makeNote({ color: null }) },
282290
})
283-
const swatch = wrapper.find('.note-dialog__swatch')
284-
await swatch.trigger('click')
285-
expect(swatch.classes()).toContain('note-dialog__swatch--active')
286-
await swatch.trigger('click')
287-
expect(swatch.classes()).not.toContain('note-dialog__swatch--active')
291+
// Click a color swatch (skip the first "no color" swatch)
292+
const colorSwatch = wrapper.findAll('.note-dialog__swatch').at(1)!
293+
await colorSwatch.trigger('click')
294+
expect(colorSwatch.classes()).toContain('note-dialog__swatch--active')
295+
await colorSwatch.trigger('click')
296+
expect(colorSwatch.classes()).not.toContain('note-dialog__swatch--active')
288297
})
289298

290299
it('saves immediately on color change for existing notes', async () => {
@@ -328,7 +337,7 @@ describe('NoteDialog', () => {
328337
// Should be in view mode
329338
expect(wrapper.find('.nc-text-area').exists()).toBe(false)
330339
// Swatches still visible
331-
expect(wrapper.findAll('.note-dialog__swatch')).toHaveLength(16)
340+
expect(wrapper.findAll('.note-dialog__swatch')).toHaveLength(17)
332341
})
333342
})
334343
})

src/components/Notes/NoteDialog.vue

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@
4646
<!-- Color swatches (always visible) -->
4747
<div class="note-dialog__color">
4848
<div class="note-dialog__swatches">
49+
<button
50+
type="button"
51+
class="note-dialog__swatch note-dialog__swatch--none"
52+
:class="{ 'note-dialog__swatch--active': colorValue === '' }"
53+
:style="{ borderColor: colorValue === '' ? 'var(--color-main-text)' : 'transparent' }"
54+
:aria-label="strings.noColor"
55+
@click="toggleColor('')"
56+
/>
4957
<button
5058
v-for="c in colorOptions"
5159
:key="c"
@@ -299,6 +307,7 @@ const strings = {
299307
view: t('pantry', 'Preview'),
300308
untitled: t('pantry', 'Untitled note'),
301309
noContent: t('pantry', 'Click to add content …'),
310+
noColor: t('pantry', 'Default (no color)'),
302311
}
303312
</script>
304313

@@ -416,6 +425,19 @@ const strings = {
416425
&--active {
417426
transform: scale(1.15);
418427
}
428+
429+
&--none {
430+
background: var(--color-background-hover);
431+
// Diagonal line to indicate "no color"
432+
background-image: linear-gradient(
433+
135deg,
434+
transparent 40%,
435+
var(--color-error, #e00) 40%,
436+
var(--color-error, #e00) 60%,
437+
transparent 60%
438+
);
439+
background-size: 100% 100%;
440+
}
419441
}
420442
}
421443
</style>

0 commit comments

Comments
 (0)