Skip to content

Commit

Permalink
chore: remove padding for anvil embed apps (#37173)
Browse files Browse the repository at this point in the history
## Description
I removed the styles from the DSL and changed the layout type for main
container to `LAYOUT_COLUMN`.

## Automation

/ok-to-test tags="@tag.All"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/11720581716>
> Commit: 4ccd877
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11720581716&attempt=2"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Thu, 07 Nov 2024 11:30:39 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced the `MainCanvasWrapper` component for dynamic styling based
on URL parameters.
	- Added a new rendering behavior for the `LayoutColumn` component.

- **Improvements**
- Updated highlight derivation and layout type in the `LayoutColumn`
component.
	- Simplified layout structure in the `anvilDSLTransformer` function.
- Adjusted layout properties for better alignment and spacing in the
`LayoutColumn` component.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
KelvinOm authored Nov 7, 2024
1 parent 9ffcb64 commit 1f25adc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
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 {
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

0 comments on commit 1f25adc

Please sign in to comment.