Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,15 @@ export const InputShape = forwardRef<any, ShapeProps>((props, ref) => {

const { width: restrictedWidth, height: restrictedHeight } = restrictedSize;

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

const commonGroupProps = useGroupShapeProps(
props,
Expand Down Expand Up @@ -72,7 +79,13 @@ export const InputShape = forwardRef<any, ShapeProps>((props, ref) => {
fontFamily={INPUT_SHAPE.DEFAULT_FONT_FAMILY}
fontSize={INPUT_SHAPE.DEFAULT_FONT_SIZE}
lineHeight={INPUT_SHAPE.DEFAULT_LINE_HEIGHT}
fill={disabled ? DISABLED_COLOR_VALUES.DEFAULT_TEXT_COLOR : textColor}
fill={
disabled
? DISABLED_COLOR_VALUES.DEFAULT_TEXT_COLOR
: isPlaceholder
? '#8c8c8c'
: textColor
}
align="left"
ellipsis={true}
wrap="none"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const DEFAULT_FONT_SIZE = 16;
const DEFAULT_FILL_TEXT = '#000000';
const DEFAULT_PADDING = 10;
const DEFAULT_LINE_HEIGHT = 1.25;
const DEFAULT_FILL_TEXT_INPUT = '#8c8c8c';
const DEFAULT_FILL_TEXT_INPUT = '#000000';
const DEFAULT_FONT_SIZE_INPUT = 15;
const DEFAULT_TEXT_WIDTH = 165;
const DEFAULT_TEXT_HEIGHT = 38;
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 @@ -22,6 +22,11 @@ export const useShapeProps = (
[otherProps?.textColor]
);

const isPlaceholder = useMemo(
() => otherProps?.isPlaceholder ?? true,
[otherProps?.isPlaceholder]
);

const fontVariant = useMemo(
() => otherProps?.fontVariant ?? defaultStyleShape.DEFAULT_FONT_VARIANT,
[otherProps?.fontVariant]
Expand Down Expand Up @@ -93,5 +98,6 @@ export const useShapeProps = (
textDecoration,
textAlignment,
disabled,
isPlaceholder,
};
};
1 change: 1 addition & 0 deletions src/core/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export interface OtherProps {
selectedBackgroundColor?: string;
textAlignment?: 'left' | 'center' | 'right';
disabled?: boolean;
isPlaceholder?: boolean;
}

export const BASE_ICONS_URL = '/icons/';
Expand Down
1 change: 1 addition & 0 deletions src/pods/canvas/model/shape-other-props.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const generateDefaultOtherProps = (
stroke: INPUT_SHAPE.DEFAULT_STROKE_COLOR,
backgroundColor: INPUT_SHAPE.DEFAULT_FILL_BACKGROUND,
textColor: INPUT_SHAPE.DEFAULT_FILL_TEXT,
isPlaceholder: true,
strokeStyle: [],
borderRadius: `${INPUT_SHAPE.DEFAULT_CORNER_RADIUS}`,
disabled: INPUT_SHAPE.DEFAULT_DISABLED,
Expand Down
1 change: 1 addition & 0 deletions src/pods/properties/components/password/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './password.component';
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.container {
display: flex;
gap: 0.5em;
align-items: center;
padding: var(--space-xs) var(--space-md);
border-bottom: 1px solid var(--primary-300);
}

.container :first-child {
flex: 1;
}

.checkbox {
width: var(--space-md);
height: var(--space-md);
cursor: pointer;
}
23 changes: 23 additions & 0 deletions src/pods/properties/components/password/password.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import classes from './password.component.module.css';

interface Props {
label: string;
isPassword: boolean;
onChange: (isPassword: boolean) => void;
}

export const Password: React.FC<Props> = props => {
const { label, isPassword, onChange } = props;

return (
<div className={classes.container}>
<p>{label}</p>
<input
type="checkbox"
checked={isPassword}
onChange={() => onChange(!isPassword)}
className={classes.checkbox}
/>
</div>
);
};
1 change: 1 addition & 0 deletions src/pods/properties/components/placeholder/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './placeholder.component';
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.container {
display: flex;
gap: 0.5em;
align-items: center;
padding: var(--space-xs) var(--space-md);
border-bottom: 1px solid var(--primary-300);
}

.container :first-child {
flex: 1;
}

.checkbox {
width: var(--space-md);
height: var(--space-md);
cursor: pointer;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import classes from './placeholder.component.module.css';

interface Props {
label: string;
isPlaceholder: boolean;
onChange: (isPlaceholder: boolean) => void;
}

export const Placeholder: React.FC<Props> = props => {
const { label, isPlaceholder, onChange } = props;

return (
<div className={classes.container}>
<p>{label}</p>
<input
type="checkbox"
checked={isPlaceholder}
onChange={() => onChange(!isPlaceholder)}
className={classes.checkbox}
/>
</div>
);
};
1 change: 1 addition & 0 deletions src/pods/properties/properties.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const multiSelectEnabledProperties: (keyof OtherProps)[] = [
'selectedBackgroundColor',
'textAlignment',
'disabled',
'isPlaceholder',
];

export type PropsValueTypes =
Expand Down
21 changes: 21 additions & 0 deletions src/pods/properties/properties.pod.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useMemo } from 'react';
import { extractMultiplePropsInCommon } from './properties.business';
import { ShowProp } from './components/show-prop';
import { iconCollection } from './components/icon-selector/modal/icons';
import { Placeholder } from './components/placeholder';

export const PropertiesPod = () => {
const { selectionInfo, fullDocument } = useCanvasContext();
Expand Down Expand Up @@ -191,6 +192,26 @@ export const PropertiesPod = () => {
}
/>
</ShowProp>
<ShowProp
singleSelection={isSingleSelection}
multipleSelectionPropsInCommon={multipleSelectionPropsInCommon}
propKey="isPlaceholder"
propValue={selectedShapeData?.otherProps?.isPlaceholder}
>
<Placeholder
label="Placeholder"
isPlaceholder={
selectedShapeData?.otherProps?.isPlaceholder ?? false
}
onChange={isPlaceholder =>
updateOtherPropsOnSelected(
'isPlaceholder',
isPlaceholder,
isMultipleSelection
)
}
/>
</ShowProp>
<ShowProp
singleSelection={isSingleSelection}
multipleSelectionPropsInCommon={multipleSelectionPropsInCommon}
Expand Down