mirror of https://github.com/abpframework/abp.git
9 changed files with 207 additions and 136 deletions
@ -1,12 +1,30 @@ |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo.Views.Components.Themes.Shared.Demos.ButtonsDemo |
|||
<h2> |
|||
Basic Buttons |
|||
</h2> |
|||
<abp-demo-section name="Buttons.Basic" view-path="@ButtonsDemoViewComponent.ViewPath"> |
|||
<abp-button button-type="Primary" text="Primary button" /> |
|||
<abp-button button-type="Secondary" text="Secondary button" /> |
|||
<abp-button button-type="Info" text="Info button" /> |
|||
<abp-button button-type="Warning" text="Warning button" /> |
|||
<abp-button button-type="Dark" text="Dark button" /> |
|||
<abp-button button-type="Light" text="Light button" /> |
|||
</abp-demo-section> |
|||
|
|||
<abp-component-demo-section title="Basics" view-path="@ButtonsDemoViewComponent.ViewPath"> |
|||
<abp-button text="Default" /> |
|||
<abp-button button-type="Primary" text="Primary" /> |
|||
<abp-button button-type="Secondary">Secondary</abp-button> |
|||
<abp-button button-type="Success">Success</abp-button> |
|||
<abp-button button-type="Danger">Danger</abp-button> |
|||
<abp-button button-type="Warning">Warning</abp-button> |
|||
<abp-button button-type="Info">Info</abp-button> |
|||
<abp-button button-type="Light">Light</abp-button> |
|||
<abp-button button-type="Dark">Dark</abp-button> |
|||
<abp-button button-type="Link">Link</abp-button> |
|||
</abp-component-demo-section> |
|||
|
|||
<abp-component-demo-section title="Outline" view-path="@ButtonsDemoViewComponent.ViewPath"> |
|||
<abp-button button-type="Outline_Primary">Primary</abp-button> |
|||
<abp-button button-type="Outline_Secondary">Secondary</abp-button> |
|||
<abp-button button-type="Outline_Success">Success</abp-button> |
|||
<abp-button button-type="Outline_Danger">Danger</abp-button> |
|||
<abp-button button-type="Outline_Warning">Warning</abp-button> |
|||
<abp-button button-type="Outline_Info">Info</abp-button> |
|||
<abp-button button-type="Outline_Light">Light</abp-button> |
|||
<abp-button button-type="Outline_Dark">Dark</abp-button> |
|||
</abp-component-demo-section> |
|||
|
|||
<abp-component-demo-section title="Icons" view-path="@ButtonsDemoViewComponent.ViewPath"> |
|||
<abp-button button-type="Warning" icon="pencil" text="Edit" /> |
|||
<abp-button button-type="Info" icon-type="FontAwesome" icon="info" text="Information" /> |
|||
</abp-component-demo-section> |
|||
@ -0,0 +1,105 @@ |
|||
using System; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Razor.TagHelpers; |
|||
using Microsoft.Extensions.FileProviders; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers; |
|||
using Volo.Abp.VirtualFileSystem; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo.Views.Components.Themes.Shared.TagHelpers |
|||
{ |
|||
public class AbpComponentDemoSectionTagHelper : AbpTagHelper |
|||
{ |
|||
private const string DemoSectionOpeningTag = "<abp-component-demo-section"; |
|||
private const string DemoSectionClosingTag = "</abp-component-demo-section"; |
|||
|
|||
public string ViewPath { get; set; } |
|||
public string Title { get; set; } |
|||
|
|||
private readonly IVirtualFileProvider _virtualFileProvider; |
|||
|
|||
public AbpComponentDemoSectionTagHelper(IVirtualFileProvider virtualFileProvider) |
|||
{ |
|||
_virtualFileProvider = virtualFileProvider; |
|||
} |
|||
|
|||
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) |
|||
{ |
|||
output.TagName = null; |
|||
|
|||
var content = await output.GetChildContentAsync(); |
|||
|
|||
output.PreContent.AppendHtml("<div class=\"abp-component-demo-section\">"); |
|||
output.PreContent.AppendHtml($"<h2>{Title}</h2>"); |
|||
output.PreContent.AppendHtml("<div class=\"abp-component-demo-section-body\">"); |
|||
/* component rendering here */ |
|||
output.PostContent.AppendHtml("</div>"); //abp-component-demo-section-body
|
|||
AppendRawSource(output); |
|||
AppendBootstrapSource(output, content); |
|||
output.PostContent.AppendHtml("</div>"); //abp-component-demo-section
|
|||
} |
|||
|
|||
private static void AppendBootstrapSource(TagHelperOutput output, TagHelperContent content) |
|||
{ |
|||
output.PostContent.AppendHtml("<div class=\"abp-component-demo-section-bs-source\">"); |
|||
output.PostContent.AppendHtml("<h3>Bootstrap</h3>"); |
|||
output.PostContent.AppendHtml("<pre>"); |
|||
output.PostContent.Append(content.GetContent()); |
|||
output.PostContent.AppendHtml("</pre>"); |
|||
output.PostContent.AppendHtml("</div>"); |
|||
} |
|||
|
|||
private void AppendRawSource(TagHelperOutput output) |
|||
{ |
|||
output.PostContent.AppendHtml("<div class=\"abp-component-demo-section-raw-source\">"); |
|||
output.PostContent.AppendHtml("<h3>ABP Tag Helpers</h3>"); |
|||
output.PostContent.AppendHtml("<pre>"); |
|||
output.PostContent.Append(GetRawDemoSource()); |
|||
output.PostContent.AppendHtml("</pre>"); |
|||
output.PostContent.AppendHtml("</div>"); |
|||
} |
|||
|
|||
private string GetRawDemoSource() |
|||
{ |
|||
StringBuilder sourceBuilder = null; |
|||
|
|||
var lines = GetFileContent().SplitToLines(); |
|||
|
|||
foreach (var line in lines) |
|||
{ |
|||
if (line.Contains(DemoSectionOpeningTag) && GetName(line) == Title) |
|||
{ |
|||
sourceBuilder = new StringBuilder(); |
|||
} |
|||
else if (line.Contains(DemoSectionClosingTag, StringComparison.InvariantCultureIgnoreCase)) |
|||
{ |
|||
if (sourceBuilder == null) |
|||
{ |
|||
continue; |
|||
} |
|||
|
|||
return sourceBuilder.ToString(); |
|||
} |
|||
else if (sourceBuilder != null) |
|||
{ |
|||
sourceBuilder.AppendLine(line); |
|||
} |
|||
} |
|||
|
|||
throw new AbpException($"Could not find {Title} demo section inside {ViewPath}"); |
|||
} |
|||
|
|||
private string GetFileContent() |
|||
{ |
|||
var viewFileInfo = _virtualFileProvider.GetFileInfo(ViewPath); |
|||
return viewFileInfo.ReadAsString(); |
|||
} |
|||
|
|||
private string GetName(string line) |
|||
{ |
|||
var str = line.Substring(line.IndexOf("title=\"", StringComparison.OrdinalIgnoreCase) + "title=\"".Length); |
|||
str = str.Left(str.IndexOf("\"", StringComparison.OrdinalIgnoreCase)); |
|||
return str; |
|||
} |
|||
} |
|||
} |
|||
@ -1,101 +0,0 @@ |
|||
using System; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc.TagHelpers; |
|||
using Microsoft.AspNetCore.Razor.TagHelpers; |
|||
using Microsoft.Extensions.FileProviders; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers; |
|||
using Volo.Abp.VirtualFileSystem; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo.Views.Components.Themes.Shared.TagHelpers |
|||
{ |
|||
public class AbpDemoSectionTagHelper : AbpTagHelper |
|||
{ |
|||
private const string DemoSectionOpeningTag = "<abp-demo-section"; |
|||
private const string DemoSectionClosingTag = "</abp-demo-section"; |
|||
|
|||
public string ViewPath { get; set; } |
|||
|
|||
public string Name { get; set; } |
|||
|
|||
private readonly IVirtualFileProvider _virtualFileProvider; |
|||
|
|||
public AbpDemoSectionTagHelper(IVirtualFileProvider virtualFileProvider) |
|||
{ |
|||
_virtualFileProvider = virtualFileProvider; |
|||
} |
|||
|
|||
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) |
|||
{ |
|||
output.TagName = null; |
|||
|
|||
var content = await output.GetChildContentAsync(); |
|||
|
|||
output.PreContent.AppendHtml("<div class=\"abp-demo-section\">"); |
|||
output.PreContent.AppendHtml("<div class=\"abp-demo-section-body\">"); |
|||
|
|||
/* component rendering here */ |
|||
|
|||
output.PostContent.AppendHtml("</div>"); //abp-demo-section-body
|
|||
|
|||
output.PostContent.AppendHtml("<div class=\"abp-demo-section-raw-source\">"); |
|||
output.PostContent.AppendHtml("<h3>ABP Tag Helpers</h3>"); |
|||
output.PostContent.AppendHtml("<pre>"); |
|||
output.PostContent.Append(GetRawDemoSource()); |
|||
output.PostContent.AppendHtml("</pre>"); |
|||
output.PostContent.AppendHtml("</div>"); //abp-demo-section-raw-source
|
|||
|
|||
output.PostContent.AppendHtml("<div class=\"abp-demo-section-bs-source\">"); |
|||
output.PostContent.AppendHtml("<h3>Bootstrap</h3>"); |
|||
output.PostContent.AppendHtml("<pre>"); |
|||
output.PostContent.Append(content.GetContent()); |
|||
output.PostContent.AppendHtml("</pre>"); |
|||
output.PostContent.AppendHtml("</div>"); //abp-demo-section-bs-source
|
|||
|
|||
output.PostContent.AppendHtml("</div>"); //abp-demo-section
|
|||
} |
|||
|
|||
private string GetRawDemoSource() |
|||
{ |
|||
var viewFileInfo = _virtualFileProvider.GetFileInfo(ViewPath); |
|||
var viewFileContent = viewFileInfo.ReadAsString(); |
|||
var lines = viewFileContent.SplitToLines(); |
|||
|
|||
StringBuilder sb = null; |
|||
|
|||
foreach (var line in lines) |
|||
{ |
|||
if (line.Contains(DemoSectionOpeningTag)) |
|||
{ |
|||
if (GetName(line) == Name) |
|||
{ |
|||
sb = new StringBuilder(); |
|||
} |
|||
} |
|||
else if (line.Contains(DemoSectionClosingTag, StringComparison.InvariantCultureIgnoreCase)) |
|||
{ |
|||
if (sb == null) |
|||
{ |
|||
continue; |
|||
} |
|||
|
|||
return sb.ToString(); |
|||
} |
|||
else if (sb != null) |
|||
{ |
|||
sb.AppendLine(line); |
|||
} |
|||
} |
|||
|
|||
return ""; |
|||
} |
|||
|
|||
private string GetName(string line) |
|||
{ |
|||
var str = line.Substring(line.IndexOf("name=\"", StringComparison.OrdinalIgnoreCase) + "name=\"".Length); |
|||
str = str.Left(str.IndexOf("\"", StringComparison.OrdinalIgnoreCase)); |
|||
return str; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.UI.Navigation; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Demo |
|||
{ |
|||
public class BasicThemeDemoMenuContributor : IMenuContributor |
|||
{ |
|||
public Task ConfigureMenuAsync(MenuConfigurationContext context) |
|||
{ |
|||
if(context.Menu.Name == StandardMenus.Main) |
|||
{ |
|||
AddMainMenuItems(context); |
|||
} |
|||
|
|||
return Task.CompletedTask; |
|||
} |
|||
|
|||
private void AddMainMenuItems(MenuConfigurationContext context) |
|||
{ |
|||
context.Menu.AddItem( |
|||
new ApplicationMenuItem("BasicThemeDemo.Components", "Components") |
|||
.AddItem( |
|||
new ApplicationMenuItem("BasicThemeDemo.Components.Buttons", "Buttons", url: "/Components/Buttons") |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
@page |
|||
@model Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Demo.Pages.IndexModel |
|||
<h1>Basic Theme Demo</h1> |
|||
@ -0,0 +1,12 @@ |
|||
using Microsoft.AspNetCore.Mvc.RazorPages; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Demo.Pages |
|||
{ |
|||
public class IndexModel : PageModel |
|||
{ |
|||
public void OnGet() |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -1,29 +1,29 @@ |
|||
.abp-demo-section { |
|||
.abp-component-demo-section { |
|||
border: 1px solid #999; |
|||
padding: 10px; |
|||
} |
|||
|
|||
.abp-demo-section-body { |
|||
.abp-component-demo-section-body { |
|||
padding-bottom: 10px; |
|||
} |
|||
|
|||
.abp-demo-section-raw-source { |
|||
.abp-component-demo-section-raw-source { |
|||
background-color: #eee; |
|||
padding: 5px; |
|||
} |
|||
|
|||
.abp-demo-section-raw-source pre { |
|||
.abp-component-demo-section-raw-source pre { |
|||
border: 1px solid #999; |
|||
margin: 5px; |
|||
} |
|||
|
|||
|
|||
.abp-demo-section-bs-source { |
|||
.abp-component-demo-section-bs-source { |
|||
background-color: #ddd; |
|||
padding: 5px; |
|||
} |
|||
|
|||
.abp-demo-section-bs-source pre { |
|||
.abp-component-demo-section-bs-source pre { |
|||
border: 1px solid #999; |
|||
margin: 5px; |
|||
} |
|||
|
|||
Loading…
Reference in new issue