Skip to content

Commit fb93b95

Browse files
committed
feat: store real color values in edgeless
1 parent 9e11e04 commit fb93b95

File tree

192 files changed

+895
-287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+895
-287
lines changed

blocksuite/tests-legacy/attachment.spec.ts

+60-10
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,12 @@ test('can insert attachment from slash menu', async ({ page }) => {
144144
page,
145145
`
146146
<affine:note
147-
prop:background="--affine-v2-edgeless-note-white"
147+
prop:background={
148+
Object {
149+
"dark": "#000000",
150+
"light": "#ffffff",
151+
}
152+
}
148153
prop:displayMode="both"
149154
prop:edgeless={
150155
Object {
@@ -191,7 +196,12 @@ test('should undo/redo works for attachment', async ({ page }) => {
191196
await assertStoreMatchJSX(
192197
page,
193198
` <affine:note
194-
prop:background="--affine-v2-edgeless-note-white"
199+
prop:background={
200+
Object {
201+
"dark": "#000000",
202+
"light": "#ffffff",
203+
}
204+
}
195205
prop:displayMode="both"
196206
prop:edgeless={
197207
Object {
@@ -229,7 +239,12 @@ test('should undo/redo works for attachment', async ({ page }) => {
229239
page,
230240
`
231241
<affine:note
232-
prop:background="--affine-v2-edgeless-note-white"
242+
prop:background={
243+
Object {
244+
"dark": "#000000",
245+
"light": "#ffffff",
246+
}
247+
}
233248
prop:displayMode="both"
234249
prop:edgeless={
235250
Object {
@@ -260,7 +275,12 @@ test('should undo/redo works for attachment', async ({ page }) => {
260275
page,
261276
`
262277
<affine:note
263-
prop:background="--affine-v2-edgeless-note-white"
278+
prop:background={
279+
Object {
280+
"dark": "#000000",
281+
"light": "#ffffff",
282+
}
283+
}
264284
prop:displayMode="both"
265285
prop:edgeless={
266286
Object {
@@ -348,7 +368,12 @@ test('should turn attachment to image works', async ({ page }) => {
348368
page,
349369
`
350370
<affine:note
351-
prop:background="--affine-v2-edgeless-note-white"
371+
prop:background={
372+
Object {
373+
"dark": "#000000",
374+
"light": "#ffffff",
375+
}
376+
}
352377
prop:displayMode="both"
353378
prop:edgeless={
354379
Object {
@@ -382,7 +407,12 @@ test('should turn attachment to image works', async ({ page }) => {
382407
page,
383408
`
384409
<affine:note
385-
prop:background="--affine-v2-edgeless-note-white"
410+
prop:background={
411+
Object {
412+
"dark": "#000000",
413+
"light": "#ffffff",
414+
}
415+
}
386416
prop:displayMode="both"
387417
prop:edgeless={
388418
Object {
@@ -431,7 +461,12 @@ test('should attachment can be deleted', async ({ page }) => {
431461
page,
432462
`
433463
<affine:note
434-
prop:background="--affine-v2-edgeless-note-white"
464+
prop:background={
465+
Object {
466+
"dark": "#000000",
467+
"light": "#ffffff",
468+
}
469+
}
435470
prop:displayMode="both"
436471
prop:edgeless={
437472
Object {
@@ -475,7 +510,12 @@ test.fixme(`support dragging attachment block directly`, async ({ page }) => {
475510
await assertStoreMatchJSX(
476511
page,
477512
` <affine:note
478-
prop:background="--affine-v2-edgeless-note-white"
513+
prop:background={
514+
Object {
515+
"dark": "#000000",
516+
"light": "#ffffff",
517+
}
518+
}
479519
prop:displayMode="both"
480520
prop:edgeless={
481521
Object {
@@ -531,7 +571,12 @@ test.fixme(`support dragging attachment block directly`, async ({ page }) => {
531571
page,
532572
/*xml*/ `<affine:page>
533573
<affine:note
534-
prop:background="--affine-v2-edgeless-note-white"
574+
prop:background={
575+
Object {
576+
"dark": "#000000",
577+
"light": "#ffffff",
578+
}
579+
}
535580
prop:displayMode="both"
536581
prop:edgeless={
537582
Object {
@@ -589,7 +634,12 @@ test.fixme(`support dragging attachment block directly`, async ({ page }) => {
589634
page,
590635
/*xml*/ `<affine:page>
591636
<affine:note
592-
prop:background="--affine-v2-edgeless-note-white"
637+
prop:background={
638+
Object {
639+
"dark": "#000000",
640+
"light": "#ffffff",
641+
}
642+
}
593643
prop:displayMode="both"
594644
prop:edgeless={
595645
Object {

blocksuite/tests-legacy/clipboard/list.spec.ts

+24-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { expect } from '@playwright/test';
2+
import { lightThemeV2 } from '@toeverything/theme/v2';
23

34
import { initDatabaseColumn } from '../database/actions.js';
45
import {
@@ -441,7 +442,12 @@ test(scoped`should copy and paste of database work`, async ({ page }) => {
441442
/*xml*/ `
442443
<affine:page>
443444
<affine:note
444-
prop:background="--affine-v2-edgeless-note-white"
445+
prop:background={
446+
Object {
447+
"dark": "#000000",
448+
"light": "#ffffff",
449+
}
450+
}
445451
prop:displayMode="both"
446452
prop:edgeless={
447453
Object {
@@ -491,7 +497,12 @@ test(scoped`should copy and paste of database work`, async ({ page }) => {
491497
/*xml*/ `
492498
<affine:page>
493499
<affine:note
494-
prop:background="--affine-v2-edgeless-note-white"
500+
prop:background={
501+
Object {
502+
"dark": "#000000",
503+
"light": "#ffffff",
504+
}
505+
}
495506
prop:displayMode="both"
496507
prop:edgeless={
497508
Object {
@@ -574,17 +585,24 @@ test(scoped`paste note block with background`, async ({ page }) => {
574585
await selectNoteInEdgeless(page, ids.noteId);
575586

576587
await triggerComponentToolbarAction(page, 'changeNoteColor');
577-
const color = '--affine-v2-edgeless-note-grey';
578-
await changeEdgelessNoteBackground(page, color);
579-
await assertEdgelessNoteBackground(page, ids.noteId, color);
588+
await changeEdgelessNoteBackground(page, 'White');
589+
await assertEdgelessNoteBackground(
590+
page,
591+
ids.noteId,
592+
lightThemeV2['edgeless/note/white']
593+
);
580594

581595
await copyByKeyboard(page);
582596

583597
await page.mouse.move(0, 0);
584598
await pasteByKeyboard(page, false);
585599
const noteIds = await getAllNoteIds(page);
586600
for (const noteId of noteIds) {
587-
await assertEdgelessNoteBackground(page, noteId, color);
601+
await assertEdgelessNoteBackground(
602+
page,
603+
noteId,
604+
lightThemeV2['edgeless/note/white']
605+
);
588606
}
589607
});
590608

blocksuite/tests-legacy/edgeless/auto-complete.spec.ts

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import {
2-
DEFAULT_NOTE_BACKGROUND_COLOR,
3-
ShapeFillColor,
4-
StrokeColor,
5-
} from '@blocksuite/affine-model';
61
import { expect, type Page } from '@playwright/test';
2+
import { lightThemeV2 } from '@toeverything/theme/v2';
73

84
import { clickView, moveView } from '../utils/actions/click.js';
95
import { dragBetweenCoords } from '../utils/actions/drag.js';
@@ -139,11 +135,9 @@ test.describe('auto-complete', () => {
139135
await createShapeElement(page, [0, 0], [100, 100], Shape.Square);
140136
await assertSelectedBound(page, [0, 0, 100, 100]);
141137
await triggerComponentToolbarAction(page, 'changeShapeStrokeColor');
142-
const lineColor = StrokeColor.Red;
143-
await changeShapeStrokeColor(page, lineColor);
138+
await changeShapeStrokeColor(page, 'MediumRed');
144139
await triggerComponentToolbarAction(page, 'changeShapeFillColor');
145-
const color = ShapeFillColor.Green;
146-
await changeShapeFillColor(page, color);
140+
await changeShapeFillColor(page, 'HeavyGreen');
147141
await dragBetweenViewCoords(page, [120, 50], [200, 0]);
148142

149143
const noteButton = getAutoCompletePanelButton(page, 'note');
@@ -168,7 +162,7 @@ test.describe('auto-complete', () => {
168162
await assertEdgelessNoteBackground(
169163
page,
170164
noteId,
171-
DEFAULT_NOTE_BACKGROUND_COLOR
165+
lightThemeV2['edgeless/note/white']
172166
);
173167

174168
const rect = await edgelessNote.boundingBox();
@@ -181,15 +175,18 @@ test.describe('auto-complete', () => {
181175
// select connector
182176
await dragBetweenViewCoords(page, [140, 50], [160, 0]);
183177
await waitNextFrame(page);
184-
await assertConnectorStrokeColor(page, lineColor);
178+
await assertConnectorStrokeColor(
179+
page,
180+
'MediumRed',
181+
lightThemeV2['edgeless/palette/medium/redMedium']
182+
);
185183

186184
// select note block
187185
await page.mouse.click(rect.x + rect.width / 2, rect.y + rect.height / 2);
188186
await waitNextFrame(page);
189187

190188
await triggerComponentToolbarAction(page, 'changeNoteColor');
191-
const noteColor = '--affine-v2-edgeless-note-red';
192-
await changeEdgelessNoteBackground(page, noteColor);
189+
await changeEdgelessNoteBackground(page, 'Red');
193190

194191
// move to arrow icon
195192
await page.mouse.move(
@@ -223,7 +220,11 @@ test.describe('auto-complete', () => {
223220
return note?.getAttribute('data-block-id');
224221
});
225222
assertExists(noteId2);
226-
await assertEdgelessNoteBackground(page, noteId, noteColor);
223+
await assertEdgelessNoteBackground(
224+
page,
225+
noteId,
226+
lightThemeV2['edgeless/note/red']
227+
);
227228

228229
expect(await edgelessNote.count()).toBe(2);
229230
});

blocksuite/tests-legacy/edgeless/brush.spec.ts

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { StrokeColor } from '@blocksuite/affine-model';
21
import { expect } from '@playwright/test';
2+
import { lightThemeV2 } from '@toeverything/theme/v2';
33

44
import {
55
assertEdgelessTool,
@@ -80,15 +80,14 @@ test('add brush element with color', async ({ page }) => {
8080
await switchEditorMode(page);
8181

8282
await setEdgelessTool(page, 'brush');
83-
const color = StrokeColor.Blue;
84-
await selectBrushColor(page, color);
83+
await selectBrushColor(page, 'Blue');
8584

8685
const start = { x: 100, y: 100 };
8786
const end = { x: 200, y: 200 };
8887
await dragBetweenCoords(page, start, end, { steps: 100 });
8988

9089
const [pickedColor] = await pickColorAtPoints(page, [[110, 110]]);
91-
90+
const color = lightThemeV2['edgeless/palette/medium/blueMedium'];
9291
await assertEdgelessColorSameWithHexColor(page, color, pickedColor);
9392
});
9493

@@ -101,8 +100,8 @@ test('keep same color when mouse mode switched back to brush', async ({
101100
await deleteAll(page);
102101

103102
await setEdgelessTool(page, 'brush');
104-
const color = StrokeColor.Blue;
105-
await selectBrushColor(page, color);
103+
await selectBrushColor(page, 'Blue');
104+
106105
const start = { x: 200, y: 200 };
107106
const end = { x: 300, y: 300 };
108107
await dragBetweenCoords(page, start, end, { steps: 100 });
@@ -113,7 +112,9 @@ test('keep same color when mouse mode switched back to brush', async ({
113112
await setEdgelessTool(page, 'brush');
114113
const origin = { x: 100, y: 100 };
115114
await dragBetweenCoords(page, origin, start, { steps: 100 });
115+
116116
const [pickedColor] = await pickColorAtPoints(page, [[110, 110]]);
117+
const color = lightThemeV2['edgeless/palette/medium/blueMedium'];
117118
await assertEdgelessColorSameWithHexColor(page, color, pickedColor);
118119
});
119120

@@ -124,8 +125,7 @@ test('add brush element with different size', async ({ page }) => {
124125

125126
await setEdgelessTool(page, 'brush');
126127
await selectBrushSize(page, 'ten');
127-
const color = StrokeColor.Blue;
128-
await selectBrushColor(page, color);
128+
await selectBrushColor(page, 'Blue');
129129

130130
const start = { x: 100, y: 100 };
131131
const end = { x: 200, y: 100 };
@@ -143,6 +143,7 @@ test('add brush element with different size', async ({ page }) => {
143143
[110, 105],
144144
]);
145145

146+
const color = lightThemeV2['edgeless/palette/medium/blueMedium'];
146147
await assertEdgelessColorSameWithHexColor(page, color, topEdge);
147148
await assertEdgelessColorSameWithHexColor(page, color, bottomEdge);
148149
assertSameColor(nearTopEdge, '#84cfff');

blocksuite/tests-legacy/edgeless/connector/connector.spec.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { StrokeColor } from '@blocksuite/affine-model';
21
import { expect } from '@playwright/test';
32

43
import {
@@ -149,7 +148,7 @@ test('change connector line width', async ({ page }) => {
149148

150149
await page.mouse.click(start.x + 5, start.y);
151150
await triggerComponentToolbarAction(page, 'changeConnectorStrokeColor');
152-
await changeConnectorStrokeColor(page, StrokeColor.Grey);
151+
await changeConnectorStrokeColor(page, 'MediumGrey');
153152

154153
await triggerComponentToolbarAction(page, 'changeConnectorStrokeStyles');
155154
await changeConnectorStrokeWidth(page, 5);
@@ -174,7 +173,7 @@ test('change connector stroke style', async ({ page }) => {
174173

175174
await page.mouse.click(start.x + 5, start.y);
176175
await triggerComponentToolbarAction(page, 'changeConnectorStrokeColor');
177-
await changeConnectorStrokeColor(page, StrokeColor.Grey);
176+
await changeConnectorStrokeColor(page, 'MediumGrey');
178177

179178
await triggerComponentToolbarAction(page, 'changeConnectorStrokeStyles');
180179
await changeConnectorStrokeStyle(page, 'dash');

blocksuite/tests-legacy/edgeless/lock.spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ test.describe('lock', () => {
5959
test('edgeless element can be locked and unlocked', async ({ page }) => {
6060
await edgelessCommonSetup(page);
6161

62-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6362
const wrapTest = async <F extends (...args: any) => any>(
6463
elementCreateFn: F,
6564
...args: Parameters<F>

blocksuite/tests-legacy/edgeless/note/note.spec.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
NoteDisplayMode,
55
} from '@blocksuite/affine-model';
66
import { expect } from '@playwright/test';
7+
import { lightThemeV2 } from '@toeverything/theme/v2';
78

89
import {
910
activeNoteInEdgeless,
@@ -304,14 +305,17 @@ test('change note color', async ({ page }) => {
304305
await assertEdgelessNoteBackground(
305306
page,
306307
noteId,
307-
'--affine-v2-edgeless-note-white'
308+
lightThemeV2['edgeless/note/white']
308309
);
309310

310311
await selectNoteInEdgeless(page, noteId);
311312
await triggerComponentToolbarAction(page, 'changeNoteColor');
312-
const color = '--affine-v2-edgeless-note-green';
313-
await changeEdgelessNoteBackground(page, color);
314-
await assertEdgelessNoteBackground(page, noteId, color);
313+
await changeEdgelessNoteBackground(page, 'Green');
314+
await assertEdgelessNoteBackground(
315+
page,
316+
noteId,
317+
lightThemeV2['edgeless/note/green']
318+
);
315319
});
316320

317321
test('cursor for active and inactive state', async ({ page }) => {

0 commit comments

Comments
 (0)