Skip to content

Commit 6c94b66

Browse files
Theme: update styleControls to handle comp theme styles
1 parent b0883df commit 6c94b66

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

client/packages/lowcoder/src/comps/controls/styleControl.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import { useIsMobile } from "util/hooks";
3636
import { CSSCodeControl, ObjectControl, RadiusControl, StringControl } from "./codeControl";
3737
import { ColorControl } from "./colorControl";
3838
import {
39-
defaultTheme,
4039
DepColorConfig,
4140
DEP_TYPE,
4241
RadiusConfig,
@@ -82,6 +81,7 @@ import { faTextWidth } from "@fortawesome/free-solid-svg-icons";
8281
import appSelectControl from "./appSelectControl";
8382
import { JSONObject, JSONValue } from "@lowcoder-ee/util/jsonTypes";
8483
import { CompTypeContext } from "../utils/compTypeContext";
84+
import { defaultTheme } from "@lowcoder-ee/constants/themeConstants";
8585

8686
function isSimpleColorConfig(config: SingleColorConfig): config is SimpleColorConfig {
8787
return config.hasOwnProperty("color");
@@ -357,6 +357,7 @@ function calcColors<ColorMap extends Record<string, string>>(
357357
) {
358358
let themeWithDefault = (theme || defaultTheme) as unknown as Record<string, string>;
359359
themeWithDefault = {...themeWithDefault, ...(compTheme || {})};
360+
360361
// Cover what is not there for the first pass
361362
let res: Record<string, string> = {};
362363
colorConfigs.forEach((config) => {
@@ -628,6 +629,10 @@ function calcColors<ColorMap extends Record<string, string>>(
628629
}
629630
if (isDepColorConfig(config)) {
630631
if (config.depType && config.depType === DEP_TYPE.CONTRAST_TEXT) {
632+
if (compTheme?.[name]) {
633+
res[name] = compTheme[name];
634+
return;
635+
}
631636
// bgColor is the background color of the container component, equivalent to canvas
632637
let depKey = config.depName ? res[config.depName] : themeWithDefault[config.depTheme!];
633638
if (bgColor && config.depTheme === "canvas") {
@@ -640,12 +645,16 @@ function calcColors<ColorMap extends Record<string, string>>(
640645
);
641646
} else if (config?.depType === DEP_TYPE.SELF && config.depTheme === "canvas" && bgColor) {
642647
res[name] = bgColor;
648+
} else if ((config?.depType || config?.depName) && compTheme?.[name]) {
649+
res[name] = compTheme[name];
643650
} else {
644651
const rest = [];
645652
config.depName && rest.push(res[config.depName]);
646653
config.depTheme && rest.push(themeWithDefault[config.depTheme]);
647654
res[name] = config.transformer(rest[0], rest[1]);
648655
}
656+
} else {
657+
res[name] = themeWithDefault[config.name]
649658
}
650659
});
651660
return res as ColorMap;

client/packages/lowcoder/src/pages/setting/theme/ThemeCompPanel.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,11 @@ export const ThemeCompPanel = (props: any) => {
314314
);
315315
}, [appDsl, theme]);
316316

317-
if(!compList.length) return (
318-
<RightPanelContentWrapper>
319-
<EmptyCompContent />
320-
</RightPanelContentWrapper>
321-
)
317+
// if(!compList.length) return (
318+
// <RightPanelContentWrapper>
319+
// <EmptyCompContent />
320+
// </RightPanelContentWrapper>
321+
// )
322322

323323
return (
324324
<Flex style={{

0 commit comments

Comments
 (0)