Skip to content

Commit 59452d2

Browse files
committed
make a seperate section for disabled
1 parent ede27eb commit 59452d2

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
ButtonCompWrapper,
2222
buttonRefMethods,
2323
ButtonStyleControl,
24+
DisabledButtonStyleControl,
2425
} from "./buttonCompConstants";
2526
import { RefControl } from "comps/controls/refControl";
2627
import { Tooltip } from "antd";
@@ -133,6 +134,7 @@ const childrenMap = {
133134
prefixIcon: IconControl,
134135
suffixIcon: IconControl,
135136
style: ButtonStyleControl,
137+
disabledStyle: DisabledButtonStyleControl,
136138
animationStyle: styleControl(AnimationStyle, 'animationStyle'),
137139
viewRef: RefControl<HTMLElement>,
138140
tooltip: StringControl
@@ -173,6 +175,7 @@ const ButtonPropertyView = React.memo((props: {
173175
{props.children.suffixIcon.propertyView({ label: trans("button.suffixIcon") })}
174176
</Section>
175177
<Section name={sectionNames.style}>{props.children.style.getPropertyView()}</Section>
178+
<Section name="Disabled">{props.children.disabledStyle.getPropertyView()}</Section>
176179
</>
177180
)}
178181
</>
@@ -212,6 +215,7 @@ const ButtonView = React.memo((props: ToViewReturn<ChildrenType>) => {
212215
<Button100
213216
ref={props.viewRef}
214217
$buttonStyle={props.style}
218+
$disabledStyle={props.disabledStyle}
215219
loading={props.loading}
216220
disabled={
217221
props.disabled ||

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { default as Button } from "antd/es/button";
22
import { styleControl } from "comps/controls/styleControl";
3-
import { ButtonStyleType, ButtonStyle } from "comps/controls/styleControlConstants";
3+
import { ButtonStyleType, ButtonStyle, DisabledButtonStyle } from "comps/controls/styleControlConstants";
44
import { migrateOldData } from "comps/generators/simpleGenerators";
55
import styled, { css } from "styled-components";
66
import { genActiveColor, genHoverColor } from "lowcoder-design";
77
import { refMethods } from "comps/generators/withMethodExposing";
88
import { blurMethod, clickMethod, focusWithOptions } from "comps/utils/methodUtils";
99

10-
export function getButtonStyle(buttonStyle: ButtonStyleType) {
10+
export function getButtonStyle(buttonStyle: ButtonStyleType, disabledStyle?: any) {
1111
const hoverColor = buttonStyle.background && genHoverColor(buttonStyle.background);
1212
const activeColor = buttonStyle.background && genActiveColor(buttonStyle.background);
1313
return css`
@@ -52,19 +52,22 @@ export function getButtonStyle(buttonStyle: ButtonStyleType) {
5252
/* Disabled state styling */
5353
&:disabled,
5454
&.ant-btn-disabled {
55-
color: ${buttonStyle.disabledText || buttonStyle.text};
56-
background: ${buttonStyle.disabledBackground || buttonStyle.background};
55+
color: ${disabledStyle?.disabledText || buttonStyle.text};
56+
background: ${disabledStyle?.disabledBackground || buttonStyle.background};
5757
border-color: ${
58-
buttonStyle.disabledBorder || buttonStyle.border
58+
disabledStyle?.disabledBorder || buttonStyle.border
5959
} !important;
6060
cursor: not-allowed;
6161
}
6262
}
6363
`;
6464
}
6565

66-
export const Button100 = styled(Button)<{ $buttonStyle?: ButtonStyleType }>`
67-
${(props) => props.$buttonStyle && getButtonStyle(props.$buttonStyle)}
66+
export const Button100 = styled(Button)<{
67+
$buttonStyle?: ButtonStyleType;
68+
$disabledStyle?: any;
69+
}>`
70+
${(props) => props.$buttonStyle && getButtonStyle(props.$buttonStyle, props.$disabledStyle)}
6871
width: 100%;
6972
height: auto;
7073
display: inline-flex;
@@ -116,6 +119,10 @@ function fixOldData(oldData: any) {
116119
const ButtonTmpStyleControl = styleControl(ButtonStyle, 'style');
117120
export const ButtonStyleControl = migrateOldData(ButtonTmpStyleControl, fixOldData);
118121

122+
// Create disabled style control
123+
const DisabledButtonTmpStyleControl = styleControl(DisabledButtonStyle, 'disabledStyle');
124+
export const DisabledButtonStyleControl = migrateOldData(DisabledButtonTmpStyleControl, fixOldData);
125+
119126
export const buttonRefMethods = refMethods<HTMLElement>([
120127
focusWithOptions,
121128
blurMethod,

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,10 @@ export const DISABLED_STYLE_FIELDS = [
991991
export const ButtonStyle = [
992992
getBackground('primary'),
993993
...STYLING_FIELDS_SEQUENCE,
994+
] as const;
995+
996+
// Create separate disabled style control
997+
export const DisabledButtonStyle = [
994998
...DISABLED_STYLE_FIELDS,
995999
] as const;
9961000

@@ -1013,7 +1017,6 @@ export const ToggleButtonStyle = [
10131017
...style,
10141018
};
10151019
}),
1016-
...DISABLED_STYLE_FIELDS,
10171020
] as const;
10181021

10191022
export const TextStyle = [
@@ -2321,6 +2324,7 @@ export type InputFieldStyleType = StyleConfigType<typeof InputFieldStyle>;
23212324
export type SignatureContainerStyleType = StyleConfigType<typeof SignatureContainerStyle>;
23222325
export type ColorPickerStyleType = StyleConfigType<typeof ColorPickerStyle>;
23232326
export type ButtonStyleType = StyleConfigType<typeof ButtonStyle>;
2327+
export type DisabledButtonStyleType = StyleConfigType<typeof DisabledButtonStyle>;
23242328
export type ToggleButtonStyleType = StyleConfigType<typeof ToggleButtonStyle>;
23252329
export type TextStyleType = StyleConfigType<typeof TextStyle>;
23262330
export type TextContainerStyleType = StyleConfigType<typeof TextContainerStyle>;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy