Skip to content

Commit e8ffb3c

Browse files
Macraheeliftikhar5
Mac
authored andcommitted
Item & Signature
1 parent 0c30fb0 commit e8ffb3c

File tree

5 files changed

+106
-14
lines changed

5 files changed

+106
-14
lines changed

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

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ import { BoolControl } from "comps/controls/boolControl";
2424
import type { ItemType } from "antd/es/menu/hooks/useItems";
2525
import { RefControl } from "comps/controls/refControl";
2626
import { EditorContext } from "comps/editorState";
27+
import { CompTypeContext } from "@lowcoder-ee/comps/utils/compTypeContext";
28+
import { setInitialCompStyles } from "@lowcoder-ee/comps/utils/themeUtil";
29+
import { ThemeContext } from "@lowcoder-ee/comps/utils/themeContext";
2730

2831
const Error = styled.div`
2932
color: #f5222d;
@@ -70,10 +73,28 @@ const ScannerTmpComp = (function () {
7073
maskClosable: withDefault(BoolControl, true),
7174
onEvent: ScannerEventHandlerControl,
7275
disabled: BoolCodeControl,
73-
style: styleControl(DropdownStyle),
76+
style: styleControl(DropdownStyle, 'style'),
7477
viewRef: RefControl<HTMLElement>,
7578
};
76-
return new UICompBuilder(childrenMap, (props) => {
79+
return new UICompBuilder(childrenMap, (props ,dispatch) => {
80+
81+
const theme = useContext(ThemeContext);
82+
const compType = useContext(CompTypeContext);
83+
const compTheme = theme?.theme?.components?.[compType];
84+
const styleProps: Record<string, any> = {};
85+
['style'].forEach((key: string) => {
86+
styleProps[key] = (props as any)[key];
87+
});
88+
89+
useEffect(() => {
90+
setInitialCompStyles({
91+
dispatch,
92+
compTheme,
93+
styleProps,
94+
});
95+
}, []);
96+
97+
7798
const [showModal, setShowModal] = useState(false);
7899
const [errMessage, setErrMessage] = useState("");
79100
const [videoConstraints, setVideoConstraints] = useState<MediaTrackConstraints>({

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ import { hiddenPropertyView } from "comps/utils/propertyUtils";
1212
import { trans } from "i18n";
1313
import { StringControl } from "comps/controls/codeControl";
1414

15-
import { useContext } from "react";
15+
import { useContext, useEffect } from "react";
1616
import { EditorContext } from "comps/editorState";
1717
import { withDefault } from "../generators";
18+
import { CompTypeContext } from "@lowcoder-ee/comps/utils/compTypeContext";
19+
import { setInitialCompStyles } from "@lowcoder-ee/comps/utils/themeUtil";
20+
import { ThemeContext } from "@lowcoder-ee/comps/utils/themeContext";
1821

1922
// TODO: add styling for image (size)
2023
// TODO: add styling for bouding box (individual backround)
@@ -31,8 +34,8 @@ const childrenMap = {
3134
level: dropdownControl(levelOptions, 'L'),
3235
includeMargin: BoolControl.DEFAULT_TRUE,
3336
image: StringControl,
34-
style: withDefault(styleControl(QRCodeStyle),{background:'transparent'}),
35-
animationStyle: styleControl(AnimationStyle),
37+
style: styleControl(QRCodeStyle , 'style'),
38+
animationStyle: styleControl(AnimationStyle , 'animationStyle'),
3639
restrictPaddingOnRotation: withDefault(StringControl, 'qrCode'),
3740
};
3841

@@ -78,7 +81,24 @@ const QRCodeView = (props: RecordConstructorToView<typeof childrenMap>) => {
7881
};
7982

8083
let QRCodeBasicComp = (function () {
81-
return new UICompBuilder(childrenMap, (props) => <QRCodeView {...props} />)
84+
return new UICompBuilder(childrenMap, (props , dispatch) =>{
85+
86+
const theme = useContext(ThemeContext);
87+
const compType = useContext(CompTypeContext);
88+
const compTheme = theme?.theme?.components?.[compType];
89+
const styleProps: Record<string, any> = {};
90+
['style' , 'animationStyle'].forEach((key: string) => {
91+
styleProps[key] = (props as any)[key];
92+
});
93+
94+
useEffect(() => {
95+
setInitialCompStyles({
96+
dispatch,
97+
compTheme,
98+
styleProps,
99+
});
100+
}, []);
101+
return( <QRCodeView {...props} />)})
82102
.setPropertyViewFn((children) => (
83103
<>
84104
<Section name={sectionNames.basic}>

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { hiddenPropertyView } from "comps/utils/propertyUtils";
1919
import { trans } from "i18n";
2020
import { changeValueAction, multiChangeAction } from "lowcoder-core";
2121
import { Section, sectionNames, UndoIcon } from "lowcoder-design";
22-
import React, { Suspense, useState } from "react";
22+
import React, { Suspense, useEffect, useState } from "react";
2323
import ReactResizeDetector from "react-resize-detector";
2424
import type SignatureCanvasType from "react-signature-canvas";
2525
import styled from "styled-components";
@@ -29,6 +29,9 @@ import { formDataChildren, FormDataPropertyView } from "./formComp/formDataConst
2929

3030
import { useContext } from "react";
3131
import { EditorContext } from "comps/editorState";
32+
import { CompTypeContext } from "@lowcoder-ee/comps/utils/compTypeContext";
33+
import { setInitialCompStyles } from "@lowcoder-ee/comps/utils/themeUtil";
34+
import { ThemeContext } from "@lowcoder-ee/comps/utils/themeContext";
3235

3336
const Wrapper = styled.div<{ $style: SignatureStyleType; $isEmpty: boolean }>`
3437
height: 100%;
@@ -99,19 +102,36 @@ const childrenMap = {
99102
tips: withDefault(StringControl, trans('signature.signHere')),
100103
onEvent: ChangeEventHandlerControl,
101104
label: withDefault(LabelControl, {position: 'column', text: ''}),
102-
style: styleControl(SignatureContainerStyle),
103-
labelStyle: styleControl(LabelStyle),
105+
style: styleControl(SignatureContainerStyle , 'style'),
106+
labelStyle: styleControl(LabelStyle , 'labelStyle'),
104107
showUndo: withDefault(BoolControl, true),
105108
showClear: withDefault(BoolControl, true),
106109
value: stateComp(''),
107-
inputFieldStyle: styleControl(SignatureStyle),
110+
inputFieldStyle: styleControl(SignatureStyle , 'inputFieldStyle'),
108111
...formDataChildren,
109112
};
110113

