Skip to content
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

feat: Variable width for property pane size and side by side editor #30550

Merged
merged 22 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b75dff1
feat: Added proportional sizing for canvas, property pane and editor …
albinAppsmith Jan 23, 2024
7b0d202
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith Jan 23, 2024
8db5e17
feat: width fix for property pane
albinAppsmith Jan 23, 2024
7596c8c
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith Jan 23, 2024
cb3800d
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith Jan 24, 2024
487201f
canvas width
albinAppsmith Jan 24, 2024
cd2ba2c
fix: change in width calculation
albinAppsmith Jan 24, 2024
77c364c
fix: canvas resize
albinAppsmith Jan 24, 2024
3f77aa2
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith Jan 25, 2024
9add86a
feat: Changed feat calculation logic
albinAppsmith Jan 25, 2024
3237830
fix: canvas rerender issue
albinAppsmith Jan 25, 2024
c1e3c2e
fix: Added max width to segmented control
albinAppsmith Jan 26, 2024
8b52bc9
fix propertypane width
albinAppsmith Jan 29, 2024
fd569b8
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith Jan 29, 2024
78c5f14
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith Jan 30, 2024
ec7c5db
feat: Added zoom in/out functionality to canvas
albinAppsmith Jan 30, 2024
49a2ec6
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith Jan 31, 2024
5d05d59
reverted changes
albinAppsmith Jan 31, 2024
97dd1c3
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith Feb 1, 2024
cc450f5
fix: new scrollbar related change for canvas in splitscreen
albinAppsmith Feb 1, 2024
c5fb95a
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith Feb 1, 2024
4aabead
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
albinAppsmith Feb 2, 2024
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 @@ -21,6 +21,7 @@ import { APP_SETTINGS_PANE_WIDTH } from "constants/AppConstants";
import styled from "styled-components";
import WalkthroughContext from "components/featureWalkthrough/walkthroughContext";
import { MAIN_CONTAINER_WIDGET_ID } from "constants/WidgetConstants";
import { getIsSideBySideEnabled } from "selectors/ideSelectors";

export const PROPERTY_PANE_ID = "t--property-pane-sidebar";

