Skip to content

Commit daf75e5

Browse files
Merge pull request #2127 from iamfaran/fix/1758-tabbed
[Fix]: #1758 tabbed container padding and remove unnecessary code
2 parents dafdca9 + a8e7046 commit daf75e5

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

client/packages/lowcoder/src/comps/comps/tabs/tabbedContainerComp.tsx

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import { trans } from "i18n";
3131
import { BoolCodeControl, NumberControl } from "comps/controls/codeControl";
3232
import { DisabledContext } from "comps/generators/uiCompBuilder";
3333
import { EditorContext } from "comps/editorState";
34-
import { checkIsMobile } from "util/commonUtils";
3534
import { messageInstance } from "lowcoder-design/src/components/GlobalInstances";
3635
import { BoolControl } from "comps/controls/boolControl";
3736
import { PositionControl,dropdownControl } from "comps/controls/dropdownControl";
@@ -150,14 +149,14 @@ const StyledTabs = styled(Tabs)<{
150149
$style: TabContainerStyleType;
151150
$headerStyle: ContainerHeaderStyleType;
152151
$bodyStyle: TabBodyStyleType;
153-
$isMobile?: boolean;
154152
$showHeader?: boolean;
155-
$animationStyle:AnimationStyleType;
153+
$animationStyle: AnimationStyleType;
156154
$isDestroyPane?: boolean;
155+
$placement?: string;
157156
}>`
158157
&.ant-tabs {
159158
height: 100%;
160-
${props=>props.$animationStyle}
159+
${props => props.$animationStyle}
161160
}
162161
163162
.ant-tabs-content-animated {
@@ -170,20 +169,16 @@ const StyledTabs = styled(Tabs)<{
170169
171170
.ant-tabs-nav {
172171
display: ${(props) => (props.$showHeader ? "block" : "none")};
173-
padding: 0 ${(props) => (props.$isMobile ? 16 : 24)}px;
174172
margin: 0px;
175173
}
176174
177175
.ant-tabs-tab + .ant-tabs-tab {
178-
margin: 0 0 0 20px;
176+
${(props) => (props.$placement === "left" || props.$placement === "right")
177+
? `margin: 20px 0 0 0;`
178+
: `margin: 0 0 0 20px;`}
179179
}
180180
181-
.ant-tabs-nav-operations {
182-
margin-right: -24px;
183-
}
184-
185-
${(props) =>
186-
props.$style && getStyle(props.$style, props.$headerStyle, props.$bodyStyle)}
181+
${(props) => props.$style && getStyle(props.$style, props.$headerStyle, props.$bodyStyle)}
187182
188183
/* Conditional styling for all modes except Destroy Inactive Pane */
189184
${(props) => !props.$isDestroyPane && `
@@ -207,7 +202,6 @@ const ContainerInTab = (props: ContainerBaseProps) => {
207202
type TabPaneContentProps = {
208203
autoHeight: boolean;
209204
showVerticalScrollbar: boolean;
210-
paddingWidth: number;
211205
horizontalGridCells: number;
212206
bodyBackground: string;
213207
layoutView: any;
@@ -219,7 +213,6 @@ type TabPaneContentProps = {
219213
const TabPaneContent: React.FC<TabPaneContentProps> = ({
220214
autoHeight,
221215
showVerticalScrollbar,
222-
paddingWidth,
223216
horizontalGridCells,
224217
bodyBackground,
225218
layoutView,
@@ -243,7 +236,7 @@ const TabPaneContent: React.FC<TabPaneContentProps> = ({
243236
positionParams={positionParamsView}
244237
dispatch={dispatch}
245238
autoHeight={autoHeight}
246-
containerPadding={[paddingWidth, 0]}
239+
containerPadding={[0, 0]}
247240
/>
248241
</ScrollBar>
249242
</BackgroundColorContext.Provider>
@@ -272,11 +265,7 @@ const TabbedContainer = (props: TabbedContainerProps) => {
272265
}
273266
}, [activeKey, props.selectedTabKey.value]);
274267

275-
const editorState = useContext(EditorContext);
276-
const maxWidth = editorState.getAppSettings().maxWidth;
277-
const isMobile = checkIsMobile(maxWidth);
278268
const showHeader = props.showHeader.valueOf();
279-
const paddingWidth = isMobile ? 8 : 0;
280269

281270
const tabItems = visibleTabs.map((tab) => {
282271
const id = String(tab.id);
@@ -302,7 +291,6 @@ const TabbedContainer = (props: TabbedContainerProps) => {
302291
<TabPaneContent
303292
autoHeight={props.autoHeight}
304293
showVerticalScrollbar={props.showVerticalScrollbar}
305-
paddingWidth={paddingWidth}
306294
horizontalGridCells={horizontalGridCells}
307295
bodyBackground={bodyStyle.background}
308296
layoutView={containerChildren.layout.getView()}
@@ -327,14 +315,14 @@ const TabbedContainer = (props: TabbedContainerProps) => {
327315
$bodyStyle={bodyStyle}
328316
$showHeader={showHeader}
329317
$isDestroyPane={tabBehavior === "destroy"}
318+
$placement={props.placement}
330319
onChange={(key) => {
331320
if (key !== props.selectedTabKey.value) {
332321
props.selectedTabKey.onChange(key);
333322
props.onEvent("change");
334323
}
335324
}}
336325
animated
337-
$isMobile={isMobile}
338326
items={tabItems}
339327
tabBarGutter={props.tabsGutter}
340328
centered={props.tabsCentered}

0 commit comments

Comments
 (0)