PromucFlow_constructor/app/client/src/layoutSystems/common/WidgetNamesCanvas/WidgetNameConstants.ts

53 lines
1.8 KiB
TypeScript
Raw Normal View History

chore: code changes for widget position observer and widget name on canvas (#27367) ## Description The PR contains non integrated code changes for below new features, The changes are not integrated to work but only contains the ground work code changes that can be added to css based layout/ Anvil once that is available in Release. - **Widget Position observer-** Since we are moving to css based layout, the positions of widgets will be unknown. To solve the issue we have introduced the above feature that stores/updates position of widgets on Redux state whenever a widget position updates. without manually triggering any action - **Widget Name on Canvas-** For the New Layout the existing widget name is inconsistent as it would cut off or visually not visible. to solve that the widget name will now be drawn on html canvas than it being a dom node component #### PR fixes following issue(s) Fixes #26945 Fixes #26948 #### Type of change - Chore (housekeeping or task changes that don't impact user perception) ## Testing #### How Has This Been Tested? - [ ] Manual - [ ] JUnit - [ ] Jest #### Test Plan > Add Testsmith test cases links that relate to this PR #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --------- Co-authored-by: Ashok Kumar M <35134347+marks0351@users.noreply.github.com> Co-authored-by: Abhinav Jha <abhinav@appsmith.com>
2023-10-06 10:07:43 +00:00
import { Colors } from "constants/Colors";
import type { CSSProperties } from "react";
export const WIDGET_NAME_CANVAS = "widget-name-canvas";
export const WIDGET_NAME_FONT_SIZE = 14;
export const WIDGET_NAME_LINE_HEIGHT = Math.floor(WIDGET_NAME_FONT_SIZE * 1.2);
export const WIDGET_NAME_VERTICAL_PADDING = 4;
export const WIDGET_NAME_HORIZONTAL_PADDING = 6;
export const WIDGET_NAME_ICON_PADDING = 16;
export const DEFAULT_WIDGET_NAME_CANVAS_HEIGHT = 600;
export const WIDGET_NAME_CANVAS_PADDING = 20;
feat: add layouts and widgets for sections and zones. (#29713) ## Description 1. Create Section Widget. 2. Create Zone Widget. 3. Create layouts and presets for Sections and zones. 4. Upate layout for Anvil Main Canvas. 5. Refactor BaseLayoutComponent. Separate renderer for edit and view modes. 6. Add childrenMap context to avoid prop drilling through all layouts. 7. Add Anvil Config for WDS widgets. #### Type of change - New feature (non-breaking change which adds functionality) ## Testing #### How Has This Been Tested? - [x] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress #### Test Plan ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new `Zone Stepper Control` component for UI interaction. - Added `AnvilCanvas` and `AnvilMainCanvas` components with improved performance and interaction features. - Implemented `LayoutProvider` and `useClickToClearSelections` for better layout management. - Launched `AnvilCanvasDraggingArena` and `AnvilHighlightingCanvas` components with enhanced drag-and-drop capabilities. - New `useZoneMinWidth` hook to calculate minimum zone width based on child widgets. - Added `SectionRow`, `Section`, `ZoneColumn`, and `Zone` components for advanced layout structuring. - New `WidgetRenderer` component for dynamic child widget rendering. - **Enhancements** - Improved canvas activation and deactivation logic with `useCanvasActivation` and `useCanvasActivationStates`. - Enhanced drag-and-drop experience with updated `useCanvasDragging` logic. - Streamlined `AnvilMainCanvas` integration with conditional rendering based on `renderMode`. - Optimized `FlexLayout` component to handle new `isContainer` and `layoutType` properties. - **Bug Fixes** - Fixed issues with widget positioning and event handling in `WidgetNamesCanvas` components. - Corrected `PageView` width property type for consistent page rendering. - **Refactor** - Consolidated Anvil layout update management with `anvilSagas` and `anvilChecksSagas`. - Refined `SectionWidget` and `ZoneWidget` configuration for improved stability and performance. - Streamlined `LayoutElementPositionsObserver` with `layoutType` enhancements. - **Documentation** - Updated comments and added clarifications for better developer understanding of canvas-related hooks and components. - **Style** - Modified `.anvil-canvas` class styles for full-width and height presentation. - **Chores** - Cleaned up import statements and removed unused code across various components and utilities. - **Tests** - Enhanced Cypress tests with additional selectors and interaction commands for `AutoDimension` feature verification. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Ashok Kumar M <35134347+marks0351@users.noreply.github.com>
2023-12-26 14:16:58 +00:00
export const WIDGET_NAME_COMPONENT_BUFFER = 8;
chore: code changes for widget position observer and widget name on canvas (#27367) ## Description The PR contains non integrated code changes for below new features, The changes are not integrated to work but only contains the ground work code changes that can be added to css based layout/ Anvil once that is available in Release. - **Widget Position observer-** Since we are moving to css based layout, the positions of widgets will be unknown. To solve the issue we have introduced the above feature that stores/updates position of widgets on Redux state whenever a widget position updates. without manually triggering any action - **Widget Name on Canvas-** For the New Layout the existing widget name is inconsistent as it would cut off or visually not visible. to solve that the widget name will now be drawn on html canvas than it being a dom node component #### PR fixes following issue(s) Fixes #26945 Fixes #26948 #### Type of change - Chore (housekeeping or task changes that don't impact user perception) ## Testing #### How Has This Been Tested? - [ ] Manual - [ ] JUnit - [ ] Jest #### Test Plan > Add Testsmith test cases links that relate to this PR #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --------- Co-authored-by: Ashok Kumar M <35134347+marks0351@users.noreply.github.com> Co-authored-by: Abhinav Jha <abhinav@appsmith.com>
2023-10-06 10:07:43 +00:00
export const WIDGET_NAME_HEIGHT = Math.floor(
WIDGET_NAME_LINE_HEIGHT + WIDGET_NAME_VERTICAL_PADDING * 1.5,
);
export const WIDGET_NAME_TEXT_COLOR = Colors.WHITE;
//Adding this here as Konva accepts this type of path for SVG
export const warningSVGPath =
"M 18 9 C 18 13.9706 13.9706 18 9 18 C 4.0294 18 0 13.9706 0 9 C 0 4.0294 4.0294 0 9 0 C 13.9706 0 18 4.0294 18 9 Z M 7.875 3.9375 V 10.125 H 10.125 V 3.9375 H 7.875 Z M 9 14.0625 C 9.6213 14.0625 10.125 13.5588 10.125 12.9375 C 10.125 12.3162 9.6213 11.8125 9 11.8125 C 8.3787 11.8125 7.875 12.3162 7.875 12.9375 C 7.875 13.5588 8.3787 14.0625 9 14.0625 Z";
//Indicates the state of widget name
export enum WidgetNameState {
SELECTED = "SELECTED",
ERROR = "ERROR",
FOCUSED = "FOCUSED",
}
//fill colors of widget name based on state
export const WIDGET_NAME_FILL_COLORS = {
[WidgetNameState.SELECTED]: Colors.JAFFA_DARK,
[WidgetNameState.FOCUSED]: Colors.WATUSI,
[WidgetNameState.ERROR]: Colors.DANGER_SOLID,
};
//CSS properties of the wrapper object of the html canvas
export const widgetNameWrapperStyle: CSSProperties = {
position: "absolute",
top: 0,
left: 0,
zIndex: 2,
pointerEvents: "none",
display: "flex",
flexDirection: "column",
alignItems: "center",
width: "100%",
height: "100%",
};