PromucFlow_constructor/app/client/src/pages/AppViewer/AppViewerButton.tsx
Valera Melnikov b7ec5dacd8
chore: rename old ADS package (#35517)
## Description
Rename package `design-system-old` to `@appsmith/ads-old`.

## Automation

/ok-to-test tags="@tag.All"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!CAUTION]
> 🔴 🔴 🔴 Some tests have failed.
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/10286195096>
> Commit: c0d478694b12f35b88687b6dae6f252967fba540
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10286195096&attempt=1&selectiontype=test&testsstatus=failed&specsstatus=fail"
target="_blank">Cypress dashboard</a>.
> Tags: @tag.All
> Spec: 
> The following are new failures, please fix them before merging the PR:
<ol>
>
<li>cypress/e2e/Regression/ClientSide/BugTests/DatasourceSchema_spec.ts</ol>
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/identified-flaky-tests-65890b3c81d7400d08fa9ee3?branch=master"
target="_blank">List of identified flaky tests</a>.
> <hr>Wed, 07 Aug 2024 15:26:02 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No
2024-08-08 15:55:00 +03:00

133 lines
3.2 KiB
TypeScript

import type { ButtonVariant } from "components/constants";
import { ButtonVariantTypes } from "components/constants";
import type { NavigationSetting } from "constants/AppConstants";
import { NAVIGATION_SETTINGS } from "constants/AppConstants";
import styled from "styled-components";
import { StyledButton as Button } from "widgets/ButtonWidget/component";
import {
getMenuItemBackgroundColorOnHover,
getMenuItemTextColor,
getSignInButtonStyles,
} from "./utils";
import { getTypographyByKey } from "@appsmith/ads-old";
const StyledButton = styled(Button)<{
primaryColor: string;
navColorStyle: NavigationSetting["colorStyle"];
varient?: ButtonVariant;
insideSidebar?: boolean;
isMinimal?: boolean;
}>`
padding: 6px 12px;
line-height: 1.2;
transition: all 0.3s ease-in-out;
box-shadow: none;
display: flex;
align-items: center;
justify-content: center;
span {
max-width: 100%;
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)};`;
}
}};
}
}
${({ insideSidebar = false, isMinimal }) => {
if (!insideSidebar) {
return "";
}
return `
padding: 8px 10px;
gap: 10px;
width: 100%;
justify-content: ${isMinimal ? "center" : "flex-start"};
.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;
}
svg path {
fill: ${styles.color} !important;
}
&:hover,
&:active,
&:focus {
background-color: ${styles.backgroundOnHover} !important;
span {
color: ${styles.color} !important;
}
svg path {
fill: ${styles.color} !important;
}
}
`;
if (insideSidebar) {
secondaryVarientStyles += `
padding: 10px;
justify-content: center;
`;
}
return varient === ButtonVariantTypes.SECONDARY
? secondaryVarientStyles
: "";
}}
`;
export default StyledButton;