Skip to content

Commit

Permalink
fix(core): color palette types
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Dec 18, 2024
1 parent f0d99f4 commit aa95267
Show file tree
Hide file tree
Showing 6 changed files with 200 additions and 199 deletions.
19 changes: 18 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,23 @@
"fs-xattr": "npm:@napi-rs/xattr@latest",
"vite": "6.0.3",
"decode-named-character-reference@npm:^1.0.0": "patch:decode-named-character-reference@npm%3A1.0.2#~/.yarn/patches/decode-named-character-reference-npm-1.0.2-db17a755fd.patch",
"@atlaskit/pragmatic-drag-and-drop@npm:^1.1.0": "patch:@atlaskit/pragmatic-drag-and-drop@npm%3A1.4.0#~/.yarn/patches/@atlaskit-pragmatic-drag-and-drop-npm-1.4.0-75c45f52d3.patch"
"@atlaskit/pragmatic-drag-and-drop@npm:^1.1.0": "patch:@atlaskit/pragmatic-drag-and-drop@npm%3A1.4.0#~/.yarn/patches/@atlaskit-pragmatic-drag-and-drop-npm-1.4.0-75c45f52d3.patch",
"@blocksuite/affine": "portal:/Users/fundon/dev/toeverything/blocksuite/packages/affine/all",
"@blocksuite/affine-block-embed": "portal:/Users/fundon/dev/toeverything/blocksuite/packages/affine/block-embed",
"@blocksuite/affine-block-list": "portal:/Users/fundon/dev/toeverything/blocksuite/packages/affine/block-list",
"@blocksuite/affine-block-paragraph": "portal:/Users/fundon/dev/toeverything/blocksuite/packages/affine/block-paragraph",
"@blocksuite/affine-block-surface": "portal:/Users/fundon/dev/toeverything/blocksuite/packages/affine/block-surface",
"@blocksuite/affine-components": "portal:/Users/fundon/dev/toeverything/blocksuite/packages/affine/components",
"@blocksuite/data-view": "portal:/Users/fundon/dev/toeverything/blocksuite/packages/affine/data-view",
"@blocksuite/affine-model": "portal:/Users/fundon/dev/toeverything/blocksuite/packages/affine/model",
"@blocksuite/affine-shared": "portal:/Users/fundon/dev/toeverything/blocksuite/packages/affine/shared",
"@blocksuite/affine-widget-scroll-anchoring": "portal:/Users/fundon/dev/toeverything/blocksuite/packages/affine/widget-scroll-anchoring",
"@blocksuite/blocks": "portal:/Users/fundon/dev/toeverything/blocksuite/packages/blocks",
"@blocksuite/block-std": "portal:/Users/fundon/dev/toeverything/blocksuite/packages/framework/block-std",
"@blocksuite/global": "portal:/Users/fundon/dev/toeverything/blocksuite/packages/framework/global",
"@blocksuite/inline": "portal:/Users/fundon/dev/toeverything/blocksuite/packages/framework/inline",
"@blocksuite/store": "portal:/Users/fundon/dev/toeverything/blocksuite/packages/framework/store",
"@blocksuite/sync": "portal:/Users/fundon/dev/toeverything/blocksuite/packages/framework/sync",
"@blocksuite/presets": "portal:/Users/fundon/dev/toeverything/blocksuite/packages/presets"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import {
FontFamilyMap,
FontStyle,
FontWeightMap,
LineColor,
LineColorMap,
PointStyle,
StrokeColor,
StrokeColorMap,
StrokeStyle,
TextAlign,
} from '@blocksuite/affine/blocks';
Expand Down Expand Up @@ -152,12 +152,12 @@ export const ConnectorSettings = () => {

const currentColor = useMemo(() => {
const color = settings.connector.stroke;
return getColorFromMap(color, LineColorMap);
return getColorFromMap(color, StrokeColorMap);
}, [getColorFromMap, settings.connector.stroke]);

const colorItems = useMemo(() => {
const { stroke } = settings.connector;
return Object.entries(LineColor).map(([name, value]) => {
return Object.entries(StrokeColor).map(([name, value]) => {
const handler = () => {
editorSetting.set('connector', { stroke: value });
};
Expand Down Expand Up @@ -322,7 +322,7 @@ export const ConnectorSettings = () => {

const textColorItems = useMemo(() => {
const { color } = settings.connector.labelStyle;
return Object.entries(LineColor).map(([name, value]) => {
return Object.entries(StrokeColor).map(([name, value]) => {
const handler = () => {
editorSetting.set('connector', {
labelStyle: {
Expand All @@ -346,7 +346,7 @@ export const ConnectorSettings = () => {

const textColor = useMemo(() => {
const { color } = settings.connector.labelStyle;
return getColorFromMap(color, LineColorMap);
return getColorFromMap(color, StrokeColorMap);
}, [getColorFromMap, settings]);

const getElements = useCallback((doc: Doc) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MenuItem, MenuTrigger, Slider } from '@affine/component';
import { SettingRow } from '@affine/component/setting-components';
import { EditorSettingService } from '@affine/core/modules/editor-setting';
import { useI18n } from '@affine/i18n';
import { LineColor, LineColorMap } from '@blocksuite/affine/blocks';
import { StrokeColor, StrokeColorMap } from '@blocksuite/affine/blocks';
import type { Doc } from '@blocksuite/affine/store';
import { useFramework, useLiveData } from '@toeverything/infra';
import { useCallback, useMemo } from 'react';
Expand All @@ -22,12 +22,12 @@ export const PenSettings = () => {
const getColorFromMap = useColor();

const currentColor = useMemo(() => {
return getColorFromMap(settings.brush.color, LineColorMap);
return getColorFromMap(settings.brush.color, StrokeColorMap);
}, [getColorFromMap, settings.brush.color]);

const colorItems = useMemo(() => {
const { color } = settings.brush;
return Object.entries(LineColor).map(([name, value]) => {
return Object.entries(StrokeColor).map(([name, value]) => {
const handler = () => {
editorSetting.set('brush', { color: value });
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import {
FontStyle,
FontWeightMap,
getShapeName,
LineColor,
LineColorMap,
ShapeFillColor,
ShapeStyle,
ShapeType,
StrokeColor,
StrokeColorMap,
StrokeStyle,
TextAlign,
} from '@blocksuite/affine/blocks';
Expand Down Expand Up @@ -226,7 +226,7 @@ export const ShapeSettings = () => {

const borderColorItems = useMemo(() => {
const { strokeColor } = settings[`shape:${currentShape}`];
return Object.entries(LineColor).map(([name, value]) => {
return Object.entries(StrokeColor).map(([name, value]) => {
const handler = () => {
editorSetting.set(`shape:${currentShape}`, { strokeColor: value });
};
Expand Down Expand Up @@ -316,7 +316,7 @@ export const ShapeSettings = () => {

const textColorItems = useMemo(() => {
const { color } = settings[`shape:${currentShape}`];
return Object.entries(LineColor).map(([name, value]) => {
return Object.entries(StrokeColor).map(([name, value]) => {
const handler = () => {
editorSetting.set(`shape:${currentShape}`, { color: value });
};
Expand Down Expand Up @@ -375,12 +375,12 @@ export const ShapeSettings = () => {

const borderColor = useMemo(() => {
const color = settings[`shape:${currentShape}`].strokeColor;
return getColorFromMap(color, LineColorMap);
return getColorFromMap(color, StrokeColorMap);
}, [currentShape, getColorFromMap, settings]);

const textColor = useMemo(() => {
const color = settings[`shape:${currentShape}`].color;
return getColorFromMap(color, LineColorMap);
return getColorFromMap(color, StrokeColorMap);
}, [currentShape, getColorFromMap, settings]);

const height = currentDoc === 'flow' ? 456 : 180;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
FontFamilyMap,
FontStyle,
FontWeightMap,
LineColor,
LineColorMap,
StrokeColor,
StrokeColorMap,
TextAlign,
} from '@blocksuite/affine/blocks';
import type { Doc } from '@blocksuite/affine/store';
Expand Down Expand Up @@ -72,7 +72,7 @@ export const TextSettings = () => {

const colorItems = useMemo(() => {
const { color } = settings['affine:edgeless-text'];
return Object.entries(LineColor).map(([name, value]) => {
return Object.entries(StrokeColor).map(([name, value]) => {
const handler = () => {
editorSetting.set('affine:edgeless-text', { color: value });
};
Expand Down Expand Up @@ -137,7 +137,7 @@ export const TextSettings = () => {

const currentColor = useMemo(() => {
const { color } = settings['affine:edgeless-text'];
return getColorFromMap(color, LineColorMap);
return getColorFromMap(color, StrokeColorMap);
}, [getColorFromMap, settings]);

const getElements = useCallback((doc: Doc) => {
Expand Down
Loading

0 comments on commit aa95267

Please sign in to comment.