Skip to content

Commit fe04c8b

Browse files
feat(ui): allow configuring background via css instead of an image (#1101)
Co-authored-by: Stavros <steveiliop56@gmail.com>
1 parent 8bf032c commit fe04c8b

6 files changed

Lines changed: 16 additions & 5 deletions

File tree

‎.env.example‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ TINYAUTH_UI_TITLE="Tinyauth"
205205
TINYAUTH_UI_FORGOTPASSWORDMESSAGE="You can change your password by changing the configuration."
206206
# Path to the background image.
207207
TINYAUTH_UI_BACKGROUNDIMAGE="/background.webp"
208+
# Value of the CSS background property, takes precedence over the background image.
209+
TINYAUTH_UI_BACKGROUNDCSS=
208210
# Enable UI warnings.
209211
TINYAUTH_UI_WARNINGSENABLED=true
210212

‎frontend/src/components/layout/layout.tsx‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ const BaseLayout = ({ children }: { children: React.ReactNode }) => {
1515
return (
1616
<div
1717
className="flex flex-col justify-center items-center min-h-svh px-4"
18-
style={{
19-
backgroundImage: `url(${ui.backgroundImage})`,
20-
backgroundSize: "cover",
21-
backgroundPosition: "center",
22-
}}
18+
style={
19+
ui.backgroundCss
20+
? { background: ui.backgroundCss }
21+
: {
22+
backgroundImage: `url(${ui.backgroundImage})`,
23+
backgroundSize: "cover",
24+
backgroundPosition: "center",
25+
}
26+
}
2327
>
2428
<div className="absolute top-4 right-4">
2529
<QuickActions />

‎frontend/src/schemas/app-context-schema.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const uiSchema = z.object({
1818
title: z.string(),
1919
forgotPasswordMessage: z.string(),
2020
backgroundImage: z.string(),
21+
backgroundCss: z.string(),
2122
warningsEnabled: z.boolean(),
2223
});
2324

‎internal/controller/context_controller.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ type ACRUI struct {
5656
Title string `json:"title"`
5757
ForgotPasswordMessage string `json:"forgotPasswordMessage"`
5858
BackgroundImage string `json:"backgroundImage"`
59+
BackgroundCSS string `json:"backgroundCss"`
5960
WarningsEnabled bool `json:"warningsEnabled"`
6061
}
6162

@@ -161,6 +162,7 @@ func (controller *ContextController) appContextHandler(c *gin.Context) {
161162
Title: controller.config.UI.Title,
162163
ForgotPasswordMessage: controller.config.UI.ForgotPasswordMessage,
163164
BackgroundImage: controller.config.UI.BackgroundImage,
165+
BackgroundCSS: controller.config.UI.BackgroundCSS,
164166
WarningsEnabled: controller.config.UI.WarningsEnabled,
165167
},
166168
App: ACRApp{

‎internal/controller/context_controller_test.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func TestContextController(t *testing.T) {
4545
Title: cfg.UI.Title,
4646
ForgotPasswordMessage: cfg.UI.ForgotPasswordMessage,
4747
BackgroundImage: cfg.UI.BackgroundImage,
48+
BackgroundCSS: cfg.UI.BackgroundCSS,
4849
WarningsEnabled: cfg.UI.WarningsEnabled,
4950
},
5051
App: ACRApp{

‎internal/model/config.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ type UIConfig struct {
205205
Title string `description:"The title of the UI." yaml:"title,omitempty"`
206206
ForgotPasswordMessage string `description:"Message displayed on the forgot password page." yaml:"forgotPasswordMessage,omitempty"`
207207
BackgroundImage string `description:"Path to the background image." yaml:"backgroundImage,omitempty"`
208+
BackgroundCSS string `description:"Value of the CSS background property, takes precedence over the background image." yaml:"backgroundCss,omitempty"`
208209
WarningsEnabled bool `description:"Enable UI warnings." yaml:"warningsEnabled,omitempty"`
209210
}
210211

0 commit comments

Comments
 (0)