Skip to content

Allow dynamic/conditional styles + Refactor logic for applying theme on each comp #1105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
stop overriding dynamic styles
  • Loading branch information
raheeliftikhar5 committed Aug 13, 2024
commit 2098b4492e9b0347ec4eed18b98b91d16dfd62b5
10 changes: 5 additions & 5 deletions client/packages/lowcoder/src/comps/comps/textComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ let TextTmpComp = (function () {
};
return new UICompBuilder(childrenMap, (props, dispatch) => {
const value = props.text.value;

useMergeCompStyles(
props as Record<string, any>,
dispatch
);
// useMergeCompStyles(
// props as Record<string, any>,
// dispatch
// );

return (
<TextContainer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { UICompType, uiCompRegistry } from "../uiCompRegistry";
import { getNpmPackageMeta } from "../utils/remote";
import { compPluginsList } from "constants/compPluginConstants";
import Select from "antd/es/select";
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";

export type NewChildren<ChildrenCompMap extends Record<string, Comp<unknown>>> =
ChildrenCompMap & {
Expand Down Expand Up @@ -281,6 +282,7 @@ function UIView(props: {
}) {
const comp = props.comp;
const childrenProps = childrenToProps(comp.children);
const childrenJsonProps = comp.toJsonValue();
const parentDisabled = useContext(DisabledContext);
const disabled = childrenProps['disabled'];
if (disabled !== undefined && typeof disabled === 'boolean') {
Expand All @@ -296,6 +298,11 @@ function UIView(props: {
}
//END ADD BY FRED

useMergeCompStyles(
childrenJsonProps as Record<string, any>,
comp.dispatch
);

// render condition for modal and drawer as we are not getting compType here
if (comp.children.hasOwnProperty('showMask') && comp.children.hasOwnProperty('maskClosable')) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,13 @@ export const ThemeCompPanel = (props: any) => {

if (newComp) {
const compChildrens = newComp.children;
let styleChildrenKeys = Object.keys(compChildrens).filter(child => child.toLowerCase().endsWith('style'));
let styleChildrenKeys = Object.keys(compChildrens).filter(child => child.toLowerCase().endsWith('style' || 'styles'));
let styleChildrens: Record<string, any> = {};
styleChildrenKeys.forEach((childKey: string) => {
styleChildrens[childKey] = compChildrens[childKey];
})
if (compChildrens.container) {
styleChildrenKeys = Object.keys(compChildrens.container.children).filter(child => child.toLowerCase().endsWith('style'));
styleChildrenKeys = Object.keys(compChildrens.container.children).filter(child => child.toLowerCase().endsWith('style' || 'styles'));
styleChildrenKeys.forEach((childKey: string) => {
styleChildrens[childKey] = compChildrens.container.children[childKey];
})
Expand Down