Open Closed

LeptonX Custom Theme tries to load from _content instead of wwwroot/side-menu/css #3657


User avatar
0
hakan.uskaner created

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: v6.0.0.rc.3
  • UI type: Blazor Server
  • DB provider: EF Core / MongoDB
  • Tiered (MVC) or Identity Server Separated (Angular): yes

Hi,

i am trying to a dd a custom thme to a Blazor project like in this link: https://docs.abp.io/en/commercial/6.0/themes/lepton-x/commercial/blazor?UI=BlazorServer there you write:

I did place all files at wwwroot/side-menu/css , but they wont loaded, because the Theme tries to access it in its own content.

I receive this error:

I also tried moving these Files to Themes/LeptonX/Global/side-menu/css like suggest in mvc part, but this didn't work.

How can i add them correctly ?

Regards Hakan Uskaner


6 Answer(s)
  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Hi @hakan.uskuner

    It seems there is a mistake in the documentation. Blazor has a special case while providing embedded resources. It accesses resources via assembly name. So place you files under wwwroot/_content/Volo.Abp.AspNetCore.Components.Web.LeptonXTheme/side-menu/css/ folder.

    • I've created two style files:

    • Configured them in Module file

      Configure<LeptonXThemeOptions>(options =>
      {
          options.DefaultStyle = LeptonXStyleNames.System;
      
          // Adding a new theme
          options.Styles.Add("red", 
              new LeptonXThemeStyle(
              LocalizableString.Create<Test50Resource>("Theme:Red"),
              "bi bi-circle-fill"));
      });
      
    • And the result:

    Your credit is refunded since there is a mistake in documentation,

  • User Avatar
    0
    hakan.uskaner created

    Hi Ensin,

    thank you. That fixed it.

  • User Avatar
    0
    hakan.uskaner created

    Hi @ensin,,

    one thing is Left. :

    LocalizableString.Create<Test50Resource>("Theme:Red")

    I use a microservicetemplate called "AppMicro" and tried as resource AppMicroResource and AppMicroSharedLocalizationModule but this wont work for localization. i have added the "Theme:Red" to en.json and de.json without being noticed.

    How can i fix the localization ?

  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Sorry about it, that was my test project name.

    LeptonX uses IStringLocalizerFactory to localize theme names.

    If you use a resource that configured in your application, it'll work.

     LocalizableString.Create<AppMicroResource>("Theme:Red")
    

    The example below should work. Can you check which resource is configured in your Domain.Shared module class?

    Isn't it something like below?

    Configure<AbpLocalizationOptions>(options =>
    {
        options.Resources
            .Add<AppMicroResource>("en")
            .AddBaseTypes(typeof(AbpValidationResource))
            .AddVirtualJson("/Localization/AppMicroResource");
    });
    
  • User Avatar
    0
    hakan.uskaner created

    Hi Ensin,

    i am using a microservice template, and i did update the app/blazor project to use leptonx. The code you provided for AbpLocalizationOptions is part of the Shared project: AppMicro.Shared.Localization and yes the name of the ressource is AppMicroResource:

    So normally i would expect that this should work within the app Blazor project, where the typeof(AppMicroSharedLocalizationModule), is added as dependency:

        options.Styles.Add("custom-light",
               new LeptonXThemeStyle(
               LocalizableString.Create&lt;AppMicroSharedLocalizationModule&gt;("Theme:Light"),
               "bi bi-circle-fill"));
            options.Styles.Add("custom-dark",
               new LeptonXThemeStyle(
               LocalizableString.Create&lt;AppMicroResource&gt;("Theme:Dark"),
               "bi bi-circle-fill"));
    

    I did try both. Within the Blazor project i didn't find any AbpLocalizationOptions ..

  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    We have fixed the issue that you mentioned lastly and it'll be released with next LeptonX release

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11