Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added margin top to the onboarding flow if banner visible #31497

Merged
merged 4 commits into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions app/client/src/ce/pages/Applications/CreateNewAppsOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,29 @@ import StartWithTemplatesWrapper from "./StartWithTemplatesWrapper";
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
import { FEATURE_FLAG } from "@appsmith/entities/FeatureFlag";
import type { Template } from "api/TemplatesApi";
import { shouldShowLicenseBanner } from "@appsmith/selectors/tenantSelectors";

const SectionWrapper = styled.div`
const SectionWrapper = styled.div<{ isBannerVisible: boolean }>`
display: flex;
flex-direction: column;
padding: 0 var(--ads-v2-spaces-7) var(--ads-v2-spaces-7);
${(props) => `
margin-top: ${props.theme.homePage.header}px;
margin-top: ${
props.theme.homePage.header + (props.isBannerVisible ? 40 : 0)
}px;
Comment on lines +64 to +71
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dynamic adjustment of the SectionWrapper component's styling based on the isBannerVisible state is well-implemented. Using a styled component to conditionally apply the additional top margin ensures that the layout adapts seamlessly to the presence of the license banner. This approach maintains the separation of concerns by keeping styling logic within the styled component definition. However, consider extracting the calculation of the top margin into a separate function for better readability and maintainability.

+ const calculateTopMargin = (isBannerVisible: boolean) => props.theme.homePage.header + (isBannerVisible ? 40 : 0) + 'px';
- margin-top: ${props.theme.homePage.header + (props.isBannerVisible ? 40 : 0)}px;
+ margin-top: ${calculateTopMargin(props.isBannerVisible)};

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
const SectionWrapper = styled.div<{ isBannerVisible: boolean }>`
display: flex;
flex-direction: column;
padding: 0 var(--ads-v2-spaces-7) var(--ads-v2-spaces-7);
${(props) => `
margin-top: ${props.theme.homePage.header}px;
margin-top: ${
props.theme.homePage.header + (props.isBannerVisible ? 40 : 0)
}px;
const SectionWrapper = styled.div<{ isBannerVisible: boolean }>`
display: flex;
flex-direction: column;
padding: 0 var(--ads-v2-spaces-7) var(--ads-v2-spaces-7);
${(props) => `
+ const calculateTopMargin = (isBannerVisible: boolean) => props.theme.homePage.header + (isBannerVisible ? 40 : 0) + 'px';
- margin-top: ${props.theme.homePage.header + (props.isBannerVisible ? 40 : 0)}px;
+ margin-top: ${calculateTopMargin(props.isBannerVisible)};

`}
background: var(--ads-v2-color-gray-50);
${(props) => `
min-height: calc(100vh - ${props.theme.homePage.header}px);
`}
`;

const BackWrapper = styled.div<{ hidden?: boolean }>`
const BackWrapper = styled.div<{ hidden?: boolean; isBannerVisible: boolean }>`
position: sticky;
display: flex;
justify-content: space-between;
${(props) => `
top: ${props.theme.homePage.header}px;
top: ${props.theme.homePage.header + (props.isBannerVisible ? 40 : 0)}px;
`}
background: inherit;
padding: var(--ads-v2-spaces-3);
Expand Down Expand Up @@ -202,6 +205,8 @@ const CreateNewAppsOption = ({
FEATURE_FLAG.ab_start_with_data_default_enabled,
);

const isBannerVisible = useSelector(shouldShowLicenseBanner);

const dispatch = useDispatch();
const onClickStartFromTemplate = () => {
AnalyticsUtil.logEvent("CREATE_APP_FROM_TEMPLATE");
Expand Down Expand Up @@ -496,8 +501,8 @@ const CreateNewAppsOption = ({
};

return (
<SectionWrapper>
<BackWrapper hidden={!useType}>
<SectionWrapper isBannerVisible={!!isBannerVisible}>
<BackWrapper hidden={!useType} isBannerVisible={!!isBannerVisible}>
<LinkWrapper
className="t--create-new-app-option-goback"
data-testid="t--create-new-app-option-goback"
Expand Down
Loading