Skip to content

Commit 4751e88

Browse files
Macraheeliftikhar5
Mac
authored andcommitted
Doc & File
1 parent 80560a9 commit 4751e88

File tree

2 files changed

+49
-9
lines changed

2 files changed

+49
-9
lines changed

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

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ import { messageInstance } from "lowcoder-design/src/components/GlobalInstances"
4242

4343
import React, { useContext } from "react";
4444
import { EditorContext } from "comps/editorState";
45-
45+
import { CompTypeContext } from "@lowcoder-ee/comps/utils/compTypeContext";
46+
import { setInitialCompStyles } from "@lowcoder-ee/comps/utils/themeUtil";
47+
import { ThemeContext } from "@lowcoder-ee/comps/utils/themeContext";
4648
const FileSizeControl = codeControl((value) => {
4749
if (typeof value === "number") {
4850
return value;
@@ -100,8 +102,8 @@ const commonChildren = {
100102
showUploadList: BoolControl.DEFAULT_TRUE,
101103
disabled: BoolCodeControl,
102104
onEvent: eventHandlerControl(EventOptions),
103-
style: styleControl(FileStyle),
104-
animationStyle: styleControl(AnimationStyle),
105+
style: styleControl(FileStyle , 'style'),
106+
animationStyle: styleControl(AnimationStyle , 'animationStyle'),
105107
parseFiles: BoolPureControl,
106108
parsedValue: stateComp<Array<JSONValue | null>>([]),
107109
prefixIcon: withDefault(IconControl, "/icon:solid/arrow-up-from-bracket"),
@@ -379,9 +381,27 @@ const childrenMap = {
379381
...formDataChildren,
380382
};
381383

382-
let FileTmpComp = new UICompBuilder(childrenMap, (props, dispatch) => (
384+
let FileTmpComp = new UICompBuilder(childrenMap, (props, dispatch) => {
385+
386+
const theme = useContext(ThemeContext);
387+
const compType = useContext(CompTypeContext);
388+
const compTheme = theme?.theme?.components?.[compType];
389+
const styleProps: Record<string, any> = {};
390+
['style', 'animationStyle'].forEach((key: string) => {
391+
styleProps[key] = (props as any)[key];
392+
});
393+
394+
useEffect(() => {
395+
setInitialCompStyles({
396+
dispatch,
397+
compTheme,
398+
styleProps,
399+
});
400+
}, []);
401+
return(
402+
383403
<Upload {...props} dispatch={dispatch} />
384-
))
404+
)})
385405
.setPropertyViewFn((children) => (
386406
<>
387407
<Section name={sectionNames.basic}>

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { styleControl } from "comps/controls/styleControl";
22
import { AnimationStyle, AnimationStyleType, FileViewerStyle, FileViewerStyleType, heightCalculator, widthCalculator } from "comps/controls/styleControlConstants";
33
import { isEmpty } from "lodash";
4-
import { useState } from "react";
4+
import { useEffect, useState } from "react";
55
import { DocumentViewer } from "react-documents";
66
import styled, { css } from "styled-components";
77
import { Section, sectionNames } from "lowcoder-design";
@@ -13,6 +13,9 @@ import { trans } from "i18n";
1313

1414
import { useContext } from "react";
1515
import { EditorContext } from "comps/editorState";
16+
import { CompTypeContext } from "@lowcoder-ee/comps/utils/compTypeContext";
17+
import { setInitialCompStyles } from "@lowcoder-ee/comps/utils/themeUtil";
18+
import { ThemeContext } from "@lowcoder-ee/comps/utils/themeContext";
1619

1720
const getStyle = (style: FileViewerStyleType) => {
1821
return css`
@@ -67,10 +70,27 @@ const DraggableFileViewer = (props: { src: string; style: FileViewerStyleType,an
6770
let FileViewerBasicComp = (function () {
6871
const childrenMap = {
6972
src: StringControl,
70-
style: styleControl(FileViewerStyle),
71-
animationStyle: styleControl(AnimationStyle),
73+
style: styleControl(FileViewerStyle , 'style'),
74+
animationStyle: styleControl(AnimationStyle , 'animationStyle'),
7275
};
73-
return new UICompBuilder(childrenMap, (props) => {
76+
return new UICompBuilder(childrenMap, (props , dispatch) => {
77+
78+
const theme = useContext(ThemeContext);
79+
const compType = useContext(CompTypeContext);
80+
const compTheme = theme?.theme?.components?.[compType];
81+
const styleProps: Record<string, any> = {};
82+
['style', 'animationStyle'].forEach((key: string) => {
83+
styleProps[key] = (props as any)[key];
84+
});
85+
86+
useEffect(() => {
87+
setInitialCompStyles({
88+
dispatch,
89+
compTheme,
90+
styleProps,
91+
});
92+
}, []);
93+
7494
if (isEmpty(props.src)) {
7595
return (
7696
<ErrorWrapper

0 commit comments

Comments
 (0)