Skip to content

Commit a5ec696

Browse files
Macraheeliftikhar5
Mac
authored andcommitted
tabbed container component
1 parent 9ee311e commit a5ec696

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

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

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { NameGenerator } from "comps/utils";
1515
import { ScrollBar, Section, sectionNames } from "lowcoder-design";
1616
import { HintPlaceHolder } from "lowcoder-design";
1717
import _ from "lodash";
18-
import React, { useCallback, useContext } from "react";
18+
import React, { useCallback, useContext, useEffect } from "react";
1919
import styled, { css } from "styled-components";
2020
import { IContainer } from "../containerBase/iContainer";
2121
import { SimpleContainerComp } from "../containerBase/simpleContainerComp";
@@ -35,6 +35,9 @@ import { checkIsMobile } from "util/commonUtils";
3535
import { messageInstance } from "lowcoder-design/src/components/GlobalInstances";
3636
import { BoolControl } from "comps/controls/boolControl";
3737
import { PositionControl } from "comps/controls/dropdownControl";
38+
import { setInitialCompStyles } from "@lowcoder-ee/comps/utils/themeUtil";
39+
import { ThemeContext } from "@lowcoder-ee/comps/utils/themeContext";
40+
import { CompTypeContext } from "@lowcoder-ee/comps/utils/compTypeContext";
3841

3942
const EVENT_OPTIONS = [
4043
{
@@ -57,10 +60,10 @@ const childrenMap = {
5760
onEvent: eventHandlerControl(EVENT_OPTIONS),
5861
disabled: BoolCodeControl,
5962
showHeader: withDefault(BoolControl, true),
60-
style: withDefault(styleControl(TabContainerStyle),{borderWidth:'1px'}),
61-
headerStyle: styleControl(ContainerHeaderStyle),
62-
bodyStyle: styleControl(TabBodyStyle),
63-
animationStyle: styleControl(AnimationStyle),
63+
style: styleControl(TabContainerStyle , 'style'),
64+
headerStyle: styleControl(ContainerHeaderStyle , 'headerStyle'),
65+
bodyStyle: styleControl(TabBodyStyle , 'bodyStyle'),
66+
animationStyle: styleControl(AnimationStyle , 'animationStyle'),
6467
tabsGutter: withDefault(NumberControl, 32),
6568
tabsCentered: withDefault(BoolControl, false),
6669
};
@@ -288,6 +291,23 @@ const TabbedContainer = (props: TabbedContainerProps) => {
288291

289292
export const TabbedContainerBaseComp = (function () {
290293
return new UICompBuilder(childrenMap, (props, dispatch) => {
294+
295+
const theme = useContext(ThemeContext);
296+
const compType = useContext(CompTypeContext);
297+
const compTheme = theme?.theme?.components?.[compType];
298+
const styleProps: Record<string, any> = {};
299+
['style', 'headerStyle', 'bodyStyle', 'animationStyle'].forEach((key: string) => {
300+
styleProps[key] = (props as any)[key];
301+
});
302+
303+
useEffect(() => {
304+
setInitialCompStyles({
305+
dispatch,
306+
compTheme,
307+
styleProps,
308+
});
309+
}, []);
310+
291311
return (
292312
<DisabledContext.Provider value={props.disabled}>
293313
<TabbedContainer {...props} dispatch={dispatch} />

0 commit comments

Comments
 (0)