Skip to content

Commit a4922bd

Browse files
author
Aqib Mirza
committed
feat: margin padding and select box options
1 parent cf3a59e commit a4922bd

30 files changed

+337
-72
lines changed

client/packages/lowcoder/src/comps/comps/buttonComp/buttonCompConstants.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ export function getButtonStyle(buttonStyle: ButtonStyleType) {
1212
const activeColor = genActiveColor(buttonStyle.background);
1313
return css`
1414
border-radius: ${buttonStyle.radius};
15+
margin: ${buttonStyle.margin};
16+
padding: ${buttonStyle.padding};
1517
&:not(:disabled) {
1618
// click animation color
1719
--antd-wave-shadow-color: ${buttonStyle.border};
1820
border-color: ${buttonStyle.border};
1921
color: ${buttonStyle.text};
2022
background-color: ${buttonStyle.background};
2123
border-radius: ${buttonStyle.radius};
24+
margin: ${buttonStyle.margin};
25+
padding: ${buttonStyle.padding};
2226
2327
:hover,
2428
:focus {
@@ -37,12 +41,14 @@ export function getButtonStyle(buttonStyle: ButtonStyleType) {
3741
: buttonStyle.border};
3842
}
3943
}
44+
4045
`;
4146
}
4247

4348
export const Button100 = styled(Button)<{ $buttonStyle?: ButtonStyleType }>`
4449
${(props) => props.$buttonStyle && getButtonStyle(props.$buttonStyle)}
45-
width: 100%;
50+
width: -webkit-fill-available;
51+
height: auto;
4652
display: inline-flex;
4753
justify-content: center;
4854
align-items: center;

client/packages/lowcoder/src/comps/comps/buttonComp/dropdownComp.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,30 @@ const DropdownButton = styled(Dropdown.Button)`
2929

3030
const LeftButtonWrapper = styled.div<{ $buttonStyle: ButtonStyleType }>`
3131
width: calc(100% - 32px);
32-
32+
${(props) => `margin: ${props.$buttonStyle.margin};`}
33+
margin-right: 0;
3334
.ant-btn {
3435
${(props) => getButtonStyle(props.$buttonStyle)}
36+
margin: 0 !important;
37+
height: 100%;
3538
&.ant-btn-default {
39+
margin: 0 !important;
3640
${(props) => `border-radius: ${props.$buttonStyle.radius} 0 0 ${props.$buttonStyle.radius};`}
3741
}
3842
width: 100%;
3943
}
4044
`;
4145

