diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/Button_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/Button_spec.js index 2d260dde248e..8a2e23e43627 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/Button_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/Button_spec.js @@ -19,12 +19,20 @@ describe("Button Widget Functionality", function() { it("Button-Style Validation", function() { //Changing the style of the button from the property pane and verify it's color. + // Change to Warning button sytle + cy.changeButtonStyle(2, "rgb(254, 184, 17)", "rgba(0, 0, 0, 0)"); + cy.get(publishPage.backToEditor).click({ force: true }); + cy.openPropertyPane("buttonwidget"); + // Change to Info button sytle + cy.changeButtonStyle(4, "rgb(102, 152, 255)", "rgba(0, 0, 0, 0)"); + cy.get(publishPage.backToEditor).click({ force: true }); + cy.openPropertyPane("buttonwidget"); // Change to Secondary button sytle - cy.changeButtonStyle(2, "rgba(0, 0, 0, 0)", "rgba(0, 0, 0, 0)"); + cy.changeButtonStyle(5, "rgb(133, 130, 130)", "rgba(0, 0, 0, 0)"); cy.get(publishPage.backToEditor).click({ force: true }); // Change to Danger button sytle cy.openPropertyPane("buttonwidget"); - cy.changeButtonStyle(3, "rgb(179, 3, 56)", "rgb(139, 2, 43)"); + cy.changeButtonStyle(3, "rgb(242, 43, 43)", "rgb(139, 2, 43)"); cy.get(publishPage.backToEditor).click({ force: true }); // Change to Primary button sytle cy.openPropertyPane("buttonwidget"); diff --git a/app/client/package.json b/app/client/package.json index 5ab6aa46c122..21dd4bc8df5f 100644 --- a/app/client/package.json +++ b/app/client/package.json @@ -146,7 +146,7 @@ "styled-components": "^5.2.0", "styled-system": "^5.1.5", "tern": "^0.21.0", - "tinycolor2": "^1.4.1", + "tinycolor2": "^1.4.2", "toposort": "^2.0.2", "ts-loader": "^6.0.4", "tslib": "^2.1.0", diff --git a/app/client/src/components/designSystems/appsmith/FilePickerComponent.tsx b/app/client/src/components/designSystems/appsmith/FilePickerComponent.tsx index c7732b0ff03d..011aa100be7e 100644 --- a/app/client/src/components/designSystems/appsmith/FilePickerComponent.tsx +++ b/app/client/src/components/designSystems/appsmith/FilePickerComponent.tsx @@ -29,9 +29,8 @@ class FilePickerComponent extends React.Component< } return ( { - if (props.filled) { - return props.accent === "grey" - ? props.theme.colors.textOnGreyBG - : props.theme.colors.textOnDarkBG; - } - if (props.accent) { - if (props.accent === "secondary") { - return props.theme.colors[AccentColorMap["primary"]]; - } - return props.theme.colors[AccentColorMap[props.accent]]; +export enum ButtonStyleTypes { + PRIMARY = "PRIMARY", + WARNING = "WARNING", + DANGER = "DANGER", + INFO = "INFO", + SECONDARY = "SECONDARY", + CUSTOM = "CUSTOM", +} +export type ButtonStyle = keyof typeof ButtonStyleTypes; + +export enum ButtonVariantTypes { + SOLID = "SOLID", + OUTLINE = "OUTLINE", + GHOST = "GHOST", +} +export type ButtonVariant = keyof typeof ButtonVariantTypes; + +const getCustomTextColor = ( + theme: Theme, + backgroundColor?: string, + prevButtonStyle?: ButtonStyle, +) => { + if (!backgroundColor) + return theme.colors.button[ + (prevButtonStyle || ButtonStyleTypes.PRIMARY).toLowerCase() + ].solid.textColor; + const isDark = tinycolor(backgroundColor).isDark(); + if (isDark) { + return theme.colors.button.custom.solid.light.textColor; } + return theme.colors.button.custom.solid.dark.textColor; }; -const getButtonFillStyles = (props: { theme: Theme } & ButtonStyleProps) => { - if (props.filled) { - return props.accent === "grey" - ? props.theme.colors.dropdownIconDarkBg - : props.theme.colors.textOnDarkBG; +const getCustomHoverColor = ( + theme: Theme, + prevButtonStyle?: ButtonStyle, + buttonVariant?: ButtonVariant, + backgroundColor?: string, +) => { + if (!backgroundColor) { + return theme.colors.button[ + (prevButtonStyle || ButtonStyleTypes.PRIMARY).toLowerCase() + ][(buttonVariant || ButtonVariantTypes.SOLID).toLowerCase()].hoverColor; } - if (props.accent) { - if (props.accent === "secondary") { - return props.theme.colors[AccentColorMap["primary"]]; - } - return props.theme.colors[AccentColorMap[props.accent]]; + + switch (buttonVariant) { + case ButtonVariantTypes.OUTLINE: + return backgroundColor + ? tinycolor(backgroundColor) + .lighten(40) + .toString() + : theme.colors.button.primary.outline.hoverColor; + break; + case ButtonVariantTypes.GHOST: + return backgroundColor + ? tinycolor(backgroundColor) + .lighten(40) + .toString() + : theme.colors.button.primary.ghost.hoverColor; + break; + + default: + return backgroundColor + ? tinycolor(backgroundColor) + .darken(10) + .toString() + : theme.colors.button.primary.solid.hoverColor; + break; } }; +const getCustomBackgroundColor = ( + theme: Theme, + prevButtonStyle?: ButtonStyle, + buttonVariant?: ButtonVariant, + backgroundColor?: string, +) => { + return buttonVariant === ButtonVariantTypes.SOLID + ? backgroundColor + ? backgroundColor + : theme.colors.button[ + (prevButtonStyle || ButtonStyleTypes.PRIMARY).toLowerCase() + ].solid.bgColor + : "none"; +}; + +const getCustomBorderColor = ( + theme: Theme, + prevButtonStyle?: ButtonStyle, + buttonVariant?: ButtonVariant, + backgroundColor?: string, +) => { + return buttonVariant === ButtonVariantTypes.OUTLINE + ? backgroundColor + ? backgroundColor + : theme.colors.button[ + (prevButtonStyle || ButtonStyleTypes.PRIMARY).toLowerCase() + ].outline.borderColor + : "none"; +}; + +const RecaptchaWrapper = styled.div` + position: relative; + .grecaptcha-badge { + visibility: hidden; + } +`; + const ToolTipContent = styled.div` max-width: 350px; `; @@ -64,118 +154,257 @@ const ToolTipWrapper = styled.div` } `; -const ButtonColorStyles = css` - color: ${getButtonColorStyles}; - svg { - fill: ${getButtonFillStyles}; - } -`; +const ButtonContainer = styled.div` + display: flex; + align-items: center; + justify-content: center; + height: 100%; -const RecaptchaWrapper = styled.div` - position: relative; - .grecaptcha-badge { - visibility: hidden; + & > button { + height: 100%; } `; -const AccentColorMap: Record = { - primary: "primaryOld", - secondary: "secondaryOld", - error: "error", - grey: "dropdownGreyBg", -}; +const StyledButton = styled(Button)` + height: 100%; + background-image: none !important; + font-weight: ${(props) => props.theme.fontWeights[2]}; + outline: none; + padding: 0px 10px; -const ButtonWrapper = styled((props: ButtonStyleProps & IButtonProps) => ( -