-
Notifications
You must be signed in to change notification settings - Fork 4.6k
chore: add code for paragraph-text morphing #36065
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
260bfc9
572f5ae
67e8211
68ce8f2
1b1d2ab
e1b3c9f
c8be2f8
395574a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,35 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import type { WidgetProps } from "widgets/BaseWidget"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import type { PropertyUpdates } from "WidgetProvider/constants"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import type { InputType } from "./types"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { INPUT_TYPE_TO_WIDGET_TYPE_MAP } from "./constants"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export function isReadOnlyUpdateHook( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
jsartisan marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| props: WidgetProps, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| propertyName: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| propertyValue: boolean, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const updates: PropertyUpdates[] = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| propertyPath: propertyName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| propertyValue: propertyValue, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // if user is marking readOnly as true and if the input type is not INPUT_CURRENCY_WIDGET or INPUT_PHONE_WIDGET, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // then we update the type to WDS_KEY_VALUE_WIDGET, else we update the type based on the input type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| !["WDS_CURRENCY_INPUT_WIDGET", "WDS_PHONE_INPUT_WIDGET"].includes( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| props.type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| updates.push({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| propertyPath: "type", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| propertyValue: propertyValue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? "WDS_KEY_VALUE_WIDGET" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : INPUT_TYPE_TO_WIDGET_TYPE_MAP[props.inputType as InputType], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+20
to
+32
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simplify the logic by using a ternary operator. The Apply this diff to simplify the logic: - if (propertyValue) {
- updates.push({
- propertyPath: "type",
- propertyValue: "WDS_KEY_VALUE_WIDGET",
- });
- } else {
- updates.push({
- propertyPath: "type",
- propertyValue:
- INPUT_TYPE_TO_WIDGET_TYPE_MAP[props.inputType as InputType],
- });
- }
+ updates.push({
+ propertyPath: "type",
+ propertyValue: propertyValue
+ ? "WDS_KEY_VALUE_WIDGET"
+ : INPUT_TYPE_TO_WIDGET_TYPE_MAP[props.inputType as InputType],
+ });Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return updates; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| import { WDSBaseInputWidget } from "./widget"; | ||
|
|
||
| export { WDSBaseInputWidget }; | ||
|
|
||
| export * from "./types"; | ||
| export * from "./constants"; | ||
| export type { BaseInputWidgetProps } from "./widget/types"; | ||
| export type { BaseInputComponentProps } from "./component/types"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import type { INPUT_TYPES } from "./constants"; | ||
|
|
||
| export type InputType = (typeof INPUT_TYPES)[keyof typeof INPUT_TYPES]; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| import { TYPOGRAPHY_VARIANTS } from "@appsmith/wds-theming"; | ||
| import { ValidationTypes } from "constants/WidgetValidation"; | ||
|
|
||
| import { fontSizeUpdateHook } from "../../helpers"; | ||
|
|
||
| export const propertyPaneStyleConfig = [ | ||
| { | ||
| sectionName: "General", | ||
|
|
@@ -32,7 +34,7 @@ export const propertyPaneStyleConfig = [ | |
| isJSConvertible: true, | ||
| isBindProperty: true, | ||
| isTriggerProperty: false, | ||
| isReusable: true, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isReusable is not required for fontSize as discussed with taras. |
||
| updateHook: fontSizeUpdateHook, | ||
| validation: { | ||
| type: ValidationTypes.TEXT, | ||
| params: { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| export const FONT_SIZE_TO_WIDGET_TYPE_MAP = { | ||
| body: "WDS_PARAGRAPH_WIDGET", | ||
| subtitle: "WDS_HEADING_WIDGET", | ||
| title: "WDS_HEADING_WIDGET", | ||
| heading: "WDS_HEADING_WIDGET", | ||
| }; | ||
|
jsartisan marked this conversation as resolved.
Outdated
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import type { PropertyUpdates } from "WidgetProvider/constants"; | ||
| import type { WidgetProps } from "widgets/BaseWidget"; | ||
|
|
||
| import { FONT_SIZE_TO_WIDGET_TYPE_MAP } from "./constants"; | ||
|
|
||
| export function fontSizeUpdateHook( | ||
| props: WidgetProps, | ||
| propertyName: string, | ||
| propertyValue: string, | ||
| ) { | ||
| const updates: PropertyUpdates[] = [ | ||
| { | ||
| propertyPath: propertyName, | ||
| propertyValue: propertyValue, | ||
| }, | ||
| ]; | ||
|
|
||
| updates.push({ | ||
| propertyPath: "type", | ||
| propertyValue: | ||
| FONT_SIZE_TO_WIDGET_TYPE_MAP[ | ||
| propertyValue as keyof typeof FONT_SIZE_TO_WIDGET_TYPE_MAP | ||
|
jsartisan marked this conversation as resolved.
Outdated
|
||
| ], | ||
| }); | ||
|
|
||
| return updates; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| export * from "./constants"; | ||
| export { WDSPhoneInputWidget } from "./widget"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved it to parent to avoid cyclic imports.