-
Notifications
You must be signed in to change notification settings - Fork 261
(feat) O3-5027: Implement beautiful configurable login page #1460
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
Open
UjjawalPrabhat
wants to merge
4
commits into
openmrs:main
Choose a base branch
from
UjjawalPrabhat:feature/configurable-login-page
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4f67b63
refactor(login): address review feedback on PR scope
UjjawalPrabhat a52afaa
Merge branch 'openmrs:main' into feature/configurable-login-page
UjjawalPrabhat 523002d
Merge branch 'openmrs:main' into feature/configurable-login-page
UjjawalPrabhat 4b0f4a3
Merge branch 'openmrs:main' into feature/configurable-login-page
UjjawalPrabhat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,81 @@ | ||
# openmrs-esm-login-app | ||
|
||
openmrs-esm-login-app is responsible for rendering the loading page, | ||
the login page, and the location picker. | ||
openmrs-esm-login-app is responsible for rendering the loading page, the login page, and the location picker. | ||
|
||
## Configuration | ||
|
||
The login page can be customized through configuration. This allows implementers to: | ||
|
||
- Choose from multiple layouts (default or split-screen) | ||
- Customize backgrounds (colors, images, or gradients) | ||
- Brand the login page with custom titles, subtitles, and logos | ||
- Style the login card and buttons | ||
- Add custom links and help text | ||
- Configure the footer with additional logos | ||
|
||
See the [configuration schema](src/config-schema.ts) for all available options. | ||
|
||
## Configuration Examples | ||
|
||
### Split-Screen Layout with Image Background | ||
|
||
```json | ||
{ | ||
"@openmrs/esm-login-app": { | ||
"layout": { | ||
"type": "split-screen", | ||
"columnPosition": "right" | ||
}, | ||
"background": { | ||
"type": "image", | ||
"value": "https://example.com/hospital-bg.jpg" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Color Background | ||
|
||
```json | ||
{ | ||
"@openmrs/esm-login-app": { | ||
"background": { | ||
"type": "color", | ||
"value": "#0066cc" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Gradient Background | ||
|
||
```json | ||
{ | ||
"@openmrs/esm-login-app": { | ||
"background": { | ||
"type": "gradient", | ||
"value": "linear-gradient(135deg, #667eea 0%, #764ba2 100%)" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Custom Branding | ||
|
||
```json | ||
{ | ||
"@openmrs/esm-login-app": { | ||
"branding": { | ||
"title": "Welcome to My Clinic", | ||
"subtitle": "Electronic Medical Records System" | ||
}, | ||
"logo": { | ||
"src": "https://example.com/logo.png", | ||
"alt": "My Clinic" | ||
}, | ||
"button": { | ||
"backgroundColor": "#0071c5" | ||
} | ||
} | ||
} | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
packages/apps/esm-login-app/src/background/background-wrapper.component.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import React, { useMemo } from 'react'; | ||
import { useConfig } from '@openmrs/esm-framework'; | ||
import { type ConfigSchema } from '../config-schema'; | ||
import styles from './background-wrapper.scss'; | ||
|
||
interface BackgroundWrapperProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
const BackgroundWrapper: React.FC<BackgroundWrapperProps> = ({ children }) => { | ||
const config = useConfig<ConfigSchema>(); | ||
const { layout, background } = config; | ||
|
||
const backgroundStyles = useMemo(() => { | ||
const style: React.CSSProperties = {}; | ||
|
||
switch (background.type) { | ||
case 'color': | ||
if (background.value) { | ||
style.backgroundColor = background.value; | ||
} | ||
break; | ||
|
||
case 'image': | ||
if (background.value) { | ||
// Simple URL-based approach - let browser handle loading | ||
style.backgroundImage = `url(${background.value})`; | ||
style.backgroundSize = background.size || 'cover'; | ||
style.backgroundPosition = background.position || 'center'; | ||
style.backgroundRepeat = background.repeat || 'no-repeat'; | ||
style.backgroundAttachment = background.attachment || 'scroll'; | ||
} | ||
break; | ||
|
||
case 'gradient': | ||
if (background.value) { | ||
style.background = background.value; | ||
} | ||
break; | ||
|
||
default: | ||
// Use default styling | ||
break; | ||
} | ||
|
||
return style; | ||
}, [background]); | ||
|
||
const overlayStyles = useMemo(() => { | ||
if (!background.overlay.enabled) { | ||
return {}; | ||
} | ||
|
||
return { | ||
backgroundColor: background.overlay.color, | ||
opacity: background.overlay.opacity, | ||
mixBlendMode: background.overlay.blendMode || 'normal', | ||
}; | ||
}, [background]); | ||
|
||
const hasCustomBackground = background.type !== 'default' && background.value; | ||
const hasOverlay = background.overlay.enabled && hasCustomBackground; | ||
|
||
// Split-screen layout: Background image on one side, login card on opposite side | ||
if (layout.type === 'split-screen' && background.type === 'image' && background.value) { | ||
// Determine which side gets the background image based on columnPosition | ||
// If card is on left, bg is on right. If card is on right, bg is on left. | ||
// If card is center, bg is on left by default | ||
const bgPosition = layout.columnPosition === 'right' ? 'left' : 'right'; | ||
|
||
return ( | ||
<div className={`${styles.backgroundWrapper} ${styles.splitScreenContainer}`}> | ||
<div | ||
className={`${styles.backgroundPanel} ${styles[`bgPosition-${bgPosition}`]}`} | ||
style={{ | ||
backgroundImage: `url(${background.value})`, | ||
backgroundSize: background.size || 'cover', | ||
backgroundPosition: background.position || 'center', | ||
backgroundRepeat: background.repeat || 'no-repeat', | ||
}} | ||
/> | ||
<div className={styles.content}>{children}</div> | ||
</div> | ||
); | ||
} | ||
|
||
// Default layout: Simple background with optional overlay | ||
return ( | ||
<div | ||
className={`${styles.backgroundWrapper} ${hasCustomBackground ? styles.customBackground : ''}`} | ||
style={backgroundStyles} | ||
> | ||
{hasOverlay && <div className={styles.overlay} style={overlayStyles} />} | ||
<div className={styles.content}>{children}</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default BackgroundWrapper; |
96 changes: 96 additions & 0 deletions
96
packages/apps/esm-login-app/src/background/background-wrapper.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
@use '@carbon/layout'; | ||
@use '@openmrs/esm-styleguide/src/vars' as *; | ||
|
||
.backgroundWrapper { | ||
min-height: 100vh; | ||
position: relative; | ||
|
||
&.customBackground { | ||
// Ensure proper background attachment | ||
background-attachment: scroll; | ||
|
||
@media (min-width: 769px) { | ||
// Enable fixed backgrounds on desktop for better visual effect | ||
&[style*='background-attachment: fixed'] { | ||
background-attachment: fixed; | ||
} | ||
} | ||
|
||
@media (max-width: 768px) { | ||
// Always use scroll on mobile for better performance | ||
background-attachment: scroll !important; | ||
} | ||
} | ||
} | ||
|
||
.overlay { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
z-index: 1; | ||
pointer-events: none; | ||
transition: opacity 0.3s ease-in-out; | ||
} | ||
|
||
.content { | ||
position: relative; | ||
z-index: 2; | ||
min-height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
|
||
.customBackground & { | ||
// Add subtle backdrop for better content readability on custom backgrounds | ||
backdrop-filter: blur(0.5px); | ||
} | ||
} | ||
|
||
// Split-screen layout styles | ||
.splitScreenContainer { | ||
display: flex; | ||
min-height: 100vh; | ||
position: relative; | ||
overflow: hidden; | ||
|
||
.content { | ||
position: relative; | ||
z-index: 2; | ||
width: 100%; | ||
} | ||
|
||
@media (max-width: 768px) { | ||
// On mobile, stack vertically with background on top | ||
flex-direction: column; | ||
|
||
.backgroundPanel { | ||
position: relative !important; | ||
width: 100% !important; | ||
height: 30vh !important; | ||
left: 0 !important; | ||
right: 0 !important; | ||
} | ||
} | ||
} | ||
|
||
.backgroundPanel { | ||
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
width: 50%; | ||
z-index: 1; | ||
|
||
&.bgPosition-left { | ||
left: 0; | ||
} | ||
|
||
&.bgPosition-right { | ||
right: 0; | ||
} | ||
|
||
@media (min-width: 769px) and (max-width: 1024px) { | ||
// On tablets, adjust background width | ||
width: 40%; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @UjjawalPrabhat , We need Loginbackground to be configurable, i went ahead and tested your code .Check this out.
loginbackground.webm These changes override the default login image.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @sherrif10, the Logo change config you're referring to wasn't implemented by me. It was there from before and therefore the logo is editable. If you're referring to background change then that is available in a separate section called as background.
Do you want me to make the Logo constant?
Also please let me know if there's any other changes or enhancements required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need the login page to look like this . Share the vedio of your changes before and after

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sherrif10 could you send the images used in this the login page?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @UjjawalPrabhat , We want to come up with something like that in the image i shared, FYI , Login page is already configurable, the only changes needed is to make login page appear like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sherrif10 I'm on it. I was talking about the images used like the 3 doctor's and logo image used in the login page. It'd be easier for me to configure then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it needs to be configurable and when the configuration is set to default, Default OMRS login page should appear, Then you should consider making it appear left or right on the login page.