Skip to content

Commit

Permalink
Merge pull request #645 from Lemoncode/dev
Browse files Browse the repository at this point in the history
push to production active page, disabled, richttext
  • Loading branch information
brauliodiez authored Jan 2, 2025
2 parents b061dc1 + c3b70f2 commit 54bf203
Show file tree
Hide file tree
Showing 26 changed files with 414 additions and 18 deletions.
63 changes: 63 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@fontsource/balsamiq-sans": "^5.0.21",
"@types/lodash.clonedeep": "^4.5.9",
"@uiw/react-color-chrome": "^2.3.2",
"html2canvas": "^1.4.1",
"immer": "^10.1.1",
"konva": "^9.3.12",
"lodash.clonedeep": "^4.5.0",
Expand All @@ -30,6 +31,7 @@
"react-konva": "^18.2.10",
"react-konva-utils": "^1.0.6",
"tiny-invariant": "^1.3.3",
"use-debounce": "^10.0.4",
"use-image": "^1.1.1",
"uuid": "^10.0.0"
},
Expand Down
1 change: 1 addition & 0 deletions public/icons/calendar-disabled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/clock-disabled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions public/text/rich-text.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { forwardRef } from 'react';
import { ShapeProps } from '../shape.model';
import { fitSizeToShapeSizeRestrictions } from '@/common/utils/shapes/shape-restrictions';
import { Group, Rect, Text, Image } from 'react-konva';
import { DISABLED_COLOR_VALUES, INPUT_SHAPE } from './shape.const';
import { BASIC_SHAPE, DISABLED_COLOR_VALUES } from './shape.const';
import { useShapeProps } from '../../shapes/use-shape-props.hook';
import { useGroupShapeProps } from '../mock-components.utils';

import calendarIconSrc from '/icons/calendar.svg';
import disabledCalendarIconSrc from '/icons/calendar-disabled.svg';

