Skip to content

Common style config added, number input component updated, link compo… #698

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
Show file tree
Hide file tree
Changes from all 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
17 changes: 9 additions & 8 deletions client/packages/lowcoder/src/comps/comps/buttonComp/linkComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ import { RefControl } from "comps/controls/refControl";
import { EditorContext } from "comps/editorState";
import React, { useContext } from "react";

const Link = styled(Button)<{ $style: LinkStyleType }>`
const Link = styled(Button) <{ $style: LinkStyleType }>`
${(props) => `
color: ${props.$style.text};
margin: ${props.$style.margin};
padding: ${props.$style.padding};
font-size: ${props.$style.textSize};
font-style:${props.$style.fontStyle};
font-family:${props.$style.fontFamily};
font-weight:${props.$style.textWeight};
border: ${props.$style.borderWidth} solid ${props.$style.border};
background-color: ${props.$style.background};
&:hover {
Expand Down Expand Up @@ -118,15 +119,15 @@ const LinkTmpComp = (function () {
{hiddenPropertyView(children)}
{loadingPropertyView(children)}
</Section>
<Section name={sectionNames.advanced}>
{children.prefixIcon.propertyView({ label: trans("button.prefixIcon") })}
{children.suffixIcon.propertyView({ label: trans("button.suffixIcon") })}
</Section></>
<Section name={sectionNames.advanced}>
{children.prefixIcon.propertyView({ label: trans("button.prefixIcon") })}
{children.suffixIcon.propertyView({ label: trans("button.suffixIcon") })}
</Section></>
)}

{(useContext(EditorContext).editorModeStatus === "layout" || useContext(EditorContext).editorModeStatus === "both") && (
<><Section name={sectionNames.style}>{children.style.getPropertyView()}</Section></>
)}
{(useContext(EditorContext).editorModeStatus === "layout" || useContext(EditorContext).editorModeStatus === "both") && (
<><Section name={sectionNames.style}>{children.style.getPropertyView()}</Section></>
)}
</>
);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import { EditorContext } from "comps/editorState";
const getStyle = (style: InputLikeStyleType) => {
return css`
border-radius: ${style.radius};
border-width:${style.borderWidth} !important;
// still use antd style when disabled
&:not(.ant-input-number-disabled) {
color: ${style.text};
Expand All @@ -78,11 +79,17 @@ const getStyle = (style: InputLikeStyleType) => {
}
.ant-input-number {
margin: 0;

}
.ant-input-number input {
.ant-input-number-input {
margin: 0;
padding: ${style.padding};
height: ${heightCalculator(style.margin)};
color:${style.text};
font-family:${style.fontFamily} !important;
font-weight:${style.textWeight} !important;
font-size:${style.textSize} !important;
font-style:${style.fontStyle} !important;
}

.ant-input-number-handler-wrap {
Expand Down Expand Up @@ -110,7 +117,7 @@ const getStyle = (style: InputLikeStyleType) => {
`;
};

const InputNumber = styled(AntdInputNumber)<{
const InputNumber = styled(AntdInputNumber) <{
$style: InputLikeStyleType;
}>`
width: 100%;
Expand Down Expand Up @@ -377,15 +384,15 @@ const NumberInputTmpComp = (function () {
{children.max.propertyView({ label: trans("prop.maximum") })}
{children.customRule.propertyView({})}
</Section>
<Section name={sectionNames.interaction}>
{children.onEvent.getPropertyView()}
{disabledPropertyView(children)}
{hiddenPropertyView(children)}
</Section>
<Section name={sectionNames.interaction}>
{children.onEvent.getPropertyView()}
{disabledPropertyView(children)}
{hiddenPropertyView(children)}
</Section>
</>
)}
{(useContext(EditorContext).editorModeStatus === "layout" || useContext(EditorContext).editorModeStatus === "both") && (

{(useContext(EditorContext).editorModeStatus === "layout" || useContext(EditorContext).editorModeStatus === "both") && (
children.label.getPropertyView()
)}

Expand Down
3 changes: 3 additions & 0 deletions client/packages/lowcoder/src/comps/comps/progressComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const getStyle = (style: ProgressStyleType) => {
line-height: 2;
.ant-progress-text {
color: ${style.text};
font-style:${style.fontStyle};
font-family:${style.fontFamily};
font-weight:${style.textWeight};
}
width: ${widthCalculator(style.margin)};
height: ${heightCalculator(style.margin)};
Expand Down
127 changes: 59 additions & 68 deletions client/packages/lowcoder/src/comps/controls/styleControlConstants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,18 @@ const HEADER_BACKGROUND = {
} as const;

const BG_STATIC_BORDER_RADIUS = [getBackground(), getStaticBorder(), RADIUS] as const;
const STYLING_FIELDS_SEQUENCE = [
TEXT,
TEXT_SIZE,
TEXT_WEIGHT,
FONT_FAMILY,
FONT_STYLE,
BORDER,
MARGIN,
PADDING,
RADIUS,
BORDER_WIDTH,
]

const FILL = {
name: "fill",
Expand Down Expand Up @@ -448,36 +460,40 @@ function getStaticBackground(color: string) {
} as const;
}


function replaceAndMergeMultipleStyles(originalArray: any[], styleToReplace: string, replacingStyles: any[]): any[] {
let temp = []
let foundIndex = originalArray.findIndex((element) => element.name === styleToReplace)

if (foundIndex !== -1) {
let elementsBeforeFoundIndex = originalArray.filter((item, index) => index < foundIndex)
let elementsAfterFoundIndex = originalArray.filter((item, index) => index > foundIndex)
temp = [...elementsBeforeFoundIndex, ...replacingStyles, ...elementsAfterFoundIndex]
} else
temp = [...originalArray]

return temp
}

export const ButtonStyle = [
...getBgBorderRadiusByBg("primary"),
BORDER_WIDTH,
TEXT,
TEXT_SIZE,
TEXT_WEIGHT,
FONT_FAMILY,
FONT_STYLE,
MARGIN,
PADDING
...STYLING_FIELDS_SEQUENCE
] as const;

export const ToggleButtonStyle = [
getBackground("canvas"),
{
name: "border",
label: trans("style.border"),
depName: "text",
depType: DEP_TYPE.SELF,
transformer: toSelf,
},
RADIUS,
BORDER_WIDTH,
TEXT,
TEXT_SIZE,
TEXT_WEIGHT,
FONT_FAMILY,
FONT_STYLE,
MARGIN,
PADDING,
...STYLING_FIELDS_SEQUENCE.map((style) => {
if (style.name === 'border') {
return {
...style,
depType: DEP_TYPE.SELF,
transformer: toSelf
}
}
return {
...style
}
})
] as const;

export const TextStyle = [
Expand All @@ -488,23 +504,14 @@ export const TextStyle = [
depType: DEP_TYPE.SELF,
transformer: toSelf,
},
TEXT,
TEXT_SIZE,
TEXT_WEIGHT,
FONT_FAMILY,
FONT_STYLE,
BORDER,
MARGIN,
PADDING,
...STYLING_FIELDS_SEQUENCE,
{
name: "links",
label: trans("style.links"),
depTheme: "primary",
depType: DEP_TYPE.SELF,
transformer: toSelf,
},
RADIUS,
BORDER_WIDTH,
] as const;

export const MarginStyle = [
Expand Down Expand Up @@ -681,15 +688,8 @@ export const SliderStyle = [

export const InputLikeStyle = [
LABEL,
...getStaticBgBorderRadiusByBg(SURFACE_COLOR),
BORDER_WIDTH,
TEXT,
TEXT_SIZE,
TEXT_WEIGHT,
FONT_FAMILY,
FONT_STYLE,
MARGIN,
PADDING,
getStaticBackground(SURFACE_COLOR),
...STYLING_FIELDS_SEQUENCE,
...ACCENT_VALIDATE,
] as const;

Expand Down Expand Up @@ -1046,21 +1046,15 @@ function handleToHoverLink(color: string) {
}

export const LinkStyle = [
...LinkTextStyle,

{
name: "background",
label: trans("style.background"),
depTheme: "canvas",
depType: DEP_TYPE.SELF,
transformer: toSelf,
},
MARGIN,
PADDING,
FONT_FAMILY,
FONT_STYLE,
BORDER,
BORDER_WIDTH,
TEXT_SIZE
...replaceAndMergeMultipleStyles(STYLING_FIELDS_SEQUENCE, 'text', [...LinkTextStyle])
] as const;

export const DividerStyle = [
Expand All @@ -1069,34 +1063,31 @@ export const DividerStyle = [
label: trans("color"),
color: lightenColor(SECOND_SURFACE_COLOR, 0.05),
},
BORDER_WIDTH,
MARGIN,
PADDING,
{
name: "text",
label: trans("text"),
depName: "color",
transformer: handleToDividerText,
},
TEXT_SIZE,
TEXT_WEIGHT,
FONT_FAMILY,
FONT_STYLE
...STYLING_FIELDS_SEQUENCE.map((style) => {
if (style.name === 'text') {
return {
name: "text",
label: trans("text"),
depName: "color",
transformer: handleToDividerText,
}
}
return style
})
] as const;

// Hidden border and borderWidth properties as AntD doesnt allow these properties for progress bar
export const ProgressStyle = [
{
...replaceAndMergeMultipleStyles(STYLING_FIELDS_SEQUENCE, 'text', [{
name: "text",
label: trans("text"),
depTheme: "canvas",
depType: DEP_TYPE.CONTRAST_TEXT,
transformer: contrastText,
},
}]).filter((style)=> ['border','borderWidth'].includes(style.name) === false),
TRACK,
FILL,
SUCCESS,
MARGIN,
PADDING,
] as const;

export const NavigationStyle = [
Expand Down