File tree Expand file tree Collapse file tree 6 files changed +39
-1
lines changed
documentation/docs/tutorial/03-Customization Expand file tree Collapse file tree 6 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,26 @@ const admin = new AdminForth({
94
94
Here is how it looks:
95
95
![ AdminForth Themes] ( image-10.png )
96
96
97
+ ## Single theme
98
+
99
+ If you want to enforce a consistent theme and disable the theme switcher, you can configure AdminForth to use only one theme variant.
100
+
101
+ ``` ts title='./index.ts'
102
+
103
+ const admin = new AdminForth ({
104
+ ...
105
+ customization : {
106
+ // diff-add
107
+ singleTheme: " light" ,
108
+ styles: {
109
+ ...
110
+ }
111
+ }
112
+ },
113
+ ...
114
+ });
115
+ ```
116
+
97
117
98
118
## Square vs rounded buttons?
99
119
Original file line number Diff line number Diff line change @@ -223,6 +223,7 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
223
223
everyPageBottom : this . adminforth . config . customization . globalInjections . everyPageBottom ,
224
224
} ,
225
225
rememberMeDays : this . adminforth . config . auth . rememberMeDays ,
226
+ singleTheme : this . adminforth . config . customization . singleTheme ,
226
227
} ;
227
228
} ,
228
229
} ) ;
@@ -301,6 +302,7 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
301
302
loginPromptHTML : await tr ( this . adminforth . config . auth . loginPromptHTML , 'system.loginPromptHTML' ) ,
302
303
loginPageInjections : this . adminforth . config . customization . loginPageInjections ,
303
304
rememberMeDays : this . adminforth . config . auth . rememberMeDays ,
305
+ singleTheme : this . adminforth . config . customization . singleTheme ,
304
306
}
305
307
306
308
const loggedInPart = {
Original file line number Diff line number Diff line change 24
24
/>
25
25
26
26
<div class =" flex items-center ms-3 " >
27
- <span
27
+ <span
28
+ v-if =" !coreStore.config?.singleTheme"
28
29
@click =" toggleTheme" class =" cursor-pointer flex items-center gap-1 block px-4 py-2 text-sm text-black hover:bg-lightHtml dark:text-darkSidebarTextHover dark:hover:bg-darkHtml dark:hover:text-darkSidebarTextActive" role =" menuitem" >
29
30
<IconMoonSolid class =" w-5 h-5 text-blue-300" v-if =" coreStore.theme !== 'dark'" />
30
31
<IconSunSolid class =" w-5 h-5 text-yellow-300" v-else />
@@ -410,6 +411,14 @@ onBeforeMount(()=>{
410
411
document .documentElement .classList .toggle (' dark' , theme .value === ' dark' );
411
412
})
412
413
414
+ watch (() => coreStore .config ?.singleTheme , (singleTheme ) => {
415
+ if (singleTheme ) {
416
+ theme .value = singleTheme ;
417
+ window .localStorage .setItem (' af__theme' , singleTheme );
418
+ document .documentElement .classList .toggle (' dark' , theme .value === ' dark' );
419
+ }
420
+ }, { immediate: true })
421
+
413
422
414
423
const ctaBadge: Ref <(AnnouncementBadgeResponse & { hash: string ; }) | null > = computed (() => {
415
424
const badge = coreStore .config ?.announcementBadge ;
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ export type ResourceColumns = {
21
21
22
22
export type CoreConfig = {
23
23
brandName : string ,
24
+ singleTheme ?: 'light' | 'dark' ,
24
25
brandLogo : string ,
25
26
title : string ,
26
27
datesFormat : string ,
Original file line number Diff line number Diff line change @@ -619,6 +619,11 @@ interface AdminForthInputConfigCustomization {
619
619
*/
620
620
brandName ?: string ,
621
621
622
+ /**
623
+ * Whether to use single theme for the app
624
+ */
625
+ singleTheme ?: 'light' | 'dark' ,
626
+
622
627
/**
623
628
* Whether to show brand name in sidebar
624
629
* default is true
Original file line number Diff line number Diff line change @@ -1065,6 +1065,7 @@ export interface AdminForthConfigForFrontend {
1065
1065
rememberMeDays : number ,
1066
1066
showBrandNameInSidebar : boolean ,
1067
1067
brandLogo ?: string ,
1068
+ singleTheme ?: 'light' | 'dark' ,
1068
1069
datesFormat : string ,
1069
1070
timeFormat : string ,
1070
1071
auth : any ,
You can’t perform that action at this time.
0 commit comments