const datepickerInputShapeRestrictions: ShapeSizeRestrictions = {
minWidth: 100,
Expand Down Expand Up @@ -45,7 +46,7 @@ export const DatepickerInputShape = forwardRef<any, ShapeProps>(
const { width: restrictedWidth, height: restrictedHeight } = restrictedSize;

const { stroke, fill, textColor, strokeStyle, borderRadius, disabled } =
useShapeProps(otherProps, INPUT_SHAPE);
useShapeProps(otherProps, BASIC_SHAPE);

const commonGroupProps = useGroupShapeProps(
props,
Expand All @@ -64,7 +65,7 @@ export const DatepickerInputShape = forwardRef<any, ShapeProps>(
const labelFontSize = Math.min(restrictedHeight * 0.3, 12);

const calendarIcon = new window.Image();
calendarIcon.src = calendarIconSrc;
calendarIcon.src = disabled ? disabledCalendarIconSrc : calendarIconSrc;

return (
<Group {...commonGroupProps} {...shapeProps}>
Expand All @@ -79,7 +80,7 @@ export const DatepickerInputShape = forwardRef<any, ShapeProps>(
disabled ? DISABLED_COLOR_VALUES.DEFAULT_STROKE_COLOR : stroke
}
dash={strokeStyle}
strokeWidth={2}
strokeWidth={BASIC_SHAPE.DEFAULT_STROKE_WIDTH}
fill={
disabled ? DISABLED_COLOR_VALUES.DEFAULT_BACKGROUND_COLOR : fill
}
Expand All @@ -91,14 +92,16 @@ export const DatepickerInputShape = forwardRef<any, ShapeProps>(
width={labelFontSize + 20}
height={labelFontSize}
cornerRadius={borderRadius}
strokeWidth={BASIC_SHAPE.DEFAULT_STROKE_WIDTH}
fill="white"
/>
{/* Label "Date" */}
<Text
text="Date"
x={13}
y={-5}
fontSize={labelFontSize}
fontFamily={BASIC_SHAPE.DEFAULT_FONT_FAMILY}
fontSize={BASIC_SHAPE.DEFAULT_FONT_SIZE - 4}
fill={disabled ? DISABLED_COLOR_VALUES.DEFAULT_TEXT_COLOR : stroke}
align="center"
color={stroke}
Expand All @@ -110,7 +113,7 @@ export const DatepickerInputShape = forwardRef<any, ShapeProps>(
x={10}
y={(restrictedHeight - fontSize) / 2 + 2}
width={availableWidth}
fontSize={fontSize}
fontSize={BASIC_SHAPE.DEFAULT_FONT_SIZE}
align="left"
ellipsis={true}
wrap="none"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ export const ListBoxShape = forwardRef<any, ListBoxShapeProps>((props, ref) => {
);

const calculateItemBackground = (index: number) => {
if (disabled) return DISABLED_COLOR_VALUES.DEFAULT_BACKGROUND_COLOR;
if (disabled) {
return selectedItem === index
? DISABLED_COLOR_VALUES.DEFAULT_STROKE_COLOR
: DISABLED_COLOR_VALUES.DEFAULT_BACKGROUND_COLOR;
}

return selectedItem === index ? selectedBackgroundColor : fill;
};
Expand Down Expand Up @@ -127,6 +131,7 @@ export const ListBoxShape = forwardRef<any, ListBoxShapeProps>((props, ref) => {
fill={calculateItemBackground(index)}
stroke={calculateItemStroke(index)}
strokeWidth={selectedItem === index ? 1 : 0}
cornerRadius={borderRadius}
/>
<Text
x={10}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ export const ProgressBarShape = forwardRef<any, ShapeProps>((props, ref) => {
);
const { width: restrictedWidth, height: restrictedHeight } = restrictedSize;

const { progress, borderRadius } = useShapeProps(otherProps, BASIC_SHAPE);
const { progress, borderRadius, fill, stroke } = useShapeProps(
otherProps,
BASIC_SHAPE
);

const progressWidth = useMemo(
() => (progress / 100) * restrictedWidth,
Expand All @@ -54,7 +57,7 @@ export const ProgressBarShape = forwardRef<any, ShapeProps>((props, ref) => {
width={restrictedWidth}
height={restrictedHeight}
cornerRadius={borderRadius}
stroke="black"
stroke={stroke}
strokeWidth={2}
fill="white"
/>
Expand All @@ -66,9 +69,9 @@ export const ProgressBarShape = forwardRef<any, ShapeProps>((props, ref) => {
width={progressWidth}
height={restrictedHeight}
cornerRadius={borderRadius}
stroke="black"
stroke={stroke}
strokeWidth={2}
fill="lightgrey"
fill={fill}
/>
</Group>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useGroupShapeProps } from '../../mock-components.utils';
import { splitCSVContent, setTime } from './timepickerinput-shape.business';

import clockIconSrc from '/icons/clock.svg';
import disabledClockIconSrc from '/icons/clock-disabled.svg';

const timepickerInputShapeRestrictions: ShapeSizeRestrictions = {
minWidth: 100,
Expand Down Expand Up @@ -68,7 +69,7 @@ export const TimepickerInputShape = forwardRef<any, ShapeProps>(
const labelFontSize = Math.min(restrictedHeight * 0.3, 12);

const clockIcon = new window.Image();
clockIcon.src = clockIconSrc;
clockIcon.src = disabled ? disabledClockIconSrc : clockIconSrc;

return (
<Group {...commonGroupProps} {...shapeProps}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './normaltext-shape';
export * from './smalltext-shape';
export * from './paragraph-text-shape';
export * from './link-text-shape';
export * from './rich-text/';
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { fitSizeToShapeSizeRestrictions } from '@/common/utils/shapes/shape-rest
import { BASIC_SHAPE } from '../front-components/shape.const';
import { useShapeProps } from '../../shapes/use-shape-props.hook';
import { useGroupShapeProps } from '../mock-components.utils';
import { useResizeOnFontSizeChange } from './front-text-hooks/resize-fontsize-change.hook';

const paragraphSizeRestrictions: ShapeSizeRestrictions = {
minWidth: 200,
Expand Down Expand Up @@ -41,7 +40,7 @@ export const ParagraphShape = forwardRef<any, ShapeProps>((props, ref) => {
);
const { width: restrictedWidth, height: restrictedHeight } = restrictedSize;

const { textColor, fontSize, textAlignment, fontVariant } = useShapeProps(
const { textColor, fontSize, textAlignment } = useShapeProps(
otherProps,
BASIC_SHAPE
);
Expand All @@ -53,8 +52,6 @@ export const ParagraphShape = forwardRef<any, ShapeProps>((props, ref) => {
ref
);

useResizeOnFontSizeChange(id, { x, y }, text, fontSize, fontVariant, true);

return (
<Group {...commonGroupProps} {...shapeProps}>
<Text
Expand Down
Loading

0 comments on commit 54bf203

Please sign in to comment.