Skip to content

Commit 55157a8

Browse files
committed
[Fix]: #1626 Hide Width in Grid Mode
1 parent e035ee2 commit 55157a8

File tree

2 files changed

+57
-45
lines changed

2 files changed

+57
-45
lines changed

client/packages/lowcoder/src/comps/comps/columnLayout/columnLayout.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ const childrenMap = {
121121
columnGap: withDefault(StringControl, "0"),
122122
style: styleControl(ContainerStyle, 'style'),
123123
columnStyle: styleControl(ResponsiveLayoutColStyle , 'columnStyle'),
124-
useFlexLayout: withDefault(BoolControl, true),
124+
useFlexLayout: withDefault(BoolControl, false),
125125
};
126126

127127
type ViewProps = RecordConstructorToView<typeof childrenMap>;
@@ -239,6 +239,7 @@ export const ResponsiveLayoutBaseComp = (function () {
239239
{children.columns.propertyView({
240240
title: trans("responsiveLayout.column"),
241241
newOptionLabel: trans("responsiveLayout.addColumn"),
242+
useFlexLayout: children.useFlexLayout.getView(),
242243
})}
243244
</Section>
244245

client/packages/lowcoder/src/comps/controls/optionsControl.tsx

+55-44
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { ControlItemCompBuilder } from "comps/generators/controlCompBuilder";
4040
import { ColorControl } from "./colorControl";
4141
import { StringStateControl } from "./codeStateControl";
4242
import { reduceInContext } from "../utils/reduceContext";
43+
import React from "react";
4344

4445
const OptionTypes = [
4546
{
@@ -65,10 +66,13 @@ type OptionControlParam = {
6566
title?: string;
6667
// The new option's label name
6768
newOptionLabel?: string;
69+
// Whether to use flex layout (for column options)
70+
useFlexLayout?: boolean;
6871
};
6972

7073
type OptionPropertyParam = {
7174
autoMap?: boolean;
75+
useFlexLayout?: boolean;
7276
};
7377

7478
interface OptionCompProperty {
@@ -176,7 +180,7 @@ export function manualOptionsControl<T extends OptionsControlType>(
176180
itemTitle={(comp) => comp.children.label.getView()}
177181
popoverTitle={() => trans("edit")}
178182
content={(comp) => {
179-
return hasPropertyView(comp) ? comp.propertyView({}) : comp.getPropertyView();
183+
return hasPropertyView(comp) ? comp.propertyView({ useFlexLayout: param.useFlexLayout }) : comp.getPropertyView();
180184
}}
181185
items={manualComp.getView()}
182186
onAdd={() => {
@@ -576,7 +580,7 @@ const StyledContent = styled.div`
576580
}
577581
`;
578582

579-
const ColumnOption = new MultiCompBuilder(
583+
let ColumnOption = new MultiCompBuilder(
580584
{
581585
id: valueComp<number>(-1),
582586
label: StringControl,
@@ -591,48 +595,55 @@ const ColumnOption = new MultiCompBuilder(
591595
padding: withDefault(StringControl, ""),
592596
},
593597
(props) => props
594-
)
595-
.setPropertyViewFn((children) => (
596-
<StyledContent>
597-
{children.minWidth.propertyView({
598-
label: trans('responsiveLayout.minWidth'),
599-
preInputNode: <StyledIcon as={WidthIcon} title="" />,
600-
placeholder: '3px',
601-
})}
602-
{children.width.propertyView({
603-
label: trans('responsiveLayout.width'),
604-
preInputNode: <StyledIcon as={WidthIcon} title="" />,
605-
placeholder: '50%',
606-
})}
607-
{children.background.propertyView({
608-
label: trans('style.background'),
609-
})}
610-
{children.backgroundImage.propertyView({
611-
label: `Background Image`,
612-
// preInputNode: <StyledIcon as={ImageCompIcon} title="" />,
613-
placeholder: 'https://temp.im/350x400',
614-
})}
615-
{children.border.propertyView({
616-
label: trans('style.border')
617-
})}
618-
{children.radius.propertyView({
619-
label: trans('style.borderRadius'),
620-
preInputNode: <StyledIcon as={IconRadius} title="" />,
621-
placeholder: '3px',
622-
})}
623-
{children.margin.propertyView({
624-
label: trans('style.margin'),
625-
preInputNode: <StyledIcon as={ExpandIcon} title="" />,
626-
placeholder: '3px',
627-
})}
628-
{children.padding.propertyView({
629-
label: trans('style.padding'),
630-
preInputNode: <StyledIcon as={CompressIcon} title="" />,
631-
placeholder: '3px',
632-
})}
633-
</StyledContent>
634-
))
635-
.build();
598+
).build();
599+
600+
// Add propertyView method through class extension
601+
ColumnOption = class extends ColumnOption implements OptionCompProperty {
602+
propertyView(param: OptionPropertyParam) {
603+
const useFlexLayout = param?.useFlexLayout !== undefined ? param.useFlexLayout : true;
604+
605+
return (
606+
<StyledContent>
607+
{useFlexLayout && this.children.minWidth.propertyView({
608+
label: trans('responsiveLayout.minWidth'),
609+
preInputNode: <StyledIcon as={WidthIcon} title="" />,
610+
placeholder: '3px',
611+
})}
612+
{useFlexLayout && this.children.width.propertyView({
613+
label: trans('responsiveLayout.width'),
614+
preInputNode: <StyledIcon as={WidthIcon} title="" />,
615+
placeholder: '50%',
616+
})}
617+
{this.children.background.propertyView({
618+
label: trans('style.background'),
619+
})}
620+
{this.children.backgroundImage.propertyView({
621+
label: `Background Image`,
622+
// preInputNode: <StyledIcon as={ImageCompIcon} title="" />,
623+
placeholder: 'https://temp.im/350x400',
624+
})}
625+
{this.children.border.propertyView({
626+
label: trans('style.border')
627+
})}
628+
{this.children.radius.propertyView({
629+
label: trans('style.borderRadius'),
630+
preInputNode: <StyledIcon as={IconRadius} title="" />,
631+
placeholder: '3px',
632+
})}
633+
{this.children.margin.propertyView({
634+
label: trans('style.margin'),
635+
preInputNode: <StyledIcon as={ExpandIcon} title="" />,
636+
placeholder: '3px',
637+
})}
638+
{this.children.padding.propertyView({
639+
label: trans('style.padding'),
640+
preInputNode: <StyledIcon as={CompressIcon} title="" />,
641+
placeholder: '3px',
642+
})}
643+
</StyledContent>
644+
);
645+
}
646+
};
636647

637648
export const ColumnOptionControl = manualOptionsControl(ColumnOption, {
638649
initOptions: [

0 commit comments

Comments
 (0)