diff --git a/app/client/src/constants/WidgetConstants.tsx b/app/client/src/constants/WidgetConstants.tsx index 53463300db..6119b727c4 100644 --- a/app/client/src/constants/WidgetConstants.tsx +++ b/app/client/src/constants/WidgetConstants.tsx @@ -4,7 +4,8 @@ export type WidgetType = | "CONTAINER_WIDGET" | "LIST_WIDGET" | "INPUT_TEXT_WIDGET" - | "CALLOUT_WIDGET"; + | "CALLOUT_WIDGET" + | "ICON_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 index 88d097f0d5..eeeb302043 100644 --- a/app/client/src/editorComponents/CalloutComponent.tsx +++ b/app/client/src/editorComponents/CalloutComponent.tsx @@ -1,5 +1,6 @@ import * as React from "react"; import { IComponentProps } from "./BaseComponent"; +import { Callout, Code, H5, Intent, Switch } from "@blueprintjs/core"; import styled from "../constants/DefaultTheme"; const CalloutContainer = styled("span")` @@ -17,10 +18,12 @@ class CalloutComponent extends React.Component { render() { return ( -
-

{this.props.heading}

+ {this.props.description} -
+
); } @@ -28,8 +31,9 @@ class CalloutComponent extends React.Component { export interface ICalloutComponentProps extends IComponentProps { id?: string; - heading?: string; + title?: string; description?: string; + intent?: Intent; ellipsize?: boolean; } diff --git a/app/client/src/editorComponents/IconComponent.tsx b/app/client/src/editorComponents/IconComponent.tsx new file mode 100644 index 0000000000..9d37a672d4 --- /dev/null +++ b/app/client/src/editorComponents/IconComponent.tsx @@ -0,0 +1,35 @@ +import * as React from "react"; +import { IComponentProps } from "./BaseComponent"; +import { Icon, Intent } from "@blueprintjs/core"; +import { IconName } from "@blueprintjs/icons"; +import styled from "../constants/DefaultTheme"; + +const IconContainer = 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 IconComponent extends React.Component { + render() { + return ( + + + + ); + } +} + +export interface IIconComponentProps extends IComponentProps { + iconSize?: number; + icon?: IconName; + intent?: Intent; + ellipsize?: boolean; +} + +export default IconComponent; diff --git a/app/client/src/mockResponses/CanvasResponse.ts b/app/client/src/mockResponses/CanvasResponse.ts index 10ba73252b..d633f14f50 100644 --- a/app/client/src/mockResponses/CanvasResponse.ts +++ b/app/client/src/mockResponses/CanvasResponse.ts @@ -42,9 +42,22 @@ const CanvasResponse: IContainerWidgetProps = { bottomRow: 5, rightColumn: 5, id: "sample_id", - heading: "Visually important content", + title: "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." + "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.", + icon: "", + intent: "primary" + }, + { + widgetId: "1", + widgetType: "ICON_WIDGET", + topRow: 4, + leftColumn: 4, + bottomRow: 5, + rightColumn: 5, + icon: "globe", + iconSize: "20", + intent: "primary" } ], topRow: 0, diff --git a/app/client/src/utils/WidgetRegistry.tsx b/app/client/src/utils/WidgetRegistry.tsx index dcbd7e0a2c..75e663e031 100644 --- a/app/client/src/utils/WidgetRegistry.tsx +++ b/app/client/src/utils/WidgetRegistry.tsx @@ -7,6 +7,7 @@ import InputTextWidget, { IInputTextWidgetProps } from "../widgets/InputTextWidget"; import CalloutWidget, { ICalloutWidgetProps } from "../widgets/CalloutWidget"; +import IconWidget, { IIconWidgetProps } from "../widgets/IconWidget"; import WidgetFactory from "./WidgetFactory"; import React from "react"; @@ -37,6 +38,12 @@ class WidgetBuilderRegistry { return ; } }); + + WidgetFactory.registerWidgetBuilder("ICON_WIDGET", { + buildWidget(widgetData: IIconWidgetProps): JSX.Element { + return ; + } + }); } } diff --git a/app/client/src/widgets/CalloutWidget.tsx b/app/client/src/widgets/CalloutWidget.tsx index 45bb5727a3..63e0409ddb 100644 --- a/app/client/src/widgets/CalloutWidget.tsx +++ b/app/client/src/widgets/CalloutWidget.tsx @@ -1,5 +1,6 @@ import * as React from "react"; import BaseWidget, { IWidgetProps, IWidgetState } from "./BaseWidget"; +import { Callout, Code, H5, Intent, Switch } from "@blueprintjs/core"; import { WidgetType, CSSUnits } from "../constants/WidgetConstants"; import CalloutComponent from "../editorComponents/CalloutComponent"; import _ from "lodash"; @@ -22,7 +23,7 @@ class CalloutWidget extends BaseWidget { widgetId={this.props.widgetId} key={this.props.widgetId} id={this.props.id} - heading={this.props.heading} + title={this.props.title} description={this.props.description} /> ); @@ -35,8 +36,9 @@ class CalloutWidget extends BaseWidget { export interface ICalloutWidgetProps extends IWidgetProps { id?: string; - heading?: string; + title?: string; description?: string; + intent?: Intent; ellipsize?: boolean; } diff --git a/app/client/src/widgets/IconWidget.tsx b/app/client/src/widgets/IconWidget.tsx new file mode 100644 index 0000000000..55c296299a --- /dev/null +++ b/app/client/src/widgets/IconWidget.tsx @@ -0,0 +1,44 @@ +import * as React from "react"; +import BaseWidget, { IWidgetProps, IWidgetState } from "./BaseWidget"; +import { WidgetType, CSSUnits } from "../constants/WidgetConstants"; +import { Icon, Intent } from "@blueprintjs/core"; +import { IconName } from "@blueprintjs/icons"; +import IconComponent from "../editorComponents/IconComponent"; +import _ from "lodash"; + +class IconWidget extends BaseWidget { + constructor(widgetProps: IIconWidgetProps) { + super(widgetProps); + } + + getWidgetView() { + return ( + + ); + } + + getWidgetType(): WidgetType { + return "ICON_WIDGET"; + } +} + +export interface IIconWidgetProps extends IWidgetProps { + icon?: IconName; + iconSize?: number; + ellipsize?: boolean; + intent?: Intent; +} + +export default IconWidget;