Skip to content

Commit

Permalink
#585 define disabled property
Browse files Browse the repository at this point in the history
  • Loading branch information
oleojake committed Dec 23, 2024
1 parent 537d333 commit 3fddd6e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const DEFAULT_FONT_VARIANT = 'normal';
const DEFAULT_FONT_STYLE = 'normal';
const DEFAULT_TEXT_DECORATION = 'none';
const DEFAULT_TEXT_ALIGNMENT = 'left';
const DEFAULT_DISABLED = false;

export interface DefaultStyleShape {
DEFAULT_CORNER_RADIUS: number;
Expand All @@ -34,6 +35,7 @@ export interface DefaultStyleShape {
DEFAULT_FONT_STYLE: string;
DEFAULT_TEXT_DECORATION: string;
DEFAULT_TEXT_ALIGNMENT: 'left' | 'center' | 'right';
DEFAULT_DISABLED: boolean;
}

export const BASIC_SHAPE: DefaultStyleShape = {
Expand All @@ -53,6 +55,7 @@ export const BASIC_SHAPE: DefaultStyleShape = {
DEFAULT_FONT_STYLE,
DEFAULT_TEXT_DECORATION,
DEFAULT_TEXT_ALIGNMENT,
DEFAULT_DISABLED,
};

export const INPUT_SHAPE: DefaultStyleShape = {
Expand All @@ -72,6 +75,7 @@ export const INPUT_SHAPE: DefaultStyleShape = {
DEFAULT_FONT_STYLE,
DEFAULT_TEXT_DECORATION,
DEFAULT_TEXT_ALIGNMENT,
DEFAULT_DISABLED,
};

//! maybe a function to calc max height base on the text
Expand All @@ -92,6 +96,7 @@ export const POSTIT_SHAPE: DefaultStyleShape = {
DEFAULT_FONT_STYLE,
DEFAULT_TEXT_DECORATION,
DEFAULT_TEXT_ALIGNMENT,
DEFAULT_DISABLED,
};

interface FontValues {
Expand All @@ -114,6 +119,18 @@ export const FONT_SIZE_VALUES: FontValues = {
LINK: 20,
};

interface DisabledValues {
DEFAULT_STROKE_COLOR: string;
DEFAULT_BACKGROUND_COLOR: string;
DEFAULT_TEXT_COLOR: string;
}

export const DISABLED_COLOR_VALUES: DisabledValues = {
DEFAULT_STROKE_COLOR: '#D9D9D9',
DEFAULT_BACKGROUND_COLOR: '#F5F5F5',
DEFAULT_TEXT_COLOR: '#B0B0B0',
};

export const LINK_SHAPE: DefaultStyleShape = {
...BASIC_SHAPE,
DEFAULT_FILL_TEXT: '#0000FF',
Expand Down
6 changes: 6 additions & 0 deletions src/common/components/shapes/use-shape-props.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ export const useShapeProps = (
[otherProps?.selectedBackgroundColor]
);

const disabled = useMemo(
() => otherProps?.disabled ?? defaultStyleShape.DEFAULT_DISABLED,
[otherProps?.disabled]
);

return {
stroke,
fill,
Expand All @@ -87,5 +92,6 @@ export const useShapeProps = (
fontSize,
textDecoration,
textAlignment,
disabled,
};
};
1 change: 1 addition & 0 deletions src/core/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export interface OtherProps {
activeElement?: number;
selectedBackgroundColor?: string;
textAlignment?: 'left' | 'center' | 'right';
disabled?: boolean;
}

export const BASE_ICONS_URL = '/icons/';
Expand Down

0 comments on commit 3fddd6e

Please sign in to comment.