Improved CSS handling

This commit is contained in:
Shaun Walker
2019-09-21 22:15:44 -04:00
parent 054495056d
commit 5f62957752
15 changed files with 142 additions and 39 deletions

View File

@ -1,11 +1,16 @@
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using Oqtane.Shared;
using Oqtane.Models;
using System.Threading.Tasks;
namespace Oqtane.Themes
{
public class ContainerBase : ComponentBase, IContainerControl
{
[Inject]
protected IJSRuntime JSRuntime { get; set; }
[CascadingParameter]
protected PageState PageState { get; set; }
@ -14,6 +19,21 @@ namespace Oqtane.Themes
public virtual string Name { get; set; }
public string ThemePath()
{
return "Themes/" + this.GetType().Namespace + "/";
}
public async Task AddCSS(string Url)
{
if (!Url.StartsWith("http"))
{
Url = ThemePath() + Url;
}
var interop = new Interop(JSRuntime);
await interop.AddCSS("Theme:" + Utilities.CreateIdFromUrl(Url), Url);
}
public string NavigateUrl()
{
return NavigateUrl(PageState.Page.Path);