Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a055656

Browse files
committed
Creating function that helps to replace style from common style array with special array of styles, so individual styles of a component also can be handled, progress bar component updated
1 parent 5a4e1c4 commit a055656

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

‎client/packages/lowcoder/src/comps/comps/progressComp.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ const getStyle = (style: ProgressStyleType) => {
1818
line-height: 2;
1919
.ant-progress-text {
2020
color: ${style.text};
21+
font-style:${style.fontStyle};
22+
font-family:${style.fontFamily};
23+
font-weight:${style.textWeight};
2124
}
2225
width: ${widthCalculator(style.margin)};
2326
height: ${heightCalculator(style.margin)};

‎client/packages/lowcoder/src/comps/controls/styleControlConstants.tsx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,21 @@ function getStaticBackground(color: string) {
460460
} as const;
461461
}
462462

463+
464+
function replaceAndMergeMultipleStyles(originalArray: any[], styleToReplace: string, replacingStyles: any[]): any[] {
465+
let temp = []
466+
let foundIndex = originalArray.findIndex((element) => element.name === styleToReplace)
467+
468+
if (foundIndex !== -1) {
469+
let elementsBeforeFoundIndex = originalArray.filter((item, index) => index < foundIndex)
470+
let elementsAfterFoundIndex = originalArray.filter((item, index) => index > foundIndex)
471+
temp = [...elementsBeforeFoundIndex, ...replacingStyles, ...elementsAfterFoundIndex]
472+
} else
473+
temp = [...originalArray]
474+
475+
return temp
476+
}
477+
463478
export const ButtonStyle = [
464479
...getBgBorderRadiusByBg("primary"),
465480
...STYLING_FIELDS_SEQUENCE
@@ -674,14 +689,6 @@ export const SliderStyle = [
674689
export const InputLikeStyle = [
675690
LABEL,
676691
getStaticBackground(SURFACE_COLOR),
677-
// TEXT,
678-
// TEXT_SIZE,
679-
// TEXT_WEIGHT,
680-
// FONT_FAMILY,
681-
// FONT_STYLE,
682-
// MARGIN,
683-
// PADDING,
684-
// BORDER_WIDTH,
685692
...STYLING_FIELDS_SEQUENCE,
686693
...ACCENT_VALIDATE,
687694
] as const;
@@ -1047,8 +1054,7 @@ export const LinkStyle = [
10471054
depType: DEP_TYPE.SELF,
10481055
transformer: toSelf,
10491056
},
1050-
...LinkTextStyle,
1051-
...STYLING_FIELDS_SEQUENCE.filter((style) => style.name !== 'text')
1057+
...replaceAndMergeMultipleStyles(STYLING_FIELDS_SEQUENCE, 'text', [...LinkTextStyle])
10521058
] as const;
10531059

10541060
export const DividerStyle = [
@@ -1070,19 +1076,18 @@ export const DividerStyle = [
10701076
})
10711077
] as const;
10721078

1079+
// Hidden border and borderWidth properties as AntD doesnt allow these properties for progress bar
10731080
export const ProgressStyle = [
1074-
{
1081+
...replaceAndMergeMultipleStyles(STYLING_FIELDS_SEQUENCE, 'text', [{
10751082
name: "text",
10761083
label: trans("text"),
10771084
depTheme: "canvas",
10781085
depType: DEP_TYPE.CONTRAST_TEXT,
10791086
transformer: contrastText,
1080-
},
1087+
}]).filter((style)=> ['border','borderWidth'].includes(style.name) === false),
10811088
TRACK,
10821089
FILL,
10831090
SUCCESS,
1084-
MARGIN,
1085-
PADDING,
10861091
] as const;
10871092

10881093
export const NavigationStyle = [

0 commit comments

Comments
 (0)