From 4e7fbcfe2eba0237587cb9aa646377952a5b45b3 Mon Sep 17 00:00:00 2001 From: ilkin-overleaf <100852799+ilkin-overleaf@users.noreply.github.com> Date: Tue, 28 May 2024 11:48:42 +0300 Subject: [PATCH] Merge pull request #18473 from overleaf/ii-bs5-settings-grid-fix [web] Adjust column breakpoints in bs5 account settings page GitOrigin-RevId: 90e7fe7561a75439166472627fdb6189ebcdefa1 --- .../settings/components/emails/add-email.tsx | 16 +++---- .../settings/components/emails/header.tsx | 4 +- .../components/emails/reconfirmation-info.tsx | 4 +- .../settings/components/emails/row.tsx | 18 ++++---- .../js/features/settings/components/root.tsx | 6 +-- .../js/features/ui/components/ol/ol-col.tsx | 44 +++++++++++++++---- 6 files changed, 60 insertions(+), 32 deletions(-) diff --git a/services/web/frontend/js/features/settings/components/emails/add-email.tsx b/services/web/frontend/js/features/settings/components/emails/add-email.tsx index 08c4eb5295..0803e0c9ba 100644 --- a/services/web/frontend/js/features/settings/components/emails/add-email.tsx +++ b/services/web/frontend/js/features/settings/components/emails/add-email.tsx @@ -109,7 +109,7 @@ function AddEmail() { if (!isFormVisible) { return ( - + {state.data.emailCount >= emailAddressLimit ? ( @@ -152,7 +152,7 @@ function AddEmail() {
- + {InputComponent}
@@ -160,10 +160,10 @@ function AddEmail() {
- + @@ -182,7 +182,7 @@ function AddEmail() { - + {InputComponent} {!isSsoAvailableForDomain ? ( @@ -205,10 +205,10 @@ function AddEmail() { {!isSsoAvailableForDomain ? ( - + @@ -221,7 +221,7 @@ function AddEmail() { ) : ( - +
- + - + {isBootstrap5 ? ( - + - + {userEmailData.affiliation?.institution && ( )} - + @@ -94,7 +94,7 @@ function SSOAffiliationInfo({ userEmailData }: SSOAffiliationInfoProps) { if (userEmailData.samlProviderId) { return ( - +

- +

- +

diff --git a/services/web/frontend/js/features/settings/components/root.tsx b/services/web/frontend/js/features/settings/components/root.tsx index 170044dcb2..2c0d43e968 100644 --- a/services/web/frontend/js/features/settings/components/root.tsx +++ b/services/web/frontend/js/features/settings/components/root.tsx @@ -35,7 +35,7 @@ function SettingsPageRoot() { return (

- + {isReady ? : null} @@ -60,10 +60,10 @@ function SettingsPageContent() { - + - + diff --git a/services/web/frontend/js/features/ui/components/ol/ol-col.tsx b/services/web/frontend/js/features/ui/components/ol/ol-col.tsx index 7e617fcea4..3b7d50a8f3 100644 --- a/services/web/frontend/js/features/ui/components/ol/ol-col.tsx +++ b/services/web/frontend/js/features/ui/components/ol/ol-col.tsx @@ -8,23 +8,51 @@ type OLColProps = React.ComponentProps & { function OLCol(props: OLColProps) { const { bs3Props, ...rest } = props - const sizes = new Set(['xs', 'sm', 'md', 'lg', 'xl', 'xxl']) const getBs3Sizes = (obj: typeof rest) => { - return Object.entries(obj).reduce( + const bs5ToBs3SizeMap = { + xs: undefined, + sm: undefined, + md: 'sm', + lg: 'md', + xl: 'lg', + xxl: undefined, + } as const + + const isBs5ToBs3SizeMapKey = ( + key: string + ): key is keyof typeof bs5ToBs3SizeMap => { + return key in bs5ToBs3SizeMap + } + + const sizes = Object.entries(obj).reduce( (prev, [key, value]) => { - if (sizes.has(key)) { - if (typeof value === 'object') { - prev[key] = value.span - prev[`${key}Offset`] = value.offset - } else { - prev[key] = value + if (isBs5ToBs3SizeMapKey(key)) { + const bs3Size = bs5ToBs3SizeMap[key] + + if (bs3Size) { + if (typeof value === 'object') { + prev[bs3Size] = value.span + prev[`${bs3Size}Offset`] = value.offset + } else { + prev[bs3Size] = value + } } } + return prev }, {} as Record ) + + // Add a default sizing for `col-xs-12` if no sizing is available + if ( + !Object.keys(sizes).some(key => ['xs', 'sm', 'md', 'lg'].includes(key)) + ) { + sizes.xs = 12 + } + + return sizes } const bs3ColProps: React.ComponentProps = {