Adding New Metronic Theme
Metronic theme currently has 12 different themes and AspNet Zero includes them all. However, you might want to add a new theme option designed by your team to those options. This document explains step by step to add a new theme option to AspNet Zero. Just note that, the added theme must be a Metronic theme or at least it must be compatible with Metronic.
Rest of the document will use ThemeX as the new theme name.
.Net Part
Go to
*Application.Sharedproject, openAppConsts.csand add new field named ThemeX.Go to
*.Web.Coreproject.Create new UICustomizer named
ThemeXUiCustomizer.cs. CopyThemeDefaultUiCustomizer.csintoThemeXUiCustomizer.csand change necessary settings. (It has setting methods, If your new ThemeX also have that settings keep them otherwise delete them)Open
UiThemeCustomizerFactory.csand add ThemeX code parts inGetUiCustomizerInternalfunction.... if (theme.Equals(AppConsts.ThemeX, StringComparison.InvariantCultureIgnoreCase)) { return _serviceProvider.GetService<ThemeXUiCustomizer>(); } ...
Go to
*.Coreproject. OpenAppSettingProvider.csAdd a method named
GetThemeXSettingswhich returns ThemeX settings.Call it in
GetSettingDefinitionsfunction... return GetHostSettings().Union(GetTenantSettings()).Union(GetSharedSettings()) // theme settings .Union(GetDefaultThemeSettings()) .Union(GetTheme2Settings()) .Union(GetTheme3Settings()) .Union(GetTheme4Settings()) .Union(GetTheme5Settings()) .Union(GetTheme6Settings()) .Union(GetTheme7Settings()) .Union(GetTheme8Settings()) .Union(GetTheme9Settings()) .Union(GetTheme10Settings()) .Union(GetTheme11Settings()) .Union(GetTheme12Settings()) .Union(GetThemeXSettings());//add ThemeXSettings ...
Angular Part
- Go to src-> app -> shared -> layout folder
- Go to themes folder.
- Create a folder named
themeXand go to themeX folder.- Create components named
themeX-brandandthemeX-layout - Copy their body from default theme components (from
default-brandanddefault-layout) and change needed changes. - Create
ThemeXThemeAssetContributorand copy its content fromDefaultThemeAssetContributor.This class returns additional assets so make needed changes for your new themeX.
- Create components named
- Create a folder named
- Go to theme-selection folder. Open
theme-selection-panel.component.htmland add themeX to list.
- Go to themes folder.
- Go to src-> app -> shared -> helper and open
DynamicResourceHelpers.ts. AddThemeXThemeAssetContributortogetAdditionalThemeAssetsfunction
...
if (theme === 'themeX') {
return new ThemeXThemeAssetContributor().getAssetUrls();
}
...
Go to src -> app -> admin folder
Go to ui-customization folder.
Create
themex-theme-ui-settingscomponent. Copy its content fromdefault-theme-ui-settingscomponent. This is where you select UI settings, If your new ThemeX also have that settings keep them otherwise delete them and add what is needed.Open
ui-customization.component.htmland add your component.<tab *ngFor="let themeSetting of themeSettings" [active]="themeSetting.theme == currentThemeName"> <!--...--> <themex-theme-ui-settings *ngIf="themeSetting.theme == 'themeX'" [settings]="themeSetting"></themex-theme-ui-settings> </tab>
Open
admin.module.tsand addThemeXThemeUiSettingsComponentto declarations.
Go to src -> app . Open
app.module.tsand addThemeXLayoutComponentandThemeXBrandComponentto declarations.Go to src -> app. Open
app.component.htmland add ThemeX code part.<div [ngClass]="{'subscription-bar-visible': subscriptionStatusBarVisible()}"> <!--...--> <themex-layout *ngIf="theme=='themeX'"></themex-layout> </div>If your theme uses dynamic bundles, open the
bundle.jsand add your bundles.ASP.NET Zero has custom CSS file for datepicker in Angular version (bs-datepicker.css). If the default design is not compatible with your theme, you can change the related CSS file.