2023-03-23 11:41:58 +00:00
|
|
|
import type { ButtonVariant } from "components/constants";
|
|
|
|
|
import { ButtonVariantTypes } from "components/constants";
|
|
|
|
|
import type { NavigationSetting } from "constants/AppConstants";
|
|
|
|
|
import { NAVIGATION_SETTINGS } from "constants/AppConstants";
|
2022-05-04 09:45:57 +00:00
|
|
|
import styled from "styled-components";
|
|
|
|
|
import { StyledButton as Button } from "widgets/ButtonWidget/component";
|
2023-03-23 11:41:58 +00:00
|
|
|
import {
|
|
|
|
|
getMenuItemBackgroundColorOnHover,
|
|
|
|
|
getMenuItemTextColor,
|
|
|
|
|
getSignInButtonStyles,
|
|
|
|
|
} from "./utils";
|
2024-08-08 12:55:00 +00:00
|
|
|
import { getTypographyByKey } from "@appsmith/ads-old";
|
2022-05-04 09:45:57 +00:00
|
|
|
|
2023-03-23 11:41:58 +00:00
|
|
|
const StyledButton = styled(Button)<{
|
|
|
|
|
primaryColor: string;
|
|
|
|
|
navColorStyle: NavigationSetting["colorStyle"];
|
|
|
|
|
varient?: ButtonVariant;
|
|
|
|
|
insideSidebar?: boolean;
|
|
|
|
|
isMinimal?: boolean;
|
|
|
|
|
}>`
|
2022-05-04 09:45:57 +00:00
|
|
|
padding: 6px 12px;
|
|
|
|
|
line-height: 1.2;
|
2023-03-23 11:41:58 +00:00
|
|
|
transition: all 0.3s ease-in-out;
|
|
|
|
|
box-shadow: none;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
2022-05-04 09:45:57 +00:00
|
|
|
|
|
|
|
|
span {
|
|
|
|
|
max-width: 100%;
|
2023-03-23 11:41:58 +00:00
|
|
|
color: ${({ navColorStyle, primaryColor }) =>
|
|
|
|
|
getMenuItemTextColor(primaryColor, navColorStyle, true)} !important;
|
|
|
|
|
transition: all 0.3s ease-in-out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
svg path {
|
|
|
|
|
fill: ${({ navColorStyle, primaryColor }) =>
|
|
|
|
|
getMenuItemTextColor(primaryColor, navColorStyle, true)};
|
|
|
|
|
transition: all 0.3s ease-in-out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&:hover,
|
|
|
|
|
&:active,
|
|
|
|
|
&:focus {
|
|
|
|
|
background-color: ${({ navColorStyle, primaryColor }) =>
|
|
|
|
|
getMenuItemBackgroundColorOnHover(
|
|
|
|
|
primaryColor,
|
|
|
|
|
navColorStyle,
|
|
|
|
|
)} !important;
|
|
|
|
|
|
|
|
|
|
span {
|
|
|
|
|
${({ navColorStyle, primaryColor }) => {
|
|
|
|
|
if (navColorStyle !== NAVIGATION_SETTINGS.COLOR_STYLE.LIGHT) {
|
|
|
|
|
return `color: ${getMenuItemTextColor(
|
|
|
|
|
primaryColor,
|
|
|
|
|
navColorStyle,
|
|
|
|
|
)} !important`;
|
|
|
|
|
}
|
|
|
|
|
}};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
svg path {
|
|
|
|
|
${({ navColorStyle, primaryColor }) => {
|
|
|
|
|
if (navColorStyle !== NAVIGATION_SETTINGS.COLOR_STYLE.LIGHT) {
|
|
|
|
|
return `fill: ${getMenuItemTextColor(primaryColor, navColorStyle)};`;
|
|
|
|
|
}
|
|
|
|
|
}};
|
|
|
|
|
}
|
2022-05-04 09:45:57 +00:00
|
|
|
}
|
2023-03-23 11:41:58 +00:00
|
|
|
|
|
|
|
|
${({ insideSidebar = false, isMinimal }) => {
|
|
|
|
|
if (!insideSidebar) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return `
|
|
|
|
|
padding: 8px 10px;
|
|
|
|
|
gap: 10px;
|
|
|
|
|
width: 100%;
|
|
|
|
|
justify-content: ${isMinimal ? "center" : "flex-start"};
|
2024-08-08 12:55:00 +00:00
|
|
|
|
2023-03-23 11:41:58 +00:00
|
|
|
.bp3-button-text {
|
|
|
|
|
${getTypographyByKey("h5")}
|
|
|
|
|
font-weight: 400;
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
|
|
// Secondary button styles (such as the sign in button)
|
|
|
|
|
${({ insideSidebar = false, navColorStyle, primaryColor, varient }) => {
|
|
|
|
|
const styles = getSignInButtonStyles(primaryColor, navColorStyle);
|
|
|
|
|
|
|
|
|
|
let secondaryVarientStyles = `
|
|
|
|
|
background-color: ${styles.background} !important;
|
|
|
|
|
|
|
|
|
|
span {
|
|
|
|
|
color: ${styles.color} !important;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-05 06:49:20 +00:00
|
|
|
svg path {
|
|
|
|
|
fill: ${styles.color} !important;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-23 11:41:58 +00:00
|
|
|
&:hover,
|
2024-08-08 12:55:00 +00:00
|
|
|
&:active,
|
2023-03-23 11:41:58 +00:00
|
|
|
&:focus {
|
|
|
|
|
background-color: ${styles.backgroundOnHover} !important;
|
|
|
|
|
|
|
|
|
|
span {
|
|
|
|
|
color: ${styles.color} !important;
|
|
|
|
|
}
|
2023-05-05 06:49:20 +00:00
|
|
|
|
|
|
|
|
svg path {
|
|
|
|
|
fill: ${styles.color} !important;
|
|
|
|
|
}
|
2023-03-23 11:41:58 +00:00
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
if (insideSidebar) {
|
|
|
|
|
secondaryVarientStyles += `
|
|
|
|
|
padding: 10px;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return varient === ButtonVariantTypes.SECONDARY
|
|
|
|
|
? secondaryVarientStyles
|
|
|
|
|
: "";
|
|
|
|
|
}}
|
2022-05-04 09:45:57 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
export default StyledButton;
|