111114
const SignatureCanvas = React.lazy(() => import("react-signature-canvas"));
112115

113116
let SignatureTmpComp = (function () {
114117
return new UICompBuilder(childrenMap, (props, dispatch) => {
118+
119+
const theme = useContext(ThemeContext);
120+
const compType = useContext(CompTypeContext);
121+
const compTheme = theme?.theme?.components?.[compType];
122+
const styleProps: Record<string, any> = {};
123+
['style', 'labelStyle', 'inputFieldStyle'].forEach((key: string) => {
124+
styleProps[key] = (props as any)[key];
125+
});
126+
127+
useEffect(() => {
128+
setInitialCompStyles({
129+
dispatch,
130+
compTheme,
131+
styleProps,
132+
});
133+
}, []);
134+
115135
let canvas: SignatureCanvasType | null = null;
116136
const [isBegin, setIsBegin] = useState(false);
117137
const [canvasSize, setCanvasSize] = useState([0, 0]);

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

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ import { Transfer } from "antd";
1313
import ReactResizeDetector from "react-resize-detector";
1414
import { changeEvent, eventHandlerControl, searchEvent, selectedChangeEvent } from "../controls/eventHandlerControl";
1515
import styled, { css } from "styled-components";
16-
import { useEffect, useRef, useState } from "react";
16+
import { useContext, useEffect, useRef, useState } from "react";
1717
import { valueComp, withDefault } from "../generators";
1818
import type { TransferDirection } from 'antd/es/transfer';
1919
import { _ } from "core-js";
20-
20+
import { CompTypeContext } from "@lowcoder-ee/comps/utils/compTypeContext";
21+
import { setInitialCompStyles } from "@lowcoder-ee/comps/utils/themeUtil";
22+
import { ThemeContext } from "@lowcoder-ee/comps/utils/themeContext";
2123

2224
const Container = styled.div<{ $style: TransferStyleType }>`
2325
height: 100%;
@@ -57,7 +59,7 @@ const defaultItems = [
5759
const EventOptions = [changeEvent, searchEvent, selectedChangeEvent] as const;
5860

5961
const childrenMap = {
60-
style: styleControl(TransferStyle),
62+
style: styleControl(TransferStyle , 'style'),
6163
onEvent: eventHandlerControl(EventOptions),
6264
sourceTitle: withDefault(StringControl, trans('transfer.sourceTitle')),
6365
targetTitle: withDefault(StringControl, trans('transfer.targetTitle')),
@@ -140,7 +142,27 @@ const TransferView = (props: RecordConstructorToView<typeof childrenMap> & {
140142
};
141143

142144
let TransferBasicComp = (function () {
143-
return new UICompBuilder(childrenMap, (props, dispatch) => <TransferView {...props} dispatch={dispatch} />)
145+
return new UICompBuilder(childrenMap, (props, dispatch) => {
146+
147+
const theme = useContext(ThemeContext);
148+
const compType = useContext(CompTypeContext);
149+
const compTheme = theme?.theme?.components?.[compType];
150+
const styleProps: Record<string, any> = {};
151+
['style'].forEach((key: string) => {
152+
styleProps[key] = (props as any)[key];
153+
});
154+
155+
useEffect(() => {
156+
setInitialCompStyles({
157+
dispatch,
158+
compTheme,
159+
styleProps,
160+
});
161+
}, []);
162+
163+
164+
return (
165+
<TransferView {...props} dispatch={dispatch} />)})
144166
.setPropertyViewFn((children) => (
145167
<>
146168
<Section name={sectionNames.basic}>

client/packages/lowcoder/src/constants/themeConstants.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ const pageLayout = {
8888
borderWidth: '1px',
8989
}
9090
};
91+
92+
const qrCode = {
93+
style: {
94+
background:'transparent'
95+
}
96+
};
97+
98+
9199
export const defaultTheme: ThemeDetail = {
92100
primary: "#3377FF",
93101
textDark: "#222222",
@@ -119,6 +127,7 @@ export const defaultTheme: ThemeDetail = {
119127
columnLayout,
120128
tabbedContainer,
121129
step,
130+
qrCode,
122131
treeSelect,
123132
pageLayout,
124133
password: input,

0 commit comments

Comments
 (0)