Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[WIP] Theme style fixes relative to active/inactive preventOverwriteStyles flag#1217

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
FalkWolsky merged 5 commits intodevfromtheme-style-fixes
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,7 @@ import { trans } from "i18n";
import { ControlNode } from "lowcoder-design";
import { StringControl } from "comps/controls/codeControl";
import SliderControl from "@lowcoder-ee/comps/controls/sliderControl";
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";

const childrenMap = {
header: SimpleContainerComp,
Expand DownExpand Up@@ -65,6 +66,7 @@ const childrenMap = {
// Compatible with old style data 2022-8-15
const layoutBaseComp = migrateOldData(
new MultiCompBuilder(childrenMap, (props, dispatch) => {
useMergeCompStyles(props, dispatch);
return { ...props, dispatch };
}).build(),
fixOldStyleData
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,7 +33,7 @@ import { darkenColor, isDarkColor, ScrollBar } from "lowcoder-design";
import React, { Children, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
import { Resizable } from "react-resizable";
import styled, { css } from "styled-components";
import { useUserViewMode } from "util/hooks";
import {useMergeCompStyles,useUserViewMode } from "util/hooks";
import { TableImplComp } from "./tableComp";
import { useResizeDetector } from "react-resize-detector";
import { SlotConfigContext } from "comps/controls/slotControl";
Expand DownExpand Up@@ -903,7 +903,6 @@ export function TableCompView(props: {
updateEmptyRows();
}, [updateEmptyRows]);


const pageDataInfo = useMemo(() => {
// Data pagination
let pagedData = data;
Expand All@@ -928,6 +927,11 @@ export function TableCompView(props: {

const childrenProps = childrenToProps(comp.children);

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

const handleChangeEvent = useCallback(
(eventName: TableEventOptionValues) => {
if (eventName === "saveChanges" && !compChildren.onEvent.isBind(eventName)) {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,6 +28,7 @@ import { ContainerBodyChildComp } from "./containerBodyChildComp";
import { trans } from "i18n";
import { ControlNode } from "lowcoder-design";
import SliderControl from "@lowcoder-ee/comps/controls/sliderControl";
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";

const childrenMap = {
header: SimpleContainerComp,
Expand All@@ -53,6 +54,7 @@ const childrenMap = {
// Compatible with old style data 2022-8-15
const TriContainerBaseComp = migrateOldData(
new MultiCompBuilder(childrenMap, (props, dispatch) => {
useMergeCompStyles(props, dispatch);
return { ...props, dispatch };
}).build(),
fixOldStyleData
Expand Down
29 changes: 14 additions & 15 deletionsclient/packages/lowcoder/src/comps/controls/styleControl.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -673,10 +673,10 @@ function calcColors<ColorMap extends Record<string, string>>(
themeWithDefault.textDark,
themeWithDefault.textLight
);
} else if (config?.depType === DEP_TYPE.SELF && config.depTheme === "canvas" && bgColor) {
res[name] = bgColor;
} else if ((config?.depType || config?.depName) && compTheme?.[name]) {
res[name] = compTheme[name];
} else if (config?.depType === DEP_TYPE.SELF && config.depTheme === "canvas" && bgColor) {
res[name] = bgColor;
} else {
const rest = [];
config.depName && rest.push(res[config.depName]);
Expand DownExpand Up@@ -900,22 +900,21 @@ export function styleControl<T extends readonly SingleColorConfig[]>(

const appSettingsComp = editorState?.getAppSettingsComp();
const preventAppStylesOverwriting = appSettingsComp?.getView()?.preventAppStylesOverwriting;
const { appliedThemeId, preventStyleOverwriting } = comp?.comp?.container ||comp?.comp || {};
const { appliedThemeId, preventStyleOverwriting } =(comp?.comp ||{});
const appTheme = isPreviewTheme || isDefaultTheme || (!preventStyleOverwriting && !preventAppStylesOverwriting)
? theme?.theme
: defaultTheme;
const compTheme = isPreviewTheme || isDefaultTheme || (compType && !preventStyleOverwriting && !preventAppStylesOverwriting)
? {
...(omit(defaultTheme, 'components', 'chart')),
...defaultTheme.components?.[compType]?.[styleKey] as unknown as Record<string, string>,
...(omit(theme?.theme, 'components', 'chart')),
...theme?.theme?.components?.[compType]?.[styleKey] as unknown as Record<string, string>,
// ...(
// theme?.theme?.components?.[compType]?.[styleKey]
// // || defaultTheme.components?.[compType]?.[styleKey]
// ) as unknown as Record<string, string>
}
: defaultTheme.components?.[compType]?.[styleKey];
let compTheme: JSONValue|undefined = {};
if (appliedThemeId !== themeId) {
compTheme = isPreviewTheme || isDefaultTheme || (compType && !preventStyleOverwriting && !preventAppStylesOverwriting)
? {
...(omit(defaultTheme, 'components', 'chart')),
...defaultTheme.components?.[compType]?.[styleKey] as unknown as Record<string, string>,
...(omit(theme?.theme, 'components', 'chart')),
...theme?.theme?.components?.[compType]?.[styleKey] as unknown as Record<string, string>,
}
: defaultTheme.components?.[compType]?.[styleKey];
}
const styleProps = (!comp && !compType) || preventStyleOverwriting || preventAppStylesOverwriting || appliedThemeId === themeId
? props as ColorMap
: {} as ColorMap;
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -290,7 +290,7 @@ const UIView = React.memo((props: {
}

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

Expand Down
3 changes: 2 additions & 1 deletionclient/packages/lowcoder/src/comps/hooks/hookComp.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,7 +88,8 @@ const TitleHookComp = withPropertyViewFn(TitleTmp2Comp, (comp) => {
);
});
const builtInRemoteComps: Omit<RemoteCompInfo, "compName"> = {
source: !!REACT_APP_BUNDLE_BUILTIN_PLUGIN ? "bundle" : "npm",
// source: !!REACT_APP_BUNDLE_BUILTIN_PLUGIN ? "bundle" : "npm",
source: "npm",
isRemote: true,
packageName: "lowcoder-comps",
};
Expand Down
3 changes: 2 additions & 1 deletionclient/packages/lowcoder/src/comps/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -119,7 +119,8 @@ type Registry = {
};

const builtInRemoteComps: Omit<RemoteCompInfo, "compName"> = {
source: !!REACT_APP_BUNDLE_BUILTIN_PLUGIN ? "bundle" : "npm",
// source: !!REACT_APP_BUNDLE_BUILTIN_PLUGIN ? "bundle" : "npm",
source: "npm",
isRemote: true,
packageName: "lowcoder-comps",
};
Expand Down
3 changes: 2 additions & 1 deletionclient/packages/lowcoder/src/comps/utils/themeUtil.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,10 +38,11 @@ export function setInitialCompStyles({
const actions: Record<string, any> = {
appliedThemeId: changeValueAction(themeId || '', true),
};

styleKeys.forEach(styleKey => {
actions[styleKey] = changeValueAction({
...(compTheme?.[styleKey] as object || {}),
//...styleProps[styleKey],
...styleProps[styleKey],
}, true);
})

Expand Down
34 changes: 28 additions & 6 deletionsclient/packages/lowcoder/src/util/hooks.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@ import { AppPathParams } from "constants/applicationConstants";
import React, {
Dispatch,
SetStateAction,
useCallback,
useContext,
useEffect,
useMemo,
Expand DownExpand Up@@ -179,28 +180,49 @@ export function useMergeCompStyles(
const themeId = theme?.themeId;
const appSettingsComp = editorState?.getAppSettingsComp();
const preventAppStylesOverwriting = appSettingsComp?.getView()?.preventAppStylesOverwriting;
const { preventStyleOverwriting } = props;
const { preventStyleOverwriting, appliedThemeId } = props;

const styleKeys = Object.keys(props).filter(key => key.toLowerCase().endsWith('style' || 'styles'));
const styleProps: Record<string, any> = {};
styleKeys.forEach((key: string) => {
styleProps[key] = (props as any)[key];
});

const mergeStyles = useCallback(
({
dispatch,
compTheme,
styleProps,
themeId
}: any) => {
setInitialCompStyles({
dispatch,
compTheme,
styleProps,
themeId,
})
},
[]
);

useEffect(() => {
if (preventAppStylesOverwriting || preventStyleOverwriting) return;
setInitialCompStyles({
if (
preventAppStylesOverwriting
|| preventStyleOverwriting
|| themeId === appliedThemeId
) return;
mergeStyles({
dispatch,
compTheme,
styleProps,
themeId,
});
})
}, [
themeId,
JSON.stringify(styleProps),
JSON.stringify(compTheme),
setInitialCompStyles,
mergeStyles,
preventAppStylesOverwriting,
preventStyleOverwriting,
]);
}
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp