diff --git a/app/client/src/constants/WidgetConstants.tsx b/app/client/src/constants/WidgetConstants.tsx index e44d801ca8..53463300db 100644 --- a/app/client/src/constants/WidgetConstants.tsx +++ b/app/client/src/constants/WidgetConstants.tsx @@ -3,7 +3,8 @@ export type WidgetType = | "IMAGE_WIDGET" | "CONTAINER_WIDGET" | "LIST_WIDGET" - | "INPUT_TEXT_WIDGET"; + | "INPUT_TEXT_WIDGET" + | "CALLOUT_WIDGET"; export type ContainerOrientation = "HORIZONTAL" | "VERTICAL"; export type PositionType = "ABSOLUTE" | "CONTAINER_DIRECTION"; export type CSSUnit = diff --git a/app/client/src/editorComponents/CalloutComponent.tsx b/app/client/src/editorComponents/CalloutComponent.tsx new file mode 100644 index 0000000000..88d097f0d5 --- /dev/null +++ b/app/client/src/editorComponents/CalloutComponent.tsx @@ -0,0 +1,36 @@ +import * as React from "react"; +import { IComponentProps } from "./BaseComponent"; +import styled from "../constants/DefaultTheme"; + +const CalloutContainer = styled("span")` + color: ${props => props.theme.primaryColor}; + position: ${props => props.style.positionType}; + left: ${props => { + return props.style.xPosition + props.style.xPositionUnit; + }}; + top: ${props => { + return props.style.yPosition + props.style.yPositionUnit; + }}; +`; + +class CalloutComponent extends React.Component { + render() { + return ( + +
+

{this.props.heading}

+ {this.props.description} +
+
+ ); + } +} + +export interface ICalloutComponentProps extends IComponentProps { + id?: string; + heading?: string; + description?: string; + ellipsize?: boolean; +} + +export default CalloutComponent; diff --git a/app/client/src/mockResponses/CanvasResponse.ts b/app/client/src/mockResponses/CanvasResponse.ts index 8152d320ad..10ba73252b 100644 --- a/app/client/src/mockResponses/CanvasResponse.ts +++ b/app/client/src/mockResponses/CanvasResponse.ts @@ -33,6 +33,18 @@ const CanvasResponse: IContainerWidgetProps = { minLength: "4", maxLength: "12", size: "30" + }, + { + widgetId: "1", + widgetType: "CALLOUT_WIDGET", + topRow: 3, + leftColumn: 1, + bottomRow: 5, + rightColumn: 5, + id: "sample_id", + heading: "Visually important content", + description: + "The component is a simple wrapper around the CSS API that provides props for modifiers and optional title element. Any additional HTML props will be spread to the rendered
element." } ], topRow: 0, diff --git a/app/client/src/utils/WidgetRegistry.tsx b/app/client/src/utils/WidgetRegistry.tsx index fc74241a32..dcbd7e0a2c 100644 --- a/app/client/src/utils/WidgetRegistry.tsx +++ b/app/client/src/utils/WidgetRegistry.tsx @@ -6,6 +6,7 @@ import TextWidget, { ITextWidgetProps } from "../widgets/TextWidget"; import InputTextWidget, { IInputTextWidgetProps } from "../widgets/InputTextWidget"; +import CalloutWidget, { ICalloutWidgetProps } from "../widgets/CalloutWidget"; import WidgetFactory from "./WidgetFactory"; import React from "react"; @@ -30,6 +31,12 @@ class WidgetBuilderRegistry { return ; } }); + + WidgetFactory.registerWidgetBuilder("CALLOUT_WIDGET", { + buildWidget(widgetData: ICalloutWidgetProps): JSX.Element { + return ; + } + }); } } diff --git a/app/client/src/widgets/CalloutWidget.tsx b/app/client/src/widgets/CalloutWidget.tsx new file mode 100644 index 0000000000..45bb5727a3 --- /dev/null +++ b/app/client/src/widgets/CalloutWidget.tsx @@ -0,0 +1,43 @@ +import * as React from "react"; +import BaseWidget, { IWidgetProps, IWidgetState } from "./BaseWidget"; +import { WidgetType, CSSUnits } from "../constants/WidgetConstants"; +import CalloutComponent from "../editorComponents/CalloutComponent"; +import _ from "lodash"; + +class CalloutWidget extends BaseWidget { + constructor(widgetProps: ICalloutWidgetProps) { + super(widgetProps); + } + + getWidgetView() { + return ( + + ); + } + + getWidgetType(): WidgetType { + return "CALLOUT_WIDGET"; + } +} + +export interface ICalloutWidgetProps extends IWidgetProps { + id?: string; + heading?: string; + description?: string; + ellipsize?: boolean; +} + +export default CalloutWidget; diff --git a/app/client/src/widgets/InputTextWidget.tsx b/app/client/src/widgets/InputTextWidget.tsx index 5a93ce0b8c..69dca5eb71 100644 --- a/app/client/src/widgets/InputTextWidget.tsx +++ b/app/client/src/widgets/InputTextWidget.tsx @@ -33,7 +33,7 @@ class InputTextWidget extends BaseWidget { } getWidgetType(): WidgetType { - return "TEXT_WIDGET"; + return "INPUT_TEXT_WIDGET"; } }