Skip to content

Commit 1587f0b

Browse files
Macraheeliftikhar5
Mac
authored andcommitted
float component
1 parent 11abdfa commit 1587f0b

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

client/packages/lowcoder/src/comps/comps/buttonComp/floatButtonComp.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import { IconControl } from "comps/controls/iconControl";
1616
import styled from "styled-components";
1717
import { ButtonEventHandlerControl } from "comps/controls/eventHandlerControl";
1818
import { manualOptionsControl } from "comps/controls/optionsControl";
19+
import { useContext, useEffect } from "react";
20+
import { ThemeContext } from "@lowcoder-ee/comps/utils/themeContext";
21+
import { CompTypeContext } from "@lowcoder-ee/comps/utils/compTypeContext";
22+
import { setInitialCompStyles } from "@lowcoder-ee/comps/utils/themeUtil";
1923

2024
const StyledFloatButton = styled(FloatButton)<{
2125
$animationStyle: AnimationStyleType;
@@ -83,8 +87,8 @@ const childrenMap = {
8387
image: StringControl,
8488
icon: withDefault(IconControl, '/icon:antd/questioncircleoutlined'),
8589
badgeStyle: styleControl(BadgeStyle),
86-
style: styleControl(FloatButtonStyle),
87-
animationStyle: styleControl(AnimationStyle),
90+
style: styleControl(FloatButtonStyle , 'style'),
91+
animationStyle: styleControl(AnimationStyle , 'animationStyle'),
8892
buttons: manualOptionsControl(buttonGroupOption, {
8993
initOptions: [
9094
{ id: 0, label: trans("optionsControl.optionI", { i: '1' }), icon: "/icon:antd/filetextoutlined", badge: '1' },
@@ -131,9 +135,26 @@ const FloatButtonView = (props: RecordConstructorToView<typeof childrenMap>) =>
131135
};
132136

133137
let FloatButtonBasicComp = (function () {
134-
return new UICompBuilder(childrenMap, (props) => (
138+
return new UICompBuilder(childrenMap, (props , dispatch) => {
139+
const theme = useContext(ThemeContext);
140+
const compType = useContext(CompTypeContext);
141+
const compTheme = theme?.theme?.components?.[compType];
142+
const styleProps: Record<string, any> = {};
143+
['style', 'animationStyle'].forEach((key: string) => {
144+
styleProps[key] = (props as any)[key];
145+
});
146+
147+
useEffect(() => {
148+
setInitialCompStyles({
149+
dispatch,
150+
compTheme,
151+
styleProps,
152+
});
153+
}, []);
154+
155+
return(
135156
<FloatButtonView {...props} />
136-
))
157+
)})
137158
.setPropertyViewFn((children) => (
138159
<>
139160
<Section name={sectionNames.basic}>

0 commit comments

Comments
 (0)