4246
const RightButtonWrapper = styled.div<{ $buttonStyle: ButtonStyleType }>`
43-
width: 32px;
47+
// width: 32px;
48+
${(props) => `margin: ${props.$buttonStyle.margin};`}
4449
margin-left: -1px;
45-
4650
.ant-btn {
4751
${(props) => getButtonStyle(props.$buttonStyle)}
52+
margin: 0 !important;
53+
height: 100%;
4854
&.ant-btn-default {
55+
margin: 0 !important;
4956
${(props) => `border-radius: 0 ${props.$buttonStyle.radius} ${props.$buttonStyle.radius} 0;`}
5057
}
5158
width: 100%;
@@ -69,6 +76,7 @@ const DropdownTmpComp = (function () {
6976
.map((option, index) => ({
7077
title: option.label,
7178
label: option.label,
79+
style: {padding: props.style.padding},
7280
key: option.label + " - " + index,
7381
disabled: option.disabled,
7482
icon: hasIcon && <span>{option.prefixIcon}</span>,
@@ -83,6 +91,7 @@ const DropdownTmpComp = (function () {
8391

8492
return (
8593
<ButtonCompWrapper disabled={props.disabled}>
94+
{console.log("props,", props)}
8695
{props.onlyMenu ? (
8796
<Dropdown disabled={props.disabled} overlay={menu}>
8897
<Button100 $buttonStyle={props.style} disabled={props.disabled}>

client/packages/lowcoder/src/comps/comps/buttonComp/linkComp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { hasIcon } from "comps/utils";
2121
import { RefControl } from "comps/controls/refControl";
2222

2323
const Link = styled(Button)<{ $style: LinkStyleType }>`
24-
${(props) => `color: ${props.$style.text};`}
24+
${(props) => `color: ${props.$style.text};margin: ${props.$style.margin}; padding: ${props.$style.padding};`}
2525
&.ant-btn {
2626
display: inline-flex;
2727
align-items: center;

client/packages/lowcoder/src/comps/comps/dateComp/dateCompUtil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const disabledTime = (min: string, max: string) => {
6363
export const getStyle = (style: DateTimeStyleType) => {
6464
return css`
6565
border-radius: ${style.radius};
66-
66+
padding: ${style.padding};
6767
&:not(.ant-picker-disabled) {
6868
border-color: ${style.border};
6969
background-color: ${style.background};

client/packages/lowcoder/src/comps/comps/dividerComp.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Section, sectionNames } from "lowcoder-design";
88
import _ from "lodash";
99
import styled from "styled-components";
1010
import { styleControl } from "comps/controls/styleControl";
11-
import { DividerStyle, DividerStyleType } from "comps/controls/styleControlConstants";
11+
import { DividerStyle, DividerStyleType, heightCalculator, widthCalculator } from "comps/controls/styleControlConstants";
1212
import { migrateOldData } from "comps/generators/simpleGenerators";
1313
import { hiddenPropertyView } from "comps/utils/propertyUtils";
1414
import { trans } from "i18n";
@@ -22,6 +22,17 @@ const StyledDivider = styled(Divider)<IProps>`
2222
display: flex;
2323
align-items: center;
2424
}
25+
min-width: 0;
26+
width: ${(props) => {
27+
return widthCalculator(props.$style.margin);
28+
}};
29+
min-height: ${(props) => {
30+
return heightCalculator(props.$style.margin);
31+
}};
32+
margin: ${(props) => {
33+
return props.$style.margin;
34+
}};
35+
padding: ${(props) => props.$style.padding};
2536
border-top: 1px ${(props) => (props.dashed ? "dashed" : "solid")} ${(props) => props.$style.color};
2637
2738
&.ant-divider-horizontal.ant-divider-with-text {

client/packages/lowcoder/src/comps/comps/fileComp/fileComp.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { darkenColor } from "components/colorSelect/colorUtils";
66
import { Section, sectionNames } from "components/Section";
77
import { IconControl } from "comps/controls/iconControl";
88
import { styleControl } from "comps/controls/styleControl";
9-
import { FileStyle, FileStyleType } from "comps/controls/styleControlConstants";
9+
import { FileStyle, FileStyleType, heightCalculator, widthCalculator } from "comps/controls/styleControlConstants";
1010
import { withMethodExposing } from "comps/generators/withMethodExposing";
1111
import { hasIcon } from "comps/utils";
1212
import { getComponentDocUrl } from "comps/utils/compDocUtil";
@@ -133,6 +133,10 @@ const getStyle = (style: FileStyleType) => {
133133
return css`
134134
.ant-btn {
135135
border-radius: ${style.radius};
136+
margin: ${style.margin};
137+
padding: ${style.padding};
138+
width: ${widthCalculator(style.margin)};
139+
height: ${heightCalculator(style.margin)};
136140
}
137141
138142
.ant-btn:not(:disabled) {

client/packages/lowcoder/src/comps/comps/fileViewerComp.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { styleControl } from "comps/controls/styleControl";
2-
import { FileViewerStyle, FileViewerStyleType } from "comps/controls/styleControlConstants";
2+
import { FileViewerStyle, FileViewerStyleType, heightCalculator, widthCalculator } from "comps/controls/styleControlConstants";
33
import { isEmpty } from "lodash";
44
import { useState } from "react";
55
import { DocumentViewer } from "react-documents";
@@ -13,6 +13,11 @@ import { trans } from "i18n";
1313

1414
const getStyle = (style: FileViewerStyleType) => {
1515
return css`
16+
width: ${widthCalculator(style.margin)};
17+
height: ${heightCalculator(style.margin)};
18+
margin: ${style.margin};
19+
padding: ${style.padding};
20+
1621
overflow: hidden;
1722
background-color: ${style.background};
1823
border: 1px solid ${style.border};

client/packages/lowcoder/src/comps/comps/imageComp.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { useEffect, useRef, useState } from "react";
99
import _ from "lodash";
1010
import ReactResizeDetector from "react-resize-detector";
1111
import { styleControl } from "comps/controls/styleControl";
12-
import { ImageStyle, ImageStyleType } from "comps/controls/styleControlConstants";
12+
import { ImageStyle, ImageStyleType, heightCalculator, widthCalculator } from "comps/controls/styleControlConstants";
1313
import { hiddenPropertyView } from "comps/utils/propertyUtils";
1414
import { trans } from "i18n";
1515
import { AutoHeightControl } from "comps/controls/autoHeightControl";
@@ -23,7 +23,6 @@ const Container = styled.div<{ $style: ImageStyleType | undefined }>`
2323
display: flex;
2424
align-items: center;
2525
justify-content: center;
26-
2726
.ant-image,
2827
img {
2928
width: 100%;
@@ -43,6 +42,10 @@ const getStyle = (style: ImageStyleType) => {
4342
img {
4443
border: 1px solid ${style.border};
4544
border-radius: ${style.radius};
45+
margin: ${style.margin};
46+
padding: ${style.padding};
47+
max-width: ${widthCalculator(style.margin)};
48+
max-height: ${heightCalculator(style.margin)};
4649
}
4750
4851
.ant-image-mask {

client/packages/lowcoder/src/comps/comps/numberInputComp/numberInputComp.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { formDataChildren, FormDataPropertyView } from "../formComp/formDataCons
3030
import { withMethodExposing, refMethods } from "../../generators/withMethodExposing";
3131
import { RefControl } from "../../controls/refControl";
3232
import { styleControl } from "comps/controls/styleControl";
33-
import { InputLikeStyle, InputLikeStyleType } from "comps/controls/styleControlConstants";
33+
import { InputLikeStyle, InputLikeStyleType, heightCalculator, widthCalculator } from "comps/controls/styleControlConstants";
3434
import {
3535
disabledPropertyView,
3636
hiddenPropertyView,
@@ -58,7 +58,9 @@ const getStyle = (style: InputLikeStyleType) => {
5858
color: ${style.text};
5959
background-color: ${style.background};
6060
border-color: ${style.border};
61-
61+
//margin: ${style.margin};
62+
padding: 0;
63+
width: ${widthCalculator(style.margin)};
6264
&.ant-input-number-focused {
6365
border-color: ${style.accent};
6466
}
@@ -71,6 +73,14 @@ const getStyle = (style: InputLikeStyleType) => {
7173
color: ${style.text};
7274
opacity: 0.4;
7375
}
76+
.ant-input-number {
77+
margin: 0;
78+
}
79+
.ant-input-number input {
80+
margin: 0;
81+
padding: ${style.padding};
82+
height: ${heightCalculator(style.margin)};
83+
}
7484
7585
.ant-input-number-handler-wrap {
7686
background-color: ${style.background};

client/packages/lowcoder/src/comps/comps/numberInputComp/rangeSliderComp.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const RangeSliderBasicComp = (function () {
2828
range={true}
2929
value={[props.start.value, props.end.value]}
3030
$style={props.style}
31+
style={{margin: 0}}
3132
onChange={([start, end]) => {
3233
props.start.onChange(start);
3334
props.end.onChange(end);

client/packages/lowcoder/src/comps/comps/numberInputComp/sliderComp.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const SliderBasicComp = (function () {
3131
{...props}
3232
value={props.value.value}
3333
$style={props.style}
34+
style={{margin: 0}}
3435
onChange={(e) => {
3536
props.value.onChange(e);
3637
props.onEvent("change");

client/packages/lowcoder/src/comps/comps/progressCircleComp.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Progress } from "antd";
22
import { styleControl } from "comps/controls/styleControl";
3-
import { ProgressStyle, ProgressStyleType } from "comps/controls/styleControlConstants";
3+
import { ProgressStyle, ProgressStyleType, heightCalculator, widthCalculator } from "comps/controls/styleControlConstants";
44
import styled, { css } from "styled-components";
55
import { Section, sectionNames } from "lowcoder-design";
66
import { numberExposingStateControl } from "../controls/codeStateControl";
@@ -11,6 +11,10 @@ import { trans } from "i18n";
1111

1212
const getStyle = (style: ProgressStyleType) => {
1313
return css`
14+
width: ${widthCalculator(style.margin)};
15+
height: ${heightCalculator(style.margin)};
16+
margin: ${style.margin};
17+
padding: ${style.padding};
1418
.ant-progress-text {
1519
color: ${style.text};
1620
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { BoolControl } from "../controls/boolControl";
55
import { UICompBuilder } from "../generators";
66
import { NameConfig, NameConfigHidden, withExposingConfigs } from "../generators/withExposing";
77
import { styleControl } from "comps/controls/styleControl";
8-
import { ProgressStyle, ProgressStyleType } from "comps/controls/styleControlConstants";
8+
import { ProgressStyle, ProgressStyleType, heightCalculator, widthCalculator } from "comps/controls/styleControlConstants";
99
import styled, { css } from "styled-components";
1010
import { hiddenPropertyView } from "comps/utils/propertyUtils";
1111
import { trans } from "i18n";
@@ -16,6 +16,10 @@ const getStyle = (style: ProgressStyleType) => {
1616
.ant-progress-text {
1717
color: ${style.text};
1818
}
19+
width: ${widthCalculator(style.margin)};
20+
height: ${heightCalculator(style.margin)};
21+
margin: ${style.margin};
22+
padding: ${style.padding};
1923
.ant-progress-inner {
2024
background-color: ${style.track};
2125
.ant-progress-bg {

client/packages/lowcoder/src/comps/comps/qrCodeComp.tsx

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { BoolControl } from "comps/controls/boolControl";
33
import { stringExposingStateControl } from "comps/controls/codeStateControl";
44
import { dropdownControl } from "comps/controls/dropdownControl";
55
import { styleControl } from "comps/controls/styleControl";
6-
import { QRCodeStyle } from "comps/controls/styleControlConstants";
6+
import { QRCodeStyle, heightCalculator, widthCalculator } from "comps/controls/styleControlConstants";
77
import { UICompBuilder } from "comps/generators/uiCompBuilder";
88
import { NameConfig, NameConfigHidden, withExposingConfigs } from "comps/generators/withExposing";
99
import { Section, sectionNames } from "lowcoder-design";
@@ -34,18 +34,28 @@ const QRCodeView = (props: RecordConstructorToView<typeof childrenMap>) => {
3434
return <>{trans("QRCode.maxLength")}</>;
3535
}
3636
return (
37-
<QRCodeSVG
38-
value={value}
39-
level={props.level}
40-
width="100%"
41-
height="100%"
42-
bgColor={props.style.background}
43-
fgColor={props.style.color}
44-
includeMargin={props.includeMargin}
45-
imageSettings={
46-
props.image ? { src: props.image, width: 0, height: 0, excavate: true } : undefined
47-
}
48-
/>
37+
<div
38+
style={{
39+
margin: props.style.margin,
40+
padding: props.includeMargin ? props.style.padding : 0,
41+
width: widthCalculator(props.style.margin),
42+
height: heightCalculator(props.style.margin),
43+
background: props.style.background,
44+
}}
45+
>
46+
<QRCodeSVG
47+
value={value}
48+
level={props.level}
49+
width="100%"
50+
height="100%"
51+
bgColor={props.style.background}
52+
fgColor={props.style.color}
53+
includeMargin={false}
54+
imageSettings={
55+
props.image ? { src: props.image, width: 0, height: 0, excavate: true } : undefined
56+
}
57+
/>
58+
</div>
4959
);
5060
};
5161

client/packages/lowcoder/src/comps/comps/selectInputComp/cascaderContants.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import { i18nObjs, trans } from "i18n";
1818
import { RefControl } from "comps/controls/refControl";
1919
import { CascaderRef } from "antd/lib/cascader";
2020

21+
import { MarginControl } from "../../controls/marginControl";
22+
import { PaddingControl } from "../../controls/paddingControl";
23+
2124
export const defaultDataSource = JSON.stringify(i18nObjs.cascader, null, " ");
2225

2326
export const CascaderChildren = {
@@ -31,6 +34,8 @@ export const CascaderChildren = {
3134
style: styleControl(CascaderStyle),
3235
showSearch: BoolControl.DEFAULT_TRUE,
3336
viewRef: RefControl<CascaderRef>,
37+
margin: MarginControl,
38+
padding: PaddingControl,
3439
};
3540

3641
export const CascaderPropertyView = (

client/packages/lowcoder/src/comps/comps/selectInputComp/checkboxComp.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export const getStyle = (style: CheckboxStyleType) => {
6464
}
6565
6666
.ant-checkbox-wrapper {
67+
padding: ${style.padding};
6768
.ant-checkbox-inner,
6869
.ant-checkbox-checked::after {
6970
border-radius: ${style.radius};

client/packages/lowcoder/src/comps/comps/selectInputComp/multiSelectComp.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@ import {
1212
} from "./selectCompConstants";
1313
import { SelectInputInvalidConfig, useSelectInputValidate } from "./selectInputConstants";
1414

15+
import { PaddingControl } from "../../controls/paddingControl";
16+
import { MarginControl } from "../../controls/marginControl";
17+
1518
const MultiSelectBasicComp = (function () {
1619
const childrenMap = {
1720
...SelectChildrenMap,
1821
value: arrayStringExposingStateControl("value", ["1", "2"]),
1922
style: styleControl(MultiSelectStyle),
23+
margin: MarginControl,
24+
padding: PaddingControl,
2025
};
2126
return new UICompBuilder(childrenMap, (props, dispatch) => {
2227
const valueSet = new Set<any>(props.options.map((o) => o.value)); // Filter illegal default values entered by the user

client/packages/lowcoder/src/comps/comps/selectInputComp/radioComp.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ const getStyle = (style: RadioStyleType) => {
1616
return css`
1717
.ant-radio-wrapper:not(.ant-radio-wrapper-disabled) {
1818
color: ${style.staticText};
19-
height: 22px;
19+
// height: 22px;
2020
max-width: calc(100% - 8px);
21-
21+
padding: ${style.padding};
2222
span:not(.ant-radio) {
2323
${EllipsisTextCss};
2424
}

0 commit comments

Comments
 (0)