Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
@@ -1,16 +1,18 @@
import React from "react";
import { deriveAlignedColumnHighlights } from "../../utils/layouts/highlights/alignedColumnHighlights";
import BaseLayoutComponent from "../BaseLayoutComponent";
import {
type DeriveHighlightsFn,
LayoutComponentTypes,
type LayoutProps,
} from "layoutSystems/anvil/utils/anvilTypes";
import type { FlexLayoutProps } from "./FlexLayout";
import { deriveColumnHighlights } from "layoutSystems/anvil/utils/layouts/highlights/columnHighlights";
import { MainCanvasWrapper } from "./MainCanvasWrapper";

class LayoutColumn extends BaseLayoutComponent {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@riodeuno This type has not been used anywhere. The same situation applies to many other types (we need to check this). In this PR, I use LayoutColumn type for the main container, since previously changes to ALIGNED_LAYOUT_COLUMN affected not only the main container but also the zones

static type: LayoutComponentTypes = LayoutComponentTypes.LAYOUT_COLUMN;

static deriveHighlights: DeriveHighlightsFn = deriveColumnHighlights;
static deriveHighlights: DeriveHighlightsFn = deriveAlignedColumnHighlights;

static getChildTemplate(props: LayoutProps): LayoutProps | null {
if (props.childTemplate || props.childTemplate === null)
Expand All @@ -19,18 +21,27 @@ class LayoutColumn extends BaseLayoutComponent {
return {
insertChild: true,
layoutId: "",
layoutType: LayoutComponentTypes.WIDGET_ROW,
layoutType: LayoutComponentTypes.ALIGNED_WIDGET_ROW,
layout: [],
};
}

getFlexLayoutProps(): Omit<FlexLayoutProps, "children"> {
return {
...super.getFlexLayoutProps(),
alignSelf: "stretch",
height: "100%",
gap: "spacing-4",
direction: "column",
};
}

renderViewMode(): JSX.Element {
return (
<MainCanvasWrapper {...this.getFlexLayoutProps()}>
{super.renderChildren()}
</MainCanvasWrapper>
);
}
}

export default LayoutColumn;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from "react";
import { FlexLayout, type FlexLayoutProps } from "./FlexLayout";

export const MainCanvasWrapper = (props: FlexLayoutProps) => {
const { search } = window.location;
const queryParams = new URLSearchParams(search);
const isEmbed = queryParams.get("embed") === "true";

return (
<FlexLayout {...props} padding={isEmbed ? "spacing-0" : "spacing-4"}>
{props.children}
</FlexLayout>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,8 @@ export function anvilDSLTransformer(dsl: DSLWidget) {
_dsl.layout = [
{
layoutId: generateReactKey(),
layoutType: LayoutComponentTypes.ALIGNED_LAYOUT_COLUMN,
layoutType: LayoutComponentTypes.LAYOUT_COLUMN,
layout: [],
layoutStyle: {
border: "none",
height: "100%",
padding: "spacing-4",
gap: "spacing-4",
},
isDropTarget: true,
isPermanent: true,
childTemplate: {
Expand Down