Expand All @@ -41,7 +42,7 @@ const StyledResizer = styled.div<{ resizing: boolean }>`

interface Props {
width: number;
onDragEnd?: () => void;
onDragEnd: () => void;
onWidthChange: (width: number) => void;
}

Expand All @@ -57,6 +58,7 @@ export const PropertyPaneSidebar = memo((props: Props) => {
const isAppSettingsPaneOpen = useSelector(getIsAppSettingsPaneOpen);
const { isOpened: isWalkthroughOpened, popFeature } =
useContext(WalkthroughContext) || {};
const isSideBySideEnabled = useSelector(getIsSideBySideEnabled);

//while dragging or resizing and
//the current selected WidgetId is not equal to previous widget id,
Expand Down Expand Up @@ -139,7 +141,7 @@ export const PropertyPaneSidebar = memo((props: Props) => {
ref={sidebarRef}
>
{/* RESIZER */}
{!isAppSettingsPaneOpen && (
{!isAppSettingsPaneOpen && !isSideBySideEnabled && (
<StyledResizer
className={`absolute top-0 left-0 w-2 h-full -ml-1 group cursor-ew-resize ${tailwindLayers.resizer}`}
onMouseDown={onMouseDown}
Expand Down
4 changes: 4 additions & 0 deletions app/client/src/constants/AppConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export const CANVAS_BACKGROUND_COLOR = "#FFFFFF";
export const DEFAULT_ENTITY_EXPLORER_WIDTH = 256;
export const DEFAULT_PROPERTY_PANE_WIDTH = 288;
export const APP_SETTINGS_PANE_WIDTH = 525;
export const DEFAULT_APP_SIDEBAR_WIDTH = 50;
export const DEFAULT_EDITOR_PANE_WIDTH = 255;
export const DEFAULT_PP_LARGE_WIDTH = window.innerWidth * 0.18;

const APP_STORE_NAMESPACE = "APPSMITH_LOCAL_STORE";

Expand Down Expand Up @@ -44,6 +47,7 @@ export const MOBILE_MAX_WIDTH = 767;
export const TABLET_MIN_WIDTH = 768;
export const TABLET_MAX_WIDTH = 991;
export const DESKTOP_MIN_WIDTH = 992;
export const DESKTOP_BASE_WIDTH = 1440;

export const NAVIGATION_SETTINGS = {
ORIENTATION: {
Expand Down
4 changes: 2 additions & 2 deletions app/client/src/pages/Editor/IDE/EditorPane/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ import { SentryRoute } from "@appsmith/AppRouter";
import { ADD_PATH } from "constants/routes";
import EditorPaneSegments from "./EditorPaneSegments";
import GlobalAdd from "./GlobalAdd";
import { useEditorPaneWidth } from "../hooks";
import { getPagesActiveStatus } from "selectors/ideSelectors";
import EntityProperties from "pages/Editor/Explorer/Entity/EntityProperties";
import { MinimalSegment } from "./MinimalSegment";
import { Pages } from "./components/Pages";
import { useEditorPaneWidth } from "../hooks";

const EditorPane = ({ match: { path } }: RouteComponentProps) => {
const width = useEditorPaneWidth();
const pagesActive = useSelector(getPagesActiveStatus);

return (
<Flex
className="ide-editor-left-pane"
className="ide-editor-left-pane transition-[width] ease-linear"
flexDirection="column"
gap="spacing-2"
height="100%"
Expand Down
8 changes: 5 additions & 3 deletions app/client/src/pages/Editor/IDE/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
queryListURL,
widgetListURL,
} from "@appsmith/RouteBuilder";
import { DEFAULT_EDITOR_PANE_WIDTH } from "constants/AppConstants";

export const useCurrentAppState = () => {
const [appState, setAppState] = useState(EditorState.EDITOR);
Expand Down Expand Up @@ -94,7 +95,7 @@ export const useCurrentEditorState = () => {
};

export const useEditorPaneWidth = (): number => {
const [width, setWidth] = useState(255);
const [width, setWidth] = useState(DEFAULT_EDITOR_PANE_WIDTH);
const isSideBySideEnabled = useSelector(getIsSideBySideEnabled);
const editorMode = useSelector(getIDEViewMode);
const { segment } = useCurrentEditorState();
Expand All @@ -105,9 +106,10 @@ export const useEditorPaneWidth = (): number => {
editorMode === EditorViewMode.SplitScreen &&
segment !== EditorEntityTab.UI
) {
setWidth(255 + propertyPaneWidth);
// 1px is propertypane border width
setWidth(DEFAULT_EDITOR_PANE_WIDTH + propertyPaneWidth + 1);
} else {
setWidth(255);
setWidth(DEFAULT_EDITOR_PANE_WIDTH);
}
}, [isSideBySideEnabled, editorMode, segment, propertyPaneWidth]);

Expand Down
10 changes: 8 additions & 2 deletions app/client/src/reducers/uiReducers/propertyPaneReducer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import type {
ShowPropertyPanePayload,
} from "@appsmith/constants/ReduxActionConstants";
import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants";
import { DEFAULT_PROPERTY_PANE_WIDTH } from "constants/AppConstants";
import {
DEFAULT_PP_LARGE_WIDTH,
DEFAULT_PROPERTY_PANE_WIDTH,
} from "constants/AppConstants";
import { createImmerReducer } from "utils/ReducerUtils";

export interface SelectedPropertyPanel {
Expand All @@ -15,7 +18,10 @@ const initialState: PropertyPaneReduxState = {
widgetId: undefined,
lastWidgetId: undefined,
isNew: false,
width: DEFAULT_PROPERTY_PANE_WIDTH,
width:
window.innerWidth > 1440
? DEFAULT_PP_LARGE_WIDTH
: DEFAULT_PROPERTY_PANE_WIDTH,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic for setting the width of the property pane based on the window width is straightforward and correctly implements the feature enhancement described. However, directly accessing window.innerWidth in the reducer's initial state is not ideal for server-side rendering (SSR) scenarios or testing environments where window might not be available.

Consider using a more SSR-friendly approach, such as injecting the window width into the reducer through an action dispatched on the client side after the application mounts.

selectedPropertyPanel: {},
};

Expand Down
7 changes: 7 additions & 0 deletions app/client/src/utils/hooks/useDeviceDetect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
TABLET_MIN_WIDTH,
TABLET_MAX_WIDTH,
DESKTOP_MIN_WIDTH,
DESKTOP_BASE_WIDTH,
} from "constants/AppConstants";

export function useIsMobileDevice() {
Expand All @@ -22,3 +23,9 @@ export function useIsDesktopDevice() {
minWidth: DESKTOP_MIN_WIDTH,
});
}

export function useIsBaseDesignWidth() {
return useMediaQuery({
maxWidth: DESKTOP_BASE_WIDTH,
});
}
6 changes: 5 additions & 1 deletion app/client/src/utils/hooks/useDynamicAppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ import { useLocation } from "react-router";
import { CANVAS_VIEWPORT } from "constants/componentClassNameConstants";
import { getLayoutSystemType } from "selectors/layoutSystemSelectors";
import { useIsAppSidebarEnabled } from "../../navigation/featureFlagHooks";
import { useCurrentEditorState } from "pages/Editor/IDE/hooks";
import { EditorEntityTab } from "@appsmith/entities/IDE/constants";

const GUTTER_WIDTH = 72;
export const AUTOLAYOUT_RESIZER_WIDTH_BUFFER = 40;
Expand Down Expand Up @@ -80,6 +82,7 @@ export const useDynamicAppLayout = () => {
const isEmbed = queryParams.get("embed");
const isNavbarVisibleInEmbeddedApp = queryParams.get("navbar");
const isAppSidebarEnabled = useIsAppSidebarEnabled();
const { segment } = useCurrentEditorState();

const isPreviewing = isPreviewMode;

Expand Down Expand Up @@ -137,7 +140,8 @@ export const useDynamicAppLayout = () => {
if (
isPreviewing === false &&
!isAppSettingsPaneOpen &&
appMode === APP_MODE.EDIT
appMode === APP_MODE.EDIT &&
segment === EditorEntityTab.UI
) {
calculatedWidth -= propertyPaneWidth;
}
Expand Down
Loading