Skip to content

Commit 2cf899d

Browse files
committed
feat: add option to disable background blend mode for login image
1 parent 6fe976c commit 2cf899d

File tree

6 files changed

+27
-1
lines changed

6 files changed

+27
-1
lines changed

adminforth/documentation/docs/tutorial/03-Customization/01-branding.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,18 @@ auth: {
169169
`loginBackgroundPosition` accepts values:
170170

171171
- `over` - image will be over the whole login page with cover mode
172-
- `1/2`(default), `3/4`, `2/5`, `3/5` etc. - image will be in the left side of the login page with cover mode
172+
- `1/2`(default), `3/4`, `2/5`, `3/5` etc. - image will be in the left side of the login page with cover mode
173+
174+
### Disabling background blend mode
175+
176+
When using `loginBackgroundPosition: 'over'`, AdminForth applies a background blend mode by default to ensure text readability over the background image. If you want to disable this blend mode and display the background image without any overlay effects, you can add:
177+
178+
```ts title='./index.ts'
179+
auth: {
180+
...
181+
loginBackgroundImage: '@@/photo-1516501312919-d0cb0b7b60b8.jpeg',
182+
loginBackgroundPosition: 'over',
183+
//diff-add
184+
removeBackgroundBlendMode: true,
185+
}
186+
```

adminforth/modules/restApi.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
215215
usernameFieldName: usernameColumn.label,
216216
loginBackgroundImage: this.adminforth.config.auth.loginBackgroundImage,
217217
loginBackgroundPosition: this.adminforth.config.auth.loginBackgroundPosition,
218+
removeBackgroundBlendMode: this.adminforth.config.auth.removeBackgroundBlendMode,
218219
title: this.adminforth.config.customization?.title,
219220
demoCredentials: this.adminforth.config.auth.demoCredentials,
220221
loginPromptHTML: await tr(this.adminforth.config.auth.loginPromptHTML, 'system.loginPromptHTML'),
@@ -297,6 +298,7 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
297298
usernameFieldName: usernameColumn.label,
298299
loginBackgroundImage: this.adminforth.config.auth.loginBackgroundImage,
299300
loginBackgroundPosition: this.adminforth.config.auth.loginBackgroundPosition,
301+
removeBackgroundBlendMode: this.adminforth.config.auth.removeBackgroundBlendMode,
300302
title: this.adminforth.config.customization?.title,
301303
demoCredentials: this.adminforth.config.auth.demoCredentials,
302304
loginPromptHTML: await tr(this.adminforth.config.auth.loginPromptHTML, 'system.loginPromptHTML'),

adminforth/spa/src/spa_types/core.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export type CoreConfig = {
3434
passwordHashField: string,
3535
loginBackgroundImage: string,
3636
loginBackgroundPosition: string,
37+
removeBackgroundBlendMode: boolean,
3738
userFullnameField: string,
3839
},
3940
emptyFieldPlaceholder?: {

adminforth/spa/src/views/LoginView.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
'background-image': 'url(' + loadFile(coreStore.config?.loginBackgroundImage) + ')',
55
'background-size': 'cover',
66
'background-position': 'center',
7+
'background-blend-mode': coreStore.config?.removeBackgroundBlendMode ? 'normal' : 'darken'
78
}: {}"
89
>
910

adminforth/types/Back.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,13 @@ export interface AdminForthInputConfig {
940940
*/
941941
loginBackgroundPosition?: 'over' | '1/2' | '1/3' | '2/3' | '3/4' | '2/5' | '3/5',
942942

943+
/**
944+
* If true, background blend mode will be removed from login background image when position is 'over'
945+
*
946+
* Default: false
947+
*/
948+
removeBackgroundBlendMode?: boolean,
949+
943950
/**
944951
* Function or functions which will be called before user try to login.
945952
* Each function will resive User object as an argument

adminforth/types/Common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,7 @@ export interface AdminForthConfigForFrontend {
10551055
usernameFieldName: string,
10561056
loginBackgroundImage: string,
10571057
loginBackgroundPosition: string,
1058+
removeBackgroundBlendMode: boolean,
10581059
title?: string,
10591060
demoCredentials?: string,
10601061
loginPromptHTML?: string,

0 commit comments

Comments
 (0)