From 201d72f9802921344b6056f91b51405e51f9c2d2 Mon Sep 17 00:00:00 2001 From: suubi-joshua Date: Tue, 27 Aug 2024 21:19:58 +0300 Subject: [PATCH 1/6] Added config to allow addition of Powered by Logo --- .../esm-login-app/__mocks__/config.mock.ts | 8 +++++ .../apps/esm-login-app/src/config-schema.ts | 29 +++++++++++++++ .../esm-login-app/src/footer.component.tsx | 33 +++++++++++++++++ .../src/login/login.component.tsx | 8 ++--- .../apps/esm-login-app/src/login/login.scss | 36 +++++++++++++++++-- .../apps/esm-login-app/src/logo.component.tsx | 2 +- 6 files changed, 107 insertions(+), 9 deletions(-) create mode 100644 packages/apps/esm-login-app/src/footer.component.tsx diff --git a/packages/apps/esm-login-app/__mocks__/config.mock.ts b/packages/apps/esm-login-app/__mocks__/config.mock.ts index 16b2bc691..105c045b6 100644 --- a/packages/apps/esm-login-app/__mocks__/config.mock.ts +++ b/packages/apps/esm-login-app/__mocks__/config.mock.ts @@ -19,5 +19,13 @@ export const mockConfig: ConfigSchema = { links: { loginSuccess: '${openmrsSpaBase}/home', }, + footer: { + logos: [ + { + src: null, + alt: 'Logo', + } + ], + }, showPasswordOnSeparateScreen: true, }; diff --git a/packages/apps/esm-login-app/src/config-schema.ts b/packages/apps/esm-login-app/src/config-schema.ts index b550a92fc..885b67f7f 100644 --- a/packages/apps/esm-login-app/src/config-schema.ts +++ b/packages/apps/esm-login-app/src/config-schema.ts @@ -68,6 +68,29 @@ export const configSchema = { _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.', }, }, + footer: { + logos: { + _type: Type.Array, + _items: { + _type: Type.Object, + _properties: { + src: { + _type: Type.String, + _required: true, + _description: 'The source URL of the logo image', + _validations: [validators.isUrl] + }, + alt: { + _type: Type.String, + _required: true, + _description: 'The alternative text for the logo image' + } + } + }, + _default: [], + _description: 'An array of logos to be displayed in the footer.', + } + }, showPasswordOnSeparateScreen: { _type: Type.Boolean, _default: true, @@ -95,5 +118,11 @@ export interface ConfigSchema { alt: string; src: string; }; + footer: { + logos: Array<{ + src: string; + alt: string; + }>; + }; showPasswordOnSeparateScreen: boolean; } diff --git a/packages/apps/esm-login-app/src/footer.component.tsx b/packages/apps/esm-login-app/src/footer.component.tsx new file mode 100644 index 000000000..2edf5c8c8 --- /dev/null +++ b/packages/apps/esm-login-app/src/footer.component.tsx @@ -0,0 +1,33 @@ +import React from 'react'; +import { interpolateUrl, useConfig } from '@openmrs/esm-framework'; +import { type TFunction } from 'react-i18next'; +import { type ConfigSchema } from './config-schema'; +import styles from './login/login.scss'; + +const Footer: React.FC<{ t: TFunction }> = ({ t }) => { + const config = useConfig(); + const logos = config.footer.logos || []; + + return ( +
+

{t('poweredBy', 'Powered by')}

+
+ {logos.length > 0 ? ( + logos.map((logo, index) => ( + {logo.alt + )) + ) : ( + + + + )} +
+
+ ); +}; + +export default Footer; \ No newline at end of file diff --git a/packages/apps/esm-login-app/src/login/login.component.tsx b/packages/apps/esm-login-app/src/login/login.component.tsx index 51a263ed46..b19a204e3 100644 --- a/packages/apps/esm-login-app/src/login/login.component.tsx +++ b/packages/apps/esm-login-app/src/login/login.component.tsx @@ -14,6 +14,7 @@ import { } from '@openmrs/esm-framework'; import { type ConfigSchema } from '../config-schema'; import Logo from '../logo.component'; +import Footer from '../footer.component'; import styles from './login.scss'; export interface LoginReferrer { @@ -265,14 +266,9 @@ const Login: React.FC = () => { )} -
-

{t('poweredBy', 'Powered by')}

