diff --git a/blocksuite/affine/block-embed/package.json b/blocksuite/affine/block-embed/package.json
index f68bc94507f3e..54b7a974c5e02 100644
--- a/blocksuite/affine/block-embed/package.json
+++ b/blocksuite/affine/block-embed/package.json
@@ -25,7 +25,7 @@
"@floating-ui/dom": "^1.6.10",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
- "@toeverything/theme": "^1.1.1",
+ "@toeverything/theme": "^1.1.2",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
"zod": "^3.23.8"
diff --git a/blocksuite/affine/block-list/package.json b/blocksuite/affine/block-list/package.json
index a74235e60e4ce..4b638c4883a23 100644
--- a/blocksuite/affine/block-list/package.json
+++ b/blocksuite/affine/block-list/package.json
@@ -23,7 +23,7 @@
"@floating-ui/dom": "^1.6.10",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
- "@toeverything/theme": "^1.1.1",
+ "@toeverything/theme": "^1.1.2",
"@types/mdast": "^4.0.4",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
diff --git a/blocksuite/affine/block-paragraph/package.json b/blocksuite/affine/block-paragraph/package.json
index 5f017119ca91d..588b21a5a67d9 100644
--- a/blocksuite/affine/block-paragraph/package.json
+++ b/blocksuite/affine/block-paragraph/package.json
@@ -23,7 +23,7 @@
"@floating-ui/dom": "^1.6.10",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
- "@toeverything/theme": "^1.1.1",
+ "@toeverything/theme": "^1.1.2",
"@types/mdast": "^4.0.4",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
diff --git a/blocksuite/affine/block-surface/package.json b/blocksuite/affine/block-surface/package.json
index 7ef1baabb2a20..dde9ecdbae7e4 100644
--- a/blocksuite/affine/block-surface/package.json
+++ b/blocksuite/affine/block-surface/package.json
@@ -22,7 +22,7 @@
"@blocksuite/store": "workspace:*",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
- "@toeverything/theme": "^1.1.1",
+ "@toeverything/theme": "^1.1.2",
"fractional-indexing": "^3.2.0",
"lit": "^3.2.0",
"lodash.chunk": "^4.2.0",
diff --git a/blocksuite/affine/components/package.json b/blocksuite/affine/components/package.json
index bee8a8178adad..d972ba400943a 100644
--- a/blocksuite/affine/components/package.json
+++ b/blocksuite/affine/components/package.json
@@ -24,7 +24,7 @@
"@lit/context": "^1.1.2",
"@lottiefiles/dotlottie-wc": "^0.4.0",
"@preact/signals-core": "^1.8.0",
- "@toeverything/theme": "^1.1.1",
+ "@toeverything/theme": "^1.1.2",
"date-fns": "^4.0.0",
"katex": "^0.16.11",
"lit": "^3.2.0",
diff --git a/blocksuite/affine/components/src/icons/edgeless.ts b/blocksuite/affine/components/src/icons/edgeless.ts
index d881a2ac6afa9..ec00b1991fdad 100644
--- a/blocksuite/affine/components/src/icons/edgeless.ts
+++ b/blocksuite/affine/components/src/icons/edgeless.ts
@@ -427,21 +427,6 @@ export const ViewBarIcon = icons.ViewBarIcon({
height: '24',
});
-export const TransparentIcon = html``;
-
export const MoreHorizontalIcon = icons.MoreHorizontalIcon({
width: '24',
height: '24',
diff --git a/blocksuite/affine/data-view/package.json b/blocksuite/affine/data-view/package.json
index a7aaa480d660b..c9f3d5956b9f0 100644
--- a/blocksuite/affine/data-view/package.json
+++ b/blocksuite/affine/data-view/package.json
@@ -23,7 +23,7 @@
"@floating-ui/dom": "^1.6.10",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
- "@toeverything/theme": "^1.1.1",
+ "@toeverything/theme": "^1.1.2",
"date-fns": "^4.0.0",
"lit": "^3.2.0",
"zod": "^3.23.8"
diff --git a/blocksuite/affine/model/src/blocks/frame/frame-model.ts b/blocksuite/affine/model/src/blocks/frame/frame-model.ts
index 9a53be18aae5d..29b8c524c73fb 100644
--- a/blocksuite/affine/model/src/blocks/frame/frame-model.ts
+++ b/blocksuite/affine/model/src/blocks/frame/frame-model.ts
@@ -30,7 +30,7 @@ export const FrameBlockSchema = defineBlockSchema({
flavour: 'affine:frame',
props: (internal): FrameBlockProps => ({
title: internal.Text(),
- background: '--affine-palette-transparent',
+ background: 'transparent',
xywh: `[0,0,100,100]`,
index: 'a0',
childElementIds: Object.create(null),
diff --git a/blocksuite/affine/model/src/consts/brush.ts b/blocksuite/affine/model/src/consts/brush.ts
index cdbfc9a505acc..209d66e30e926 100644
--- a/blocksuite/affine/model/src/consts/brush.ts
+++ b/blocksuite/affine/model/src/consts/brush.ts
@@ -1,3 +1,3 @@
-import { LineColor } from './line.js';
+import { StrokeColor } from './color.js';
-export const DEFAULT_BRUSH_COLOR = LineColor.Blue;
+export const DEFAULT_BRUSH_COLOR = StrokeColor.Blue;
diff --git a/blocksuite/affine/model/src/consts/color.ts b/blocksuite/affine/model/src/consts/color.ts
new file mode 100644
index 0000000000000..c708ca11372a5
--- /dev/null
+++ b/blocksuite/affine/model/src/consts/color.ts
@@ -0,0 +1,97 @@
+import { themeToVar } from '@toeverything/theme/v2';
+import { z } from 'zod';
+
+import { createEnumMap } from '../utils/enum.js';
+
+export const Transparent = 'transparent';
+export const White = themeToVar('edgeless/palette/white');
+export const Black = themeToVar('edgeless/palette/black');
+
+export const Light = {
+ Red: themeToVar('edgeless/palette/light/redLight'),
+ Orange: themeToVar('edgeless/palette/light/orangeLight'),
+ Yellow: themeToVar('edgeless/palette/light/yellowLight'),
+ Green: themeToVar('edgeless/palette/light/greenLight'),
+ Blue: themeToVar('edgeless/palette/light/blueLight'),
+ Purple: themeToVar('edgeless/palette/light/purpleLight'),
+ Magenta: themeToVar('edgeless/palette/light/magentaLight'),
+ Grey: themeToVar('edgeless/palette/light/greyLight'),
+} as const;
+
+export const LIGHT_PALETTES = [
+ Light.Red,
+ Light.Orange,
+ Light.Yellow,
+ Light.Green,
+ Light.Blue,
+ Light.Purple,
+ Light.Magenta,
+ Light.Grey,
+] as const;
+
+export const Medium = {
+ Red: themeToVar('edgeless/palette/medium/redMedium'),
+ Orange: themeToVar('edgeless/palette/medium/orangeMedium'),
+ Yellow: themeToVar('edgeless/palette/medium/yellowMedium'),
+ Green: themeToVar('edgeless/palette/medium/greenMedium'),
+ Blue: themeToVar('edgeless/palette/medium/blueMedium'),
+ Purple: themeToVar('edgeless/palette/medium/purpleMedium'),
+ Magenta: themeToVar('edgeless/palette/medium/magentaMedium'),
+ Grey: themeToVar('edgeless/palette/medium/greyMedium'),
+} as const;
+
+export const MEDIUM_PALETTES = [
+ Medium.Red,
+ Medium.Orange,
+ Medium.Yellow,
+ Medium.Green,
+ Medium.Blue,
+ Medium.Purple,
+ Medium.Magenta,
+ Medium.Grey,
+] as const;
+
+export const Heavy = {
+ Red: themeToVar('edgeless/palette/heavy/red'),
+ Orange: themeToVar('edgeless/palette/heavy/orange'),
+ Yellow: themeToVar('edgeless/palette/heavy/yellow'),
+ Green: themeToVar('edgeless/palette/heavy/green'),
+ Blue: themeToVar('edgeless/palette/heavy/blue'),
+ Purple: themeToVar('edgeless/palette/heavy/purple'),
+ Magenta: themeToVar('edgeless/palette/heavy/magenta'),
+} as const;
+
+export const HEAVY_PALETTES = [
+ Heavy.Red,
+ Heavy.Orange,
+ Heavy.Yellow,
+ Heavy.Green,
+ Heavy.Blue,
+ Heavy.Purple,
+ Heavy.Magenta,
+] as const;
+
+export const PALETTES = [
+ // Light
+ ...LIGHT_PALETTES,
+
+ Transparent,
+
+ // Medium
+ ...MEDIUM_PALETTES,
+
+ White,
+
+ // Heavy
+ ...HEAVY_PALETTES,
+
+ Black,
+] as const;
+
+export const PaletteEnum = z.enum(PALETTES);
+
+export const StrokeColor = { Black, White, ...Medium } as const;
+
+export const StrokeColorMap = createEnumMap(StrokeColor);
+
+export const STROKE_COLORS = [...MEDIUM_PALETTES, Black, White] as const;
diff --git a/blocksuite/affine/model/src/consts/connector.ts b/blocksuite/affine/model/src/consts/connector.ts
index 4222f985746b5..97b35b7808ce5 100644
--- a/blocksuite/affine/model/src/consts/connector.ts
+++ b/blocksuite/affine/model/src/consts/connector.ts
@@ -1,5 +1,5 @@
import { createEnumMap } from '../utils/enum.js';
-import { LineColor } from './line.js';
+import { StrokeColor } from './color.js';
export enum ConnectorEndpoint {
Front = 'Front',
@@ -16,9 +16,9 @@ export enum PointStyle {
export const PointStyleMap = createEnumMap(PointStyle);
-export const DEFAULT_CONNECTOR_COLOR = LineColor.Grey;
+export const DEFAULT_CONNECTOR_COLOR = StrokeColor.Grey;
-export const DEFAULT_CONNECTOR_TEXT_COLOR = LineColor.Black;
+export const DEFAULT_CONNECTOR_TEXT_COLOR = StrokeColor.Black;
export const DEFAULT_FRONT_END_POINT_STYLE = PointStyle.None;
diff --git a/blocksuite/affine/model/src/consts/frame.ts b/blocksuite/affine/model/src/consts/frame.ts
index 15c98574c3cfd..fd5d90841847e 100644
--- a/blocksuite/affine/model/src/consts/frame.ts
+++ b/blocksuite/affine/model/src/consts/frame.ts
@@ -1,27 +1,3 @@
-import { z } from 'zod';
+import { Light } from './color.js';
-export enum FrameBackgroundColor {
- Blue = '--affine-tag-blue',
- Gray = '--affine-tag-gray',
- Green = '--affine-tag-green',
- Orange = '--affine-tag-orange',
- Pink = '--affine-tag-pink',
- Purple = '--affine-tag-purple',
- Red = '--affine-tag-red',
- Teal = '--affine-tag-teal',
- Yellow = '--affine-tag-yellow',
-}
-
-export const FRAME_BACKGROUND_COLORS = [
- FrameBackgroundColor.Gray,
- FrameBackgroundColor.Red,
- FrameBackgroundColor.Orange,
- FrameBackgroundColor.Yellow,
- FrameBackgroundColor.Green,
- FrameBackgroundColor.Teal,
- FrameBackgroundColor.Blue,
- FrameBackgroundColor.Purple,
- FrameBackgroundColor.Pink,
-];
-
-export const FrameBackgroundColorsSchema = z.nativeEnum(FrameBackgroundColor);
+export const FrameBackgroundColor = Light;
diff --git a/blocksuite/affine/model/src/consts/index.ts b/blocksuite/affine/model/src/consts/index.ts
index f871216c5c3a1..62c70b8c25fc4 100644
--- a/blocksuite/affine/model/src/consts/index.ts
+++ b/blocksuite/affine/model/src/consts/index.ts
@@ -1,4 +1,5 @@
export * from './brush.js';
+export * from './color.js';
export * from './connector.js';
export * from './doc.js';
export * from './frame.js';
diff --git a/blocksuite/affine/model/src/consts/line.ts b/blocksuite/affine/model/src/consts/line.ts
index 83ff57c90232f..0b246849cd1ee 100644
--- a/blocksuite/affine/model/src/consts/line.ts
+++ b/blocksuite/affine/model/src/consts/line.ts
@@ -13,6 +13,20 @@ export enum LineWidth {
Two = 2,
}
+export const LINE_WIDTHS = [
+ LineWidth.Two,
+ LineWidth.Four,
+ LineWidth.Six,
+ LineWidth.Eight,
+ LineWidth.Ten,
+ LineWidth.Twelve,
+];
+
+/**
+ * Use `StrokeColor` instead.
+ *
+ * @deprecated
+ */
export enum LineColor {
Black = '--affine-palette-line-black',
Blue = '--affine-palette-line-blue',
diff --git a/blocksuite/affine/model/src/consts/note.ts b/blocksuite/affine/model/src/consts/note.ts
index 7046999f9982d..b203e37bfc6ed 100644
--- a/blocksuite/affine/model/src/consts/note.ts
+++ b/blocksuite/affine/model/src/consts/note.ts
@@ -1,3 +1,4 @@
+import { themeToVar } from '@toeverything/theme/v2';
import { z } from 'zod';
import { createEnumMap } from '../utils/enum.js';
@@ -8,23 +9,23 @@ export const NOTE_MIN_HEIGHT = 92;
export const DEFAULT_NOTE_WIDTH = NOTE_MIN_WIDTH;
export const DEFAULT_NOTE_HEIGHT = NOTE_MIN_HEIGHT;
-export enum NoteBackgroundColor {
- Black = '--affine-note-background-black',
- Blue = '--affine-note-background-blue',
- Green = '--affine-note-background-green',
- Grey = '--affine-note-background-grey',
- Magenta = '--affine-note-background-magenta',
- Orange = '--affine-note-background-orange',
- Purple = '--affine-note-background-purple',
- Red = '--affine-note-background-red',
- Teal = '--affine-note-background-teal',
- White = '--affine-note-background-white',
- Yellow = '--affine-note-background-yellow',
-}
+export const NoteBackgroundColor = {
+ Yellow: themeToVar('edgeless/note/yellow'),
+ Orange: themeToVar('edgeless/note/orange'),
+ Red: themeToVar('edgeless/note/red'),
+ Magenta: themeToVar('edgeless/note/magenta'),
+ Purple: themeToVar('edgeless/note/purple'),
+ Blue: themeToVar('edgeless/note/blue'),
+ Teal: themeToVar('edgeless/note/teal'),
+ Green: themeToVar('edgeless/note/green'),
+ Black: themeToVar('edgeless/note/black'),
+ Grey: themeToVar('edgeless/note/grey'),
+ White: themeToVar('edgeless/note/white'),
+} as const;
export const NoteBackgroundColorMap = createEnumMap(NoteBackgroundColor);
-export const NOTE_BACKGROUND_COLORS = [
+export const NOTE_BACKGROUND_PALETTES = [
NoteBackgroundColor.Yellow,
NoteBackgroundColor.Orange,
NoteBackgroundColor.Red,
@@ -38,9 +39,9 @@ export const NOTE_BACKGROUND_COLORS = [
NoteBackgroundColor.White,
] as const;
-export const DEFAULT_NOTE_BACKGROUND_COLOR = NoteBackgroundColor.White;
+export const NoteBackgroundPaletteEnum = z.enum(NOTE_BACKGROUND_PALETTES);
-export const NoteBackgroundColorsSchema = z.nativeEnum(NoteBackgroundColor);
+export const DEFAULT_NOTE_BACKGROUND_COLOR = NoteBackgroundColor.White;
export enum NoteShadow {
Box = '--affine-note-shadow-box',
diff --git a/blocksuite/affine/model/src/consts/shape.ts b/blocksuite/affine/model/src/consts/shape.ts
index 5ffb459671383..427bdad8263d7 100644
--- a/blocksuite/affine/model/src/consts/shape.ts
+++ b/blocksuite/affine/model/src/consts/shape.ts
@@ -1,6 +1,4 @@
-import { z } from 'zod';
-
-import { LINE_COLORS, LineColor } from './line.js';
+import { Black, Light, LIGHT_PALETTES, StrokeColor, White } from './color.js';
export const DEFAULT_ROUGHNESS = 1.4;
@@ -49,42 +47,12 @@ export enum ShapeStyle {
Scribbled = 'Scribbled',
}
-export enum ShapeFillColor {
- Black = '--affine-palette-shape-black',
- Blue = '--affine-palette-shape-blue',
- Green = '--affine-palette-shape-green',
- Grey = '--affine-palette-shape-grey',
- Magenta = '--affine-palette-shape-magenta',
- Orange = '--affine-palette-shape-orange',
- Purple = '--affine-palette-shape-purple',
- Red = '--affine-palette-shape-red',
- Teal = '--affine-palette-shape-teal',
- White = '--affine-palette-shape-white',
- Yellow = '--affine-palette-shape-yellow',
-}
-
-export const SHAPE_FILL_COLORS = [
- ShapeFillColor.Yellow,
- ShapeFillColor.Orange,
- ShapeFillColor.Red,
- ShapeFillColor.Magenta,
- ShapeFillColor.Purple,
- ShapeFillColor.Blue,
- ShapeFillColor.Teal,
- ShapeFillColor.Green,
- ShapeFillColor.Black,
- ShapeFillColor.Grey,
- ShapeFillColor.White,
-] as const;
-
-export const DEFAULT_SHAPE_FILL_COLOR = ShapeFillColor.Yellow;
-
-export const FillColorsSchema = z.nativeEnum(ShapeFillColor);
+export const ShapeFillColor = { Black, White, ...Light } as const;
-export const SHAPE_STROKE_COLORS = LINE_COLORS;
+export const SHAPE_FILL_COLORS = [...LIGHT_PALETTES, Black, White];
-export const DEFAULT_SHAPE_STROKE_COLOR = LineColor.Yellow;
+export const DEFAULT_SHAPE_FILL_COLOR = Light.Yellow;
-export const DEFAULT_SHAPE_TEXT_COLOR = LineColor.Black;
+export const DEFAULT_SHAPE_STROKE_COLOR = StrokeColor.Yellow;
-export const StrokeColorsSchema = z.nativeEnum(LineColor);
+export const DEFAULT_SHAPE_TEXT_COLOR = StrokeColor.Black;
diff --git a/blocksuite/affine/model/src/consts/text.ts b/blocksuite/affine/model/src/consts/text.ts
index 83ca28c327c49..3f9887621ef23 100644
--- a/blocksuite/affine/model/src/consts/text.ts
+++ b/blocksuite/affine/model/src/consts/text.ts
@@ -1,5 +1,5 @@
import { createEnumMap } from '../utils/enum.js';
-import { LineColor } from './line.js';
+import { StrokeColor } from './color.js';
export enum ColorScheme {
Dark = 'dark',
@@ -67,4 +67,4 @@ export enum TextResizing {
AUTO_HEIGHT,
}
-export const DEFAULT_TEXT_COLOR = LineColor.Blue;
+export const DEFAULT_TEXT_COLOR = StrokeColor.Blue;
diff --git a/blocksuite/affine/shared/package.json b/blocksuite/affine/shared/package.json
index 9d7183f457299..8380a6a41d625 100644
--- a/blocksuite/affine/shared/package.json
+++ b/blocksuite/affine/shared/package.json
@@ -22,7 +22,7 @@
"@floating-ui/dom": "^1.6.10",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
- "@toeverything/theme": "^1.1.1",
+ "@toeverything/theme": "^1.1.2",
"@types/hast": "^3.0.4",
"@types/mdast": "^4.0.4",
"lit": "^3.2.0",
diff --git a/blocksuite/affine/shared/src/theme/css-variables.ts b/blocksuite/affine/shared/src/theme/css-variables.ts
index c8f417fc41639..e609ef0fc0077 100644
--- a/blocksuite/affine/shared/src/theme/css-variables.ts
+++ b/blocksuite/affine/shared/src/theme/css-variables.ts
@@ -1,6 +1,6 @@
/* CSS variables. You need to handle all places where `CSS variables` are marked. */
-import { LINE_COLORS, SHAPE_FILL_COLORS } from '@blocksuite/affine-model';
+import { LINE_COLORS } from '@blocksuite/affine-model';
import {
type AffineCssVariables,
type AffineTheme,
@@ -66,7 +66,6 @@ export const ColorVariables = [
'--affine-tag-orange',
'--affine-tag-gray',
...LINE_COLORS,
- ...SHAPE_FILL_COLORS,
'--affine-tooltip',
'--affine-blue',
];
diff --git a/blocksuite/affine/shared/src/utils/zod-schema.ts b/blocksuite/affine/shared/src/utils/zod-schema.ts
index 95be5b7d0ec55..ef8ce0d68bdf3 100644
--- a/blocksuite/affine/shared/src/utils/zod-schema.ts
+++ b/blocksuite/affine/shared/src/utils/zod-schema.ts
@@ -14,22 +14,20 @@ import {
DEFAULT_SHAPE_STROKE_COLOR,
DEFAULT_SHAPE_TEXT_COLOR,
DEFAULT_TEXT_COLOR,
- FillColorsSchema,
FontFamily,
FontStyle,
FontWeight,
- FrameBackgroundColorsSchema,
LayoutType,
- LineColor,
LineColorsSchema,
LineWidth,
MindmapStyle,
- NoteBackgroundColorsSchema,
+ NoteBackgroundPaletteEnum,
NoteDisplayMode,
NoteShadowsSchema,
+ PaletteEnum,
PointStyle,
ShapeStyle,
- StrokeColorsSchema,
+ StrokeColor,
StrokeStyle,
TextAlign,
TextVerticalAlign,
@@ -59,17 +57,12 @@ export const ColorSchema = z.union([
dark: z.string(),
}),
]);
-const LineColorSchema = z.union([LineColorsSchema, ColorSchema]);
-const ShapeFillColorSchema = z.union([FillColorsSchema, ColorSchema]);
-const ShapeStrokeColorSchema = z.union([StrokeColorsSchema, ColorSchema]);
-const TextColorSchema = z.union([LineColorsSchema, ColorSchema]);
+const ColorPaletteSchema = z.union([ColorSchema, PaletteEnum]);
+const LineColorSchema = z.union([LineColorsSchema, ColorPaletteSchema]);
+const TextColorSchema = z.union([LineColorsSchema, ColorPaletteSchema]);
const NoteBackgroundColorSchema = z.union([
- NoteBackgroundColorsSchema,
- ColorSchema,
-]);
-const FrameBackgroundColorSchema = z.union([
- FrameBackgroundColorsSchema,
ColorSchema,
+ NoteBackgroundPaletteEnum,
]);
export const ConnectorSchema = z
@@ -110,14 +103,11 @@ export const ConnectorSchema = z
export const BrushSchema = z
.object({
- color: LineColorSchema,
+ color: ColorPaletteSchema,
lineWidth: LineWidthSchema,
})
.default({
- color: {
- dark: LineColor.White,
- light: LineColor.Black,
- },
+ color: StrokeColor.Black,
lineWidth: LineWidth.Four,
});
@@ -140,8 +130,8 @@ const DEFAULT_SHAPE = {
const ShapeObject = {
color: TextColorSchema,
- fillColor: ShapeFillColorSchema,
- strokeColor: ShapeStrokeColorSchema,
+ fillColor: ColorPaletteSchema,
+ strokeColor: ColorPaletteSchema,
strokeStyle: StrokeStyleSchema,
strokeWidth: z.number(),
shapeStyle: ShapeStyleSchema,
@@ -235,7 +225,7 @@ export const MindmapSchema = z
export const FrameSchema = z
.object({
- background: FrameBackgroundColorSchema.optional(),
+ background: ColorPaletteSchema.optional(),
})
.default({});
diff --git a/blocksuite/affine/widget-scroll-anchoring/package.json b/blocksuite/affine/widget-scroll-anchoring/package.json
index 09d95be57bf88..2e1da5bb3b3a2 100644
--- a/blocksuite/affine/widget-scroll-anchoring/package.json
+++ b/blocksuite/affine/widget-scroll-anchoring/package.json
@@ -18,7 +18,7 @@
"@blocksuite/block-std": "workspace:*",
"@blocksuite/global": "workspace:*",
"@preact/signals-core": "^1.8.0",
- "@toeverything/theme": "^1.1.1",
+ "@toeverything/theme": "^1.1.2",
"lit": "^3.2.0"
},
"exports": {
diff --git a/blocksuite/blocks/package.json b/blocksuite/blocks/package.json
index 6325999557459..e1144c948e781 100644
--- a/blocksuite/blocks/package.json
+++ b/blocksuite/blocks/package.json
@@ -31,7 +31,7 @@
"@floating-ui/dom": "^1.6.10",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
- "@toeverything/theme": "^1.1.1",
+ "@toeverything/theme": "^1.1.2",
"@types/hast": "^3.0.4",
"@types/mdast": "^4.0.4",
"collapse-white-space": "^2.1.0",
diff --git a/blocksuite/blocks/src/effects.ts b/blocksuite/blocks/src/effects.ts
index 6fa06df40948b..ac767e0a61ef7 100644
--- a/blocksuite/blocks/src/effects.ts
+++ b/blocksuite/blocks/src/effects.ts
@@ -129,7 +129,6 @@ import { EdgelessFontWeightAndStylePanel } from './root-block/edgeless/component
import { EdgelessLineWidthPanel } from './root-block/edgeless/components/panel/line-width-panel.js';
import { NoteDisplayModePanel } from './root-block/edgeless/components/panel/note-display-mode-panel.js';
import { EdgelessNoteShadowPanel } from './root-block/edgeless/components/panel/note-shadow-panel.js';
-import { EdgelessOneRowColorPanel } from './root-block/edgeless/components/panel/one-row-color-panel.js';
import { EdgelessScalePanel } from './root-block/edgeless/components/panel/scale-panel.js';
import { EdgelessShapePanel } from './root-block/edgeless/components/panel/shape-panel.js';
import { EdgelessShapeStylePanel } from './root-block/edgeless/components/panel/shape-style-panel.js';
@@ -532,10 +531,6 @@ export function effects() {
'edgeless-frame-title-editor',
EdgelessFrameTitleEditor
);
- customElements.define(
- 'edgeless-one-row-color-panel',
- EdgelessOneRowColorPanel
- );
customElements.define('edgeless-text-editor', EdgelessTextEditor);
customElements.define('affine-image-toolbar', AffineImageToolbar);
customElements.define('affine-drop-indicator', DropIndicator);
diff --git a/blocksuite/blocks/src/root-block/edgeless/components/color-picker/button.ts b/blocksuite/blocks/src/root-block/edgeless/components/color-picker/button.ts
index dad904d91bc2c..5b2435415d078 100644
--- a/blocksuite/blocks/src/root-block/edgeless/components/color-picker/button.ts
+++ b/blocksuite/blocks/src/root-block/edgeless/components/color-picker/button.ts
@@ -3,6 +3,7 @@ import { WithDisposable } from '@blocksuite/global/utils';
import { html, LitElement } from 'lit';
import { property, query, state } from 'lit/decorators.js';
import { choose } from 'lit/directives/choose.js';
+import { ifDefined } from 'lit/directives/if-defined.js';
import { styleMap } from 'lit/directives/style-map.js';
import type { ColorEvent } from '../panel/color-panel.js';
@@ -12,7 +13,7 @@ import type {
PickColorEvent,
PickColorType,
} from './types.js';
-import { keepColor, preprocessColor } from './utils.js';
+import { keepColor, preprocessColor, rgbaToHex8 } from './utils.js';
type Type = 'normal' | 'custom';
@@ -38,10 +39,28 @@ export class EdgelessColorPickerButton extends WithDisposable(LitElement) {
get customButtonStyle() {
let b = 'transparent';
let c = 'transparent';
- if (!this.isCSSVariable) {
+
+ if (!this.isCustomColor) {
+ return { '--b': b, '--c': c };
+ }
+
+ if (this.isCSSVariable) {
+ if (!this.color.endsWith('transparent')) {
+ b = 'var(--affine-background-overlay-panel-color)';
+ c = keepColor(
+ rgbaToHex8(
+ preprocessColor(window.getComputedStyle(this))({
+ type: 'normal',
+ value: this.color,
+ }).rgba
+ )
+ );
+ }
+ } else {
b = 'var(--affine-background-overlay-panel-color)';
c = keepColor(this.color);
}
+
return { '--b': b, '--c': c };
}
@@ -49,6 +68,10 @@ export class EdgelessColorPickerButton extends WithDisposable(LitElement) {
return this.color.startsWith('--');
}
+ get isCustomColor() {
+ return !this.palettes.includes(this.color);
+ }
+
get tabContentPadding() {
return `${this.tabType === 'custom' ? 0 : 8}px`;
}
@@ -101,7 +124,9 @@ export class EdgelessColorPickerButton extends WithDisposable(LitElement) {
@@ -142,6 +167,9 @@ export class EdgelessColorPickerButton extends WithDisposable(LitElement) {
@property()
accessor color!: string;
+ @property()
+ accessor colorPanelClass: string | undefined = undefined;
+
@property({ attribute: false })
accessor colors: { type: ModeType; value: string }[] = [];
diff --git a/blocksuite/blocks/src/root-block/edgeless/components/color-picker/custom-button.ts b/blocksuite/blocks/src/root-block/edgeless/components/color-picker/custom-button.ts
index 9c76ed365f62b..72a4bdde44147 100644
--- a/blocksuite/blocks/src/root-block/edgeless/components/color-picker/custom-button.ts
+++ b/blocksuite/blocks/src/root-block/edgeless/components/color-picker/custom-button.ts
@@ -1,18 +1,35 @@
import { css, html, LitElement } from 'lit';
import { property } from 'lit/decorators.js';
-import { colorContainerStyles } from '../panel/color-panel.js';
-
export class EdgelessColorCustomButton extends LitElement {
static override styles = css`
- ${colorContainerStyles}
+ :host {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 24px;
+ height: 24px;
+ cursor: pointer;
+ }
+ :host([active]):after {
+ position: absolute;
+ display: block;
+ content: '';
+ width: 27px;
+ height: 27px;
+ border: 1.5px solid var(--affine-primary-color);
+ border-radius: 50%;
+ box-sizing: border-box;
+ overflow: hidden;
+ pointer-events: none;
+ }
.color-custom {
display: flex;
align-items: center;
justify-content: center;
- width: 16px;
- height: 16px;
+ width: 21px;
+ height: 21px;
border-radius: 50%;
box-sizing: border-box;
overflow: hidden;
@@ -43,15 +60,11 @@ export class EdgelessColorCustomButton extends LitElement {
`;
override render() {
- return html`
-
- `;
+ return html``;
}
- @property({ attribute: false })
- accessor active!: boolean;
+ @property({ attribute: true, type: Boolean })
+ accessor active: boolean = false;
}
declare global {
diff --git a/blocksuite/blocks/src/root-block/edgeless/components/panel/color-panel.ts b/blocksuite/blocks/src/root-block/edgeless/components/panel/color-panel.ts
index 04f48055fda7a..7d33780eaa411 100644
--- a/blocksuite/blocks/src/root-block/edgeless/components/panel/color-panel.ts
+++ b/blocksuite/blocks/src/root-block/edgeless/components/panel/color-panel.ts
@@ -1,15 +1,9 @@
-import { TransparentIcon } from '@blocksuite/affine-components/icons';
-import {
- ColorScheme,
- LINE_COLORS,
- LineColor,
- NoteBackgroundColor,
- ShapeFillColor,
-} from '@blocksuite/affine-model';
-import { css, html, LitElement, nothing } from 'lit';
+import { Black, ColorScheme, PALETTES, White } from '@blocksuite/affine-model';
+import { unsafeCSSVarV2 } from '@blocksuite/affine-shared/theme';
+import { css, html, LitElement, nothing, svg, type TemplateResult } from 'lit';
import { property } from 'lit/decorators.js';
+import { classMap } from 'lit/directives/class-map.js';
import { repeat } from 'lit/directives/repeat.js';
-import { styleMap } from 'lit/directives/style-map.js';
export class ColorEvent extends Event {
detail: string;
@@ -28,70 +22,64 @@ export class ColorEvent extends Event {
}
export const GET_DEFAULT_LINE_COLOR = (theme: ColorScheme) => {
- return theme === ColorScheme.Dark ? LineColor.White : LineColor.Black;
+ return theme === ColorScheme.Dark ? White : Black;
};
export function isTransparent(color: string) {
return color.toLowerCase().endsWith('transparent');
}
-function isSameColorWithBackground(color: string) {
- const colors: string[] = [
- LineColor.Black,
- LineColor.White,
- NoteBackgroundColor.Black,
- NoteBackgroundColor.White,
- ShapeFillColor.Black,
- ShapeFillColor.White,
- ];
- return colors.includes(color.toLowerCase());
-}
-
-function TransparentColor(hollowCircle = false) {
- const containerStyle = {
- position: 'relative',
- width: '16px',
- height: '16px',
- stroke: 'none',
- };
- const maskStyle = {
- position: 'absolute',
- width: '10px',
- height: '10px',
- left: '3px',
- top: '3.5px',
- borderRadius: '50%',
- background: 'var(--affine-background-overlay-panel-color)',
- };
-
- const mask = hollowCircle
- ? html``
+function TransparentIcon(hollowCircle = false) {
+ const CircleIcon: TemplateResult | typeof nothing = hollowCircle
+ ? svg``
: nothing;
return html`
- ${TransparentIcon} ${mask}
+
`;
}
-function BorderedHollowCircle(color: string) {
- const valid = color.startsWith('--');
- const strokeWidth = valid && isSameColorWithBackground(color) ? 1 : 0;
- const style = {
- fill: valid ? `var(${color})` : color,
- stroke: 'var(--affine-border-color)',
- };
+function CircleIcon(color: string) {
+ return html`
+
+ `;
+}
+
+function HollowCircleIcon(color: string) {
return html`
`;
@@ -99,76 +87,82 @@ function BorderedHollowCircle(color: string) {
function AdditionIcon(color: string, hollowCircle: boolean) {
if (isTransparent(color)) {
- return TransparentColor(hollowCircle);
+ return TransparentIcon(hollowCircle);
}
+
if (hollowCircle) {
- return BorderedHollowCircle(color);
+ return HollowCircleIcon(color);
}
- return nothing;
-}
-export function ColorUnit(
- color: string,
- {
- hollowCircle,
- letter,
- }: {
- hollowCircle?: boolean;
- letter?: boolean;
- } = {}
-) {
- const additionIcon = AdditionIcon(color, !!hollowCircle);
-
- const colorStyle =
- !hollowCircle && !isTransparent(color)
- ? { background: `var(${color})` }
- : {};
-
- const borderStyle =
- isSameColorWithBackground(color) && !hollowCircle
- ? {
- border: '0.5px solid var(--affine-border-color)',
- }
- : {};
-
- const style = {
- width: '16px',
- height: '16px',
- borderRadius: '50%',
- boxSizing: 'border-box',
- overflow: 'hidden',
- ...borderStyle,
- ...colorStyle,
- };
-
- return html`
-
- ${additionIcon}
-
- `;
+ return CircleIcon(color);
}
export class EdgelessColorButton extends LitElement {
static override styles = css`
:host {
+ position: relative;
+ width: 20px;
+ height: 20px;
display: flex;
justify-content: center;
align-items: center;
- width: 20px;
- height: 20px;
+ cursor: pointer;
}
.color-unit {
+ position: relative;
width: 16px;
height: 16px;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ border-radius: 50%;
+ box-sizing: border-box;
+ }
+ .color-unit svg {
+ width: 100%;
+ height: 100%;
+ border-radius: 50%;
+ overflow: hidden;
+ }
+ :host .color-unit:after {
+ position: absolute;
+ display: block;
+ content: '';
+ width: 100%;
+ height: 100%;
border-radius: 50%;
box-sizing: border-box;
overflow: hidden;
+ pointer-events: none;
+ border-width: 0.5px;
+ border-style: solid;
+ border-color: ${unsafeCSSVarV2('layer/insideBorder/blackBorder')};
+ }
+ :host(.black) .color-unit:after {
+ border-color: ${unsafeCSSVarV2('layer/insideBorder/border')};
+ }
+
+ :host(.large) {
+ width: 24px;
+ height: 24px;
+ }
+ :host(.large) .color-unit {
+ width: 20px;
+ height: 20px;
+ }
+
+ :host([active]):after {
+ position: absolute;
+ display: block;
+ content: '';
+ width: 27px;
+ height: 27px;
+ border: 1.5px solid var(--affine-primary-color);
+ border-radius: 50%;
+ box-sizing: border-box;
+ overflow: hidden;
+ pointer-events: none;
}
`;
@@ -178,85 +172,54 @@ export class EdgelessColorButton extends LitElement {
}
override render() {
- const { color, hollowCircle, letter } = this;
- const additionIcon = AdditionIcon(color, !!hollowCircle);
- const style: Record = {};
- if (!hollowCircle) {
- style.background = this.preprocessColor;
- if (isSameColorWithBackground(color)) {
- style.border = '0.5px solid var(--affine-border-color)';
- }
- }
+ const { color, preprocessColor, hollowCircle, letter } = this;
+ const additionIcon = AdditionIcon(preprocessColor, !!hollowCircle);
return html`
${additionIcon}
`;
}
+ @property({ attribute: true, type: Boolean })
+ accessor active: boolean = false;
+
@property({ attribute: false })
accessor color!: string;
@property({ attribute: false })
- accessor hollowCircle: boolean | undefined = undefined;
+ accessor hollowCircle: boolean = false;
@property({ attribute: false })
accessor letter: boolean | undefined = undefined;
}
-export const colorContainerStyles = css`
- .color-container {
- position: relative;
- display: flex;
- align-items: center;
- justify-content: center;
- width: 24px;
- height: 24px;
- border-radius: 50%;
- box-sizing: border-box;
- overflow: hidden;
- cursor: pointer;
- padding: 2px;
- }
-
- .color-unit::before {
- content: attr(data-letter);
- display: block;
- font-size: 12px;
- }
-
- .color-container[active]:after {
- position: absolute;
- width: 20px;
- height: 20px;
- border: 0.5px solid var(--affine-primary-color);
- border-radius: 50%;
- box-sizing: border-box;
- content: attr(data-letter);
- }
-`;
-
export class EdgelessColorPanel extends LitElement {
static override styles = css`
:host {
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- width: 184px;
- gap: 8px;
+ display: grid;
+ grid-gap: 4px;
+ grid-template-columns: repeat(9, 1fr);
}
- ${colorContainerStyles}
- `;
+ /* note */
+ :host(.small) {
+ grid-template-columns: repeat(6, 1fr);
+ grid-gap: 8px;
+ }
- get palettes() {
- return this.hasTransparent
- ? ['--affine-palette-transparent', ...this.options]
- : this.options;
- }
+ /* edgeless toolbar */
+ :host(.one-way) {
+ display: flex;
+ flex-wrap: nowrap;
+ padding: 0 2px;
+ gap: 14px;
+ box-sizing: border-box;
+ background: var(--affine-background-overlay-panel-color);
+ }
+ `;
onSelect(value: string) {
this.dispatchEvent(
@@ -274,24 +237,20 @@ export class EdgelessColorPanel extends LitElement {
${repeat(
this.palettes,
color => color,
- color => {
- const unit = ColorUnit(color, {
- hollowCircle: this.hollowCircle,
- letter: this.showLetterMark,
- });
-
- return html`
- this.onSelect(color)}
- >
- ${unit}
-
- `;
- }
+ color =>
+ html` this.onSelect(color)}
+ >
+ `
)}
-
`;
}
@@ -306,7 +265,7 @@ export class EdgelessColorPanel extends LitElement {
accessor openColorPicker!: (e: MouseEvent) => void;
@property({ type: Array })
- accessor options: readonly string[] = LINE_COLORS;
+ accessor palettes: readonly string[] = PALETTES;
@property({ attribute: false })
accessor showLetterMark = false;
@@ -334,11 +293,11 @@ export class EdgelessTextColorIcon extends LitElement {
override render() {
return html`