Skip to content

Commit

Permalink
Separate default width and height vs min width and height
Browse files Browse the repository at this point in the history
  • Loading branch information
low-earth-orbit committed Sep 18, 2024
1 parent 255c203 commit 969bff6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
4 changes: 3 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"trailingComma": "all",
"semi": true,
"singleQuote": false,
"printWidth": 80
"printWidth": 80,
"endOfLine": "lf",
"insertFinalNewline": true
}
15 changes: 9 additions & 6 deletions components/Canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ import {
redo,
setCanvasObjects,
} from "../redux/canvasSlice";
import { SHAPE_MIN_HEIGHT, SHAPE_MIN_WIDTH } from "./shapes/shapeUtils";
import { TEXT_MIN_HEIGHT, TEXT_MIN_WIDTH } from "./textFields/textFieldUtils";
import { SHAPE_DEFAULT_HEIGHT, SHAPE_DEFAULT_WIDTH } from "./shapes/shapeUtils";
import {
TEXT_DEFAULT_HEIGHT,
TEXT_DEFAULT_WIDTH,
} from "./textFields/textFieldUtils";

export interface StageSizeType {
width: number;
Expand Down Expand Up @@ -241,8 +244,8 @@ export default function Canvas() {
type: "text" as const,
x: x,
y: y,
width: TEXT_MIN_WIDTH,
height: TEXT_MIN_HEIGHT,
width: TEXT_DEFAULT_WIDTH,
height: TEXT_DEFAULT_HEIGHT,
fill: strokeColor, // use strokeColor for fill for now
// strokeWidth not applied to text field for now
text: "Double click to edit.",
Expand All @@ -264,8 +267,8 @@ export default function Canvas() {
strokeWidth: strokeWidth,
x: x,
y: y,
width: SHAPE_MIN_WIDTH,
height: SHAPE_MIN_HEIGHT,
width: SHAPE_DEFAULT_WIDTH,
height: SHAPE_DEFAULT_HEIGHT,
}; // common shape properties

let newShape: CanvasObjectType;
Expand Down
6 changes: 4 additions & 2 deletions components/shapes/shapeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ export const getStrokeWidth = (
}
};

export const SHAPE_MIN_WIDTH = 50;
export const SHAPE_MIN_HEIGHT = 50;
export const SHAPE_MIN_WIDTH = 5;
export const SHAPE_MIN_HEIGHT = 5;
export const SHAPE_DEFAULT_WIDTH = 50;
export const SHAPE_DEFAULT_HEIGHT = 50;
6 changes: 4 additions & 2 deletions components/textFields/textFieldUtils.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export const TEXT_MIN_WIDTH = 200;
export const TEXT_MIN_HEIGHT = 50;
export const TEXT_DEFAULT_WIDTH = 200;
export const TEXT_DEFAULT_HEIGHT = 50;
export const TEXT_MIN_WIDTH = 5;
export const TEXT_MIN_HEIGHT = 5;

0 comments on commit 969bff6

Please sign in to comment.