- - - +
-
); } diff --git a/packages/apps/esm-login-app/src/login/login.scss b/packages/apps/esm-login-app/src/login/login.scss index 87f113438..1e3656425 100644 --- a/packages/apps/esm-login-app/src/login/login.scss +++ b/packages/apps/esm-login-app/src/login/login.scss @@ -25,6 +25,7 @@ .poweredByTxt { @extend .caption01; + margin-bottom: 1.5rem; text-align: center; color: $color-gray-70; color: $text-02; @@ -50,9 +51,38 @@ margin-left: 0.5rem; } +.footer { + display: flex; + flex-direction: column; + align-items: center; + padding: 1.5rem; +} + +.logosContainer { + display: flex; + justify-content: center; + align-items: center; + flex-wrap: wrap; + margin-bottom: 1.5rem; + gap: 2rem; +} + +@media (min-width: 768px) { + .footer { + padding: 2rem; + } + .poweredByLogo { + height: 3.5rem; + max-width: 9rem; + } +} + .poweredByLogo { - height: 2.5rem; - width: 6.5rem; + height: 3rem; + width: auto; + max-width: 8rem; + object-fit: contain; + display: block; } .loginCard { @@ -63,6 +93,8 @@ padding: 2.5rem; position: relative; min-height: fit-content; + margin-top: 2.5rem; + margin-bottom: -3.0rem; } @media only screen and (min-width: 481px) { diff --git a/packages/apps/esm-login-app/src/logo.component.tsx b/packages/apps/esm-login-app/src/logo.component.tsx index 1488258d4..fd760bf92 100644 --- a/packages/apps/esm-login-app/src/logo.component.tsx +++ b/packages/apps/esm-login-app/src/logo.component.tsx @@ -16,7 +16,7 @@ const Logo: React.FC<{ t: TFunction }> = ({ t }) => { {t('openmrsLogo', 'OpenMRS logo')} - + ); }; From deb0137e63d809b86e3cbd4997e249a7f9541fd4 Mon Sep 17 00:00:00 2001 From: suubi-joshua Date: Wed, 28 Aug 2024 22:35:08 +0300 Subject: [PATCH 2/6] Removed the conditional rendering of the OMRS Logo --- .../esm-login-app/src/footer.component.tsx | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/packages/apps/esm-login-app/src/footer.component.tsx b/packages/apps/esm-login-app/src/footer.component.tsx index 2edf5c8c8..3b920ad6e 100644 --- a/packages/apps/esm-login-app/src/footer.component.tsx +++ b/packages/apps/esm-login-app/src/footer.component.tsx @@ -12,19 +12,16 @@ const Footer: React.FC<{ t: TFunction }> = ({ t }) => {

{t('poweredBy', 'Powered by')}

- {logos.length > 0 ? ( - logos.map((logo, index) => ( - {logo.alt - )) - ) : ( - - - - )} + + + + {logos.map((logo, index) => ( + {logo.alt + ))}
); From 48b6609cbc3d33a1186f8916eeefce95a94847ef Mon Sep 17 00:00:00 2001 From: suubi-joshua Date: Fri, 20 Sep 2024 00:22:26 +0300 Subject: [PATCH 3/6] Worked on requested changes --- packages/apps/esm-login-app/__mocks__/config.mock.ts | 6 +++--- packages/apps/esm-login-app/src/config-schema.ts | 2 +- packages/apps/esm-login-app/src/footer.component.tsx | 7 ++++--- packages/apps/esm-login-app/src/login/login.component.tsx | 4 +--- packages/apps/esm-login-app/src/login/login.scss | 8 ++++---- packages/apps/esm-login-app/src/login/login.test.tsx | 2 +- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/apps/esm-login-app/__mocks__/config.mock.ts b/packages/apps/esm-login-app/__mocks__/config.mock.ts index 105c045b6..9e7c40a34 100644 --- a/packages/apps/esm-login-app/__mocks__/config.mock.ts +++ b/packages/apps/esm-login-app/__mocks__/config.mock.ts @@ -1,4 +1,4 @@ -import { ConfigSchema } from '../src/config-schema'; +import { type ConfigSchema } from '../src/config-schema'; export const mockConfig: ConfigSchema = { provider: { @@ -22,8 +22,8 @@ export const mockConfig: ConfigSchema = { footer: { logos: [ { - src: null, - alt: 'Logo', + src: '', + alt: '', } ], }, diff --git a/packages/apps/esm-login-app/src/config-schema.ts b/packages/apps/esm-login-app/src/config-schema.ts index 885b67f7f..cfb1ca26f 100644 --- a/packages/apps/esm-login-app/src/config-schema.ts +++ b/packages/apps/esm-login-app/src/config-schema.ts @@ -71,7 +71,7 @@ export const configSchema = { footer: { logos: { _type: Type.Array, - _items: { + _elements: { _type: Type.Object, _properties: { src: { diff --git a/packages/apps/esm-login-app/src/footer.component.tsx b/packages/apps/esm-login-app/src/footer.component.tsx index 3b920ad6e..d3b4d3103 100644 --- a/packages/apps/esm-login-app/src/footer.component.tsx +++ b/packages/apps/esm-login-app/src/footer.component.tsx @@ -1,10 +1,11 @@ import React from 'react'; import { interpolateUrl, useConfig } from '@openmrs/esm-framework'; -import { type TFunction } from 'react-i18next'; +import { useTranslation } from 'react-i18next'; import { type ConfigSchema } from './config-schema'; import styles from './login/login.scss'; -const Footer: React.FC<{ t: TFunction }> = ({ t }) => { +const Footer: React.FC = () => { + const {t} = useTranslation(); const config = useConfig(); const logos = config.footer.logos || []; @@ -17,7 +18,7 @@ const Footer: React.FC<{ t: TFunction }> = ({ t }) => { {logos.map((logo, index) => ( {logo.alt diff --git a/packages/apps/esm-login-app/src/login/login.component.tsx b/packages/apps/esm-login-app/src/login/login.component.tsx index b19a204e3..6213fcd94 100644 --- a/packages/apps/esm-login-app/src/login/login.component.tsx +++ b/packages/apps/esm-login-app/src/login/login.component.tsx @@ -266,9 +266,7 @@ const Login: React.FC = () => { )} -
-
-
+