PromucFlow_constructor/app/client/src/pages/AppViewer/AppViewerButton.tsx
Dhruvik Neharia 9d5e2e0246
feat: App navigation - Logo upload (#22297)
## Description

Allowing users to upload a logo to show in the navigation along with
toggles to hide logo or application title.

Fixes #20134
Fixes #21946
Fixes #22260

## Media
<video
src="https://user-images.githubusercontent.com/22471214/235613131-129ac2ed-b994-4eab-8eba-7db297c2f7fd.mp4"><video>

## Type of change
- New feature (non-breaking change which adds functionality)

## How Has This Been Tested?
- Manual

### Test Plan
> https://github.com/appsmithorg/TestSmith/issues/2376

### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)


## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag


### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
2023-05-05 12:19:20 +05:30

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 "design-system-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;